コード例 #1
0
ファイル: ArchiveInfo.cs プロジェクト: zszqwe/anycmd
        public ArchiveInfo(DicReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            foreach (var item in reader)
            {
                this.Add(item.Key, item.Value);
            }
            OntologyDescriptor ontology;

            if (!reader.AcDomain.NodeHost.Ontologies.TryGetOntology((Guid)this["OntologyId"], out ontology))
            {
                throw new AnycmdException("意外的本体标识" + this["OntologyId"]);
            }
            if (!this.ContainsKey("OntologyCode"))
            {
                this.Add("OntologyCode", ontology.Ontology.Code);
            }
            if (!this.ContainsKey("OntologyName"))
            {
                this.Add("OntologyName", ontology.Ontology.Name);
            }
            if (!this.ContainsKey("CatalogName"))
            {
                this.Add("CatalogName", string.Format(
                             "Archive{0}{1}_{2}",
                             ontology.Ontology.Code,
                             ((DateTime)this["ArchiveOn"]).ToString("yyyyMMdd"),
                             this["NumberId"]));
            }
        }
コード例 #2
0
 public NodeInfo(DicReader dic)
 {
     if (dic == null)
     {
         throw new ArgumentNullException("dic");
     }
     foreach (var item in dic)
     {
         this.Add(item.Key, item.Value);
     }
     if (!this.ContainsKey("TransferName"))
     {
         string           transferName = string.Empty;
         IMessageTransfer transfer;
         if (dic.AcDomain.NodeHost.Transfers.TryGetTransfer((Guid)this["TransferId"], out transfer))
         {
             transferName = transfer.Name;;
         }
         this.Add("TransferName", transferName);
     }
     if (!this.ContainsKey("DeletionStateName"))
     {
         this.Add("DeletionStateName", dic.AcDomain.Translate("Edi", "Node", "DeletionStateName", (int)this["DeletionStateCode"]));
     }
     if (!this.ContainsKey("IsEnabledName"))
     {
         this.Add("IsEnabledName", dic.AcDomain.Translate("Edi", "Node", "IsEnabledName", (int)this["IsEnabled"]));
     }
 }
コード例 #3
0
        public DicReader Get(string tableOrViewName, Guid id)
        {
            var sql = "select * from " + tableOrViewName + " as a where Id=@Id";

            using (var conn = DbContext.Database.Connection)
            {
                var cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                var paramId = cmd.CreateParameter();
                paramId.ParameterName = "Id";
                paramId.Value         = id;
                paramId.DbType        = DbType.Guid;
                cmd.Parameters.Add(paramId);
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (!reader.Read())
                    {
                        return(null);
                    }
                    var dic = new DicReader(_acDomain);
                    for (var i = 0; i < reader.FieldCount; i++)
                    {
                        dic.Add(reader.GetName(i), reader.GetValue(i));
                    }
                    return(dic);
                }
            }
        }
コード例 #4
0
ファイル: ProcessInfo.cs プロジェクト: zszqwe/anycmd
        public ProcessInfo(DicReader dic)
        {
            if (dic == null)
            {
                throw new ArgumentNullException("dic");
            }
            foreach (var item in dic)
            {
                this.Add(item.Key, item.Value);
            }
            OntologyDescriptor ontology;

            if (!dic.AcDomain.NodeHost.Ontologies.TryGetOntology((Guid)this["OntologyId"], out ontology))
            {
                throw new AnycmdException("意外的本体标识" + this["OntologyId"]);
            }
            if (!this.ContainsKey("OntologyCode"))
            {
                this.Add("OntologyCode", ontology.Ontology.Code);
            }
            if (!this.ContainsKey("OntologyName"))
            {
                this.Add("OntologyName", ontology.Ontology.Name);
            }
            ProcessDescriptor process;

            if (!dic.AcDomain.NodeHost.Processs.TryGetProcess((Guid)this["Id"], out process))
            {
                throw new AnycmdException("意外的进程标识" + this["Id"]);
            }
            if (!this.ContainsKey("WebApiBaseAddress"))
            {
                this.Add("WebApiBaseAddress", process.WebApiBaseAddress);
            }
        }
コード例 #5
0
ファイル: AppSystemInfo.cs プロジェクト: zszqwe/anycmd
        public static AppSystemInfo Create(DicReader dic)
        {
            if (dic == null)
            {
                return(null);
            }
            var data = new AppSystemInfo(dic);

            return(data);
        }
コード例 #6
0
        public List <DicReader> GetPlist(string tableOrViewName, Func <SqlFilter> filterCallback, PagingInput paging)
        {
            var filter = SqlFilter.Empty;

            if (filterCallback != null)
            {
                filter = filterCallback();
            }
            string sql =
                @"SELECT TOP " + paging.PageSize + " * FROM (SELECT ROW_NUMBER() OVER(ORDER BY " + paging.SortField + " " + paging.SortOrder + ") AS RowNumber,* FROM " + tableOrViewName + " as a " + filter.FilterString + " ) a WHERE a.RowNumber > " + paging.PageIndex * paging.PageSize;
            string countSql =
                @"SELECT count(1) FROM " + tableOrViewName + " as a " + filter.FilterString;
            var list = new List <DicReader>();

            using (var conn = DbContext.Database.Connection)
            {
                var cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                if (filter.Parameters != null)
                {
                    foreach (var item in filter.Parameters)
                    {
                        cmd.Parameters.Add(item);
                    }
                }
                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();
                }
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var dic = new DicReader(_acDomain);
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            dic.Add(reader.GetName(i), reader.GetValue(i));
                        }
                        list.Add(dic);
                    }
                    reader.Close();
                    cmd.CommandText = countSql;
                    paging.Total    = (int)cmd.ExecuteScalar();
                    conn.Close();
                }
                return(list);
            }
        }
コード例 #7
0
        public BatchTr(DicReader dic)
        {
            if (dic == null)
            {
                throw new ArgumentNullException("dic");
            }
            foreach (var item in dic)
            {
                this.Add(item.Key, item.Value);
            }
            OntologyDescriptor ontology;

            if (!dic.AcDomain.NodeHost.Ontologies.TryGetOntology((Guid)this["OntologyId"], out ontology))
            {
                throw new AnycmdException("意外的本体标识" + this["OntologyId"]);
            }
            if (!this.ContainsKey("OntologyCode"))
            {
                this.Add("OntologyCode", ontology.Ontology.Code);
            }
            if (!this.ContainsKey("OntologyName"))
            {
                this.Add("OntologyName", ontology.Ontology.Name);
            }
            NodeDescriptor node;

            if (!dic.AcDomain.NodeHost.Nodes.TryGetNodeById(this["NodeId"].ToString(), out node))
            {
                throw new AnycmdException("意外的节点标识" + this["NodeId"]);
            }
            if (!this.ContainsKey("OntologyCode"))
            {
                this.Add("OntologyCode", ontology.Ontology.Code);
            }
            if (!this.ContainsKey("OntologyName"))
            {
                this.Add("OntologyName", ontology.Ontology.Name);
            }
            if (!this.ContainsKey("NodeCode"))
            {
                this.Add("NodeCode", node.Node.Code);
            }
            if (!this.ContainsKey("NodeName"))
            {
                this.Add("NodeName", node.Node.Name);
            }
        }
コード例 #8
0
ファイル: AppSystemInfo.cs プロジェクト: zszqwe/anycmd
        private AppSystemInfo(DicReader dic)
            : base(dic)
        {
            AccountState principal;

            if (!dic.AcDomain.SysUserSet.TryGetDevAccount((Guid)this["PrincipalId"], out principal))
            {
                throw new AnycmdException("意外的开发人员标识" + this["PrincipalId"]);
            }
            if (!this.ContainsKey("PrincipalName"))
            {
                this.Add("PrincipalName", principal.LoginName);
            }
            if (!this.ContainsKey("IsEnabledName"))
            {
                this.Add("IsEnabledName", dic.AcDomain.Translate("Ac", "AppSystem", "IsEnabledName", (int)this["IsEnabled"]));
            }
        }
コード例 #9
0
ファイル: ButtonInfo.cs プロジェクト: HuZeHua/InternetDemo
        public static ButtonInfo Create(DicReader dic)
        {
            if (dic == null)
            {
                return(null);
            }
            var data = new ButtonInfo();

            foreach (var item in dic)
            {
                data.Add(item.Key, item.Value);
            }
            if (!data.ContainsKey("IsEnabledName"))
            {
                data.Add("IsEnabledName", dic.AcDomain.Translate("Ac", "Button", "IsEnabledName", (int)data["IsEnabled"]));
            }

            return(data);
        }
コード例 #10
0
ファイル: EntityTypeExtension.cs プロジェクト: zszqwe/anycmd
        /// <summary>
        /// 从给定的实体类型所代表的实体集中读取给定标识的实体记录。
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static DicReader GetData(this EntityTypeState entityType, Guid id)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }
            if (entityType == EntityTypeState.Empty || entityType.AcDomain == null)
            {
                throw new InvalidOperationException();
            }
            // TODO:不能假定实体集是持久在关系数据库中的,这里需要提取策略。根据该实体类型上的不同配置以不同的策略访问不同的数据库。
            RdbDescriptor db;

            if (!entityType.AcDomain.Rdbs.TryDb(entityType.DatabaseId, out db))
            {
                throw new AnycmdException("意外的实体类型数据库标识" + entityType.Code);
            }
            if (string.IsNullOrEmpty(entityType.TableName))
            {
                throw new AnycmdException(entityType.Name + "未配置对应的数据库表");
            }
            var sql     = "select * from " + string.Format("[{0}]", entityType.TableName) + " as a where Id=@Id";
            var paramId = db.CreateParameter();

            paramId.ParameterName = "Id";
            paramId.Value         = id;
            paramId.DbType        = DbType.Guid;
            using (var reader = db.ExecuteReader(sql, paramId))
            {
                if (reader.Read())
                {
                    var dic = new DicReader(entityType.AcDomain);
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        dic.Add(reader.GetName(i), reader.GetValue(i));
                    }
                    return(dic);
                }
            }
            return(null);
        }
コード例 #11
0
 /// <summary>
 /// 从给定的实体类型所代表的实体集中读取给定标识的实体记录。
 /// </summary>
 /// <param name="entityType"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static DicReader GetData(this EntityTypeState entityType, Guid id)
 {
     if (entityType == null)
     {
         throw new ArgumentNullException("entityType");
     }
     if (entityType == EntityTypeState.Empty || entityType.AcDomain == null)
     {
         throw new InvalidOperationException();
     }
     // TODO:不能假定实体集是持久在关系数据库中的,这里需要提取策略。根据该实体类型上的不同配置以不同的策略访问不同的数据库。
     RdbDescriptor db;
     if (!entityType.AcDomain.Rdbs.TryDb(entityType.DatabaseId, out db))
     {
         throw new AnycmdException("意外的实体类型数据库标识" + entityType.Code);
     }
     if (string.IsNullOrEmpty(entityType.TableName))
     {
         throw new AnycmdException(entityType.Name + "未配置对应的数据库表");
     }
     var sql = "select * from " + string.Format("[{0}]", entityType.TableName) + " as a where Id=@Id";
     var paramId = db.CreateParameter();
     paramId.ParameterName = "Id";
     paramId.Value = id;
     paramId.DbType = DbType.Guid;
     using (var reader = db.ExecuteReader(sql, paramId))
     {
         if (reader.Read())
         {
             var dic = new DicReader(entityType.AcDomain);
             for (int i = 0; i < reader.FieldCount; i++)
             {
                 dic.Add(reader.GetName(i), reader.GetValue(i));
             }
             return dic;
         }
     }
     return null;
 }
コード例 #12
0
        public static CatalogInfo Create(DicReader dic)
        {
            if (dic == null)
            {
                return(null);
            }
            var data = new CatalogInfo();

            foreach (var item in dic)
            {
                data.Add(item.Key, item.Value);
            }
            if (!data.ContainsKey("IsEnabledName"))
            {
                data.Add("IsEnabledName", dic.AcDomain.Translate("Ac", "Catalog", "IsEnabledName", (int)data["IsEnabled"]));
            }
            if (!data.ContainsKey("CategoryName"))
            {
                data.Add("CategoryName", dic.AcDomain.Translate("Ac", "Catalog", "CategoryName", data["CategoryCode"].ToString()));
            }
            if (data["ParentCode"] != DBNull.Value)
            {
                var          parentCode = (string)data["ParentCode"];
                CatalogState parentOrg;
                if (!dic.AcDomain.CatalogSet.TryGetCatalog(parentCode, out parentOrg))
                {
                    throw new AnycmdException("意外的父目录编码" + parentCode);
                }
                data.Add("ParentName", parentOrg.Name);
            }
            else
            {
                data.Add("ParentName", CatalogState.VirtualRoot.Name);
            }

            return(data);
        }
コード例 #13
0
ファイル: InfoRuleInfo.cs プロジェクト: HuZeHua/InternetDemo
        public InfoRuleInfo(DicReader dic)
        {
            if (dic == null)
            {
                throw new ArgumentNullException("dic");
            }
            foreach (var item in dic)
            {
                this.Add(item.Key, item.Value);
            }
            InfoRuleState infoRule;

            if (!dic.AcDomain.NodeHost.InfoRules.TryGetInfoRule((Guid)this["Id"], out infoRule))
            {
                throw new GeneralException("意外的信息规则标识" + this["Id"]);
            }
            if (!this.ContainsKey("Name"))
            {
                this.Add("Name", infoRule.GetType().Name);
            }
            if (!this.ContainsKey("FullName"))
            {
                this.Add("FullName", infoRule.GetType().FullName);
            }
            if (!this.ContainsKey("Title"))
            {
                this.Add("Title", infoRule.InfoRule.Title);
            }
            if (!this.ContainsKey("Description"))
            {
                this.Add("Description", infoRule.InfoRule.Description);
            }
            if (!this.ContainsKey("Author"))
            {
                this.Add("Author", infoRule.InfoRule.Author);
            }
        }
コード例 #14
0
        public static FunctionInfo Create(DicReader dic)
        {
            if (dic == null)
            {
                return(null);
            }
            var data = new FunctionInfo();

            foreach (var item in dic)
            {
                data.Add(item.Key, item.Value);
            }
            CatalogState resource;

            if (!dic.AcDomain.CatalogSet.TryGetCatalog((Guid)data["ResourceTypeId"], out resource))
            {
                throw new GeneralException("意外的资源标识" + data["ResourceTypeId"]);
            }
            AppSystemState appSystem;

            if (!dic.AcDomain.AppSystemSet.TryGetAppSystem(resource.Code.Substring(0, resource.Code.IndexOf('.')), out appSystem))
            {
                throw new GeneralException("意外的区域应用系统标识");
            }
            if (!data.ContainsKey("AppSystemCode"))
            {
                data.Add("AppSystemCode", appSystem.Code);
            }
            if (!data.ContainsKey("AppSystemName"))
            {
                data.Add("AppSystemName", appSystem.Name);
            }

            if (!data.ContainsKey("ResourceCode"))
            {
                data.Add("ResourceCode", resource.Code);
            }
            if (!data.ContainsKey("ResourceName"))
            {
                data.Add("ResourceName", resource.Name);
            }
            if (!data.ContainsKey("IsManagedName"))
            {
                data.Add("IsManagedName", dic.AcDomain.Translate("Ac", "Function", "IsManagedName", (bool)data["IsManaged"]));
            }
            if (!data.ContainsKey("IsEnabledName"))
            {
                data.Add("IsEnabledName", dic.AcDomain.Translate("Ac", "Function", "IsEnabledName", (int)data["IsEnabled"]));
            }
            if (!data.ContainsKey("IsUiView"))
            {
                UiViewState view;
                data.Add("IsUiView", dic.AcDomain.UiViewSet.TryGetUiView((Guid)data["Id"], out view));
            }
            if (!data.ContainsKey("DeveloperCode"))
            {
                AccountState developer;
                if (dic.AcDomain.SysUserSet.TryGetDevAccount((Guid)data["DeveloperId"], out developer))
                {
                    data.Add("DeveloperCode", developer.LoginName);
                }
                else
                {
                    data.Add("DeveloperCode", "无效的值");
                }
            }

            return(data);
        }
コード例 #15
0
ファイル: ElementInfo.cs プロジェクト: HuZeHua/InternetDemo
        public static ElementInfo Create(DicReader dic)
        {
            if (dic == null)
            {
                return(null);
            }
            var data = new ElementInfo(dic.AcDomain);

            foreach (var item in dic)
            {
                data.Add(item.Key, item.Value);
            }
            data.Id = (Guid)dic["Id"];
            OntologyDescriptor ontology;

            if (!dic.AcDomain.NodeHost.Ontologies.TryGetOntology((Guid)data["OntologyId"], out ontology))
            {
                throw new GeneralException("意外的本体标识" + data["OntologyId"]);
            }
            if (!data.ContainsKey("OntologyCode"))
            {
                data.Add("OntologyCode", ontology.Ontology.Code);
            }
            if (!data.ContainsKey("OntologyName"))
            {
                data.Add("OntologyName", ontology.Ontology.Name);
            }
            if (data["MaxLength"] == DBNull.Value)
            {
                data.MaxLength = null;
            }
            else
            {
                data.MaxLength = (int?)data["MaxLength"];
            }
            if (!data.ContainsKey("DeletionStateName"))
            {
                data.Add("DeletionStateName", dic.AcDomain.Translate("Edi", "Element", "DeletionStateName", (int)data["DeletionStateCode"]));
            }
            if (!data.ContainsKey("IsEnabledName"))
            {
                data.Add("IsEnabledName", dic.AcDomain.Translate("Edi", "Element", "IsEnabledName", (int)data["IsEnabled"]));
            }
            if (data["InfoDicId"] == DBNull.Value)
            {
                data.InfoDicId = null;
            }
            else
            {
                data.InfoDicId = (Guid?)data["InfoDicId"];
            }
            if (data.InfoDicId.HasValue && !data.ContainsKey("InfoDicName"))
            {
                InfoDicState infoDic = null;
                if (data.InfoDicId != null && !dic.AcDomain.NodeHost.InfoDics.TryGetInfoDic(data.InfoDicId.Value, out infoDic))
                {
                    throw new GeneralException("意外的信息字典标识" + data.InfoDicId.Value);
                }
                if (infoDic != null)
                {
                    data.Add("InfoDicName", infoDic.Name);
                }
            }
            if (!data.ContainsKey("IsConfigValid"))
            {
                data.Add("IsConfigValid", data.IsConfigValid);
            }
            if (!data.ContainsKey("DbIsNullable"))
            {
                data.Add("DbIsNullable", data.DbIsNullable);
            }
            if (!data.ContainsKey("DbTypeName"))
            {
                data.Add("DbTypeName", data.DbTypeName);
            }
            if (!data.ContainsKey("DbMaxLength"))
            {
                data.Add("DbMaxLength", data.DbMaxLength);
            }

            return(data);
        }