protected int GetDailyPrintNumber(Date date) { PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); int no = dateNumberReference.number; Date date2 = dateNumberReference.date; while (date > date2) { date2 = date2.AddDays(1); if (!_noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(_noPrintDays, date2)) { do { no++; } while (_noPrintNumbers.ContainsKey(no)); } } while (date < date2) { if (!_noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(_noPrintDays, date2)) { do { no--; } while (_noPrintNumbers.ContainsKey(no)); } date2 = date2.AddDays(-1); } return(no); }
//protected int GetWeeklyPrintNumber(Date date) //{ // PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); // return dateNumberReference.number + (zdate.GetNearestWeekday(date, (DayOfWeek)_weekday).Subtract(dateNumberReference.date).Days / 7); //} //protected int GetEveryTwoWeekPrintNumber(Date date) //{ // PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); // return dateNumberReference.number + (zdate.GetNearestWeekday(date, (DayOfWeek)_weekday).Subtract(dateNumberReference.date).Days / 14); //} protected int GetMonthlyPrintNumber(Date date) { PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); int no = dateNumberReference.number; Date date2 = dateNumberReference.date; while (date > date2) { date2 = date2.AddMonths(1); Month month = zdate.GetMonth(date2.Month); if ((_noPrintMonths & month) != month && !_noPrintDates.ContainsKey(date2.AbsoluteDay)) { do { no++; } while (_noPrintNumbers.ContainsKey(no)); } } while (date < date2) { Month month = zdate.GetMonth(date2.Month); if ((_noPrintMonths & month) != month && !_noPrintDates.ContainsKey(date2.AbsoluteDay)) { do { no--; } while (_noPrintNumbers.ContainsKey(no)); } date2 = date2.AddMonths(-1); } return(no); }
//protected Date GetEveryTwoWeekPrintDate(int printNumber) //{ // PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(printNumber); // return dateNumberReference.date.AddDays((printNumber - dateNumberReference.number) * 14); //} protected Date GetMonthlyPrintDate(int printNumber) { //int no = refNumber; //Date date = refDate; PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(printNumber); int no = dateNumberReference.number; Date date = dateNumberReference.date; while (printNumber > no) { date = date.AddMonths(1); Month month = zdate.GetMonth(date.Month); if ((_noPrintMonths & month) != month && !_noPrintDates.ContainsKey(date.AbsoluteDay)) { do { no++; } while (_noPrintNumbers.ContainsKey(no)); } } while (printNumber < no) { date = date.AddMonths(-1); Month month = zdate.GetMonth(date.Month); if ((_noPrintMonths & month) != month && !_noPrintDates.ContainsKey(date.AbsoluteDay)) { do { no--; } while (_noPrintNumbers.ContainsKey(no)); } } return(date); }
//protected Date GetWeeklyPrintDate(int printNumber) protected Date GetPeriodPrintDate(int printNumber, int nbDaysInPeriod) { PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(printNumber); //return dateNumberReference.date.AddDays((printNumber - dateNumberReference.number) * 7); return(dateNumberReference.date.AddDays((printNumber - dateNumberReference.number) * nbDaysInPeriod)); }
public PrintDateNumberReferences(IEnumerable<XElement> xelements) { _refByDate = new SortedList<Date, PrintDateNumberReference>(); _refByNumber = new SortedList<int, PrintDateNumberReference>(); foreach (XElement xelement in xelements) { string dateRef = xelement.zAttribValue("date"); string numberRef = xelement.zAttribValue("number"); if (dateRef == null || numberRef == null) throw new PBException("error missing date or number in DateNumberReference"); PrintDateNumberReference dateNumberReference = new PrintDateNumberReference { date = Date.Parse(dateRef), number = int.Parse(numberRef) }; _refByDate.Add(dateNumberReference.date, dateNumberReference); _refByNumber.Add(dateNumberReference.number, dateNumberReference); } }
public override int GetPrintNumber(Date date, bool throwException = true) { //int refPrintNumber = _refPrintNumber; //Date refPrintDate = _refPrintDate; PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); int refPrintNumber = dateNumberReference.number; Date refPrintDate = dateNumberReference.date; if (_lastDate != null) { refPrintNumber = _lastPrintNumber; refPrintDate = (Date)_lastDate; } int printNumber = zprint.GetDailyPrintNumber(date, refPrintNumber, refPrintDate, new PrintExistsDelegate(PrintExists)); _lastDate = date; _lastPrintNumber = printNumber; return(printNumber); }
protected int GetMultiMonthlyPrintNumber(Date date, int monthFreq) { //int no = refNumber; //Date date2 = refDate; PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); int no = dateNumberReference.number; Date date2 = dateNumberReference.date; while (date > date2) { Month month; for (int i = 0; i < monthFreq; i++) { do { date2 = date2.AddMonths(1); month = zdate.GetMonth(date2.Month); } while ((_noPrintMonths & month) == month || _noPrintDates.ContainsKey(date2.AbsoluteDay)); } do { no++; } while (_noPrintNumbers.ContainsKey(no)); } while (date < date2) { for (int i = 0; i < monthFreq; i++) { Month month = zdate.GetMonth(date2.Month); while ((_noPrintMonths & month) == month || _noPrintDates.ContainsKey(date2.AbsoluteDay)) { date2 = date2.AddMonths(-1); month = zdate.GetMonth(date2.Month); } date2 = date2.AddMonths(-1); } do { no--; } while (_noPrintNumbers.ContainsKey(no)); } return(no); }
public PrintDateNumberReferences(IEnumerable <XElement> xelements) { _refByDate = new SortedList <Date, PrintDateNumberReference>(); _refByNumber = new SortedList <int, PrintDateNumberReference>(); foreach (XElement xelement in xelements) { string dateRef = xelement.zAttribValue("date"); string numberRef = xelement.zAttribValue("number"); if (dateRef == null || numberRef == null) { throw new PBException("error missing date or number in DateNumberReference"); } PrintDateNumberReference dateNumberReference = new PrintDateNumberReference { date = Date.Parse(dateRef), number = int.Parse(numberRef) }; _refByDate.Add(dateNumberReference.date, dateNumberReference); _refByNumber.Add(dateNumberReference.number, dateNumberReference); } }
protected int GetPeriodPrintNumber(Date date, int nbDaysInPeriod) { PrintDateNumberReference dateNumberReference = _dateNumberReferences.GetReference(date); return(dateNumberReference.number + (zdate.GetNearestWeekday(date, (DayOfWeek)_weekday).Subtract(dateNumberReference.date).Days / nbDaysInPeriod)); }