Example #1
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} 维度定义成功!"));
        }
Example #2
0
        /// <summary>
        /// 辅助交易表
        /// </summary>
        /// <returns></returns>
        public List <IRAPTableColDTO> GetAuxTranCols()
        {
            //找一般属性表名
            var treeModel = new IRAPTreeModelSet();
            var genAttrT4 = GetGenAttr();

            if (genAttrT4.AuxTranTBLName == null || genAttrT4.AuxTranTBLName == string.Empty)
            {
                throw new Exception($"业务操作:{_opID}的辅助交易表未定义。");
            }
            var node = _db.Set <ETreeSysDir>().FirstOrDefault(c => c.TreeID == 9 && c.Code == genAttrT4.AuxTranTBLName);

            if (node == null)
            {
                throw new Exception($"业务操作:{_opID}的辅助交易表在数据字典中未定义!");
            }
            var leafSet    = _db.Set <ETreeSysLeaf>().Where(c => c.Father == node.NodeID && c.TreeID == 9);
            var genAttrSet = _db.Set <ModelTreeGeneral>().Where(c => c.PartitioningKey == 9);
            var dto        = from a in leafSet
                             join b in genAttrSet on a.EntityID equals b.EntityID
                             orderby a.UDFOrdinal
                             select new IRAPTableColDTO
            {
                DisPlayName   = a.NodeName,
                ColName       = a.Code,
                AllowNull     = b.AllowNull,
                CollationRule = b.CollationRule,
                DataPrecision = b.DataPrecision,
                DecimalDigits = b.DecimalDigits,
                FieldWidth    = b.FieldWidth,
                IdentityInc   = b.IdentityInc,
                IdentitySeed  = b.IdentitySeed,
                IsIdentity    = b.IsIdentity,
                IsRowGuid     = b.IsRowGuid,
                Length        = b.Length,
                MimeType      = b.MimeType,
                Type          = b.Type
            };

            return(dto.ToList());
        }