Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        /// <summary>
        /// 取得員工身分名稱
        /// </summary>
        public string GetRoleNameOfEmp(string empAccount)
        {
            string roleName = "";

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

            return(roleName);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
0
        /// <summary>
        /// 取得部門最大排序編號
        /// </summary>
        public int GetDepartmentMaxSortNo()
        {
            int result = 0;

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

            return(result);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }
Beispiel #15
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);
        }
Beispiel #16
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);
        }
Beispiel #17
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);
        }
Beispiel #18
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);
        }
Beispiel #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);
        }
Beispiel #20
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);
        }
Beispiel #21
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);
        }
Beispiel #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);
        }
Beispiel #23
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);
        }
Beispiel #24
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);
        }
Beispiel #25
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);
        }
Beispiel #26
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);
        }
Beispiel #27
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);
        }
Beispiel #28
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);
        }
Beispiel #29
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);
        }
Beispiel #30
0
        /// <summary>
        /// 取得後台網頁所屬的作業代碼
        /// </summary>
        public override int GetOpIdOfPage()
        {
            if (opIdOfPage < 1 && qsUrl != "")
            {
                OperationOpInfo opInfo = null;

                using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
                {
                    opInfo = empAuthDao.GetOperationOpInfoByLinkUrl(qsUrl, false);
                    string dbErrMsg = empAuthDao.GetErrMsg();
                }

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

            return(opIdOfPage);
        }