예제 #1
0
        internal Result AddEVacationRequest()
        {
            try
            {
                Result             result;
                PlacementBLL       CurrentActualOrgAndActualJob = new PlacementBLL().GetCurrentActualOrgAndActualJob(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo);
                EVacationsRequests EVacationRequest             = new EVacationsRequests()
                {
                    EmployeeCareerHistoryID = this.EmployeeCareerHistory.EmployeeCareerHistoryID,
                    //ActualOrganizationID = CurrentActualOrgAndActualJob != null ? CurrentActualOrgAndActualJob?.Organization?.OrganizationID : (int?)null,
                    //ActualJobID = CurrentActualOrgAndActualJob != null ? CurrentActualOrgAndActualJob?.Job?.JobID != 0 ? CurrentActualOrgAndActualJob?.Job?.JobID : (int?)null : null,
                    ActualOrganizationID     = CurrentActualOrgAndActualJob?.Organization?.OrganizationID,
                    ActualJobID              = CurrentActualOrgAndActualJob?.Job?.JobID == 0 ? null : CurrentActualOrgAndActualJob?.Job?.JobID,
                    VacationStartDate        = this.VacationStartDate,
                    VacationEndDate          = this.VacationEndDate,
                    CreatorNotes             = this.CreatorNotes,
                    VacationTypeID           = (int)this.VacationTypeEnum,
                    EVacationRequestNo       = new EVacationsRequestsDAL().GetMaxEVacationRequestNoByYear(DateTime.Now.Year) + 1,
                    EVacationRequestStatusID = (int)EVacationRequestStatusEnum.Pending,
                    CreatedDate              = DateTime.Now,
                    CreatedBy = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
                };

                #region Validation to check there is any e vacation request is pending or not
                // pending means that no action by his manager till now or this e vacation is not cancelled by creator
                result = IsEVacationRequestPendingExist(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo);
                if (result != null)
                {
                    return(result);
                }
                #endregion

                #region Checking proxies
                #region Validation to check if the requester is authorized person in e services authorizations module ... if the requester has e services authorizations :
                // 1 - he can not create e vacation request if the vacation start date will be in the future
                // 2 - he can create e vacation request if the vacation period will be in the past
                if (this.VacationStartDate > DateTime.Now || this.VacationEndDate > DateTime.Now) // no need to check about of old vacations
                {
                    EServicesAuthorizationsBLL EServiceAuthorization = new EServicesAuthorizationsBLL().GetOrganizationAuthorizedPerson(CurrentActualOrgAndActualJob.Organization.OrganizationID, EServicesTypesEnum.Vacation);
                    if (EServiceAuthorization.AuthorizedPerson.EmployeeCodeNo == this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo) // thats mean the manager has authorization
                    {
                        // check the manager created valid proxy to e vacation service to other person or not
                        EServicesProxiesBLL ActiveProxy = new EServicesProxiesBLL().GetActiveByFromEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, EServicesTypesEnum.Vacation);
                        if (ActiveProxy == null) // thats mean he did not create valid proxy to e vacation service to other person
                        {
                            result = new Result();
                            //result.Entity = this;
                            result.EnumMember = VacationsValidationEnum.RejectedBecauseOfNoActiveProxyCreatedToOtherPerson.ToString();
                            return(result);
                        }
                    }

                    #region check the employee has proxy by other person or not
                    EServicesProxiesBLL ActiveEVacationServiceProxy = new EServicesProxiesBLL().GetActiveByToEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID).FirstOrDefault(x => x.EServiceType.EServiceTypeID == (int)EServicesTypesEnum.Vacation);
                    if (ActiveEVacationServiceProxy != null) // thats mean he is proxied by other person
                    {
                        result            = new Result();
                        result.Entity     = ActiveEVacationServiceProxy;
                        result.EnumMember = VacationsValidationEnum.RejectedBecauseOfEmployeeHasProxyByOtherPerson.ToString();
                        return(result);
                    }
                    #endregion
                }

                #endregion
                #endregion

                result = new Result();
                new EVacationsRequestsDAL().Insert(EVacationRequest);
                this.EVacationRequestNo = EVacationRequest.EVacationRequestNo;
                result.Entity           = this;
                result.EnumMember       = VacationsValidationEnum.Done.ToString();

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        /// <summary>
        /// Task # 255: Changing the manager of any organization must affect on e services authorization module
        ///  - removed validation of Is Placement period finished or not?
        ///
        /// </summary>
        /// <param name="Organization"></param>
        /// <returns></returns>
        public Result ChangeOrganizationManager(OrganizationsStructuresBLL Organization)
        {
            try
            {
                Result result = null;

                // Now there is no need for this condition, placement is open for all times.

                //#region Validate if the Placement period finished or not
                //result = CommonHelper.IsValidToCompleteEmployeesPlacement();
                //if (result != null)
                //    return result;
                //#endregion

                // TASK 255 (related) Changing the manager of any organization must affect on e services authorization module
                OrganizationsStructures OldOrganization = new OrganizationsStructuresDAL().GetByOrganizationID(Organization.OrganizationID);

                // TASK 330 (related) Checking the manager organization is going to be changed or not .. if the manager is not going to be changed, no need to do any action
                if (OldOrganization.ManagerCodeID.HasValue)
                {
                    if (Organization.OrganizationManager.EmployeeCodeID == OldOrganization.ManagerCodeID.Value) // thats mean the manager is not going to be changed
                    {
                        return(result);
                    }
                }

                OrganizationsStructures OrganizationStructure = new OrganizationsStructures()
                {
                    OrganizationID  = Organization.OrganizationID,
                    ManagerCodeID   = Organization.OrganizationManager != null ? Organization.OrganizationManager.EmployeeCodeID : (int?)null,
                    LastUpdatedDate = DateTime.Now,
                    LastUpdatedBy   = Organization.LoginIdentity.EmployeeCodeID
                };

                Assignings Assigning = new Assignings()
                {
                    OrganizationID  = Organization.OrganizationID,
                    ManagerCodeID   = Organization.OrganizationManager != null ? Organization.OrganizationManager.EmployeeCodeID : (int?)null,
                    LastUpdatedDate = DateTime.Now,
                    LastUpdatedBy   = Organization.LoginIdentity.EmployeeCodeID
                };

                new OrganizationsStructuresDAL().UpdateManager(OrganizationStructure);
                new AssigningsDAL().UpdateOrganizationManager(Assigning); // if the manager of organization has been changed, the manager of the same organization in Assigning must be changed (for all unfinished assignings)

                // Old and New Organization must have ManagerCodeID
                // Update AuthorizedPerson in EServices Authorization table (related to task 255)
                if (OldOrganization.ManagerCodeID.HasValue && OldOrganization.ManagerCodeID.Value > 0 &&
                    Organization.OrganizationManager != null && Organization.OrganizationManager.EmployeeCodeID > 0)
                {
                    new EServicesAuthorizationsBLL()
                    {
                        LoginIdentity = Organization.LoginIdentity
                    }.ChangeAuthorizedPersonForAllChildByOrganizationID(Organization.OrganizationID, OldOrganization.ManagerCodeID.Value, Organization.OrganizationManager.EmployeeCodeID);
                }

                #region Task 318: Service to Cancel EServicesProxies By System
                try
                {
                    result = new EServicesProxiesBLL()
                    {
                        LoginIdentity = Organization.LoginIdentity
                    }
                    .RevokeEServiceProxyByEmployeeCodeID(Organization.OrganizationManager.EmployeeCodeID, EServicesProxiesStatusEnum.CancelledBySystem, Globalization.EServiceProxyCancelledBySystemBecauseOfChangeManagerText);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion


                // this to get mobile no of manager
                EmployeesCodesBLL ManagerCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(Organization.OrganizationManager != null ? Organization.OrganizationManager.EmployeeCodeID : 0);
                if (ManagerCodeBLL != null)
                {
                    SMSLogsBLL SMSLogBLL = new SMSLogsBLL()
                    {
                        BusinssSubCategory = BusinessSubCategoriesEnum.OrganizationStructure,
                        MobileNo           = ManagerCodeBLL.Employee.EmployeeMobileNo,
                        DetailID           = 0,
                        Message            = string.Format(Globalization.SMSManagerAlreadyAssignedToOrganizationMessageText, ManagerCodeBLL.Employee.FirstNameAr + " " + ManagerCodeBLL.Employee.LastNameAr, Organization.GetOrganizationNameTillLastParentExceptPresident(Organization.OrganizationID)),
                        CreatedBy          = Organization.LoginIdentity,
                        CreatedDate        = DateTime.Now,
                    };
                    new SMSBLL().SendSMS(SMSLogBLL);
                }

                result            = new Result();
                result.Entity     = this;
                result.EnumType   = typeof(OrganizationStructureValidationEnum);
                result.EnumMember = OrganizationStructureValidationEnum.Done.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        //public BaseAssigningsBLL GetActiveAssigningByEmployeeCareerHistoryID(int EmployeeCareerHistoryID)
        //{
        //    BaseAssigningsBLL assigningBLL = new BaseAssigningsBLL();
        //    Assignings assigning = new AssigningsDAL().GetActiveAssigningByEmployeeCareerHistoryID(EmployeeCareerHistoryID);
        //    if (assigning != null)
        //        assigningBLL = new BaseAssigningsBLL().MapAssigning(assigning);

        //    return assigningBLL;
        //}

        /// <summary>
        /// Task # 226 :
        /// Finish last assigning, based on passing parameters
        /// this function called by different modules like Promotion, Delegation, or StopWork etc
        /// Task # 310 : change CareerHistoryID to EmployeeCodeID because of task 310
        /// Task 318: Service to Cancel EServicesProxies By System
        /// </summary>
        /// <param name="EmployeeCodeID"></param>
        /// <param name="AssigningEndDate"></param>
        /// <param name="EndAssigningReason"></param>
        /// <returns></returns>
        public Result BreakLastAssigning(int EmployeeCodeID, DateTime AssigningEndDate, AssigningsReasonsEnum EndAssigningReason, string EndAssigningReasonNotes = "")
        {
            Result            result       = new Result();
            BaseAssigningsBLL assigningBLL = new BaseAssigningsBLL();
            Assignings        assigning    = new AssigningsDAL().GetActiveAssigningByEmployeeCodeID(EmployeeCodeID);

            if (assigning != null)
            {
                if (assigning.IsFinished)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                    return(result);
                }

                if (AssigningEndDate < assigning.AssigningStartDate)
                {
                    result            = new Result();
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString();

                    return(result);
                }

                assigning.AssigningEndDate     = AssigningEndDate;
                assigning.EndAssigningReasonID = (int)EndAssigningReason;
                assigning.IsFinished           = true;
                assigning.Notes           = EndAssigningReasonNotes;
                assigning.LastUpdatedBy   = this.LoginIdentity.EmployeeCodeID;
                assigning.LastUpdatedDate = DateTime.Now;
                this.AssigningID          = new AssigningsDAL().BreakAssigning(assigning);
                if (this.AssigningID != 0)
                {
                    #region Cancellation of all pending e vacations requests of employee after breaking last assigning of him
                    List <EVacationsRequests> PendingEVacationRequestsList = new EVacationsRequestsDAL().GetByEmployeeCodeID(EmployeeCodeID, (int)EVacationRequestStatusEnum.Pending);
                    foreach (var item in PendingEVacationRequestsList)
                    {
                        result = new EVacationsRequestsBLL().CancelEVacationRequest(item.EVacationRequestID, EVacationRequestStatusEnum.CancelledBySystem, Globalization.EVacationRequestCancelledBySystemBecauseOfBreakingLastAssigningText);
                    }
                    #endregion

                    #region Task 318: Service to Cancel EServicesProxies By System
                    try
                    {
                        result = new EServicesProxiesBLL()
                        {
                            LoginIdentity = this.LoginIdentity
                        }
                        .RevokeEServiceProxyByEmployeeCodeID(EmployeeCodeID, EServicesProxiesStatusEnum.CancelledBySystem, Globalization.EServiceProxyCancelledBySystemBecauseOfBreakingLastAssigningText);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
            }
            else
            {
                result.EnumType   = typeof(AssigningsValidationEnum);
                result.EnumMember = AssigningsValidationEnum.RejectedBecauseAssigningNotFound.ToString();
            }

            return(result);
        }
예제 #4
0
        public virtual Result Add()
        {
            try
            {
                Result result = new Result();

                if (this.StartDate.ToString().Contains("0001"))
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseStartDateRequried.ToString();

                    return(result);
                }
                else if (this.LoginIdentity.EmployeeCodeID == this.ToEmployee.EmployeeCodeID)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseLoginManagerIsSameAsProxyEmployee.ToString();

                    return(result);
                }
                else
                {
                    EServicesProxiesBLL bll = this.GetActiveByFromEmployeeCodeID(this.FromEmployee.EmployeeCodeID, (EServicesTypesEnum)this.EServiceType.EServiceTypeID);
                    if (bll != null && bll.EServiceProxyID > 0)
                    {
                        result            = new Result();
                        result.Entity     = bll;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsAlreadyActiveProxyExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already EVacation Request Pending Exist
                    EmployeesCodes ToEmployee = new EmployeesCodesDAL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                    result = new EVacationsRequestsBLL().IsEVacationRequestPendingExist(ToEmployee.EmployeeCodeNo);
                    if (result != null)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsPendingEVacationRequestExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already Vacation Exist
                    List <BaseVacationsBLL> lst = new BaseVacationsBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID, this.StartDate, this.StartDate.AddDays(this.DaysCountInGregYear));
                    if (lst.Count > 0)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsVacationExist.ToString();

                        return(result);
                    }
                }

                EServicesProxies EServiceProxy = new EServicesProxies()
                {
                    EServiceTypeID        = this.EServiceType.EServiceTypeID,
                    FromEmployeeCodeID    = this.FromEmployee.EmployeeCodeID,
                    ToEmployeeCodeID      = this.ToEmployee.EmployeeCodeID,
                    StartDate             = this.StartDate,
                    EndDate               = this.EndDate,
                    EServiceProxyStatusID = (int)EServicesProxiesStatusEnum.Valid,
                    IsActive              = true,
                    Notes       = this.Notes,
                    CreatedDate = DateTime.Now,
                    CreatedBy   = this.LoginIdentity.EmployeeCodeID
                };

                this.EServiceProxyID = new EServicesProxiesDAL().Insert(EServiceProxy);

                #region Send SMS on creation
                EmployeesCodesBLL FromEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.FromEmployee.EmployeeCodeID);
                EmployeesCodesBLL ToEmployeeCodeBLL   = new EmployeesCodesBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                SMSBLL            SMSObj = new SMSBLL();
                SMSObj.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies,
                    DetailID           = this.EServiceProxyID,
                    MobileNo           = ToEmployeeCodeBLL.Employee.EmployeeMobileNo,
                    Message            = string.Format(Globalization.SMSEServicesProxiesCreationText,
                                                       ToEmployeeCodeBLL.Employee.EmployeeNameAr, FromEmployeeCodeBLL.Employee.EmployeeNameAr),
                    CreatedBy = this.LoginIdentity,
                });
                #endregion

                result            = new Result();
                result.Entity     = this;
                result.EnumType   = typeof(EServicesProxiesEnum);
                result.EnumMember = EServicesProxiesEnum.Done.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }