Пример #1
0
 /// <summary>
 ///     复制值
 /// </summary>
 /// <param name="source">复制的源字段</param>
 /// <param name="noChilds">是否复制子级(默认为是)</param>
 public void CopyValue(EntityConfig source, bool noChilds = false)
 {
     Caption       = source.Caption + "(复制)";
     Description   = source.Description;
     Name          = source.Name + "Copy";
     DataVersion   = source.DataVersion;
     DbIndex       = source.DbIndex;
     IsInternal    = source.IsInternal;
     NoDataBase    = source.NoDataBase;
     ReadTableName = source.ReadTableName;
     SaveTableName = source.SaveTableName;
     Classify      = source.Classify;
     CppName       = source.CppName;
     ReferenceKey  = source.ReferenceKey;
     TreeUi        = source.TreeUi;
     if (noChilds)
     {
         return;
     }
     foreach (var field in source.Properties)
     {
         var nf = new PropertyConfig();
         nf.CopyFrom(field);
         if (field.IsPrimaryKey)
         {
             nf.IsPrimaryKey = true;
         }
         Add(nf);
     }
 }
Пример #2
0
        private void FindApiClientArg(EntityConfig friend, ApiItem item, ProjectConfig apiProject)
        {
            var entity = GetEntity(p => p != friend && p.ReferenceKey == friend.Key);
            var count  = friend.Properties.Count(p => p.Name != "ClientNo");

            switch (count)
            {
            case 0:
                item.ResultArg = null;
                if (entity != null)
                {
                    entity.Option.IsDelete = true;
                }
                return;

            case 1:
                item.ResultArg =
                    CppTypeHelper.CppTypeToCsType(friend.Properties.FirstOrDefault(p => p.Name != "ClientNo"));
                if (entity != null)
                {
                    entity.Option.IsDelete = true;
                }
                return;
            }
            if (entity == null)
            {
                entity = new EntityConfig
                {
                    Parent  = apiProject,
                    Project = apiProject.Name,
                    CppName = item.CallArg,
                    Name    = ToClientName(item.CallArg),
                    Tag     = friend.Tag
                };
                apiProject.Add(entity);
            }
            entity.NoDataBase   = true;
            entity.ReferenceKey = friend.Key;
            entity.Caption      = item.Caption + "命令调用参数";
            entity.Description  = item.Caption + "命令调用参数";
            item.ResultArg      = entity.Name;

            foreach (var property in friend.Properties)
            {
                var fp = entity.Properties.FirstOrDefault(p => p.ReferenceKey == property.Key)
                         ?? entity.Properties.FirstOrDefault(p => p.Name == property.Name);
                if (fp == null)
                {
                    fp = new PropertyConfig();
                    fp.CopyFrom(property);
                    fp.Parent = entity;
                    entity.Add(fp);
                }
                fp.Parent = entity;
                fp.Option.ReferenceKey = property.Option.Key;
                fp.Caption             = property.Caption;
                fp.Tag = entity.Tag + "," + property.Name;
            }
        }
        private void FindNitifyClientEntity(EntityConfig friend, ProjectConfig apiProject, NotifyItem item)
        {
            var entity = GlobalConfig.GetEntity(p => p != friend && p.Tag == friend.Tag);

            if (entity == null)
            {
                entity = new EntityConfig
                {
                    Parent      = apiProject,
                    Project     = apiProject.Name,
                    CppName     = friend.Name,
                    Name        = ToClientName(friend.Name),
                    Caption     = item.Caption,
                    Description = item.Caption + "(消息通知)",
                    IsClass     = false,
                    Classify    = friend.Classify,
                    Tag         = friend.Tag
                };
                apiProject.Entities.Add(entity);
                SolutionConfig.Current.Entities.Add(entity);
            }
            item.ClientEntity = entity.Name;
            if (entity.PrimaryColumn == null)
            {
                entity.Properties.Add(new PropertyConfig
                {
                    Name         = entity.Name + "Id",
                    Caption      = entity.Caption + "ID",
                    Description  = entity.Caption + "ID",
                    IsPrimaryKey = true,
                    IsIdentity   = true,
                    CsType       = "int",
                    CppType      = "int",
                    Parent       = entity
                });
            }
            foreach (var property in friend.Properties)
            {
                property.CsType = CppTypeHelper.CppTypeToCsType(property);
                property.Tag    = friend.Tag + "," + property.Name;
                var fp = entity.Properties.FirstOrDefault(p => p.Tag != null && p.Tag == property.Tag)
                         ?? entity.Properties.FirstOrDefault(p => p.Name == property.Name);
                if (fp == null)
                {
                    fp = new PropertyConfig();
                    fp.CopyFrom(property);
                    fp.Parent = entity;
                    entity.Properties.Add(fp);
                }
                fp.Parent  = entity;
                fp.Tag     = property.Tag;
                fp.Caption = property.Caption;
            }
        }
 /// <summary>
 ///     复制值
 /// </summary>
 /// <param name="source">复制的源字段</param>
 /// <param name="noChilds">是否复制子级(默认为是)</param>
 public void CopyValue(EntityConfig source, bool noChilds = false)
 {
     Entity.Caption       = source.Caption + "(复制)";
     Entity.Description   = source.Description;
     Entity.Name          = source.Name + "_copy";
     Entity.DataVersion   = source.DataVersion;
     Entity.DbIndex       = source.DbIndex;
     Entity.IsInternal    = source.IsInternal;
     Entity.IsClass       = source.IsClass;
     Entity.ReadTableName = source.ReadTableName;
     Entity.CppName       = source.CppName;
     Entity.Project       = source.Project;
     if (noChilds)
     {
         return;
     }
     foreach (var field in source.Properties)
     {
         var nf = new PropertyConfig();
         nf.CopyFrom(field);
         Entity.Properties.Add(nf);
     }
 }
        private void FindApiClientArg(EntityConfig friend, ApiItem item, ProjectConfig apiProject)
        {
            var entity = GlobalConfig.GetEntity(p => p != friend && p.Tag == friend.Tag);
            var count  = friend.Properties.Count(p => p.Name != "ClientNo");

            switch (count)
            {
            case 0:
                item.ResultArg = null;
                if (entity != null)
                {
                    entity.IsDelete = true;
                }
                return;

            case 1:
                item.ResultArg =
                    CppTypeHelper.CppTypeToCsType(friend.Properties.FirstOrDefault(p => p.Name != "ClientNo"));
                if (entity != null)
                {
                    entity.IsDelete = true;
                }
                return;
            }
            if (entity == null)
            {
                entity = new EntityConfig
                {
                    Parent  = apiProject,
                    Project = apiProject.Name,
                    CppName = item.CallArg,
                    Name    = ToClientName(item.CallArg)
                };
                apiProject.Entities.Add(entity);
                Solution.Entities.Add(entity);
            }
            entity.IsClass     = true;
            entity.Tag         = friend.Tag;
            entity.Caption     = item.Caption + "命令调用参数";
            entity.Description = item.Caption + "命令调用参数";
            item.ResultArg     = entity.Name;

            foreach (var property in friend.Properties)
            {
                property.CsType = CppTypeHelper.CppTypeToCsType(property);
                if (property.Name == "ClientNo")
                {
                    continue;
                }
                property.Tag = friend.Tag + "," + property.Name;
                var fp = entity.Properties.FirstOrDefault(p => p.Tag != null && p.Tag == property.Tag)
                         ?? entity.Properties.FirstOrDefault(p => p.Name == property.Name);
                if (fp == null)
                {
                    fp = new PropertyConfig();
                    fp.CopyFrom(property);
                    fp.Parent = entity;
                    entity.Properties.Add(fp);
                }
                fp.Parent  = entity;
                fp.Tag     = property.Tag;
                fp.Caption = property.Caption;
            }
        }