Beispiel #1
0
        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")));

        }
Beispiel #2
0
        /// <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;
        }