/// <summary> /// /// </summary> /// <returns></returns> public IList <Shift> GetShiftList() { try { BShift busShift = new BShift(); return(busShift.GetAll()); } catch (Exception ex) { LogException(ex, "BExceptionShift", "GetShiftList"); throw ex; } }
/// <summary> /// همه شیفتها را برمیگرداند /// </summary> /// <returns></returns> public IList <Shift> GetAllShifts() { try { BShift bshift = new BShift(); IList <Shift> shifts = bshift.GetAll(); return(shifts); } catch (Exception ex) { LogException(ex, "BWorkGroupCalendar", "GetAllShifts"); throw ex; } }
/// <summary> /// تکرار دوره /// </summary> /// <param name="year"></param> /// <param name="startMonth"></param> /// <param name="startDay"></param> /// <param name="endMonth"></param> /// <param name="endDay"></param> /// <param name="holidayTypes"></param> /// <param name="cellInfoList"></param> public IList <CalendarCellInfo> RepetitionPeriod(int year, int startMonth, int startDay, int endMonth, int endDay, IList <decimal> holidayTypes, IList <CalendarCellInfo> cellInfoList) { try { DateTime startDate, endDate, endOfYear; if (sysLangruage == SysLanguageResource.Parsi) { startDate = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, startMonth, startDay)); endDate = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, endMonth, endDay)); endOfYear = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, 12, Utility.GetEndOfPersianMonth(year, 12))); } else { startDate = new DateTime(year, startMonth, startDay); endDate = new DateTime(year, endMonth, endDay); endOfYear = new DateTime(year, 12, DateTime.DaysInMonth(year, 12)); } if (startDate > endDate) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(ExceptionResourceKeys.WorkGroupCalendarPriodDateIsNotValid, "تاریخ ابتدا از انتها بزرگتر است", ExceptionSrc); throw exception; } IList <CalendarCellInfo> list = new List <CalendarCellInfo>(); IList <CalendarCellInfo> cells = new List <CalendarCellInfo>(); IList <CalendarCellInfo> result = new List <CalendarCellInfo>(); IList <Shift> shiftList = new BShift().GetAll(); //looking for item in parameter list by date for (DateTime date = startDate; date <= endDate; date = date.AddDays(1)) { int day = 0, month = 0; if (sysLangruage == SysLanguageResource.Parsi) { day = new PersianDateTime(date).Day; month = new PersianDateTime(date).Month; } else { day = date.Day; month = date.Month; } CalendarCellInfo info = cellInfoList.Where(x => x.Day == day && x.Month == month).FirstOrDefault(); if (info != null) { list.Add(info); } else { list.Add(null); } } if (list.Count == 0 || list.Where(x => x != null).Count() == 0) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(ExceptionResourceKeys.WorkGroupCalendarPriodIsEmpty, "در بازه زمانی مشخص شده شیفتی انتساب دهده نشده است", ExceptionSrc); throw exception; } for (DateTime index = startDate; index <= endOfYear; index = index.AddDays(list.Count)) { for (int i = 0; i < list.Count && index.AddDays(i) <= endOfYear; i++) { if (list[i] != null) { CalendarCellInfo info = new CalendarCellInfo(); info.ShiftID = list[i].ShiftID; Shift shift = shiftList.Where(x => x.ID == list[i].ShiftID).FirstOrDefault(); info.Color = shift != null ? shift.Color : ""; info.Title = list[i].Title; if (sysLangruage == SysLanguageResource.Parsi) { info.Day = new PersianDateTime(index.AddDays(i)).Day; info.Month = new PersianDateTime(index.AddDays(i)).Month; } else { info.Day = index.AddDays(i).Day; info.Month = index.AddDays(i).Month; } cells.Add(info); } } } //apply holidays List <CalendarCellInfo> holidays = new List <CalendarCellInfo>(); if (holidayTypes != null) { foreach (decimal id in holidayTypes) { holidays.AddRange(new BCalendarType().GetCalendarList(year, id)); } } foreach (CalendarCellInfo cell in cells) { if (holidays.Where(x => x.Day == cell.Day && x.Month == cell.Month).Count() == 0) { result.Add(cell); } } return(result); } catch (Exception ex) { LogException(ex, "BWorkGroupCalendar", "RepetitionPeriod"); throw ex; } }