/// <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="cfpDate"></param> protected void UpdateCFP(IList <CFP> cfpList, bool invalidateTraffic) { LogUserAction(String.Format("CFP Update Count:{0} Started", cfpList.Count)); using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { foreach (CFP cfp in cfpList) { if (cfp != null && cfp.ID > 0) { cfp.CalculationIsValid = false; cfpRepository.WithoutTransactUpdate(cfp); } else { cfpRepository.InsertCFP(cfp.PrsId, cfp.Date); } if (invalidateTraffic) { PermitRepository permitRep = new PermitRepository(); permitRep.InvalidateTrafficCalculation(cfp.PrsId, cfp.Date); } } NHibernateSessionManager.Instance.CommitTransactionOn(); LogUserAction(String.Format("CFP Update Count:{0} Finished", cfpList.Count)); } catch (Exception ex) { LogException(ex); NHibernateSessionManager.Instance.RollbackTransactionOn(); throw ex; } } }