예제 #1
0
        internal virtual bool IsAlreadyProcessed(int TransferID)
        {
            BaseTransfersBLL nn = this.GetByTransferID(TransferID);

            if (nn.IsProcessed.HasValue && nn.IsProcessed.Value == true)
            {
                return(true);
            }

            return(false);
        }
예제 #2
0
        internal BaseTransfersBLL MapTransfer(Transfers Transfer)
        {
            try
            {
                BaseTransfersBLL BaseTransfersBLL = null;
                if (Transfer != null)
                {
                    if (Transfer.TransferTypeID == Convert.ToInt16(TransfersTypesEnum.TransferEmployeeWithJob))
                    {
                        BaseTransfersBLL = GenericFactoryPattern <BaseTransfersBLL, TransferEmployeesWithJobBLL> .CreateInstance();
                    }

                    else if (Transfer.TransferTypeID == Convert.ToInt16(TransfersTypesEnum.TransferEmployeeWithoutJob))
                    {
                        BaseTransfersBLL = GenericFactoryPattern <BaseTransfersBLL, TransferEmployeesWithoutJobBLL> .CreateInstance();

                        ((TransferEmployeesWithoutJobBLL)BaseTransfersBLL).JobName          = Transfer.JobName;
                        ((TransferEmployeesWithoutJobBLL)BaseTransfersBLL).RankName         = Transfer.RankName;
                        ((TransferEmployeesWithoutJobBLL)BaseTransfersBLL).JobCode          = Transfer.JobCode;
                        ((TransferEmployeesWithoutJobBLL)BaseTransfersBLL).CareerDegreeName = Transfer.CareerDegreeName;
                        ((TransferEmployeesWithoutJobBLL)BaseTransfersBLL).OrganizationName = Transfer.OrganizationName;
                    }

                    //BaseTransfersBLL = new BaseTransfersBLL();

                    BaseTransfersBLL.Destination = Transfer.Destination;
                    BaseTransfersBLL.KSACity     = new KSACitiesBLL()
                    {
                        KSACityID = Transfer.KSACityID
                    };
                    BaseTransfersBLL.TransferID   = Transfer.TransferID;
                    BaseTransfersBLL.TransferType = new TransfersTypesBLL()
                    {
                        TransferTypeID = Transfer.TransferTypeID, TransferType = Transfer.TransfersTypes?.TransferTypeName
                    };
                    BaseTransfersBLL.TransferDate          = Transfer.TransferDate;
                    BaseTransfersBLL.EmployeeCareerHistory = Transfer.EmployeesCareersHistory != null ? new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(Transfer.EmployeesCareersHistory) : null;
                    BaseTransfersBLL.IsProcessed           = Transfer.IsProcessed;
                    BaseTransfersBLL.CreatedDate           = Transfer.CreatedDate;
                    BaseTransfersBLL.CreatedBy             = Transfer.CreatedByNav != null ? new EmployeesCodesBLL().MapEmployeeCode(Transfer.CreatedByNav) : null;
                    BaseTransfersBLL.LastUpdatedDate       = Transfer.LastUpdatedDate;
                    BaseTransfersBLL.LastUpdatedBy         = Transfer.LastUpdatedByNav != null ? new EmployeesCodesBLL().MapEmployeeCode(Transfer.LastUpdatedByNav) : null;
                }
                return(BaseTransfersBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public BaseTransfersBLL GetByTransferID(int TransferID)
        {
            try
            {
                BaseTransfersBLL EmployeeTransferBLL = null;
                Transfers        EmployeeTransfer    = new TransfersDAL().GetByTransferID(TransferID);
                if (EmployeeTransfer != null)
                {
                    EmployeeTransferBLL = MapTransfer(EmployeeTransfer);
                }

                return(EmployeeTransferBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        /// <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;
            }
        }