예제 #1
0
        private string ExtractTabName(XmlNode tabNode, int lcid, List <CrmFormTab> crmFormTabs, Entity form,
                                      EntityMetadata entity)
        {
            if (tabNode.Attributes == null || tabNode.Attributes["id"] == null)
            {
                return(string.Empty);
            }

            var tabId = tabNode.Attributes["id"].Value;

            var tabLabelNode = tabNode.SelectSingleNode("labels/label[@languagecode='" + lcid + "']");

            if (tabLabelNode == null || tabLabelNode.Attributes == null)
            {
                return(string.Empty);
            }

            var tabLabelDescAttr = tabLabelNode.Attributes["description"];

            if (tabLabelDescAttr == null)
            {
                return(string.Empty);
            }

            var tabName = tabLabelDescAttr.Value;

            var crmFormTab =
                crmFormTabs.FirstOrDefault(
                    f => f.Id == new Guid(tabId) && f.FormUniqueId == form.GetAttributeValue <Guid>("formidunique"));

            if (crmFormTab == null)
            {
                crmFormTab = new CrmFormTab
                {
                    Id           = new Guid(tabId),
                    FormUniqueId = form.GetAttributeValue <Guid>("formidunique"),
                    FormId       = form.GetAttributeValue <Guid>("formid"),
                    Form         = form.GetAttributeValue <string>("name"),
                    Entity       = entity.LogicalName,
                    Names        = new Dictionary <int, string>()
                };
                crmFormTabs.Add(crmFormTab);
            }

            if (crmFormTab.Names.ContainsKey(lcid))
            {
                return(tabName);
            }

            crmFormTab.Names.Add(lcid, tabName);
            return(tabName);
        }
예제 #2
0
        private int ExportTab(List <int> languages, ExcelWorksheet tabSheet, int line, CrmFormTab crmFormTab)
        {
            var cell = 0;

            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.Id.ToString("B");
            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.Form;
            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.FormUniqueId.ToString("B");
            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.FormId.ToString("B");

            foreach (var lcid in languages)
            {
                bool exists = crmFormTab.Names.ContainsKey(lcid);
                ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = exists
                    ? crmFormTab.Names.First(n => n.Key == lcid).Value
                    : string.Empty;
            }

            line++;
            return(line);
        }
        private string ExtractTabName(XmlNode tabNode, int lcid, List<CrmFormTab> crmFormTabs, Entity form)
        {
            if (tabNode.Attributes == null || tabNode.Attributes["id"] == null)
                return string.Empty;

            var tabId = tabNode.Attributes["id"].Value;

            var tabLabelNode = tabNode.SelectSingleNode("labels/label[@languagecode='" + lcid + "']");
            if (tabLabelNode == null || tabLabelNode.Attributes == null)
                return string.Empty;

            var tabLabelDescAttr = tabLabelNode.Attributes["description"];
            if (tabLabelDescAttr == null)
                return string.Empty;

            var tabName = tabLabelDescAttr.Value;

            var crmFormTab =
                crmFormTabs.FirstOrDefault(
                    f => f.Id == new Guid(tabId) && f.FormUniqueId == form.GetAttributeValue<Guid>("formidunique"));
            if (crmFormTab == null)
            {
                crmFormTab = new CrmFormTab
                {
                    Id = new Guid(tabId),
                    FormUniqueId = form.GetAttributeValue<Guid>("formidunique"),
                    FormId = form.GetAttributeValue<Guid>("formid"),
                    Form = form.GetAttributeValue<string>("name"),
                    Names = new Dictionary<int, string>()
                };
                crmFormTabs.Add(crmFormTab);
            }

            if (crmFormTab.Names.ContainsKey(lcid))
            {
                return tabName;
            }

            crmFormTab.Names.Add(lcid, tabName);
            return tabName;
        }
        private int ExportTab(List<int> languages, ExcelWorksheet tabSheet, int line, CrmFormTab crmFormTab)
        {
            var cell = 0;

            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.Id.ToString("B");
            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.Form;
            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.FormUniqueId.ToString("B");
            ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = crmFormTab.FormId.ToString("B");

            foreach (var lcid in languages)
            {
                bool exists = crmFormTab.Names.ContainsKey(lcid);
                ZeroBasedSheet.Cell(tabSheet, line, cell++).Value = exists
                    ? crmFormTab.Names.First(n => n.Key == lcid).Value
                    : string.Empty;
            }

            line++;
            return line;
        }