示例#1
0
        public EmployeeAuthorizationsWithOwnerInfoOfDataExamined InitialAuthorizationResult(bool isTopPageOfOperation, EmployeeAuthorizations authorizations)
        {
            EmployeeAuthorizationsWithOwnerInfoOfDataExamined authAndOwner = new EmployeeAuthorizationsWithOwnerInfoOfDataExamined(authorizations);

            if (!isTopPageOfOperation)
            {
                // get owner info for config-form
                using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
                {
                    string empAccount = empAuthDao.GetEmployeeAccountOfId(qsEmpId);
                    string dbErrMsg   = empAuthDao.GetErrMsg();

                    if (!string.IsNullOrEmpty(empAccount))
                    {
                        accountOfData = empAccount;

                        EmployeeForBackend empData = empAuthDao.GetEmployeeDataForBackend(empAccount);
                        dbErrMsg = empAuthDao.GetErrMsg();

                        if (empData != null)
                        {
                            authAndOwner.OwnerAccountOfDataExamined = empData.OwnerAccount;
                            authAndOwner.OwnerDeptIdOfDataExamined  = empData.OwnerDeptId;
                        }
                    }
                }
            }

            return(authAndOwner);
        }
示例#2
0
        /// <summary>
        /// 新增員工身分資料
        /// </summary>
        public bool InsertEmployeeRoleData(RoleParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                EmployeeRole entity = new EmployeeRole()
                {
                    RoleName        = param.RoleName,
                    RoleDisplayName = param.RoleDisplayName,
                    SortNo          = param.SortNo,
                    PostAccount     = param.PostAccount,
                    PostDate        = DateTime.Now
                };

                insResult = empAuthDao.InsertEmployeeRoleData(entity, param.CopyPrivilegeFromRoleName);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.RoleId = entity.RoleId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasRoleBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
示例#3
0
        /// <summary>
        /// 新增部門資料
        /// </summary>
        public bool InsertDepartmentData(DeptParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Department entity = new Department()
                {
                    DeptName    = param.DeptName,
                    SortNo      = param.SortNo,
                    PostAccount = param.PostAccount,
                    PostDate    = DateTime.Now
                };

                insResult = empAuthDao.InsertDepartmentData(entity);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.DeptId = (int)insResult.NewId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasDeptNameBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
示例#4
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;
            }
        }
示例#5
0
        /// <summary>
        /// 更新部門資料
        /// </summary>
        public bool UpdateDepartmentData(DeptParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Department entity = empAuthDao.GetEmptyEntity <Department>(new DepartmentRequiredPropValues()
                {
                    DeptId   = param.DeptId,
                    DeptName = ""
                });

                entity.DeptName   = param.DeptName;
                entity.SortNo     = param.SortNo;
                entity.MdfAccount = param.PostAccount;
                entity.MdfDate    = DateTime.Now;

                result   = empAuthDao.UpdateDepartmentData(entity);
                dbErrMsg = empAuthDao.GetErrMsg();

                if (!result && empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasDeptNameBeenUsed = true;
                }
            }

            return(result);
        }
示例#6
0
        /// <summary>
        /// 更新後端作業選項
        /// </summary>
        public bool UpdateOperaionData(OpParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Operations entity = empAuthDao.GetEmptyEntity <Operations>(new OperationsRequiredPropValues()
                {
                    OpId        = param.OpId,
                    IsNewWindow = !param.IsNewWindow,
                    IsHideSelf  = !param.IsHideSelf
                });

                entity.OpId           = param.OpId;
                entity.OpSubject      = param.OpSubject;
                entity.LinkUrl        = param.LinkUrl;
                entity.IsNewWindow    = param.IsNewWindow;
                entity.IconImageFile  = param.IconImageFile;
                entity.SortNo         = param.SortNo;
                entity.IsHideSelf     = param.IsHideSelf;
                entity.CommonClass    = param.CommonClass;
                entity.EnglishSubject = param.EnglishSubject;
                entity.MdfAccount     = param.PostAccount;
                entity.MdfDate        = DateTime.Now;

                result   = empAuthDao.Update();
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#7
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);
        }
示例#8
0
        /// <summary>
        /// 用共用元件類別名稱取得後端作業選項資訊
        /// </summary>
        public OperationOpInfo GetOperationOpInfoByCommonClass(string commonClass)
        {
            OperationOpInfo entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.GetOperationOpInfoByCommonClass(commonClass);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#9
0
        /// <summary>
        /// 取得後端作業選項階層資訊
        /// </summary>
        public List <OperationLevelInfo> GetOperationLevelInfo(int opId)
        {
            List <OperationLevelInfo> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entities = empAuthDao.GetOperationLevelInfo(opId);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
示例#10
0
        /// <summary>
        /// 取得後端作業選項最大排序編號
        /// </summary>
        public int GetOperationMaxSortNo(int parentId)
        {
            int result = 0;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.GetOperationMaxSortNo(parentId);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#11
0
        /// <summary>
        /// 減小後端作業選項的排序編號
        /// </summary>
        public bool DecreaseOperationSortNo(int opId, string mdfAccount)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.DecreaseOperationSortNo(opId, mdfAccount);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#12
0
        /// <summary>
        /// 取得員工資料
        /// </summary>
        public EmployeeForBackend GetEmployeeData(int empId)
        {
            EmployeeForBackend entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.GetEmployeeDataForBackend(empId);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#13
0
        /// <summary>
        /// 取得員工登入用資料
        /// </summary>
        public EmployeeToLogin GetEmployeeDataToLogin(string empAccount)
        {
            EmployeeToLogin entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.GetEmployeeDataToLogin(empAccount);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#14
0
        /// <summary>
        /// 取得後端操作記錄清單
        /// </summary>
        public List <BackEndLogForBackend> GetBackEndLogList(BackEndLogListQueryParams param)
        {
            List <BackEndLogForBackend> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entities = empAuthDao.GetBackEndLogList(param);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
示例#15
0
        /// <summary>
        /// 取得部門最大排序編號
        /// </summary>
        public int GetDepartmentMaxSortNo()
        {
            int result = 0;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.GetDepartmentMaxSortNo();
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#16
0
        /// <summary>
        /// 取得部門資料
        /// </summary>
        public DepartmentForBackend GetDepartmentData(int deptId)
        {
            DepartmentForBackend entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.GetDepartmentDataForBackend(deptId);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#17
0
        /// <summary>
        /// 用超連結網址取得後端作業選項資訊
        /// </summary>
        public OperationOpInfo GetOperationOpInfoByLinkUrl(string linkUrl)
        {
            OperationOpInfo entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.GetOperationOpInfoByLinkUrl(linkUrl);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#18
0
        /// <summary>
        /// 取得員工身分名稱
        /// </summary>
        public string GetRoleNameOfEmp(string empAccount)
        {
            string roleName = "";

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                roleName = empAuthDao.GetRoleNameOfEmp(empAccount);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(roleName);
        }
示例#19
0
        /// <summary>
        /// 取得後端作業選項清單
        /// </summary>
        public List <OperationForBackend> GetOperationList(OpListQueryParams param)
        {
            List <OperationForBackend> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entities = empAuthDao.GetOperationListForBackend(param);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
示例#20
0
        /// <summary>
        /// 取得後端作業選項資料
        /// </summary>
        public OperationForBackend GetOperationData(int opId)
        {
            OperationForBackend entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.GetOperationDataForBackend(opId);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#21
0
        /// <summary>
        /// 以重置密碼用唯一值取得員工登入用資料
        /// </summary>
        public Employee GetEmployeeDataToLoginByPasswordResetKey(string passwordResetKey)
        {
            Employee entity = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entity   = empAuthDao.Get <Employee>(emp => emp.PasswordResetKey == passwordResetKey);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entity);
        }
示例#22
0
        /// <summary>
        /// 儲存員工身分後端作業授權清單
        /// </summary>
        public bool SaveListOfEmployeeRolePrivileges(RolePrivilegeParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                List <EmployeeRoleOperationsDesc> empRoleOps = param.GenEmpRoleOps();
                result   = empAuthDao.SaveListOfEmployeeRolePrivileges(empRoleOps);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#23
0
        /// <summary>
        /// 取得選擇用部門清單
        /// </summary>
        public List <Department> GetDepartmentListToSelect()
        {
            List <Department> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entities = empAuthDao.GetList <Department>()
                           .OrderBy(dept => dept.SortNo).ToList();
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
示例#24
0
        /// <summary>
        /// 刪除部門資料
        /// </summary>
        public bool DeleteDepartmentData(DeptParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.DeleteDepartmentData(param.DeptId);
                dbErrMsg = empAuthDao.GetErrMsg();

                if (!result && empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.IsThereAccountsOfDept = true;
                }
            }

            return(result);
        }
示例#25
0
        /// <summary>
        /// 刪除員工資料
        /// </summary>
        public bool DeleteEmployeeData(int empId)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Employee entity = new Employee()
                {
                    EmpId = empId
                };

                result   = empAuthDao.Delete <Employee>(entity);
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#26
0
        /// <summary>
        /// 刪除後端作業選項
        /// </summary>
        public bool DeleteOperationData(OpParams param)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                result   = empAuthDao.DeleteOperationData(param.OpId);
                dbErrMsg = empAuthDao.GetErrMsg();

                if (!result && empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.IsThereSubitemOfOp = true;
                }
            }

            return(result);
        }
示例#27
0
        /// <summary>
        /// 更新員工的重置密碼用唯一值
        /// </summary>
        public bool UpdateEmployeePasswordResetKey(string empAccount, string passwordResetKey)
        {
            bool result = false;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Employee entity = empAuthDao.Get <Employee>(emp => emp.EmpAccount == empAccount);

                entity.PasswordResetKey     = passwordResetKey;
                entity.PasswordResetKeyDate = DateTime.Now;
                entity.MdfAccount           = empAccount;
                entity.MdfDate = DateTime.Now;

                result   = empAuthDao.Update();
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(result);
        }
示例#28
0
        /// <summary>
        /// 新增後端作業選項
        /// </summary>
        public bool InsertOperationData(OpParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                int?objParentId = null;

                if (param.ParentId != 0)
                {
                    objParentId = param.ParentId;
                }

                Operations entity = new Operations()
                {
                    ParentId       = objParentId,
                    OpSubject      = param.OpSubject,
                    LinkUrl        = param.LinkUrl,
                    IsNewWindow    = param.IsNewWindow,
                    IconImageFile  = param.IconImageFile,
                    SortNo         = param.SortNo,
                    IsHideSelf     = param.IsHideSelf,
                    CommonClass    = param.CommonClass,
                    EnglishSubject = param.EnglishSubject,
                    PostAccount    = param.PostAccount,
                    PostDate       = DateTime.Now
                };

                insResult = empAuthDao.Insert <Operations>(entity);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.OpId = (int)insResult.NewId;
                }
            }

            return(insResult.IsSuccess);
        }
示例#29
0
        /// <summary>
        /// 新增員工資料
        /// </summary>
        public bool InsertEmployeeData(AccountParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                insResult = empAuthDao.Insert <Employee>(new Employee()
                {
                    EmpAccount            = param.EmpAccount,
                    EmpPassword           = param.EmpPassword,
                    EmpName               = param.EmpName,
                    Email                 = param.Email,
                    Remarks               = param.Remarks,
                    DeptId                = param.DeptId,
                    RoleId                = param.RoleId,
                    IsAccessDenied        = param.IsAccessDenied,
                    StartDate             = param.StartDate,
                    EndDate               = param.EndDate,
                    OwnerAccount          = param.OwnerAccount,
                    PasswordHashed        = param.PasswordHashed,
                    DefaultRandomPassword = param.DefaultRandomPassword,
                    PostAccount           = param.PostAccount,
                    PostDate              = DateTime.Now
                });

                dbErrMsg = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.EmpId = (int)insResult.NewId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 2601)
                {
                    param.HasAccountBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
示例#30
0
        /// <summary>
        /// 用共用元件類別名稱取得後端作業代碼
        /// </summary>
        public int GetOpIdByCommonClass(string commonClass)
        {
            int opId = 0;

            //用共用元件類別名稱取得後端作業選項資訊
            OperationOpInfo opInfo = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                opInfo = empAuthDao.GetOperationOpInfoByCommonClass(commonClass);
                string dbErrMsg = empAuthDao.GetErrMsg();
            }

            if (opInfo != null)
            {
                opId = opInfo.OpId;
            }

            return(opId);
        }