/// <summary> /// بروزرسانی نشانه محاسبات /// </summary> /// <param name="personId"></param> /// <param name="cfpDate"></param> protected void UpdateCFP(decimal personId, DateTime cfpDate) { using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { string className = Utility.CallerCalassName; LogUserAction(String.Format("CFP {0} Prs:{1} cls:{2} ", Utility.ToPersianDate(cfpDate), personId, className)); CFP cfp = cfpRepository.GetByPersonID(personId); if (cfp != null && cfp.ID > 0) { if (cfp.Date.Date >= cfpDate.Date) { cfp.Date = cfpDate.Date; cfp.CalculationIsValid = false; cfpRepository.WithoutTransactUpdate(cfp); } } else { cfpRepository.InsertCFP(personId, cfpDate.Date); } PermitRepository permitRep = new PermitRepository(); permitRep.InvalidateTrafficCalculation(personId, cfpDate); NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); throw ex; } } }
/// <summary> /// بروزرسانی نشانه محاسبات /// </summary> /// <param name="personId"></param> /// <param name="newCfpDate"></param> protected void UpdateCFP(decimal personId, DateTime newCfpDate, bool isForce = false) { using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { IList <decimal> prsIds = new List <decimal>(); prsIds.Add(personId); IList <decimal> UiValidationGroupIdList = uivalidationGroupingRepository.GetUivalidationIdList(prsIds); DateTime calculationLockDate = Utility.GTSMinStandardDateTime; if (UiValidationGroupIdList.Count > 0) { calculationLockDate = base.UIValidator.GetCalculationLockDateByGroup(UiValidationGroupIdList.FirstOrDefault()); } string className = Utility.CallerCalassName; CFP cfp = cfpRepository.GetByPersonID(personId); DateTime finalCfpDate = Utility.GTSMinStandardDateTime; if (cfp != null && cfp.ID > 0) { if (UiValidationGroupIdList.Count > 0) { if (cfp.Date <= newCfpDate || cfp.Date < calculationLockDate) { finalCfpDate = cfp.Date; } else if (calculationLockDate <= cfp.Date && calculationLockDate >= newCfpDate) { if (!isForce) { finalCfpDate = calculationLockDate.AddDays(1); } else { finalCfpDate = newCfpDate; } } else if (newCfpDate > calculationLockDate && newCfpDate < cfp.Date) { finalCfpDate = newCfpDate; } } else { finalCfpDate = newCfpDate; } //if (UiValidationGroupIdList.Count > 0) //{ // if(calculationLockDate >= newCfpDate || calculationLockDate >= cfp.Date) // { // finalCfpDate = calculationLockDate.AddDays(1); // } // else if (cfp.Date > calculationLockDate && cfp.Date <= newCfpDate) // { // finalCfpDate = cfp.Date; // } // else if (newCfpDate > calculationLockDate && newCfpDate <= cfp.Date) // { // finalCfpDate = newCfpDate; // } //} //else //{ // finalCfpDate = newCfpDate; //} LogUserAction(String.Format("CFP {0} Prs:{1} cls:{2} ", Utility.ToPersianDate(finalCfpDate), personId, className)); cfp.Date = finalCfpDate.Date; cfp.CalculationIsValid = false; cfpRepository.WithoutTransactUpdate(cfp); } else { cfpRepository.InsertCFP(personId, finalCfpDate); } //LogUserAction(String.Format("Before InvalidateTrafficCalculation CFP {0} Prs:{1} cls:{2} ", Utility.ToPersianDate(cfpDate), personId, className)); //PermitRepository permitRep = new PermitRepository(); //permitRep.InvalidateTrafficCalculation(personId, cfpDate); NHibernateSessionManager.Instance.CommitTransactionOn(); //LogUserAction(String.Format("After InvalidateTrafficCalculation CFP {0} Prs:{1} cls:{2} ", Utility.ToPersianDate(cfpDate), personId, className)); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); LogException(ex); throw ex; } } }