Exemplo n.º 1
0
        public EmployeeInfo GetApproverAtStep(int departmentID, int locationID, StepModuleList StepModule, int stepNumber)
        {
            EmployeeInfo approverInfo = null;
            BusinessTripManagementApprover approvalList = CreateApprovalList(departmentID, locationID);

            if (approvalList != null)
            {
                Type         typeBusinessTripManagementApprover = typeof(BusinessTripManagementApprover);
                BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
                if (stepNumber == 3)
                {
                    stepNumber += 1;
                }
                PropertyInfo approverProp = typeBusinessTripManagementApprover.GetProperty(string.Format("Approver{0}", stepNumber), bindingFlags);
                if (approverProp != null)
                {
                    object approverValue = approverProp.GetValue(approvalList, null);
                    if (approverValue != null)
                    {
                        approverInfo = approverValue as EmployeeInfo;
                    }
                }
            }

            return(approverInfo);
        }
Exemplo n.º 2
0
        public BusinessTripManagementApprover CreateApprovalList(int departmentId, int locationId)
        {
            BusinessTripManagementApprover businessTripManagementApprover = new BusinessTripManagementApprover();

            EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(this.SiteUrl);
            // Department Head
            var departmentHead = _employeeInfoDAL.GetByPositionDepartment(Constants.StringConstant.EmployeePosition.DepartmentHead, departmentId, locationId);

            if (departmentHead.Count > 0)
            {
                businessTripManagementApprover.Approver1 = departmentHead[0];
            }

            // Direct BOD
            if (businessTripManagementApprover.Approver1 != null && businessTripManagementApprover.Approver1.Manager != null && businessTripManagementApprover.Approver1.Manager.LookupId > 0)
            {
                var directBODInfo = _employeeInfoDAL.GetByID(businessTripManagementApprover.Approver1.Manager.LookupId);
                if (directBODInfo != null)
                {
                    businessTripManagementApprover.Approver2 = directBODInfo;
                }
            }

            // BOD
            var bodImployeeInfo = _employeeInfoDAL.GetByEmployeeID("11009"); // Ms. Su

            if (bodImployeeInfo != null)
            {
                businessTripManagementApprover.Approver3 = bodImployeeInfo;
            }

            // Department Head of HC
            int departmentIdHC = DepartmentListSingleton.GetDepartmentByCode("HR", SiteUrl).ID;

            if (departmentIdHC != departmentId)
            {
                var departmentHeadOfHC = _employeeInfoDAL.GetByPositionDepartment(Constants.StringConstant.EmployeePosition.DepartmentHead, departmentIdHC, locationId);
                if (departmentHeadOfHC.Count > 0)
                {
                    businessTripManagementApprover.Approver4 = departmentHeadOfHC[0];
                }
            }

            if (businessTripManagementApprover.Approver2 == null)
            {
                businessTripManagementApprover.Approver2 = businessTripManagementApprover.Approver3;
            }

            return(businessTripManagementApprover);
        }
Exemplo n.º 3
0
        public BusinessTripManagementApproverModel GetApprovers(string departmentIdStr, string locationIdStr)
        {
            if (string.IsNullOrEmpty(departmentIdStr))
            {
                return(null);
            }

            BusinessTripManagementApproverModel approvers = new BusinessTripManagementApproverModel();

            try
            {
                BusinessTripManagementApprover businessTripManagementApprover = _businessTripManagementDAL.CreateApprovalList(Convert.ToInt32(departmentIdStr), Convert.ToInt32(locationIdStr));
                if (businessTripManagementApprover != null)
                {
                    if (businessTripManagementApprover.Approver1 != null)
                    {
                        approvers.Approver1 = new ApproverModel()
                        {
                            ID = businessTripManagementApprover.Approver1.ID, FullLoginName = businessTripManagementApprover.Approver1.ADAccount.FullName, LoginName = businessTripManagementApprover.Approver1.ADAccount.UserName
                        }
                    }
                    ;

                    if (businessTripManagementApprover.Approver2 != null)
                    {
                        approvers.Approver2 = new ApproverModel()
                        {
                            ID = businessTripManagementApprover.Approver2.ID, FullLoginName = businessTripManagementApprover.Approver2.ADAccount.FullName, LoginName = businessTripManagementApprover.Approver2.ADAccount.UserName
                        }
                    }
                    ;

                    if (businessTripManagementApprover.Approver3 != null)
                    {
                        approvers.Approver3 = new ApproverModel()
                        {
                            ID = businessTripManagementApprover.Approver3.ID, FullLoginName = businessTripManagementApprover.Approver3.ADAccount.FullName, LoginName = businessTripManagementApprover.Approver3.ADAccount.UserName
                        }
                    }
                    ;

                    if (businessTripManagementApprover.Approver4 != null)
                    {
                        approvers.Approver4 = new ApproverModel()
                        {
                            ID = businessTripManagementApprover.Approver4.ID, FullLoginName = businessTripManagementApprover.Approver4.ADAccount.FullName, LoginName = businessTripManagementApprover.Approver4.ADAccount.UserName
                        }
                    }
                    ;
                }

                return(approvers);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Business Trip Management Service - GetApprovers",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(null);
            }
        }