Ejemplo n.º 1
0
        /// <summary>
        /// 复制设置(不复制特定于实体的内容,如Index,Key等)
        /// </summary>
        /// <param name="source"></param>
        public void CopyConfig(PropertyConfig source, bool byName = true)
        {
            if (byName)
            {
                Name        = source.Name;        //_name
                Caption     = source.Caption;     //_caption
                Description = source.Description; //_description
                Alias       = source.Alias;       //Alias
            }
            //Agebull.EntityModel.Config.ConfigBase
            DenyScope = source.DenyScope;//阻止使用的范围


            IsUserReadOnly = source.IsUserReadOnly;       //IsUserReadOnly
            IsMemo         = source.IsMemo;               //IsMemo
            NoneJson       = source.NoneJson;             //NoneJson

            IsMoney = source.IsMoney;                     //IsMoney

            DataFormater = source.DataFormater;           //DataFormater
            DenyClient   = source.DenyClient;             //DenyClient

            CppType        = source.CppType;              //CppType
            CppName        = source.CppName;              //CppName
            CsType         = source.CsType;               //CsType
            Nullable       = source.Nullable;             //Nullable
            CustomType     = source.CustomType;           //CustomType
            IsCompute      = source.IsCompute;            //IsCompute
            ComputeGetCode = source.ComputeGetCode;       //ComputeGetCode
            ComputeSetCode = source.ComputeSetCode;       //ComputeSetCode
            IsSystemField  = source.IsSystemField;        //IsSystemField

            Initialization = source.Initialization;       //3初始值,原样写入代码,如果是文本,需要加引号
            EmptyValue     = source.EmptyValue;           //等同于空值的文本,多个用#号分开
            CanEmpty       = source.CanEmpty;             //这是数据相关的逻辑,表示在存储时必须写入数据,否则逻辑不正确
            Max            = source.Max;                  //最大
            Min            = source.Min;                  //最小
            UniqueString   = source.UniqueString;         //5是否唯一文本
            DbType         = source.DbType;               //DbType
            ArrayLen       = source.ArrayLen;             //ArrayLen
            Scale          = source.Scale;                //Scale

            Unicode           = source.Unicode;           //Unicode
            FixedLength       = source.FixedLength;       //FixedLength
            IsBlob            = source.IsBlob;            //IsBlob
            DbInnerField      = source.DbInnerField;      //数据库内部字段,如果为真,仅支持在SQL的语句中出现此字段,不支持外部的读写
            NoStorage         = source.NoStorage;         //是否不存储,如果为真,数据库的读写均忽略这个字段
            KeepStorageScreen = source.KeepStorageScreen; //跳过保存的场景
            CustomWrite       = source.CustomWrite;       //自定义保存,如果为真,数据库的写入忽略这个字段,数据的写入由代码自行维护

            LinkTable = source.LinkTable;                 //LinkTable


            IsUserId = source.IsUserId;                                   //IsUserId

            ExtendRole                = source.ExtendRole;                //扩展组合规划,
            ValueSeparate             = source.ValueSeparate;             //值分隔符
            ArraySeparate             = source.ArraySeparate;             //数组分隔符
            ExtendArray               = source.ExtendArray;               //是否扩展数组,是则解析为二维数组,否解析为一维数组
            IsKeyValueArray           = source.IsKeyValueArray;           //是否值对分隔方式,
            IsRelation                = source.IsRelation;                //是否为关系表,是则扩展组合规划 按 表名 解析成表间一对多关系
            ExtendPropertyName        = source.ExtendPropertyName;        //ExtendPropertyName
            ExtendClassName           = source.ExtendClassName;           //ExtendClassName
            ExtendClassIsPredestinate = source.ExtendClassIsPredestinate; //ExtendClassIsPredestinate
            _cppLastType              = source._cppLastType;              //_cppLastType
            IsMiddleField             = source.IsMiddleField;             //_middleField
            _innerField               = source._innerField;               //_innerField
            _columnName               = source._columnName;               //_columnName
            _dbNullable               = source._dbNullable;               //_dbNullable
            _datalen = source._datalen;                                   //_datalen
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 复制值
 /// </summary>
 /// <param name="source"></param>
 public void CopyFrom(PropertyConfig source)
 {
     //Agebull.EntityModel.Config.SimpleConfig
     Name        = source.Name;                                    //_name
     Caption     = source.Caption;                                 //_caption
     Description = source.Description;                             //_description
     //Agebull.EntityModel.Config.ConfigBase
     DenyScope   = source.DenyScope;                               //阻止使用的范围
     IsReference = source.IsReference;                             //_isReference
     //Agebull.EntityModel.Config.PropertyConfig
     Alias            = source.Alias;                              //Alias
     Group            = source.Group;                              //Group
     CreateIndex      = source.CreateIndex;                        //CreateIndex
     IsUserReadOnly   = source.IsUserReadOnly;                     //IsUserReadOnly
     IsMemo           = source.IsMemo;                             //IsMemo
     NoneJson         = source.NoneJson;                           //NoneJson
     FormCloumnSapn   = source.FormCloumnSapn;                     //FormCloumnSapn
     FormOption       = source.FormOption;                         //FormOption
     IsMoney          = source.IsMoney;                            //IsMoney
     GridAlign        = source.GridAlign;                          //GridAlign
     GridWidth        = source.GridWidth;                          //GridWidth
     DataFormater     = source.DataFormater;                       //DataFormater
     DenyClient       = source.DenyClient;                         //DenyClient
     GridDetails      = source.GridDetails;                        //GridDetails
     NoneGrid         = source.NoneGrid;                           //NoneGrid
     NoneDetails      = source.NoneDetails;                        //NoneDetails
     GridDetailsCode  = source.GridDetailsCode;                    //GridDetailsCode
     CppType          = source.CppType;                            //CppType
     CppName          = source.CppName;                            //CppName
     CsType           = source.CsType;                             //CsType
     Nullable         = source.Nullable;                           //Nullable
     CustomType       = source.CustomType;                         //CustomType
     IsCompute        = source.IsCompute;                          //IsCompute
     ComputeGetCode   = source.ComputeGetCode;                     //ComputeGetCode
     ComputeSetCode   = source.ComputeSetCode;                     //ComputeSetCode
     IsSystemField    = source.IsSystemField;                      //IsSystemField
     IsInterfaceField = source.IsInterfaceField;                   //IsInterfaceField
     Initialization   = source.Initialization;                     //3初始值,原样写入代码,如果是文本,需要加引号
     EmptyValue       = source.EmptyValue;                         //等同于空值的文本,多个用#号分开
     CanEmpty         = source.CanEmpty;                           //这是数据相关的逻辑,表示在存储时必须写入数据,否则逻辑不正确
     Max                       = source.Max;                       //最大
     Min                       = source.Min;                       //最小
     UniqueString              = source.UniqueString;              //5是否唯一文本
     DbType                    = source.DbType;                    //DbType
     ArrayLen                  = source.ArrayLen;                  //ArrayLen
     Scale                     = source.Scale;                     //Scale
     DbIndex                   = source.DbIndex;                   //DbIndex
     Unicode                   = source.Unicode;                   //Unicode
     FixedLength               = source.FixedLength;               //FixedLength
     IsBlob                    = source.IsBlob;                    //IsBlob
     DbInnerField              = source.DbInnerField;              //数据库内部字段,如果为真,仅支持在SQL的语句中出现此字段,不支持外部的读写
     NoStorage                 = source.NoStorage;                 //是否不存储,如果为真,数据库的读写均忽略这个字段
     KeepStorageScreen         = source.KeepStorageScreen;         //跳过保存的场景
     CustomWrite               = source.CustomWrite;               //自定义保存,如果为真,数据库的写入忽略这个字段,数据的写入由代码自行维护
     IsLinkField               = source.IsLinkField;               //IsLinkField
     LinkTable                 = source.LinkTable;                 //LinkTable
     IsLinkKey                 = source.IsLinkKey;                 //IsLinkKey
     IsLinkCaption             = source.IsLinkCaption;             //IsLinkCaption
     IsUserId                  = source.IsUserId;                  //IsUserId
     LinkField                 = source.LinkField;                 //LinkField
     ExtendRole                = source.ExtendRole;                //扩展组合规划,
     ValueSeparate             = source.ValueSeparate;             //值分隔符
     ArraySeparate             = source.ArraySeparate;             //数组分隔符
     ExtendArray               = source.ExtendArray;               //是否扩展数组,是则解析为二维数组,否解析为一维数组
     IsKeyValueArray           = source.IsKeyValueArray;           //是否值对分隔方式,
     IsRelation                = source.IsRelation;                //是否为关系表,是则扩展组合规划 按 表名 解析成表间一对多关系
     ExtendPropertyName        = source.ExtendPropertyName;        //ExtendPropertyName
     ExtendClassName           = source.ExtendClassName;           //ExtendClassName
     ExtendClassIsPredestinate = source.ExtendClassIsPredestinate; //ExtendClassIsPredestinate
     _isRequired               = source._isRequired;               //_isRequired
     _prefix                   = source._prefix;                   //_prefix
     _suffix                   = source._suffix;                   //_suffix
     _inputType                = source._inputType;                //_inputType
     _comboBoxUrl              = source._comboBoxUrl;              //_comboBoxUrl
     _cppLastType              = source._cppLastType;              //_cppLastType
     IsMiddleField             = source.IsMiddleField;             //_middleField
     _innerField               = source._innerField;               //_innerField
     _columnName               = source._columnName;               //_columnName
     _dbNullable               = source._dbNullable;               //_dbNullable
     _datalen                  = source._datalen;                  //_datalen
 }
Ejemplo n.º 3
0
 private static string CustomName(PropertyConfig col, string pre)
 {
     return(col.CustomType == null ? $"{pre}{col.Name}" : $"({col.CustomType}){pre}{col.Name}");
 }
 private string PropertyName2(PropertyConfig col, string pre)
 {
     return(col.CustomType == null ? $"{pre}{col.PropertyName}" : $"({col.CsType}){pre}{col.PropertyName}");
 }
Ejemplo n.º 5
0
        private void ExtendCode(StringBuilder code, PropertyConfig field, Dictionary <string, object> chFields)
        {
            if (field.ExtendClassIsPredestinate)
            {
                code.AppendFormat(@"

        {2} _{3};
        /// <summary>
        /// {0}的解析值
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public {2} {3}
        {{
            get
            {{
                if(_{3} != null)
                    return _{3};
                if(string.IsNullOrWhiteSpace({1}))
                    return _{3} = new {2}();
                return _{3} = new {2}({1});
            }}
        }}"
                                  , field.Caption
                                  , field.Name
                                  , field.ExtendClassName
                                  , field.ExtendPropertyName ?? ("V_" + field.Name));
                return;
            }
            code.AppendFormat(@"

        {3} _{4};
        /// <summary>
        /// {0}的解析值
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public {3} {4}
        {{
            get
            {{
                if(_{4} != null)
                    return _{4};
                
                if(string.IsNullOrWhiteSpace({1}))
                    return _{4} = new {3}();
                var ov = {1}.Split(new[] {{ '{2}' }}, StringSplitOptions.RemoveEmptyEntries);
                return _{4} = new {3}
                {{"
                              , field.Caption
                              , field.Name
                              , string.IsNullOrWhiteSpace(field.ValueSeparate) ? "," : field.ValueSeparate
                              , field.ExtendClassName ?? ("X_" + field.Name)
                              , field.ExtendPropertyName ?? ("V_" + field.Name));
            int idx = 0;

            foreach (var kv in chFields)
            {
                var tableSchema = kv.Value as EntityConfig;
                if (tableSchema != null)
                {
                    code.AppendFormat(@"
                    {0} = ov.Length <= {2} ? default({1}) :{1}.Parse(ov[{2}]),", kv.Key, tableSchema.PrimaryColumn.CsType, idx++);
                }
                else
                {
                    string type = kv.Value.ToString();
                    if (type == "string")
                    {
                        code.AppendFormat(@"
                    {0} = ov.Length <= {1} ? null : ov[{1}],", kv.Key, idx++);
                    }
                    else
                    {
                        code.AppendFormat(@"
                    {0} = ov.Length <= {2} ? default({1}) :{1}.Parse(ov[{2}]),", kv.Key, type, idx++);
                    }
                }
            }
            code.Append(@"
                };
            }
        }");
        }
Ejemplo n.º 6
0
        private void KeyValueArrayValidatCode(StringBuilder code, PropertyConfig field, Dictionary <string, object> chFields)
        {
            code.Append($@"
            {{
                var ov = {field.Name}.Split(new[] {{ '{(string.IsNullOrWhiteSpace(field.ArraySeparate) ? "#" : field.ArraySeparate)}' }});
                if(ov.Length == 0)
                {{
                    result.Add(""{field.Caption}"",nameof({field.Name}),$""数据不合格,长度应该为{chFields.Count}个"");
                }}
                else
                {{
                    var ovs = ov.Select(p => p.Split(new[] {{ '{(string.IsNullOrWhiteSpace(field.ValueSeparate) ? "," : field.ValueSeparate)}' }})).ToArray();
                    bool chItem=true;
                    for(int index = 1;index < {chFields.Count};index++)
                    {{
                        if(ovs[0].Length != ovs[index].Length)
                        {{
                            result.Add(""{field.Caption}"",nameof({field.Name}),$""数据不合格,每组数量应该相同"");
                            chItem = false;
                        }}
                    }}
                    if(chItem)
                    {{
                        for(int index = 1;index < {chFields.Count};index++)
                        {{");


            int idx = 0;

            foreach (var kv in chFields)
            {
                var tableSchema = kv.Value as EntityConfig;
                if (tableSchema != null)
                {
                    code.Append($@"
                            {{
                                {tableSchema.PrimaryColumn.CsType} vl;
                                if(!{tableSchema.PrimaryColumn.CsType}.TryParse(ovs[{idx++}][index],out vl))
                                    result.Add(""{field.Caption}"",nameof({field.Name}),$""第{{index}}组第{idx++}个数据值{{ovs[index][{idx++}]}}应该为{tableSchema.PrimaryColumn.CsType},但转换失败"");
                                else if(vl > 0 && {this.Project.DataBaseObjectName}.Default.{tableSchema.Name.ToPluralism()}.LoadByPrimaryKey(vl) == null)
                                    result.Add(""{field.Caption}"",nameof({field.Name}),$""第{{index}}组第{idx++}个数据值{{ovs[index][{idx++}]}}在{tableSchema.Caption ?? tableSchema.Name}中找不到对应的数据"");
                            }}");
                }
                else
                {
                    string type = kv.Value.ToString();
                    if (type == "string")
                    {
                        code.Append($@"
                            {{
                                if(string.IsNullOrWhiteSpace(ovs[{idx++}][index]))
                                    result.Add(""{field.Caption}"",nameof({field.Name}),$""第{{index}}组第{idx++}个数据值{{ovs[index][{idx++}]}}不应该为空"");
                            }}");
                    }
                    else
                    {
                        code.Append($@"
                            {{
                                {type} vl;
                                if(!{type}.TryParse(ovs[{idx++}][index],out vl))
                                    result.Add(""{field.Caption}"",nameof({field.Name}),$""第{{index}}组第{idx++}个数据值{{ovs[index][{idx++}]}}应该为{type},但转换失败"");
                            }}");
                    }
                }
            }
            code.Append(@"
                        }
                    }
                }
            }");
        }
Ejemplo n.º 7
0
        private string RelationCode(PropertyConfig field)
        {
            var friend = Entities.FirstOrDefault(p => p.Name.Equals(field.ExtendRole, StringComparison.OrdinalIgnoreCase));

            if (friend == null)
            {
                return(null);// throw new Exception(string.Format("{0}的字段{1}关联到的表{2}不存在", Entity.Caption, field.Caption, field.ExtendRole));
            }

            if (field.ExtendArray)
            {
                return(string.Format(@"
        List<long> _l{3};
        /// <summary>
        /// 对应的{0}表
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public List<long> {5}
        {{
            get
            {{
                if(_l{3} != null)
                    return _l{3};
                if(string.IsNullOrWhiteSpace({2}))
                    return _l{3}=new List<long>();
                return _l{3}= {2}.Split(new[] {{ '{4}' }}, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToList();
            }}
        }}
        IList<{1}> _{3};
        /// <summary>
        /// 对应的{0}表
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public IList<{1}> {3}
        {{
            get
            {{
                if(_{3} != null)
                    return _{3};
                if({5}.Count == 0)
                    return _{3}=new List<{1}>();
                return _{3}={1}.GetByIds({5});
            }}
        }}"
                                     , friend.Caption
                                     , friend.Name
                                     , field.Name
                                     , string.IsNullOrWhiteSpace(field.ExtendPropertyName) ? (field.Name + friend.Name) : field.ExtendPropertyName
                                     , string.IsNullOrWhiteSpace(field.ValueSeparate) ? "," : field.ValueSeparate
                                     , field.Name.ToPluralism()));
            }


            return(string.Format(@"
        {1} _{3};
        /// <summary>
        /// 对应的{0}表
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public {1} {3}
        {{
            get
            {{
                return {2} <= 0 ? null : (_{3} ?? (_{3} = {1}.GetById({2})));
            }}
        }}"
                                 , friend.Caption, friend.Name, field.Name, field.ExtendPropertyName ?? ("V_" + field.Name)));
        }
Ejemplo n.º 8
0
        private void ExtendArrayCode(StringBuilder code, PropertyConfig field, Dictionary <string, object> chFields)
        {
            if (field.ExtendClassIsPredestinate)
            {
                code.AppendFormat(@"

        List<{3}> _{4};
        /// <summary>
        /// {0}的解析值
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public List<{3}> {4}
        {{
            get
            {{
                if(_{4} != null)
                    return _{4};
                _{4} = new List<{3}>();
                if(string.IsNullOrWhiteSpace({1}))
                    return _{4};
                var ov = {1}.Split(new[] {{ '{2}' }}, StringSplitOptions.RemoveEmptyEntries);
                foreach(var vl in ov)
                {{
                    _{4}.Add(new {3}(vl));
                }}
                return _{4};
            }}
        }}"
                                  , field.Caption
                                  , field.Name
                                  , string.IsNullOrWhiteSpace(field.ArraySeparate) ? "#" : field.ArraySeparate
                                  , field.ExtendClassName
                                  , field.ExtendPropertyName ?? ("V_" + field.Name));
                return;
            }
            code.AppendFormat(@"
        List<{4}> _{5};
        /// <summary>
        /// {0}的解析值
        /// </summary>
        [IgnoreDataMember,Browsable (false)]
        public List<{4}> {5}
        {{
            get
            {{
                if(_{5} != null)
                    return _{5};
                _{5} = new List<{4}>();
                if(string.IsNullOrWhiteSpace({1}))
                    return _{5};
                var ov = {1}.Split(new[] {{ '{2}' }}, StringSplitOptions.RemoveEmptyEntries);
                var ovs = ov.Select(p => p.Split(new[] {{ '{3}' }}, StringSplitOptions.RemoveEmptyEntries)).ToArray();
                for(int index = 0;index < ovs.Length;index++)
                {{
                    _{5}.Add(new {4}
                    {{"
                              , field.Caption
                              , field.Name
                              , string.IsNullOrWhiteSpace(field.ArraySeparate) ? "#" : field.ArraySeparate
                              , string.IsNullOrWhiteSpace(field.ValueSeparate) ? "," : field.ValueSeparate
                              , ("X_" + field.Name)
                              , field.ExtendPropertyName ?? ("V_" + field.Name));
            int idx = 0;

            foreach (var kv in chFields)
            {
                var tableSchema = kv.Value as EntityConfig;
                if (tableSchema != null)
                {
                    code.AppendFormat(@"
                        {0} = ovs[index].Length <= {2} ? default({1}) : {1}.Parse(ovs[index][{2}]),", kv.Key, tableSchema.PrimaryColumn.CsType, idx++);
                }
                else
                {
                    string type = kv.Value.ToString();
                    if (type == "string")
                    {
                        code.AppendFormat(@"
                        {0} = ovs[index].Length <= {1} ? null : ovs[index][{1}],", kv.Key, idx++);
                    }
                    else
                    {
                        code.AppendFormat(@"
                        {0} = ovs[index].Length <= {2} ? default({1}) : {1}.Parse(ovs[index][{2}]),", kv.Key, type, idx++);
                    }
                }
            }
            code.AppendFormat(@"
                    }});
                }}
                return _{0};
            }}
        }}", field.ExtendPropertyName ?? ("V_" + field.Name));
        }
Ejemplo n.º 9
0
        private void ExtendValidateCode(StringBuilder code, PropertyConfig field, Dictionary <string, object> chFields)
        {
            code.Append($@"
            {{
                var ov = {field.Name}.Split(new[] {{ '{(string.IsNullOrWhiteSpace(field.ValueSeparate) ? "#" : field.ValueSeparate)}' }});
                if(ov.Length < {chFields.Count})
                {{
                    result.AddWarning(""{field.Caption}"",nameof({field.Name}),$""长度应该为{chFields.Count},数据已设置为空"");
                    {field.Name} = null;
                }}
                else
                {{");
            int idx = 0;

            foreach (var kv in chFields)
            {
                var tableSchema = kv.Value as EntityConfig;
                if (tableSchema != null)
                {
                    code.Append($@"
                    if(ov.Length > {idx++})
                    {{
                        {tableSchema.PrimaryColumn.CsType} vl;
                        if(!{tableSchema.PrimaryColumn.CsType}.TryParse(ov[{idx++}],out vl))
                        {{
                            result.AddWarning(""{field.Caption}"",nameof({field.Name}),$""第{idx++}个值应该为{tableSchema.PrimaryColumn.CsType},但转换失败,数据已设置为空"");
                            {field.Name} = null;
                        }}
                        else if(vl > 0 && {tableSchema.Name}.GetById(vl) == null)
                        {{
                            result.AddWarning(""{field.Caption}"",nameof({field.Name}),$""第{idx++}个值{tableSchema.PrimaryColumn.CsType}无法在{tableSchema.Caption ?? tableSchema.Name}中找到对应的数据,数据已设置为空"");
                            {field.Name} = null;
                        }}
                    }}");
                }
                else
                {
                    string type = kv.Value.ToString();
                    if (type == "string")
                    {
                        code.Append($@"
                    if(ov.Length > {idx++})
                    {{
                        if(string.IsNullOrWhiteSpace(ov[{idx++}]))
                        {{
                            result.AddWarning(""{field.Caption}"",nameof({field.Name}),$""第{idx++}个值不应该为空,数据已设置为空"");
                            {field.Name} = null;
                        }}
                    }}");
                    }
                    else
                    {
                        code.Append($@"
                    if(ov.Length > {idx++})
                    {{
                        {type} vl;
                        if(!{type}.TryParse(ov[{idx++}],out vl))
                        {{
                            result.AddWarning(""{field.Caption}"",nameof({field.Name}),$""第{idx++}个值应该为{type},但转换失败,数据已设置为空"");
                            {field.Name} = null;
                        }}
                    }}");
                    }
                }
            }
            code.Append(@"
                }
            }");
        }
Ejemplo n.º 10
0
 private string ExtendCodeCode(PropertyConfig field)
 {
     return(field.IsRelation ? RelationCode(field) : SubClassCode(field));
 }
Ejemplo n.º 11
0
        private static void ConfigureContext()
        {
            var currentStatusPropertyConfig = new PropertyConfig("CurrentStatus")
            {
                Converter = typeof(StatusConverter)
            };

            var employeeMapping = new TypeMapping(typeof(Employee), "HashRangeTable");

            employeeMapping.AddProperty(new PropertyConfig("ManagerName")
            {
                Attribute = "Manager"
            });
            employeeMapping.AddProperty(new PropertyConfig("CompanyName")
            {
                Attribute = "Company"
            });
            employeeMapping.AddProperty(new PropertyConfig("InternalId")
            {
                Ignore = true
            });
            employeeMapping.AddProperty(currentStatusPropertyConfig);

            var employee2Mapping = new TypeMapping(typeof(Employee2), "HashRangeTable");

            employee2Mapping.AddProperty(currentStatusPropertyConfig);

            var employee3Mapping = new TypeMapping(typeof(Employee3), "HashRangeTable");

            employee3Mapping.AddProperty(currentStatusPropertyConfig);

            var versionedEmployeeMapping = new TypeMapping(typeof(VersionedEmployee), "FakeTable");

            versionedEmployeeMapping.AddProperty(new PropertyConfig("Version")
            {
                Ignore = true
            });

            var context = AWSConfigsDynamoDB.Context;

            context.TableAliases["FakeTable"] = "HashRangeTable";


            //to save retries
            if (!context.TypeMappings.ContainsKey(typeof(VersionedEmployee)))
            {
                context.AddMapping(versionedEmployeeMapping);
            }
            if (!context.TypeMappings.ContainsKey(typeof(Employee3)))
            {
                context.AddMapping(employee3Mapping);
            }

            if (!context.TypeMappings.ContainsKey(typeof(Employee2)))
            {
                context.AddMapping(employee2Mapping);
            }
            if (!context.TypeMappings.ContainsKey(typeof(Employee)))
            {
                context.AddMapping(employeeMapping);
            }
        }
Ejemplo n.º 12
0
     public static void FieldCmp(StringBuilder code, PropertyConfig field)
     {
         CppTypeHelper.DoByCppType(field.Parent, field,
                                   (pro, len) =>
         {
             code.Append($@"
 if(strcmp(field_org.{field.Name},field_dec.{field.Name}) != 0)
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" << field_org.{field.Name} << ""***""<<field_dec.{field.Name}<<endl;
 }}");
         },
                                   (pro, type, len) =>
         {
             if (type == "tm" || len > 1)
             {
                 code.Append($@"
 if(memcmp(&field_org.{field.Name},&field_dec.{field.Name},sizeof(tm)) != 0)
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" <<endl;
 }}");
             }
             else
             {
                 code.Append($@"
 if( field_org.{field.Name} != field_dec.{field.Name})
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" << field_org.{field.Name} << ""***""<< field_dec.{field.Name}<<endl;
 }}");
             }
         },
                                   (pro, en, len) =>
         {
             code.Append($@"
 if(memcmp(&field_org.{field.Name},&field_dec.{field.Name},sizeof({en.Name})) != 0)
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" <<endl;
 }}");
         },
                                   (pro, ty, len) =>
         {
             if (len > 1)
             {
                 code.Append($@"
 if(memcmp(&field_org.{field.Name},&field_dec.{field.Name},sizeof(tm)) != 0)
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" <<endl;
 }}");
             }
             else
             {
                 code.Append($@"
 if( field_org.{field.Name} != field_dec.{field.Name})
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" << field_org.{field.Name} << ""***""<< field_dec.{field.Name}<<endl;
 }}");
             }
         },
                                   (pro, em, len) =>
         {
             if (len > 1)
             {
                 code.Append($@"
 if(memcmp(&field_org.{field.Name},&field_dec.{field.Name},sizeof(tm)) != 0)
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" <<endl;
 }}");
             }
             else
             {
                 code.Append($@"
 if( field_org.{field.Name} != field_dec.{field.Name})
 {{
     succeed = false;
     cout << ""    {field.Caption}失败:"" << field_org.{field.Name} << ""***""<< field_dec.{field.Name}<<endl;
 }}");
             }
         });
     }
Ejemplo n.º 13
0
     public static void GetRandomValue(StringBuilder code, PropertyConfig field, string entityName)
     {
         CppTypeHelper.DoByCppType(field.Parent, field,
                                   (pro, len) =>
         {
             int len2  = (len - 1) / 2;
             var value = TestLine[random.Next(TestLine.Length - 1)];
             if (value.Length > len2)
             {
                 value = value.Substring(0, len2);
             }
             code.Append($@"
 //{field.Caption} -- char[{len}]
 strcpy_s({entityName}.{field.Name},""{value}"");");
         },
                                   (pro, type, len) =>
         {
             if (type == "tm")
             {
                 DateTime tm = DateTime.Now;
                 code.Append($@"
 //{field.Caption} -- {type}
 {entityName}.{field.Name}.tm_year = {tm.Year };
 {entityName}.{field.Name}.tm_mon = {tm.Month };
 {entityName}.{field.Name}.tm_mday = {tm.Day };
 {entityName}.{field.Name}.tm_hour = {tm.Hour};
 {entityName}.{field.Name}.tm_min = {tm.Minute};
 {entityName}.{field.Name}.tm_sec = {tm.Second};");
             }
             else if (len <= 0)
             {
                 code.Append($@"
 //{field.Caption} -- {type}
 {entityName}.{field.Name} = {GetBaseTypeValue(type)};");
             }
             else
             {
                 code.Append($@"
 //{field.Caption} -- {type}[{len}]");
                 for (int idx = 0; idx < len; idx++)
                 {
                     code.Append($@"
 {entityName}.{field.Name}[{idx}] = {GetBaseTypeValue(type)};");
                 }
             }
         },
                                   (pro, en, len) =>
         {
             code.Append($@"
 //{field.Caption} -- {en.Caption}
 {CreateEntityCode(en, $"{entityName}.{field.Name}", false)};");
         },
                                   (pro, type, len) =>
         {
             var value = type.Items.Values.ToArray()[random.Next(type.Items.Count - 1)].Value;
             if (value == "'")
             {
                 value = "'\\0'";
             }
             code.Append($@"
 //{field.Caption} -- {type}
 {entityName}.{field.Name} = {value};");
         },
                                   (pro, enumcfg, len) =>
         {
             var value = enumcfg.Items[random.Next(enumcfg.Items.Count - 1)].Name;
             code.Append($@"
 //{field.Caption} -- {enumcfg}
 {entityName}.{field.Name} = GBS::Futures::{enumcfg.Name}Classify::{value};");
         });
     }
Ejemplo n.º 14
0
        private static void FormField(StringBuilder code, PropertyConfig field, string caption, string description)
        {
            string cssEnd = "";
            int    wid    = 0;

            if (field.FormCloumnSapn > 1)
            {
                cssEnd = "_" + field.FormCloumnSapn + "c";
                code.Append(@"<br/>");
            }

            code.Append($@"
            <div class='inputField{cssEnd}' id='fr_{field.Name}'>
                <div class='inputRegion' id='ir_{field.Name}'>
                    <div class='inputLabel'>{caption}:</div>");

            PropertyEasyUiModel.CheckField(field);

            if (field.InputType == "editor")
            {
                var css = field.FormCloumnSapn <= 1 ? "inputValue_Rich_S" : "inputValue_Rich";
                code.Append($@"<br/>
                    <div class='inputValue_Rich_b'>
                        <div id='{field.Name}' name='{field.Name}' class='myueditor {css}'></div>
                    </div>");
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(field.Prefix))
                {
                    code.Append(field.Prefix);
                }

                string br = null;
                string css;
                string attributes = "";
                if (field.MulitLine)
                {
                    br  = "<br/>";
                    css = field.FormCloumnSapn <= 1 ? "inputValue_Memo_S" : "inputValue_Memo";
                }
                else
                {
                    css = "inputValue" + cssEnd + " inputS";
                    if (field.IsMoney)
                    {
                        wid = 120;
                        if (field.FormCloumnSapn > 2)
                        {
                            wid += (field.FormCloumnSapn - 1) * 485;
                        }
                    }
                    else
                    {
                        int len = 0;
                        if (!string.IsNullOrWhiteSpace(field.Prefix))
                        {
                            len = field.Prefix.Length;
                        }
                        if (!string.IsNullOrWhiteSpace(field.Suffix))
                        {
                            len += field.Suffix.Length;
                        }

                        if (len > 0)
                        {
                            if (field.FormCloumnSapn > 2)
                            {
                                wid = (field.FormCloumnSapn - 1) * 485;
                            }
                            else
                            {
                                wid = 480;
                            }
                            wid -= len * 12;
                        }
                    }
                    if (wid > 0)
                    {
                        attributes += $" style='width:{wid}px'";
                    }
                    if (field.IsLinkKey)
                    {
                        var title = field.Parent.Properties.FirstOrDefault(p => p.LinkTable == field.LinkTable && p.IsLinkCaption);
                        if (title != null)
                        {
                            attributes += $" readfield='{title.Name}'";
                        }
                    }
                }


                var options = FieldOptions(field, description);
                code.Append($@"{br}
                    <input id='{field.Name}' name='{field.Name}' class='{css} {field.InputType}'{attributes}
                           data-options=""{options}""/>");
                if (!string.IsNullOrWhiteSpace(field.Suffix))
                {
                    code.Append(field.Suffix);
                }
                if (field.IsMoney)
                {
                    code.Append($@"<label id = 'cm_{field.Name}' style = 'color: red;' ></label>");
                }
            }
            code.Append(@"
                </div>
            </div>");
            //code.Append(
            //    $@"
            //    </div>
            //    <div class='inputHelp' id='hr_{field.Name}'>{
            //        description}</div>
            //</div>");
        }
 static EntityInterfaceCommand()
 {
     using (LoadingModeScope.CreateScope())
     {
         _dataState = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "数据状态",
             Description      = "数据状态",
             Index            = -1,//100,
             Name             = "DataState",
             CustomType       = "DataStateType",
             CsType           = "int",
             ColumnName       = "data_state",
             Initialization   = "0",
             DbType           = "INT",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_数据状态"
         };
         _isFreeze = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "数据是否已冻结",
             Description      = "数据是否已冻结",
             Index            = -1,//101,
             Name             = "IsFreeze",
             CsType           = "bool",
             ColumnName       = "is_freeze",
             Initialization   = "0",
             DbType           = "BOOL",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_数据状态"
         };
         _authorId = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "制作人",
             Description      = "制作人",
             Index            = -1,//102,
             Name             = "AuthorID",
             CsType           = "int",
             ColumnName       = "author_id",
             DbType           = "int",
             Initialization   = "0",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_历史"
         };
         _addDate = new PropertyConfig
         {
             IsPredefined = true,
             Caption      = "制作时间",
             Description  = "制作时间",
             Index        = -1,//103,
             Name         = "AddDate",
             CsType       = "DateTime",
             //IsCompute = true,
             ColumnName       = "add_date",
             DbType           = "DateTime",
             DbNullable       = true,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_历史"
         };
         _lastReviserId = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "最后修改者",
             Description      = "最后修改者",
             Index            = -1,//104,
             Name             = "LastReviserID",
             CsType           = "int",
             ColumnName       = "last_reviser_id",
             DbType           = "int",
             Initialization   = "0",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_历史"
         };
         _lastModifyDate = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "最后修改日期",
             Description      = "最后修改日期",
             Index            = -1,//105,
             Name             = "LastModifyDate",
             CsType           = "DateTime",
             ColumnName       = "last_modify_date",
             DbType           = "DateTime",
             DbNullable       = true,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_历史"
         };
         _auditState = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "审核状态",
             Description      = "审核状态",
             Index            = -1,//106,
             Name             = "AuditState",
             CustomType       = "AuditStateType",
             CsType           = "int",
             ColumnName       = "audit_state",
             DbType           = "int",
             Initialization   = "0",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_审核"
         };
         _auditorId = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "审核人",
             Description      = "审核人",
             Index            = -1,//107,
             Name             = "AuditorId",
             CsType           = "int",
             ColumnName       = "auditor_id",
             DbType           = "int",
             Initialization   = "0",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_审核"
         };
         _auditDate = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "审核时间",
             Description      = "审核时间",
             Index            = -1,//108,
             Name             = "AuditDate",
             CsType           = "DateTime",
             ColumnName       = "audit_date",
             DbType           = "DateTime",
             DbNullable       = true,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "系统_审核"
         };
         _memo = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "备注",
             Description      = "备注",
             Index            = -1,//27,
             Name             = "Memo",
             CsType           = "string",
             CanEmpty         = true,
             ColumnName       = "memo",
             DbType           = "TEXT",
             DbNullable       = true,
             IsSystemField    = false,
             IsInterfaceField = false,
             Group            = "备注",
             IsMemo           = true
         };
         _parent = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "上级标识",
             Description      = "上级标识,顶级为0",
             Index            = -1,//27,
             Name             = "ParentId",
             CsType           = "int",
             ColumnName       = "parent_id",
             DbType           = "int",
             DbNullable       = false,
             IsSystemField    = true,
             IsInterfaceField = true,
             Group            = "树形"
         };
         _slaveOId = new PropertyConfig
         {
             IsPredefined     = true,
             Caption          = "下级机构ID",
             Description      = "用于下级机构ID查找到对应的上级",
             Index            = -1,//28,
             Name             = "SlaveOrgId",
             CsType           = "int",
             ColumnName       = "slave_org_id",
             DbType           = "int",
             DbNullable       = false,
             IsSystemField    = false,
             IsInterfaceField = false,
             Group            = "行级权限"
         };
     }
 }