Creation of the Proxies
FormProxy : Once we got the values of the Table “systemform” related to the form in which the PBI report is embedded. The data of [SystemForm] type will be mapped into an object [FormProxy[]] of type array.
Code Block |
---|
|
var systemForm = serviceProvider.GetRequiredService<DataverseRepository<DataverseModel.SystemForm>>().FindAll(qe);
var formProxies = systemForm
.Select<Entity, FormProxy>((Func<Entity, FormProxy>)(f => new FormProxy(f)))
.OrderBy<FormProxy, string>((Func<FormProxy, string>)(f => f.ToString()))
.ToArray<FormProxy>();//convert entities into array of proxy |
TabProxy : Tab is contained in a form in the dataverse. This object will contain the form Id.
Code Block |
---|
|
public static List<TabProxy> LoadTabs(string formXML, string formid)
{
if (formXML.Equals(string.Empty))
return null;
FormModel formModel;
var tabProxies = new List<TabProxy>();
using (StringReader stringReader = new StringReader(formXML))
{
formModel = (FormModel)new XmlSerializer(typeof(FormModel)).Deserialize((TextReader)stringReader);
}
if (formModel != null && formModel.Tabs.Count > 0)
{
foreach (FormTab tab in formModel.Tabs)
{
tabProxies.Add(new TabProxy()
{
Text = tab.Labels.FirstOrDefault<FormTabLabel>()?.Description,
Value = (object)tab.Id,
Name = tab.Name != null ? tab.Name : string.Empty,
FormId = formid
});
}
}
return tabProxies;
} |
SectionProxy : Section is contained in a tab in the form and will contain the embedded PBI report. This object will contain the form id as well.
Code Block |
---|
|
public static List<SectionProxy> LoadSections(string formXML, List<TabProxy> tabProxies)
{
var sectionProxies = new List<SectionProxy>();
FormModel formModel;
using (StringReader stringReader = new StringReader(formXML))
{
formModel = (FormModel)new XmlSerializer(typeof(FormModel)).Deserialize((TextReader)stringReader);
}
if(formModel == null) { return null; }
if (formModel.Tabs == null || (formModel.Tabs != null && formModel.Tabs.Count == 0)){ return null; }
foreach (var tabProxy in tabProxies)
{
foreach (FormTabColumn column in formModel.Tabs.FirstOrDefault<FormTab>((Func<FormTab, bool>)(t => t.Id == tabProxy.Value.ToString())).Columns)
{
foreach (FormTabColumnSection section in column.Sections)
{
sectionProxies.Add(new SectionProxy()
{
Id = section.Id,
Text = (section.Labels.FirstOrDefault<FormTabColumnSectionLabel>()?.Description == "" ?
section.Name : section.Labels.FirstOrDefault<FormTabColumnSectionLabel>()?.Description + " (" + section.Name + ")"),
Section = section,
Name = section.Name,
ShowLabel = section.ShowLabel,
FormId = tabProxy.FormId
});
}
}
}
return sectionProxies;
} |