/// <summary>
        /// گزارش کارکرد یک روز پرسنل جاری را بر می گرداند
        /// </summary>
        /// <param name="dayDate">تاریخ</param>
        /// <returns>سطر گزارش کارکرد</returns>
        public PersonalMonthlyReportRow GetPersonDailyReport(DateTime dayDate)
        {
            try
            {
                IList <PersonalMonthlyReportRow> DailyRows = new List <PersonalMonthlyReportRow>();

                if (IsValidPeson())
                {
                    PersianDateTime p = new PersianDateTime(dayDate);
                    DateTime        endOfMonth;
                    if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                    {
                        endOfMonth = PersianDateTime.GetEndOfShamsiMonth(p.Year, p.Month).GregorianDate;
                    }
                    else
                    {
                        endOfMonth = new DateTime(dayDate.Year, dayDate.Month, DateTime.DaysInMonth(dayDate.Year, dayDate.Month));
                    }

                    BTemp          bTemp = new BTemp();
                    List <decimal> list  = new List <decimal>();
                    list.Add(this.workingPersonId);
                    string operationGUID = bTemp.InsertTempList(list);
                    gtsEngineWS.GTS_ExecuteByPersonIdAndToDate(BUser.CurrentUser.UserName, this.workingPersonId, dayDate.AddDays(1));
                    PersonalMonthlyReport Result = new PersonalMonthlyReport(this.workingPersonId, endOfMonth, new PersianDateTime(endOfMonth).Month, dayDate, dayDate);
                    Result.LanguageName = sysLanguageResource;

                    DailyRows = Result.PersonalMonthlyReportRows;

                    return(DailyRows.First());
                }
                else
                {
                    throw new IllegalServiceAccess(String.Format("این سرویس بعللت اعتبارسنجی قابل دسترسی نمیباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                }
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BPersonMonthlyWorkedTime", "GetPersonDailyReport");

                throw ex;
            }
        }
예제 #2
0
        public IList <Request> GetUnconfirmedRequestsByRequestSubstitute(IList <Request> requestsList)
        {
            try
            {
                IList <Request>           unConfirmedRequestsList = null;
                RequestSubstitute         requestSubstituteAlias  = null;
                GTS.Clock.Model.Temp.Temp tempAlias = new Model.Temp.Temp();
                Request requestAlias = null;
                BTemp   bTemp        = new BTemp();
                if (requestsList.Count() < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
                {
                    unConfirmedRequestsList = this.NHSession.QueryOver <RequestSubstitute>(() => requestSubstituteAlias)
                                              .JoinAlias(() => requestSubstituteAlias.Request, () => requestAlias)
                                              .Where(() => !(bool)requestSubstituteAlias.Confirmed &&
                                                     requestAlias.ID.IsIn(requestsList.Select(x => x.ID).ToArray <decimal>())
                                                     )
                                              .Select(x => x.Request)
                                              .List <Request>();
                }
                else
                {
                    string operationGUID = bTemp.InsertTempList(requestsList.Select(x => x.ID).ToList <decimal>());
                    unConfirmedRequestsList = this.NHSession.QueryOver <RequestSubstitute>(() => requestSubstituteAlias)
                                              .JoinAlias(() => requestSubstituteAlias.Request, () => requestAlias)
                                              .JoinAlias(() => requestAlias.TempList, () => tempAlias)
                                              .Where(() => !(bool)requestSubstituteAlias.Confirmed &&
                                                     tempAlias.OperationGUID == operationGUID
                                                     )
                                              .Select(x => x.Request)
                                              .List <Request>();
                }

                return(unConfirmedRequestsList);
            }
            catch (Exception ex)
            {
                LogException(ex, "BRequestSubstitute", "GetUnconfirmedRequestByRequestSubstitute");
                throw ex;
            }
        }
예제 #3
0
        public void UpdateSubstitutePrecardAccessByFlow(IList <decimal> flowIDsList)
        {
            try
            {
                string      SQLCommand              = string.Empty;
                IQuery      query                   = null;
                Flow        flowAlias               = null;
                ManagerFlow managerFlowAlias        = null;
                Manager     managerAlias            = null;
                GTS.Clock.Model.Temp.Temp tempAlias = null;
                string          operationGUID       = string.Empty;
                BTemp           bTemp               = new BTemp();
                IList <Manager> managersList        = new List <Manager>();

                if (flowIDsList.Count() < operationBatchSizeValue && operationBatchSizeValue < 2100)
                {
                    managersList = this.NHSession.QueryOver <Manager>(() => managerAlias)
                                   .JoinAlias(() => managerAlias.ManagerFlowList, () => managerFlowAlias)
                                   .JoinAlias(() => managerFlowAlias.Flow, () => flowAlias)
                                   .Where(() => flowAlias.ID.IsIn(flowIDsList.ToArray()))
                                   .List <Manager>();
                }
                else
                {
                    operationGUID = bTemp.InsertTempList(flowIDsList);
                    managersList  = this.NHSession.QueryOver <Manager>(() => managerAlias)
                                    .JoinAlias(() => managerAlias.ManagerFlowList, () => managerFlowAlias)
                                    .JoinAlias(() => managerFlowAlias.Flow, () => flowAlias)
                                    .JoinAlias(() => flowAlias.TempList, () => tempAlias)
                                    .Where(() => tempAlias.OperationGUID == operationGUID)
                                    .List <Manager>();
                    bTemp.DeleteTempList(operationGUID);
                    operationGUID = string.Empty;
                }

                if (managersList != null && managersList.Count > 0)
                {
                    if (managersList.Count() < operationBatchSizeValue && operationBatchSizeValue < 2100)
                    {
                        SQLCommand = @"
                                        DELETE FROM dbo.TA_SubstitutePrecardAccess
                                        WHERE subaccess_SubstituteId IN (
                                                                           SELECT sub_ID FROM dbo.TA_Substitute 
								                                           INNER JOIN dbo.TA_SubstitutePrecardAccess ON sub_ID = subaccess_SubstituteId
								                                           WHERE sub_ManagerId IN (:managerIdsList)
                                                                        )";
                        query      = this.NHSession.CreateSQLQuery(SQLCommand);
                        query.SetParameterList("managerIdsList", managersList.Select(x => x.ID).ToArray());
                        query.ExecuteUpdate();


                        SQLCommand = @"
                                        INSERT INTO dbo.TA_SubstitutePrecardAccess
                                                ( subaccess_PrecardId ,
                                                  subaccess_SubstituteId
                                                )
                                        SELECT precard.Precrd_ID, substitute.sub_ID FROM dbo.TA_Manager manager
                                        INNER JOIN dbo.TA_Substitute substitute ON manager.MasterMng_ID = substitute.sub_ManagerId
                                        INNER JOIN dbo.TA_ManagerFlow managerFlow ON manager.MasterMng_ID = managerFlow.mngrFlow_ManagerID
                                        INNER JOIN dbo.TA_Flow flow ON managerFlow.mngrFlow_FlowID = flow.Flow_ID
                                        INNER JOIN dbo.TA_PrecardAccessGroup precardAccessGroup ON flow.Flow_AccessGroupID = precardAccessGroup.accessGrp_ID
                                        INNER JOIN dbo.TA_PrecardAccessGroupDetail precardAccessGroupDetail ON precardAccessGroup.accessGrp_ID = precardAccessGroupDetail.accessGrpDtl_AccessGrpId
                                        INNER JOIN dbo.TA_Precard precard ON precardAccessGroupDetail.accessGrpDtl_PrecardId = precard.Precrd_ID
                                        WHERE flow.Flow_Deleted = 0 AND 
                                              flow.Flow_ActiveFlow = 1 AND
	                                          manager.MasterMng_Active = 1 AND
	                                          managerFlow.mngrFlow_Active = 1 AND
                                              substitute.sub_ManagerId IN (:managerIdsList)";
                        query      = this.NHSession.CreateSQLQuery(SQLCommand);
                        query.SetParameterList("managerIdsList", managersList.Select(x => x.ID).ToArray());
                        query.ExecuteUpdate();
                    }
                    else
                    {
                        operationGUID = bTemp.InsertTempList(managersList.Select(x => x.ID).ToList <decimal>());

                        SQLCommand = @"
                                        DELETE FROM dbo.TA_SubstitutePrecardAccess
                                        WHERE subaccess_SubstituteId IN (
                                                                           SELECT sub_ID FROM dbo.TA_Substitute 
								                                           INNER JOIN dbo.TA_SubstitutePrecardAccess ON sub_ID = subaccess_SubstituteId
								                                           INNER JOIN dbo.TA_Temp ON sub_ID = temp_ObjectID
								                                           WHERE temp_OperationGUID = :operationGUID 
                                                                        )                                         
                                      ";
                        query      = this.NHSession.CreateSQLQuery(SQLCommand);
                        query.SetParameter("operationGUID", operationGUID);
                        query.ExecuteUpdate();


                        SQLCommand = @"
                                        INSERT INTO dbo.TA_SubstitutePrecardAccess
                                                ( subaccess_PrecardId ,
                                                  subaccess_SubstituteId
                                                )
                                        SELECT precard.Precrd_ID, substitute.sub_ID FROM dbo.TA_Manager manager
                                        INNER JOIN dbo.TA_Substitute substitute ON manager.MasterMng_ID = substitute.sub_ManagerId
                                        INNER JOIN dbo.TA_ManagerFlow managerFlow ON manager.MasterMng_ID = managerFlow.mngrFlow_ManagerID
                                        INNER JOIN dbo.TA_Flow flow ON managerFlow.mngrFlow_FlowID = flow.Flow_ID
                                        INNER JOIN dbo.TA_PrecardAccessGroup precardAccessGroup ON flow.Flow_AccessGroupID = precardAccessGroup.accessGrp_ID
                                        INNER JOIN dbo.TA_PrecardAccessGroupDetail precardAccessGroupDetail ON precardAccessGroup.accessGrp_ID = precardAccessGroupDetail.accessGrpDtl_AccessGrpId
                                        INNER JOIN dbo.TA_Precard precard ON precardAccessGroupDetail.accessGrpDtl_PrecardId = precard.Precrd_ID
                                        INNER JOIN dbo.TA_Temp temp ON sub_ID = temp.temp_OperationGUID
                                        WHERE flow.Flow_Deleted = 0 AND 
                                              flow.Flow_ActiveFlow = 1 AND
	                                          manager.MasterMng_Active = 1 AND
	                                          managerFlow.mngrFlow_Active = 1 AND
	                                          temp.temp_OperationGUID = :operationGUID
                                      ";
                        query      = this.NHSession.CreateSQLQuery(SQLCommand);
                        query.SetParameter("operationGUID", operationGUID);
                        query.ExecuteUpdate();

                        bTemp.DeleteTempList(operationGUID);
                    }
                }
            }
            catch (Exception ex)
            {
                LogException(ex, ExceptionSrc, "UpdateSubstitutePrecardAccessByFlow");
            }
        }
예제 #4
0
        /// <summary>
        /// انجام محاسبات یک پرسنل  در بازه زمانی مشخص
        /// </summary>
        /// <param name="personId">کلید اصلی پرسنل</param>
        /// <param name="fromDate">تاریخ شروع</param>
        /// <param name="toDate">تاریخ پایان</param>
        /// <param name="forceCalculate">محاسبات اجباری</param>
        /// <returns>انجام شد یا نشد</returns>
        public bool Calculate(decimal personId, string fromDate, string toDate, bool forceCalculate)
        {
            try
            {
                DateTime from, to;
                object   obj = new object();
                UIValidationExceptions exception = new UIValidationExceptions();
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    from = Utility.ToMildiDate(fromDate);
                    to   = Utility.ToMildiDate(toDate);
                }
                else
                {
                    from = Utility.ToMildiDateTime(fromDate);
                    to   = Utility.ToMildiDateTime(toDate);
                }
                if (to != Utility.GTSMinStandardDateTime && from > to)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.CalculationStartDateIsGreaterThanCalculationEndDate, "تاریخ ابتدا از تاریخ انتها بزرگتر است", ExceptionSrc));
                }
                if (personId == 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.CalculationPersonNotSelected, "پرسنلی انتخاب نشده است.", ExceptionSrc));
                }
                if (exception.Count > 0)
                {
                    throw exception;
                }

                decimal[] ids = new decimal[1];
                ids[0]   = personId;
                PersonID = ids[0];
                FromDate = from;
                ToDate   = to;
                if (forceCalculate)
                {
                    BusinessEntity entity = new BusinessEntity();
                    entity.UpdateCFP(new List <Person>()
                    {
                        new Person()
                        {
                            ID = personId
                        }
                    }, from, true);
                }
                BTemp  bTemp         = new BTemp();
                string operationGUID = bTemp.InsertTempList(ids.ToList());
                CallUIValidator(this);
                gtsEngineWS.GTS_ExecutePersonsByToDateGUID(BUser.CurrentUser.UserName, operationGUID, to);
                bTemp.DeleteTempList(operationGUID);
                BaseBusiness <Entity> .LogUserAction(String.Format("CalculateAll -> personId: {0} -->Calculate(personId,toDate)", personId));

                return(true);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BEngineCalculator", "Calculate(personId,toDate)");

                throw ex;
            }
        }
예제 #5
0
        /// <summary>
        /// انجام محاسبات پرسنل جستجو شده در بازه زمانی مشخص
        /// </summary>
        /// <param name="searchKey">عبارت جستجو</param>
        /// <param name="fromDate">تاریخ شروع</param>
        /// <param name="toDate">تاریخ پایان</param>
        /// <param name="forceCalculate">محاسبات اجباری</param>
        /// <returns>انجام شد یا نشد</returns>
        public bool Calculate(string searchKey, string fromDate, string toDate, bool forceCalculate)
        {
            try
            {
                bool   IsCalculationDependOnLockDate    = true;
                string IsCalculationDependOnLockDateStr = System.Configuration.ConfigurationManager.AppSettings["IsCalculationDependOnLockDate"];

                bool resultGetAppSetting = Boolean.TryParse(IsCalculationDependOnLockDateStr, out IsCalculationDependOnLockDate);
                if (!resultGetAppSetting)
                {
                    IsCalculationDependOnLockDate = true;
                }
                UIValidationExceptions exception  = new UIValidationExceptions();
                ISearchPerson          searchTool = new BPerson();
                IList <Person>         personList = searchTool.QuickSearch(searchKey, PersonCategory.Public)
                                                    .Where(x => x.Active).ToList();
                IList <decimal> PersonIdCalculateList = new List <decimal>();
                var             ids = from o in personList
                                      select o.ID;
                DateTime from, to;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    from = Utility.ToMildiDate(fromDate);
                    to   = Utility.ToMildiDate(toDate);
                }
                else
                {
                    from = Utility.ToMildiDateTime(fromDate);
                    to   = Utility.ToMildiDateTime(toDate);
                }
                if (to != Utility.GTSMinStandardDateTime && from > to)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.CalculationStartDateIsGreaterThanCalculationEndDate, "تاریخ ابتدا از تاریخ انتها بزرگتر است", ExceptionSrc));
                }
                if (exception.Count > 0)
                {
                    throw exception;
                }
                if (forceCalculate)
                {
                    BusinessEntity entity = new BusinessEntity();


                    Dictionary <decimal, decimal>  UiValidationGroupIdPersonList = uivalidationGroupingRepository.GetUivalidationPersonIdList(ids.ToList <decimal>());
                    Dictionary <decimal, DateTime> uivalidationGroupIdDic        = new Dictionary <decimal, DateTime>();
                    foreach (KeyValuePair <decimal, decimal> uiValidateionGrpId in UiValidationGroupIdPersonList)
                    {
                        if (!uivalidationGroupIdDic.ContainsKey(uiValidateionGrpId.Value))
                        {
                            DateTime calculationLockDate = entity.UIValidator.GetCalculationLockDateByGroup(uiValidateionGrpId.Value);
                            uivalidationGroupIdDic.Add(uiValidateionGrpId.Value, calculationLockDate);
                        }
                    }
                    int personFailedToCalculateCount = 0;
                    if (IsCalculationDependOnLockDate)
                    {
                        foreach (decimal item in ids)
                        {
                            UIValidationExceptions exceptionLockDate = new UIValidationExceptions();
                            if (UiValidationGroupIdPersonList.Keys.Contains(item))
                            {
                                decimal  groupId = UiValidationGroupIdPersonList.FirstOrDefault(u => u.Key == item).Value;
                                DateTime calculationPersonLockDate = uivalidationGroupIdDic.FirstOrDefault(u => u.Key == groupId).Value;
                                if (calculationPersonLockDate >= from)
                                {
                                    personFailedToCalculateCount++;

                                    exceptionLockDate.Add(new ValidationException(ExceptionResourceKeys.UIValidation_R3_LockCalculationFromDate, String.Format("خطا در انجام محاسبات - محاسبات برای پرسنل ({0}) بسته شده است", personList.FirstOrDefault(p => p.ID == item).BarCode + "-" + personList.FirstOrDefault(p => p.ID == item).Name), ExceptionSrc));
                                    BaseBusiness <Entity> .LogException(exceptionLockDate, "BEngineCalculator", "Calculate");
                                }
                                else
                                {
                                    PersonIdCalculateList.Add(item);
                                }
                            }
                            else
                            {
                                exceptionLockDate.Add(new ValidationException(ExceptionResourceKeys.UIValidation_R3_LockCalculationFromDate, String.Format("خطا در انجام محاسبات - تاریخ بستن محاسبات برای پرسنل {0} یافت نشد", personList.FirstOrDefault(p => p.ID == item).BarCode + "-" + personList.FirstOrDefault(p => p.ID == item).Name), ExceptionSrc));
                                BaseBusiness <Entity> .LogException(exceptionLockDate, "BEngineCalculator", "Calculate");
                            }
                        }
                    }
                    else
                    {
                        PersonIdCalculateList = ids.ToList();
                    }
                    IList <CFP> cfpPersonList = new List <CFP>();
                    if (PersonIdCalculateList.Count > 0)
                    {
                        cfpPersonList = entity.GetCFPPersons(PersonIdCalculateList.Select(a => a).ToList <decimal>());
                    }
                    IList <decimal> cfpPersonIdInsertList = new List <decimal>();
                    entity.UpdateCfpByPersonList(PersonIdCalculateList, from);
                    cfpPersonIdInsertList = PersonIdCalculateList.Where(p => cfpPersonList != null && !cfpPersonList.Select(c => c.PrsId).ToList().Contains(p)).Select(p => p).Distinct().ToList <decimal>();
                    if (cfpPersonIdInsertList.Count > 0)
                    {
                        entity.InsertCfpByPersonList(cfpPersonIdInsertList, from);
                    }
                    SessionHelper.SaveSessionValue(SessionHelper.PersonIsFailedForCalculate, personFailedToCalculateCount);
                }
                else
                {
                    PersonIdCalculateList = ids.ToList();
                }

                BTemp  bTemp         = new BTemp();
                string operationGUID = bTemp.InsertTempList(PersonIdCalculateList);
                gtsEngineWS.GTS_ExecutePersonsByToDateGUID(BUser.CurrentUser.UserName, operationGUID, to);
                bTemp.DeleteTempList(operationGUID);
                BaseBusiness <Entity> .LogUserAction(String.Format("CalculateAll -> searchKey: {0} And Count: {1} -->Calculate(searchKey, toDate)", searchKey, PersonIdCalculateList.Count));

                return(true);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BEngineCalculator", "Calculate(searchKey, toDate)");

                throw ex;
            }
        }
예제 #6
0
        private void DeleteSuspendRequestStatesByFlowCondition(decimal flowID, IList <ManagerFlowConditionPrecardProxy> managerFlowConditionPreacardProxyList)
        {
            try
            {
                Request                   requestAlias       = null;
                RequestStatus             requestStatusAlias = null;
                ManagerFlow               managerFlowAlias   = null;
                Flow                      flowAlias          = null;
                GTS.Clock.Model.Temp.Temp precardAccessGroupDetailTempAlias     = null;
                PrecardAccessGroup        precardAccessGroupAlias               = null;
                PrecardAccessGroupDetail  precardAccessGroupDetailAlias         = null;
                string                    precardAccessGroupDetailOperationGUID = string.Empty;
                string                    requestStatusOperationGUID            = string.Empty;
                List <decimal>            requestStatusIdsList = new List <decimal>();
                BTemp                     tempBusiness         = new BTemp();

                precardAccessGroupDetailOperationGUID = tempBusiness.InsertTempList(managerFlowConditionPreacardProxyList.Select(x => x.ManagerFlowCondition.PrecardAccessGroupDetail.ID).ToList <decimal>());

                var EndFlowAndDeletedRequestStatusSubQuery = QueryOver.Of <RequestStatus>(() => requestStatusAlias)
                                                             .Where(() => requestStatusAlias.EndFlow || !requestStatusAlias.IsDeleted)
                                                             .And(() => requestStatusAlias.Request.ID == requestAlias.ID)
                                                             .Select(x => x.ID);

                IList <Request> requestsList = this.NHSession.QueryOver <Request>(() => requestAlias)
                                               .JoinAlias(() => requestAlias.RequestStatusList, () => requestStatusAlias)
                                               .JoinAlias(() => requestStatusAlias.ManagerFlow, () => managerFlowAlias)
                                               .JoinAlias(() => managerFlowAlias.Flow, () => flowAlias)
                                               .JoinAlias(() => flowAlias.AccessGroup, () => precardAccessGroupAlias)
                                               .JoinAlias(() => precardAccessGroupAlias.PrecardAccessGroupDetailList, () => precardAccessGroupDetailAlias)
                                               .JoinAlias(() => precardAccessGroupDetailAlias.TempList, () => precardAccessGroupDetailTempAlias)
                                               .Where(() => !flowAlias.IsDeleted &&
                                                      !requestAlias.EndFlow &&
                                                      flowAlias.ID == flowID &&
                                                      precardAccessGroupDetailTempAlias.OperationGUID == precardAccessGroupDetailOperationGUID
                                                      )
                                               .WithSubquery
                                               .WhereNotExists(EndFlowAndDeletedRequestStatusSubQuery)
                                               .List <Request>();

                tempBusiness.DeleteTempList(precardAccessGroupDetailOperationGUID);

                foreach (Request requestItem in requestsList)
                {
                    ManagerFlowConditionPrecardProxy managerFlowConditionPrecardProxy = managerFlowConditionPreacardProxyList.Where(x => x.PrecardID == requestItem.ID).FirstOrDefault();
                    if (this.CheckRequestValueAppliedFlowConditionValue(managerFlowConditionPrecardProxy.ManagerFlowCondition, requestItem))
                    {
                        requestStatusIdsList.AddRange(requestItem.RequestStatusList.Select(x => x.ID).ToList <decimal>());
                    }
                }

                if (requestStatusIdsList.Count > 0)
                {
                    requestStatusOperationGUID = tempBusiness.InsertTempList(requestStatusIdsList);

                    string SQLCommand = @"delete from TA_RequestStatus 
                                                 inner join TA_Temp
                                                 on reqStat_ID = temp_OperationGUID
                                                 where temp_OperationGUID = :operationGUID";
                    NHSession.CreateSQLQuery(SQLCommand)
                    .SetParameter("operationGUID", requestStatusOperationGUID)
                    .ExecuteUpdate();

                    tempBusiness.DeleteTempList(requestStatusOperationGUID);
                }
            }
            catch (Exception ex)
            {
                LogException(ex, "BManagerFlowCondition", "DeleteSuspendRequestStatesByFlowCondition");
                throw;
            }
        }