Exemplo n.º 1
0
        /// <summary>
        /// 定义度量
        /// </summary>
        /// <param name="ordinal"> 序号</param>
        /// <param name="MatName">名称</param>
        /// <param name="scale">精度(放大数量级)</param>
        /// <param name="unitOfMeasure">单位</param>
        /// <returns></returns>
        //定义事实表度量
        public IRAPError DefineMetMatric(int ordinal, string MatName, byte scale, string unitOfMeasure)
        {
            //  var t4RowSet = _t4treeBase.GetRSAttr<RowSet_T4R2>().Cast<RowSet_T4R2>();
            var t4RowSet = _db.Set <RowSet_T4R2>().Where(c => c.PartitioningKey == 4 && c.EntityID == _opID);
            int nameID   = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys).GetNameID(0, MatName);
            var obj      = t4RowSet.FirstOrDefault(c => c.Ordinal == ordinal);

            if (obj == null) //新增
            {
                RowSet_T4R2 row = new RowSet_T4R2()
                {
                    EntityID        = _t4treeBase.Leaf.EntityID,
                    NameID          = nameID,
                    Ordinal         = ordinal,
                    PartitioningKey = 4,
                    Scale           = scale,
                    UnitOfMeasure   = unitOfMeasure,
                    VersionLE       = 2147483647
                };
                _db.Set <RowSet_T4R2>().Add(row);
            }
            else
            {
                obj.Scale         = scale;
                obj.NameID        = nameID;
                obj.UnitOfMeasure = unitOfMeasure;
            }
            _db.SaveChanges();
            return(new IRAPError(0, "定义度量成功!"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置实体属性名称
        /// </summary>
        /// <param name="name">输入名称</param>
        public void SetEntityCodeName(string name)
        {
            int nameID = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys).GetNameID(0, name);

            _treeEntity.EntityCodeNameID = nameID;
            db.SaveChanges();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 定义行集属性
        /// </summary>
        /// <param name="attrIndex">行集属性序号</param>
        /// <param name="attrName">行集属性名称</param>
        /// <param name="rsAttrTBLName">行集属性表名</param>
        /// <param name="protect">是否保护(在界面中是否允许修改内容)</param>
        /// <returns></returns>
        public IRAPError DefineRowSet(byte attrIndex, string attrName, bool protect, string rsAttrTBLName = "")
        {
            var dbContext = db.Set <ModelTreeRowSet>();
            var rowSet    = dbContext.FirstOrDefault(c => c.TreeID == _treeID && c.RowSetID == attrIndex);
            var nameID    = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys).GetNameID(0, attrName);

            if (rsAttrTBLName == "")
            {
                rsAttrTBLName = $"RSAttr_T{_treeID}R{attrIndex}";
            }
            if (rowSet == null)
            {
                var entity = new ModelTreeRowSet
                {
                    RowSetID        = attrIndex,
                    RSAttrNameID    = nameID,
                    RSAttrTBLName   = rsAttrTBLName,
                    Protected       = protect,
                    TreeID          = (short)_treeID,
                    LastUpdatedTime = DateTime.Now
                };
                dbContext.Add(entity);
            }
            else
            {
                rowSet.RSAttrNameID  = nameID;
                rowSet.RSAttrTBLName = rsAttrTBLName;
                rowSet.Protected     = protect;
            }
            db.SaveChanges();
            return(new IRAPError(0, "行集属性定义成功!"));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 定义树的层次
        /// </summary>
        /// <param name="nodeDepth">结点深度:结点从1开始递增,叶深度为255</param>
        /// <param name="levelName">层次名称</param>
        /// <param name="defaultIconID">默认图标ID</param>
        /// <param name="codingRule">编码规则</param>
        /// <returns></returns>
        public IRAPError DefineTreeLevel(byte nodeDepth, string levelName, string codingRule = "", int defaultIconID = 0)
        {
            if (nodeDepth != 255)
            {
                if (_treeEntity.DepthLimit < nodeDepth)
                {
                    throw new Exception($"您输入树的层次 {nodeDepth} 超出树设定的最大深度:{_treeEntity.DepthLimit}。");
                }
            }
            var dbContext   = db.Set <TreeLevelEntity>();
            var levelEntity = dbContext.FirstOrDefault(c => c.TreeID == _treeID && c.NodeDepth == nodeDepth);
            var nameID      = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys).GetNameID(0, levelName);

            if (levelEntity == null)
            {
                TreeLevelEntity e = new TreeLevelEntity()
                {
                    CodingRule       = codingRule,
                    DefaultIconID    = defaultIconID,
                    LevelAliasNameID = nameID,
                    NodeDepth        = nodeDepth,
                    TreeID           = (short)_treeID
                };
                dbContext.Add(e);
            }
            else
            {
                levelEntity.DefaultIconID    = defaultIconID;
                levelEntity.LevelAliasNameID = nameID;
                levelEntity.NodeDepth        = nodeDepth;
                levelEntity.CodingRule       = codingRule;
            }
            db.SaveChanges();
            return(new IRAPError(0, $"树的第{nodeDepth}层定义成功!"));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 定义状态属性清单
        /// </summary>
        /// <param name="t5LeafID">状态叶标识</param>
        /// <param name="ordinal">状态属性序号</param>
        /// <param name="list">清单(删除后重新插入)</param>
        /// <returns></returns>
        public IRAPError DefineStatusList(int t5LeafID, int ordinal, List <TreeStatusModelRowDTO> list)
        {
            var thisState = GetStatus().FirstOrDefault(c => c.AttrIndex == ordinal);

            if (thisState == null)
            {
                throw new Exception($"第{ordinal}状态属性未定义!");
            }
            IRAPTreeBase             treeBase   = new IRAPTreeBase(db, 0, 5, t5LeafID);
            var                      namespaces = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            List <BaseRowAttrEntity> inputList  = new List <BaseRowAttrEntity>();

            foreach (TreeStatusModelRowDTO r in list)
            {
                ModelTreeStatusList e = new ModelTreeStatusList()
                {
                    EntityID     = t5LeafID,
                    Ordinal      = r.Ordinal,
                    Status       = r.Status,
                    StatusNameID = namespaces.GetNameID(0, r.StatusName)
                };
                inputList.Add(e);
            }
            return(treeBase.SaveRSAttr(typeof(ModelTreeStatusList), inputList));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 定义分类属性
        /// </summary>
        /// <param name="attrindex">分类属性序号</param>
        /// <param name="attrTreeID">分类属性树标识</param>
        /// <param name="attrName">分类属性名称</param>
        /// <param name="forceModify">如果已存在是否强制修改</param>
        /// <returns></returns>
        public IRAPError DefineClassify(int attrindex, int attrTreeID, string attrName, bool forceModify = false)
        {
            var namespaces = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            var nameID     = namespaces.GetNameID(0, attrName);
            var entity     = _classifySet.FirstOrDefault(c => c.AttrIndex == attrindex);

            if (entity != null)
            {
                if (!forceModify)
                {
                    throw new Exception($"第{attrindex}分类属性已存在! 如需强制修改请传入forceModify=true");
                }
                else
                {
                    entity.AttrNameID = nameID;
                    entity.AttrTreeID = (short)attrTreeID;
                }
            }
            else
            {
                ModelTreeClassfiyEntity e = new ModelTreeClassfiyEntity()
                {
                    AttrIndex  = (byte)attrindex,
                    AttrNameID = nameID,
                    AttrTreeID = (short)attrTreeID,
                    TreeID     = (short)_treeID
                };
                db.Set <ModelTreeClassfiyEntity>().Add(e);
            }
            db.SaveChanges();
            return(new IRAPError(0, $"第{attrindex}分类属性定义成功!"));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 定义操作类型
        /// </summary>
        /// <param name="opType">操作类型序号</param>
        /// <param name="optypeName">操作类型名</param>
        /// <param name="optypeCode">操作类型代码</param>
        /// <param name="auxFactTBLName">一般属性表</param>
        /// <param name="auxTranTBLName">辅助交易表</param>
        /// <param name="oltpTempFactTBLName">临时业务流水表</param>
        /// <param name="oltpFixedFactTBLName">固化业务流水表</param>
        /// <param name="isValid">是否有效</param>
        /// <returns></returns>
        public IRAPError DefineOptypes(short opType, string optypeName, string optypeCode, string auxFactTBLName, string auxTranTBLName,
                                       string oltpTempFactTBLName, string oltpFixedFactTBLName, bool isValid)
        {
            GenAttr_T4  genAttr = GetGenAttr();
            IRAPTreeSet t18Set  = new IRAPTreeSet(_db, 0, 18);
            //  var t4RowSet = _t4treeBase.GetRSAttr<RowSet_T4R1>().Cast<RowSet_T4R1>();
            var t4RowSet     = _db.Set <RowSet_T4R1>().Where(c => c.PartitioningKey == 4 && c.EntityID == _opID);
            var nameSpaces   = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            var optypeEntity = t4RowSet.FirstOrDefault(c => c.Ordinal == opType);

            if (optypeEntity == null)
            {  //新增
                int nameID = nameSpaces.GetNameID(0, optypeName);
                var res    = t18Set.NewTreeNode(4, 1018, optypeName, optypeCode, "Admin");

                if (res.ErrCode != 0)
                {
                    return(new IRAPError {
                        ErrCode = res.ErrCode, ErrText = res.ErrText
                    });
                }
                int         t18leafEntity = res.NewEntityID;
                RowSet_T4R1 row           = new RowSet_T4R1()
                {
                    EntityID             = _opID,
                    OpType               = opType,
                    Ordinal              = opType,
                    AuxFactTBLName       = auxFactTBLName,
                    T18LeafID            = t18leafEntity,
                    IsValid              = isValid,
                    PartitioningKey      = 4,
                    StateExclCtrlStr     = "",
                    VersionLE            = 2147483647,
                    AuthorizingCondition = "",
                    ComplementaryRule    = "",
                    BusinessDateIsValid  = false
                };
                _db.Set <RowSet_T4R1>().Add(row);
            }
            else
            {
                //修改
                optypeEntity.AuxFactTBLName = auxFactTBLName;
                optypeEntity.IsValid        = isValid;
                IRAPTreeBase tree18 = new IRAPTreeBase(_db, 0, 18, optypeEntity.T18LeafID);
                if (tree18.Leaf.NodeName != optypeName)
                {
                    tree18.Leaf.NodeName = optypeName;
                    tree18.Leaf.Code     = optypeCode;
                }
            }
            _db.SaveChanges();
            return(new IRAPError(0, "定义操作类型成功!"));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 操作类型
        /// </summary>
        /// <param name="opType"></param>
        /// <returns></returns>
        public IRAPError DeleteOpTypes(short opType)
        {
            //var t4RowSet = _t4treeBase.GetRSAttr<RowSet_T4R1>().Cast<RowSet_T4R1>();
            var t4RowSet     = _db.Set <RowSet_T4R1>().Where(c => c.PartitioningKey == 4 && c.EntityID == _opID);
            var nameSpaces   = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            var optypeEntity = t4RowSet.FirstOrDefault(c => c.Ordinal == opType);

            if (optypeEntity == null)
            {
                throw new Exception($"业务操作 {OperEntity.NodeName}[{_opID}] 的操作类型 {opType} 不存在!");
            }
            _db.Set <RowSet_T4R1>().Remove(optypeEntity);
            _db.SaveChanges();
            return(new IRAPError(0, "删除成功!"));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 定义事实表维度
        /// </summary>
        /// <param name="ordinal">维度序号</param>
        /// <param name="dimTreeID">维度树标识</param>
        /// <param name="dimName">维度名称(可为空,为空则用树的名字)</param>
        /// <returns></returns>
        public IRAPError DefineDimMatrix(int ordinal, short dimTreeID, string dimName = "")
        {
            //  var t4RowSet = _t4treeBase.GetRSAttr<RowSet_T4R3>().Cast<RowSet_T4R3>();
            var t4RowSet = _db.Set <RowSet_T4R3>().Where(c => c.PartitioningKey == 4 && c.EntityID == _opID);
            var obj      = t4RowSet.FirstOrDefault(c => c.Ordinal == ordinal);

            //检查dimTreeID参数是否存在
            if (dimName == "")
            {
                IRAPTreeModelSet modelTree = new IRAPTreeModelSet(_db);
                var treeEntity             = modelTree.GetAllTrees().FirstOrDefault(c => c.TreeID == dimTreeID);
                if (treeEntity == null)
                {
                    throw new Exception("输入参数dimTreeID不存在!");
                }
                dimName = treeEntity.TreeName;
            }
            int nameID = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys).GetNameID(0, dimName, 30);

            if (obj == null) //新增
            {
                RowSet_T4R3 row = new RowSet_T4R3()
                {
                    EntityID        = _t4treeBase.Leaf.EntityID,
                    Ordinal         = ordinal,
                    DimNameID       = nameID,
                    PartitioningKey = 4,
                    SrcFieldName    = "",
                    TreeID          = dimTreeID,
                    VersionLE       = 2147483647
                };
                _db.Set <RowSet_T4R3>().Add(row);
            }
            else //修改
            {
                obj.DimNameID = nameID;
                obj.TreeID    = dimTreeID;
            }
            _db.SaveChanges();
            return(new IRAPError(0, $"业务:{OperEntity.NodeName}[{_opID}] 第 {ordinal} 维度定义成功!"));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 定义瞬态属性
        /// </summary>
        /// <param name="attrindex">瞬态属性序号</param>
        /// <param name="statName">瞬态属性名</param>
        /// <param name="unitOfMeasure">度量单位</param>
        /// <param name="scale">放大数量级</param>
        /// <param name="protect">属性维护时是否可修改</param>
        /// <param name="forceModify">强制修改定义</param>
        /// <returns></returns>
        public IRAPError DefineTransient(int attrindex, string statName, string unitOfMeasure, byte scale, bool protect = false, bool forceModify = false)
        {
            var namespaces = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            var nameID     = namespaces.GetNameID(0, statName);
            var entity     = _transientSet.FirstOrDefault(c => c.StatIndex == attrindex);

            if (entity == null)
            {
                ModelTreeTransient e = new ModelTreeTransient()
                {
                    StatIndex     = (byte)attrindex,
                    Protected     = protect,
                    Scale         = scale,
                    StatNameID    = nameID,
                    TreeID        = (short)_treeID,
                    UnitOfMeasure = unitOfMeasure
                };
                db.Set <ModelTreeTransient>().Add(e);
            }
            else
            {
                if (!forceModify)
                {
                    throw new Exception($"第{attrindex}瞬态属性已存在! 如需强制修改请传入forceModify=true");
                }
                else
                {
                    entity.StatIndex     = (byte)attrindex;
                    entity.StatNameID    = nameID;
                    entity.Scale         = scale;
                    entity.UnitOfMeasure = unitOfMeasure;
                    entity.Protected     = protect;
                }
            }
            db.SaveChanges();
            return(new IRAPError(0, $"第{attrindex}瞬态属性定义成功!"));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 创建一颗树
        /// </summary>
        /// <param name="treeID">树标识</param>
        /// <param name="treeName">树名称</param>
        /// <param name="leafLimit">叶数量上限</param>
        /// <param name="depthLimit">深度上限</param>
        /// <param name="shareToAll">是否为共享树</param>
        /// <param name="treeType">树类型默认:2=一般树</param>
        public void CreateATree(int treeID, string treeName, int leafLimit, int depthLimit, bool shareToAll, byte treeType = 2)
        {
            var treeEntity = treesRepo.Table.FirstOrDefault(c => c.TreeID == treeID);

            if (treeEntity != null)
            {
                throw new Exception($"已存在Tree={treeID}");
            }
            IIRAPNamespaceSet nameSet = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            int nameID = nameSet.GetNameID(0, treeName, 30);
            var etree  = new ModelTreeEntity()
            {
                TreeID     = (short)treeID,
                NameID     = nameID,
                LeafLimit  = leafLimit,
                DepthLimit = depthLimit,
                ShareToAll = shareToAll,
                TreeType   = treeType
            };

            treesRepo.Insert(etree);
            treesRepo.SaveChanges();
            return;
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取NameID
        /// </summary>
        /// <param name="nameDesc"></param>
        /// <returns></returns>
        private int GetNameID(string nameDesc)
        {
            IIRAPNamespaceSet nameSet = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);

            return(nameSet.GetNameID(0, nameDesc, 30));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 修改参数名称
        /// </summary>
        /// <remarks>本方法主要用于更新参数名称,也可以在此同时更新参数值</remarks>
        /// <param name="communityID">社区标识</param>
        /// <param name="param">参数DTO对象</param>
        /// <param name="sysLogID">系统登录标识</param>
        /// <returns>IRAP系统通用错误对象,如果其中的ErrCode:0-执行成功;非0执行失败</returns>
        public IRAPError Modify(
            int communityID,
            IRAPParameterDTO param,
            long sysLogID)
        {
            IRAPError rlt = new IRAPError();

            rlt =
                GetUserInfoWithSysLogID(
                    communityID,
                    sysLogID,
                    out LoginEntity loginInfo);
            if (rlt.ErrCode != 0)
            {
                return(rlt);
            }

            List <IRAPParameterDTO> iParams =
                GetByParamID(communityID, new int[] { param.ParameterID });

            if (iParams.Count <= 0)
            {
                rlt.ErrCode = 9999;
                rlt.ErrText =
                    $"[{communityID}]社区中未找到ParameterID=[{param.ParameterID}]的参数";
                return(rlt);
            }

            IIRAPNamespaceSet namespaceSet =
                IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);

            if (param.ParameterNameID == 0)
            {
                rlt =
                    namespaceSet.Add(
                        communityID,
                        param.ParameterName,
                        loginInfo.LanguageID,
                        out int nameID);
                if (rlt.ErrCode != 0)
                {
                    return(rlt);
                }
                else
                {
                    param.ParameterNameID = nameID;
                }
            }

            try
            {
                irapParams.Update(
                    new IRAPParameterEntity()
                {
                    PartitioningKey   = param.PartitioningKey,
                    ParameterID       = param.ParameterID,
                    ParameterNameID   = param.ParameterNameID,
                    ParameterValue    = param.ParameterValue,
                    ParameterValueStr = param.ParameterValueStr,
                    UpdatedBy         = loginInfo.UserCode,
                    TimeUpdated       = DateTime.Now,
                });
                irapParams.SaveChanges();

                rlt.ErrCode = 0;
                rlt.ErrText = "更新参数成功";
            }
            catch (Exception error)
            {
                rlt.ErrCode = 9999;
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"更新参数发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"更新参数发生异常:{error.Message}";
                }
            }

            return(rlt);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 新增参数
        /// </summary>
        /// <remarks>本方法需要在序列服务器中配置NextParameterID序列</remarks>
        /// <param name="communityID">社区标识</param>
        /// <param name="paramName">参数名称</param>
        /// <param name="paramValue">参数值(整型)</param>
        /// <param name="paramStrValue">参数值(字符串)</param>
        /// <param name="sysLogID">系统登录标识</param>
        /// <param name="paramID">输出参数,新增参数的参数标识</param>
        /// <returns>IRAP系统通用错误对象,如果其中的ErrCode:0-执行成功;非0执行失败</returns>
        public IRAPError Add(
            int communityID,
            string paramName,
            int paramValue,
            string paramStrValue,
            long sysLogID,
            out int paramID)
        {
            IRAPError rlt = new IRAPError();

            paramID = 0;

            LoginEntity loginInfo = null;

            try
            {
                IRAPLog loginSet = new IRAPLog();
                loginInfo = loginSet.GetLogin(communityID, sysLogID);
                if (loginInfo == null)
                {
                    loginInfo = new LoginEntity()
                    {
                        UserCode   = "Unknown",
                        LanguageID = 30,
                    };
                }
            }
            catch (Exception error)
            {
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"获取登录信息发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"获取登录信息发生异常:{error.Message}";
                }
                rlt.ErrCode = 9999;

                return(rlt);
            }

            IIRAPNamespaceSet namespaceSet =
                IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);

            rlt =
                namespaceSet.Add(
                    communityID,
                    paramName,
                    loginInfo.LanguageID,
                    out int nameID);
            if (rlt.ErrCode != 0)
            {
                return(rlt);
            }

            rlt = RequestParameterID(out paramID);
            if (rlt.ErrCode != 0)
            {
                return(rlt);
            }

            IRAPParameterEntity entity = new IRAPParameterEntity()
            {
                ParameterID       = (byte)paramID,
                ParameterNameID   = nameID,
                PartitioningKey   = communityID * 10000,
                ParameterValue    = paramValue,
                ParameterValueStr = paramStrValue,
                UpdatedBy         = loginInfo.UserCode,
                TimeUpdated       = DateTime.Now,
            };

            try
            {
                irapParams.Insert(entity);
                irapParams.SaveChanges();
                rlt.ErrCode = 0;
                rlt.ErrText = "参数新增成功";
            }
            catch (Exception error)
            {
                rlt.ErrCode = 9999;
                if (error.InnerException.InnerException != null)
                {
                    rlt.ErrText =
                        $"新增参数发生异常:" +
                        $"{error.InnerException.InnerException.Message}";
                }
                else
                {
                    rlt.ErrText = $"新增参数发生异常:{error.Message}";
                }
            }

            return(rlt);
        }