Пример #1
0
        /// <summary>
        /// 從資料集載入身分的授權設定
        /// </summary>
        public bool LoadRoleAuthorizationsFrom(EmployeeRoleOperationsDesc roleOp)
        {
            if (isRoleAdmin)
            {
                // admin, open all
                authorizations.CanRead = true;
                authorizations.CanEdit = true;

                authorizations.CanReadSubItemOfSelf = true;
                authorizations.CanEditSubItemOfSelf = true;
                authorizations.CanAddSubItemOfSelf  = true;
                authorizations.CanDelSubItemOfSelf  = true;

                authorizations.CanReadSubItemOfCrew = true;
                authorizations.CanEditSubItemOfCrew = true;
                authorizations.CanDelSubItemOfCrew  = true;

                authorizations.CanReadSubItemOfOthers = true;
                authorizations.CanEditSubItemOfOthers = true;
                authorizations.CanDelSubItemOfOthers  = true;
            }
            else
            {
                if (roleOp == null)
                {
                    logger.Info("parameter of LoadRoleAuthorizationsFrom() is empty.");
                    return(false);
                }

                // load settings
                authorizations.ImportDataFrom(roleOp);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// 初始化授權結果
        /// </summary>
        protected virtual void InitialAuthorizationResult(bool isTopPageOfOperation)
        {
            this.isTopPageOfOperation = isTopPageOfOperation;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                //取得指定作業代碼的後端身分可使用權限
                EmployeeRoleOperationsDesc roleOp = empAuthDao.GetEmployeeRoleOperationsDescDataOfOp(roleName, opIdOfPage);

                //從資料集載入身分的授權設定
                LoadRoleAuthorizationsFrom(roleOp);
            }

            if (custEmpAuthResult != null)
            {
                //自訂帳號授權結果
                EmployeeAuthorizationsWithOwnerInfoOfDataExamined authAndOwner = custEmpAuthResult.InitialAuthorizationResult(isTopPageOfOperation, authorizations);
                ownerAccountOfDataExamined = authAndOwner.OwnerAccountOfDataExamined;
                ownerDeptIdOfDataExamined  = authAndOwner.OwnerDeptIdOfDataExamined;
                this.authorizations        = authAndOwner;

                if (authAndOwner.IsTopPageOfOperationChanged)
                {
                    this.isTopPageOfOperation = authAndOwner.IsTopPageOfOperation;
                }

                return;
            }
        }
Пример #3
0
        /// <summary>
        /// 取得後端作業選項身分授權的巢狀清單
        /// </summary>
        public List <OperationWithRoleAuth> GetOperationWithRoleAuthNestedList(string roleName)
        {
            List <OperationWithRoleAuth> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                List <Operations> topOps = empAuthDao.GetList <Operations>(op => op.ParentId == null && !op.IsHideSelf)
                                           .OrderBy(op => op.SortNo).ToList();
                List <Operations> subOps = empAuthDao.GetList <Operations>(op => op.ParentId != null && !op.IsHideSelf)
                                           .OrderBy(op => op.SortNo).ToList();
                List <EmployeeRoleOperationsDesc> roleAuthItems = empAuthDao.GetList <EmployeeRoleOperationsDesc>(ro => ro.RoleName == roleName)
                                                                  .ToList();

                if (topOps != null && subOps != null && roleAuthItems != null)
                {
                    entities = topOps.ConvertAll <OperationWithRoleAuth>(op =>
                    {
                        // top item
                        OperationWithRoleAuth opAuth = new OperationWithRoleAuth();
                        opAuth.ImportDataFrom(op);

                        EmployeeRoleOperationsDesc roleAuthItem = roleAuthItems.Find(ro => ro.OpId == op.OpId);

                        if (roleAuthItem != null)
                        {
                            opAuth.ImportDataFrom(roleAuthItem);
                        }

                        // sub item
                        opAuth.SubItems = subOps.Where(subOp => subOp.ParentId == op.OpId)
                                          .Select(subOp =>
                        {
                            OperationWithRoleAuth subOpAuth = new OperationWithRoleAuth();
                            subOpAuth.ImportDataFrom(subOp);

                            EmployeeRoleOperationsDesc subRoleAuthItem = roleAuthItems.Find(ro => ro.OpId == subOp.OpId);

                            if (subRoleAuthItem != null)
                            {
                                subOpAuth.ImportDataFrom(subRoleAuthItem);
                            }

                            return(subOpAuth);
                        }).ToList();

                        return(opAuth);
                    });
                }

                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
Пример #4
0
        public void ImportDataFrom(EmployeeRoleOperationsDesc roleOp)
        {
            CanRead = roleOp.CanRead;
            CanEdit = roleOp.CanEdit;

            CanReadSubItemOfSelf = roleOp.CanReadSubItemOfSelf;
            CanEditSubItemOfSelf = roleOp.CanEditSubItemOfSelf;
            CanAddSubItemOfSelf  = roleOp.CanAddSubItemOfSelf;
            CanDelSubItemOfSelf  = roleOp.CanDelSubItemOfSelf;

            CanReadSubItemOfCrew = roleOp.CanReadSubItemOfCrew;
            CanEditSubItemOfCrew = roleOp.CanEditSubItemOfCrew;
            CanDelSubItemOfCrew  = roleOp.CanDelSubItemOfCrew;

            CanReadSubItemOfOthers = roleOp.CanReadSubItemOfOthers;
            CanEditSubItemOfOthers = roleOp.CanEditSubItemOfOthers;
            CanDelSubItemOfOthers  = roleOp.CanDelSubItemOfOthers;
        }
Пример #5
0
        public List <EmployeeRoleOperationsDesc> GenEmpRoleOps()
        {
            List <EmployeeRoleOperationsDesc> empRoleOps = pvgChanges.Select(c =>
            {
                EmployeeRoleOperationsDesc ro = new EmployeeRoleOperationsDesc()
                {
                    RoleName    = c.RoleName,
                    OpId        = c.OpId,
                    PostAccount = this.PostAccount,
                    PostDate    = DateTime.Now,
                    MdfAccount  = this.PostAccount,
                    MdfDate     = DateTime.Now
                };

                ro.CanRead = (c.PvgOfItem & 1) == 1;
                ro.CanEdit = (c.PvgOfItem & 2) == 2;

                ro.CanReadSubItemOfSelf = (c.PvgOfSubitemSelf & 1) == 1;
                ro.CanEditSubItemOfSelf = (c.PvgOfSubitemSelf & 2) == 2;
                ro.CanAddSubItemOfSelf  = (c.PvgOfSubitemSelf & 4) == 4;
                ro.CanDelSubItemOfSelf  = (c.PvgOfSubitemSelf & 8) == 8;

                ro.CanReadSubItemOfCrew = (c.PvgOfSubitemCrew & 1) == 1;
                ro.CanEditSubItemOfCrew = (c.PvgOfSubitemCrew & 2) == 2;
                ro.CanDelSubItemOfCrew  = (c.PvgOfSubitemCrew & 8) == 8;

                ro.CanReadSubItemOfOthers = (c.PvgOfSubitemOthers & 1) == 1;
                ro.CanEditSubItemOfOthers = (c.PvgOfSubitemOthers & 2) == 2;
                ro.CanDelSubItemOfOthers  = (c.PvgOfSubitemOthers & 8) == 8;

                return(ro);
            }).ToList();


            return(empRoleOps);
        }