Exemple #1
0
        //public List<EmployeesCareersHistoryBLL> GetDeservedEmployeesInPromotion(int RankID, DateTime PromotionEndDate, int DaysCount)
        //{
        //    List<EmployeesCareersHistoryBLL> DeservedEmployeesBLLList = new List<EmployeesCareersHistoryBLL>();
        //    List<EmployeesCareersHistory> DeservedEmployeesList = new EmployeesCareersHistoryDAL().GetActiveEmployeesByRankID(RankID).Where(x => PromotionEndDate >= x.JoinDate.AddDays(DaysCount)).ToList();
        //    foreach (var item in DeservedEmployeesList)
        //    {
        //        DeservedEmployeesBLLList.Add(new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(item));
        //    }
        //    return DeservedEmployeesBLLList;
        //}

        //       public EmployeesCareersHistoryBLL GetDeservedEmployeeInPromotionByEmployeeCodeID(int EmployeeCodeID, DateTime PromotionEndDate, int DaysCount)
        //       {
        //reutthis.GetEmployeeCurrentJob(EmployeeCodeID)
        //       }

        public EmployeesCareersHistoryBLL Get(OrganizationsJobsBLL OrganizationJob, CareersHistoryTypesEnum CareerHistoryType, EmployeesCodesBLL EmployeeCode)
        {
            EmployeesCareersHistory    EmployeeCareerHistory    = new EmployeesCareersHistoryDAL().GetByOrganizationJobIDEmployeeCodeIDCareerHistoryTypeID(OrganizationJob.OrganizationJobID, (int)CareerHistoryType, EmployeeCode.EmployeeCodeID);
            EmployeesCareersHistoryBLL EmployeeCareerHistoryBLL = null;

            if (EmployeeCareerHistory != null)
            {
                EmployeeCareerHistoryBLL = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(EmployeeCareerHistory);
            }

            return(EmployeeCareerHistoryBLL);
        }
        /// <summary>
        /// it will be called by windows service to disactive employee based on transfer date
        /// </summary>
        /// <returns></returns>
        public virtual Result StartProcess()
        {
            try
            {
                Result result = new Result();
                List <BaseTransfersBLL> TransfersNotProcessed = this.GetTransfersNotProcessed();
                foreach (var item in TransfersNotProcessed)
                {
                    CareersHistoryTypesEnum CareerHistoryTypeEnum = item.TransferType.TransferTypeID == Convert.ToInt16(TransfersTypesEnum.TransferEmployeeWithJob) ? CareersHistoryTypesEnum.TransfareWithJob : CareersHistoryTypesEnum.TransfareWithoutJob;

                    if (DateTime.Now.Date >= item.TransferDate.Date)
                    {
                        #region Adding new record with new career history type (Transfare With Job) in career history of employees
                        // check if the job was is exists or not
                        EmployeesCareersHistoryBLL EmployeeCareerHistory = new EmployeesCareersHistoryBLL().Get(item.EmployeeCareerHistory.OrganizationJob, CareerHistoryTypeEnum, item.EmployeeCareerHistory.EmployeeCode);
                        if (EmployeeCareerHistory == null)
                        {
                            result = new EmployeesCareersHistoryBLL()
                            {
                                EmployeeCode      = item.EmployeeCareerHistory.EmployeeCode,
                                OrganizationJob   = item.EmployeeCareerHistory.OrganizationJob,
                                CareerHistoryType = new CareersHistoryTypesBLL()
                                {
                                    CareerHistoryTypeID = (int)CareerHistoryTypeEnum
                                },
                                CareerDegree         = item.EmployeeCareerHistory.CareerDegree,
                                JoinDate             = item.TransferDate,
                                TransactionStartDate = item.TransferDate,
                                IsActive             = false,
                                LoginIdentity        = item.CreatedBy,
                            }.Add();

                            if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString())
                            {
                                return(result);
                            }
                            else
                            {
                                #region Disactive all career hsitory of employee
                                new EmployeesCareersHistoryBLL()
                                {
                                    LoginIdentity = item.CreatedBy
                                }.DeactivateAllCareerHistoryOfEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);
                                #endregion
                            }
                        }
                        #endregion

                        #region Disactive employee
                        result = new EmployeesCodesBLL()
                        {
                            LoginIdentity = item.CreatedBy
                        }.DeactivateEmployee(item.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);
                        if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString())
                        {
                            return(result);
                        }
                        #endregion

                        #region Disactive his job in case of transfer type is "Transfare with his job"
                        if (item.TransferType.TransferTypeID == (int)TransfersTypesEnum.TransferEmployeeWithJob)
                        {
                            result = new OrganizationsJobsBLL()
                            {
                                LoginIdentity = item.CreatedBy
                            }.Transferring(item.EmployeeCareerHistory.OrganizationJob.OrganizationJobID);
                            if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString())
                            {
                                return(result);
                            }
                        }
                        #endregion

                        #region Set his job as job vacant in case of transfer type is "Transfare without his job"
                        if (item.TransferType.TransferTypeID == (int)TransfersTypesEnum.TransferEmployeeWithoutJob)
                        {
                            result = new OrganizationsJobsBLL()
                            {
                                LoginIdentity = item.CreatedBy
                            }.SetJobAsVacant(item.EmployeeCareerHistory.OrganizationJob.OrganizationJobID);
                        }
                        #endregion

                        #region Update is procees to true
                        result = new BaseTransfersBLL()
                        {
                            LoginIdentity = item.CreatedBy
                        }.MarkIsProcessToDone(item.TransferID);
                        if (result.EnumMember != CareersHistoryValidationEnum.Done.ToString())
                        {
                            return(result);
                        }
                        #endregion
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }