Esempio n. 1
0
 public void InsertCalendars(decimal calendarTypeID, int year, IList <CalendarCellInfo> calendars)
 {
     using (NHibernateSessionManager.Instance.BeginTransactionOn())
     {
         try
         {
             this.CheckUserInterfaceRuleGroup();
             DateTime yearStart, yearEnd;
             if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
             {
                 string date = String.Format("{0}/01/01", year);
                 yearStart = Utility.ToMildiDate(date);
                 date      = String.Format("{0}/12/{1}", year, Utility.GetEndOfPersianMonth(year, 12));
                 yearEnd   = Utility.ToMildiDate(date);
             }
             else
             {
                 yearStart = new DateTime(year, 1, 1);
                 yearEnd   = new DateTime(year, 12, Utility.GetEndOfMiladiMonth(year, 12));
             }
             IList <DateTime> oldCalDateList = calendarRepository.GetAllCalendarDateByTypeId(calendarTypeID);
             calendarRepository.DeleteCalendarsByType(calendarTypeID, yearStart, yearEnd);
             foreach (CalendarCellInfo cell in calendars)
             {
                 Calendar cal = cell.Export(year);
                 cal.CalendarType = new CalendarType()
                 {
                     ID = calendarTypeID
                 };
                 calendarRepository.Save(cal);
             }
             NHibernateSessionManager.Instance.CommitTransactionOn();
             this.UpdateCFPByCalendar(calendarTypeID, year, oldCalDateList, calendars);
         }
         catch (Exception ex)
         {
             NHibernateSessionManager.Instance.RollbackTransactionOn();
             LogException(ex, "BCalendarType", "InsertCalendars");
             throw ex;
         }
     }
 }