コード例 #1
0
ファイル: DocParserBase.cs プロジェクト: Enzogord/QSProjects
        protected void AddField(Expression <Func <TDoc, object> > sourceProperty, string name, PatternFieldType fieldType)
        {
            var field = new PatternField();

            field.Name = name;
            field.Type = fieldType;
            if (RootObject != null)
            {
                try{
                    field.Value = sourceProperty.Compile().Invoke(RootObject);
                }
                catch (NullReferenceException ex)
                {
                    logger.Warn(ex, "При получении значения поля {0}, произошло исключение NullReferenceException.", name);
                }
            }
            fieldsList.Add(field);
            FieldsHasValues = RootObject != null;
        }
コード例 #2
0
        private void AddFieldDecl(PatternField field, VariableType type, XmlDocument content, XmlElement fieldsDels, List <string> existFilds)
        {
            var declNode = type == VariableType.User ? "user-field-decl" : "variable-decl";

            if (field.Type == PatternFieldType.FString)
            {
                if (existFilds.Contains(field.Name))
                {
                    return;
                }

                XmlElement newFieldNode = content.CreateElement("text", declNode, "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
                newFieldNode.SetAttribute("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "string");
                newFieldNode.SetAttribute("name", "urn:oasis:names:tc:opendocument:xmlns:text:1.0", field.Name);
                if (type == VariableType.User)
                {
                    newFieldNode.SetAttribute("string-value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "");
                }
                fieldsDels.AppendChild(newFieldNode);
            }
            else if (field.Type == PatternFieldType.FDate)
            {
                if (existFilds.Contains(field.Name))
                {
                    return;
                }

                XmlElement newFieldNode = content.CreateElement("text", declNode, "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
                newFieldNode.SetAttribute("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "string");
                //newFieldNode.SetAttribute ("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "date");
                //newFieldNode.SetAttribute ("date-value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "");
                newFieldNode.SetAttribute("name", "urn:oasis:names:tc:opendocument:xmlns:text:1.0", field.Name);
                if (type == VariableType.User)
                {
                    newFieldNode.SetAttribute("string-value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "");
                }

                fieldsDels.AppendChild(newFieldNode);
            }
            else if (field.Type == PatternFieldType.FCurrency)
            {
                if (!existFilds.Contains(field.Name + ".Число"))
                {
                    XmlElement newFieldNode = content.CreateElement("text", declNode, "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
                    newFieldNode.SetAttribute("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "currency");
                    string curr = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol;
                    newFieldNode.SetAttribute("currency", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", curr);
                    newFieldNode.SetAttribute("name", "urn:oasis:names:tc:opendocument:xmlns:text:1.0", field.Name + ".Число");
                    if (type == VariableType.User)
                    {
                        newFieldNode.SetAttribute("value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "0");
                    }

                    fieldsDels.AppendChild(newFieldNode);
                }
                if (!existFilds.Contains(field.Name + ".Пропись"))
                {
                    XmlElement newFieldNode = content.CreateElement("text", declNode, "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
                    newFieldNode.SetAttribute("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "string");
                    newFieldNode.SetAttribute("name", "urn:oasis:names:tc:opendocument:xmlns:text:1.0", field.Name + ".Пропись");
                    if (type == VariableType.User)
                    {
                        newFieldNode.SetAttribute("string-value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "");
                    }

                    fieldsDels.AppendChild(newFieldNode);
                }
            }
            else if (field.Type == PatternFieldType.FAutoRowNumber || field.Type == PatternFieldType.FNumber)
            {
                if (existFilds.Contains(field.Name))
                {
                    return;
                }

                XmlElement newFieldNode = content.CreateElement("text", declNode, "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
                newFieldNode.SetAttribute("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "float");
                newFieldNode.SetAttribute("name", "urn:oasis:names:tc:opendocument:xmlns:text:1.0", field.Name);
                fieldsDels.AppendChild(newFieldNode);
            }
        }
コード例 #3
0
ファイル: DocParserBase.cs プロジェクト: Enzogord/QSProjects
        protected void AddField(Expression <Func <TDoc, object> > sourceProperty, Expression <Func <TDoc, object> > nameFromProperty, PatternFieldType fieldType)
        {
            var name = PatternField.GetFieldName(nameFromProperty);

            AddField(sourceProperty, name, fieldType);
        }
コード例 #4
0
ファイル: PatternTable.cs プロジェクト: Enzogord/QSProjects
        public PatternTable <TDoc, TRow> AddColumn(Expression <Func <TRow, object> > sourceProperty, Expression <Func <TRow, object> > nameFromProperty, PatternFieldType fieldType)
        {
            var name = PatternField.GetFieldName(nameFromProperty);

            return(AddColumn(sourceProperty, name, fieldType));
        }