コード例 #1
0
ファイル: BillRight.cs プロジェクト: JodenSoft/JodenSoft
        /// <summary>
        /// 计算当前这一行的数据,判断是否有指定权限
        /// </summary>
        /// <param name="fieldName">指定权限字段</param>
        /// <param name="table">权限配置数据</param>
        /// <param name="destBillDataRight">目标权限</param>s
        /// <param name="aEntity">数据行实体</param>
        /// <returns></returns>
        private static BillDataRight CalcCurrentEntityBillDataRight(string fieldName, BillRightInfo billRight, BillDataRight destBillDataRight, IEntityBase entity)
        {
            bool temp = false;
            int CreatedBy = -1;
            if (entity.FieldIsExists(BillRightInfo.CreatedByField) && !entity.FieldIsNull(BillRightInfo.CreatedByField) && entity.GetFieldValue<int>(BillRightInfo.CreatedByField) > 0)
            {
                CreatedBy = entity.GetFieldValue<int>(BillRightInfo.CreatedByField);
            }

            int OrganizationId = -1;
            if (entity.FieldIsExists(BillRightInfo.OrganizationIdField) && !entity.FieldIsNull(BillRightInfo.OrganizationIdField))
            {
                OrganizationId = entity.GetFieldValue<int>(BillRightInfo.OrganizationIdField);
            }

            string OrganizationCode = "XXXXXX";
            if (entity.FieldIsExists(BillRightInfo.OrganizationCodeField) && !entity.FieldIsNull(BillRightInfo.OrganizationCodeField))
            {
                OrganizationCode = entity.GetFieldValue<string>(BillRightInfo.OrganizationCodeField);
            }

            foreach (DataRow dr in billRight.DataRights.Rows)
            {
                //部门为空,则表示针对所有部门都是此角色
                bool bAllOrganization = dr.IsNull(RES.OrganizationId);

                bool bSameCreator = false;
                if (!dr.IsNull(RES.CreatedBy))
                {
                    bSameCreator = (CreatedBy == Convert.ToInt32(dr[RES.CreatedBy]));
                }

                bool bSameOrganizationId = false;
                if (!dr.IsNull(RES.OrganizationId))
                {
                    bSameOrganizationId = (OrganizationId == Convert.ToInt32(dr[RES.OrganizationId]));
                }

                bool bSameOrganizationCode = false;
                if (!dr.IsNull(RES.OrganizationCode))
                {
                    bSameOrganizationCode = OrganizationCode.StartsWith(dr[RES.OrganizationCode].ToString(), StringComparison.OrdinalIgnoreCase);
                }
                switch ((BillRightType)Convert.ToInt32(dr[fieldName]))
                {
                    case BillRightType.None: continue;
                    case BillRightType.OnlyOwner: temp = bSameCreator && (bAllOrganization || bSameOrganizationCode || bSameOrganizationId); break;
                    case BillRightType.OnlyDepartment: temp = bSameCreator || bAllOrganization || bSameOrganizationId; break;
                    case BillRightType.DepartmentAndChild: temp = bSameCreator || bAllOrganization || bSameOrganizationCode; break;
                    case BillRightType.All: temp = true; break;
                }
                if (temp)
                    return destBillDataRight;
            }
            return BillDataRight.None;
        }
コード例 #2
0
ファイル: Session.cs プロジェクト: JodenSoft/JodenSoft
        public void Assign(IEntityBase entity)
        {
            if (entity == null)
            {
                this.Clear();
                return;
            }
            if (entity.FieldIsExists("Iden"))
                this.UserId = entity.GetFieldValue<int>("Iden", -1);

            if (entity.FieldIsExists("UserName"))
                this.UserName = entity.GetFieldValue<string>("UserName", string.Empty);

            if (entity.FieldIsExists("Password"))
                this.Password = entity.GetFieldValue<string>("Password", string.Empty);

            if (entity.FieldIsExists("UserFullName"))
                this.UserFullName = entity.GetFieldValue<string>("UserFullName", string.Empty);

            if (entity.FieldIsExists("Email"))
                this.Email = entity.GetFieldValue<string>("Email", string.Empty);

            if (entity.FieldIsExists("TelephoneNo"))
                this.TelephoneNo = entity.GetFieldValue<string>("TelephoneNo", string.Empty);

            this.UserImage = null;
            if (entity.FieldIsExists("UserImage") && !entity.FieldIsNull("UserImage"))
                this.UserImage = new Bitmap(new MemoryStream(entity.GetFieldValue<byte[]>("UserImage")));

            this.UserSignImage = null;
            if (entity.FieldIsExists("UserSignImage") && !entity.FieldIsNull("UserSignImage"))
                this.UserSignImage = new Bitmap(new MemoryStream(entity.GetFieldValue<byte[]>("UserSignImage")));

        }
コード例 #3
0
ファイル: EntitySetBase.cs プロジェクト: JodenSoft/JodenSoft
 /// <summary>
 /// 计算单据数据权限
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="forceCalc">是否强制重新计算</param>
 /// <returns>数据权限值</returns>
 public BillDataRight CalcBillDataRight(IEntityBase entity, bool forceCalc)
 {
     if (entity == null)
         return BillDataRight.None;
     if (BillRightInfo == null || BillRightInfo.BillTypeId <= 0 || !BillRightInfo.UseDataRight)
         return BillDataRight.All;
     object key = entity.GetFieldValue<object>(entity.PrimaryKeyName);
     if (dictBillRights.ContainsKey(key))
     {
         if (!forceCalc)
             return dictBillRights[key];
         //强制重新计算
         BillDataRight dr = BillRight.CalcEntityBillDataRight(entity, BillRightInfo);
         dictBillRights[key] = dr;
         return dr;
     }
     else
     {
         BillDataRight dr = BillRight.CalcEntityBillDataRight(entity, BillRightInfo);
         dictBillRights.Add(key, dr);
         return dr;
     }
 }