コード例 #1
0
        private static int ExportField(List <int> languages, ExcelWorksheet labelSheet, int line,
                                       CrmFormLabel crmFormLabel)
        {
            var cell = 0;

            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Id.ToString("B");
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Entity;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Form;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.FormUniqueId.ToString("B");
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.FormId.ToString("B");
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Tab;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Section;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Attribute;

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

            line++;
            return(line);
        }
コード例 #2
0
        private void ExtractField(XmlNode cellNode, List <CrmFormLabel> crmFormLabels, Entity form, string tabName,
                                  string sectionName, int lcid)
        {
            if (cellNode.Attributes == null)
            {
                return;
            }

            var cellIdAttr = cellNode.Attributes["id"];

            if (cellIdAttr == null)
            {
                return;
            }

            if (cellNode.ChildNodes.Count == 0)
            {
                return;
            }

            var controlNode = cellNode.SelectSingleNode("control");

            if (controlNode == null || controlNode.Attributes == null)
            {
                return;
            }

            //var crmFormField = crmFormLabels.FirstOrDefault(f => f.Id == new Guid(cellIdAttr.Value) && f.FormId == form.Id);
            var crmFormField =
                crmFormLabels.FirstOrDefault(
                    f =>
                    f.Id == new Guid(cellIdAttr.Value) &&
                    f.FormUniqueId == form.GetAttributeValue <Guid>("formidunique"));

            if (crmFormField == null)
            {
                crmFormField = new CrmFormLabel
                {
                    Id           = new Guid(cellIdAttr.Value),
                    Form         = form.GetAttributeValue <string>("name"),
                    FormUniqueId = form.GetAttributeValue <Guid>("formidunique"),
                    FormId       = form.GetAttributeValue <Guid>("formid"),
                    Tab          = tabName,
                    Section      = sectionName,
                    Attribute    = controlNode.Attributes["id"].Value,
                    Names        = new Dictionary <int, string>()
                };
                crmFormLabels.Add(crmFormField);
            }

            var labelNode           = cellNode.SelectSingleNode("labels/label[@languagecode='" + lcid + "']");
            var labelNodeAttributes = labelNode == null ? null : labelNode.Attributes;
            var labelDescription    = labelNodeAttributes == null ? null : labelNodeAttributes["description"];

            if (crmFormField.Names.ContainsKey(lcid))
            {
                return;
            }

            crmFormField.Names.Add(lcid, labelDescription == null ? string.Empty : labelDescription.Value);
        }
コード例 #3
0
        private void ExtractField(XmlNode cellNode, List<CrmFormLabel> crmFormLabels, Entity form, string tabName,
           string sectionName, int lcid)
        {
            if (cellNode.Attributes == null)
                return;

            var cellIdAttr = cellNode.Attributes["id"];
            if (cellIdAttr == null)
                return;

            if (cellNode.ChildNodes.Count == 0)
                return;

            var controlNode = cellNode.SelectSingleNode("control");
            if (controlNode == null || controlNode.Attributes == null)
                return;

            //var crmFormField = crmFormLabels.FirstOrDefault(f => f.Id == new Guid(cellIdAttr.Value) && f.FormId == form.Id);
            var crmFormField =
                crmFormLabels.FirstOrDefault(
                    f =>
                        f.Id == new Guid(cellIdAttr.Value) &&
                        f.FormUniqueId == form.GetAttributeValue<Guid>("formidunique"));
            if (crmFormField == null)
            {
                crmFormField = new CrmFormLabel
                {
                    Id = new Guid(cellIdAttr.Value),
                    Form = form.GetAttributeValue<string>("name"),
                    FormUniqueId = form.GetAttributeValue<Guid>("formidunique"),
                    FormId = form.GetAttributeValue<Guid>("formid"),
                    Tab = tabName,
                    Section = sectionName,
                    Attribute = controlNode.Attributes["id"].Value,
                    Names = new Dictionary<int, string>()
                };
                crmFormLabels.Add(crmFormField);
            }

            var labelNode = cellNode.SelectSingleNode("labels/label[@languagecode='" + lcid + "']");
            var labelNodeAttributes = labelNode == null ? null : labelNode.Attributes;
            var labelDescription = labelNodeAttributes == null ? null : labelNodeAttributes["description"];

            if (crmFormField.Names.ContainsKey(lcid))
            {
                return;
            }

            crmFormField.Names.Add(lcid, labelDescription == null ? string.Empty : labelDescription.Value);
        }
コード例 #4
0
        private static int ExportField(List<int> languages, ExcelWorksheet labelSheet, int line,
          CrmFormLabel crmFormLabel)
        {
            var cell = 0;

            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Id.ToString("B");
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Form;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.FormUniqueId.ToString("B");
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.FormId.ToString("B");
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Tab;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Section;
            ZeroBasedSheet.Cell(labelSheet, line, cell++).Value = crmFormLabel.Attribute;

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

            line++;
            return line;
        }