protected void UpdateCFPByCalendar(decimal calendarTypeId, int year, IList <DateTime> oldCalDateList, IList <CalendarCellInfo> calendars) { DateTime firstDate = this.GetFirstDateDiffrence(year, oldCalDateList, calendars, calendarTypeId).Date; PersonRepository prsRep = new PersonRepository(false); IList <decimal> prsIds = prsRep.GetAllActivePersonIds(); if (InTestCasePersonContext != null && InTestCasePersonContext.Count > 0) { prsIds = InTestCasePersonContext; } //IList<CFP> cfpPersonList = base.GetCFPPersons(prsIds); IList <decimal> UiValidationGroupIdList = uivalidationGroupingRepository.GetUivalidationIdList(prsIds); Dictionary <decimal, DateTime> uivalidationGroupIdDic = new Dictionary <decimal, DateTime>(); foreach (decimal uiValidateionGrpId in UiValidationGroupIdList) { if (!uivalidationGroupIdDic.ContainsKey(uiValidateionGrpId)) { DateTime calculationLockDate = base.UIValidator.GetCalculationLockDateByGroup(uiValidateionGrpId); uivalidationGroupIdDic.Add(uiValidateionGrpId, calculationLockDate); } } CFPRepository cfpRepository = new CFPRepository(); cfpRepository.InsertAndUpdateCfpByPersons(uivalidationGroupIdDic, firstDate); }
protected override void UpdateCFP(RuleCategory obj, UIActionType action) { if (action == UIActionType.EDIT) { IList <CFP> cfpList = new List <CFP>(); Dictionary <decimal, DateTime> lockDates = new Dictionary <decimal, DateTime>(); IList <CFP> personCfpList = new CFPRepository().GetCFPListByRuleCategory(obj.ID); foreach (PersonRuleCatAssignment assgn in obj.PersonRuleCatAssignList) { DateTime calculationLockDate = DateTime.Now; decimal personId = assgn.Person.ID; if (assgn.Person.PersonTASpec.UIValidationGroup != null) { decimal uiValidateionGrpId = assgn.Person.PersonTASpec.UIValidationGroup.ID; if (!lockDates.ContainsKey(uiValidateionGrpId)) { calculationLockDate = base.UIValidator.GetCalculationLockDateByGroup(assgn.Person.PersonTASpec.UIValidationGroup.ID); lockDates.Add(uiValidateionGrpId, calculationLockDate); } else { calculationLockDate = lockDates[uiValidateionGrpId]; } } //CFP cfp = base.GetCFP(personId); CFP cfp = personCfpList.Where(x => x.PrsId == personId).FirstOrDefault(); DateTime newCfpDate = Utility.ToMildiDateTime(assgn.FromDate); // DateTime calculationLockDate = base.UIValidator.GetCalculationLockDate(personId); //بسته بودن محاسبات if (calculationLockDate > Utility.GTSMinStandardDateTime && calculationLockDate > newCfpDate) { newCfpDate = calculationLockDate.AddDays(1); } if (cfp == null || cfp.ID == 0 || cfp.Date > newCfpDate) { cfp.Date = newCfpDate.Date; cfp.PrsId = personId; cfpList.Add(cfp); } //base.UpdateCFP(personId, newCfpDate); } base.UpdateCFP(cfpList, false); } }