public void handleRolling(object RollinIn) { crit = new VersionInfoSearchCriteria(); bool change = false; RollingInfo roi = (RollingInfo)RollinIn; DateTime date = DateTime.Now; CaledTypes.Clear(); int ohour; int oday; int omonth; int oyear; if (roi.RolType == RollonTypes.today || roi.RolType == RollonTypes.Yesterday) { if (roi.RolType == RollonTypes.Yesterday) { date = date.Subtract(TimeSpan.FromDays(1)); } if (crit.DaysOfMonth.Contains(date.Day) == false || crit.DaysOfMonthR.Contains(date.Day) == true) { if (CaledTypes.Contains(catTypes.DayOM) == false) { CaledTypes.Add(catTypes.DayOM); Exclude(crit, catTypes.DayOM); } crit.RemoveDaysOfMonth(date.Day); crit.AddDaysOfMonth(date.Day, false); change = true; } if (crit.Months.Contains(date.Month) == false || crit.MonthsR.Contains(date.Month) == true) { if (CaledTypes.Contains(catTypes.Month) == false) { CaledTypes.Add(catTypes.Month); Exclude(crit, catTypes.Month); } crit.RemoveMonth(date.Month); crit.AddMonth(date.Month, false); change = true; } if (crit.Years.Contains(date.Year) == false || crit.YearsR.Contains(date.Year) == true) { if (CaledTypes.Contains(catTypes.Year) == false) { CaledTypes.Add(catTypes.Year); Exclude(crit, catTypes.Year); } crit.RemoveYears(date.Year); crit.AddYears(date.Year, false); change = true; } if (change == true) { } } else { TimeSpan span = new TimeSpan(); int m = 0; int y = 0; int mnt; int yer; int lastamount = roi.lastAmount; catTypes rcatTyp = roi.lastType; switch (roi.lastType) { case catTypes.Minute: span = new TimeSpan(0, 1, 0); break; case catTypes.Hour: span = new TimeSpan(1, 0, 0); break; case catTypes.Day: span = new TimeSpan(1, 0, 0, 0); break; case catTypes.Week: lastamount *= 7; rcatTyp = catTypes.Day; span = new TimeSpan(1, 0, 0, 0); break; case catTypes.Month: m = 1; break; case catTypes.Year: y = 1; break; } date = DateTime.Now; mnt = date.Month; yer = date.Year; for (int i = 0; i <= lastamount; i++) { if (rcatTyp == catTypes.Minute) { if (crit.Minutes.Contains(date.Minute) == false || crit.MinutesR.Contains(date.Minute) == true) { if (CaledTypes.Contains(catTypes.Minute) == false) { CaledTypes.Add(catTypes.Minute); Exclude(crit, catTypes.Minute); } crit.RemoveMinutes(date.Minute); crit.AddMinutes(date.Minute, false); change = true; } } if (rcatTyp == catTypes.Minute || rcatTyp == catTypes.Hour) { if (crit.Hours.Contains(date.Hour) == false || crit.HoursR.Contains(date.Hour) == true) { if (CaledTypes.Contains(catTypes.Hour) == false) { CaledTypes.Add(catTypes.Hour); Exclude(crit, catTypes.Hour); } crit.RemoveHours(date.Hour); crit.AddHours(date.Hour, false); change = true; } } if (rcatTyp == catTypes.Minute || rcatTyp == catTypes.Hour || rcatTyp == catTypes.Day) { if (CaledTypes.Contains(catTypes.DayOM) == false) { CaledTypes.Add(catTypes.DayOM); Exclude(crit, catTypes.DayOM); } if (crit.DaysOfMonth.Contains(date.Day) == false || crit.DaysOfMonthR.Contains(date.Day) == true) { crit.RemoveDaysOfMonth(date.Day); crit.AddDaysOfMonth(date.Day, false); change = true; } } if (rcatTyp != catTypes.Year) { yer = date.Year; } if (crit.Years.Contains(yer) == false || crit.YearsR.Contains(yer) == true) { if (CaledTypes.Contains(catTypes.Year) == false) { CaledTypes.Add(catTypes.Year); Exclude(crit, catTypes.Year); } crit.RemoveYears(yer); crit.AddYears(yer, false); change = true; } if (rcatTyp == catTypes.Year) { yer--; } if (rcatTyp == catTypes.Minute || rcatTyp == catTypes.Hour || rcatTyp == catTypes.Day || rcatTyp == catTypes.Month) { if (rcatTyp != catTypes.Month) { mnt = date.Month; } if (crit.Months.Contains(mnt) == false || crit.MonthsR.Contains(mnt) == true) { if (CaledTypes.Contains(catTypes.Month) == false) { CaledTypes.Add(catTypes.Month); Exclude(crit, catTypes.Month); } crit.RemoveMonth(mnt); crit.AddMonth(mnt, false); change = true; } if (rcatTyp == catTypes.Month) { mnt--; if (mnt == 0) { mnt = 12; yer--; } } } ohour = date.Hour; oday = date.Day; omonth = date.Month; oyear = date.Year; UnExcludeOver(date); date = date.Subtract(span); if (date.Day != oday && rcatTyp != catTypes.Day) { ExcludeOver(catTypes.Day, 0, date.Day, date.Month, date.Year, -1); } if (date.Hour != ohour ) { ExcludeOver(catTypes.Hour, date.Hour, date.Day, date.Month, date.Year, date.Minute); } if (date.Month != omonth && rcatTyp != catTypes.Month) { ExcludeOver(catTypes.Month, 0, 0, date.Month, date.Year, -1); } if (date.Year != oyear && rcatTyp != catTypes.Year) { ExcludeOver(catTypes.Year, 0, 0, 0, date.Year, -1); } }//for (int i = 0; i < lastamount; i++) } CritSet.SetCriteria(crit); }
public VersionInfoSearchCriteria ProcessString(string text) { if (timer != null) { timer.Change(Timeout.Infinite, Timeout.Infinite); timer = null; } crit = new VersionInfoSearchCriteria(); bool changed = false; string fixe = addIndicaToText(text); string[] tokens = fixe.Split(' '); int number; DayOfWeek dayOfweek; int []hour; int minute; bool last; string te; string tok; RollingInfo rollIn; for(int i = 0 ; i < tokens.Length; i++) { tok = tokens[i]; if (isDayOfMonth(tok, out number)) { // if (CaledTypes.Contains(catTypes.DayOM) == false) // { // CaledTypes.Add(catTypes.DayOM); Exclude(crit, catTypes.DayOM); // } crit.RemoveDaysOfMonth(number); crit.AddDaysOfMonth(number,false); changed = true; continue; } if (isDayOfWeek(tok, out dayOfweek)) { // if (CaledTypes.Contains(catTypes.DayOW) == false) // { // CaledTypes.Add(catTypes.DayOW); Exclude(crit, catTypes.DayOW); // } crit.RemoveDayOfWeek(dayOfweek); crit.AddDayOfWeek(dayOfweek,false); changed = true; continue; } if (isMonth(tok, out number)) { // if (CaledTypes.Contains(catTypes.Month) == false) // { // CaledTypes.Add(catTypes.Month); Exclude(crit, catTypes.Month); // } crit.RemoveMonth(number); crit.AddMonth(number,false); changed = true; continue; } if (isTime(tok, out hour, out minute)) { if (tokens.Length > i + 1 && isTimeAMPM(tokens[i + 1])) { if (tokens[i + 1].Equals("am")) { foreach (int h in hour) { if (h < 12) { // if (CaledTypes.Contains(catTypes.Hour) == false) // { // CaledTypes.Add(catTypes.Hour); Exclude(crit, catTypes.Hour); // } crit.RemoveHours(h); crit.AddHours(h, false); changed = true; } } } else { foreach (int h in hour) { if (h >= 12) { // if (CaledTypes.Contains(catTypes.Hour) == false) // { // CaledTypes.Add(catTypes.Hour); Exclude(crit, catTypes.Hour); // } crit.RemoveHours(h); crit.AddHours(h, false); changed = true; } } } } else { foreach (int h in hour) { if (h > -1 && h < 24) { // if (CaledTypes.Contains(catTypes.Hour) == false) // { // CaledTypes.Add(catTypes.Hour); Exclude(crit, catTypes.Hour); // } crit.RemoveHours(h); crit.AddHours(h, false); changed = true; } } } if (minute > 0) { // if (CaledTypes.Contains(catTypes.Minute) == false) // { // CaledTypes.Add(catTypes.Minute); Exclude(crit, catTypes.Minute); // } crit.RemoveMinutes(minute); crit.AddMinutes(minute, false); changed = true; } continue; } if (isRolling(tok, out rollIn)) { int dueTime = 60 - DateTime.Now.Second; if (dueTime == 60) { dueTime = 0; } else { handleRolling(rollIn); } timer = new Timer(handleRolling, rollIn, dueTime * 1000, 60000); } } if (changed) { return crit; } else { return null; } }