/// <summary> /// 将传入的 DayOfWeek 行星期转为汉字星期描述 /// </summary> /// <param name="weekday">DayOfWeek 的星期枚举</param> /// <returns>汉字的星期描述</returns> public static string GetWeekdayName(this System.DayOfWeek weekday) { switch (weekday) { case DayOfWeek.Monday: return("星期一"); case DayOfWeek.Tuesday: return("星期二"); case DayOfWeek.Wednesday: return("星期三"); case DayOfWeek.Thursday: return("星期四"); case DayOfWeek.Friday: return("星期五"); case DayOfWeek.Saturday: return("星期六"); default: return("星期日"); } }
public static string ConvertDayOfWeekToZh(System.DayOfWeek dw) { string DayOfWeekZh = ""; switch (dw.ToString("D")) { case "0": DayOfWeekZh = "日"; break; case "1": DayOfWeekZh = "一"; break; case "2": DayOfWeekZh = "二"; break; case "3": DayOfWeekZh = "三"; break; case "4": DayOfWeekZh = "四"; break; case "5": DayOfWeekZh = "五"; break; case "6": DayOfWeekZh = "六"; break; } return DayOfWeekZh; }
public static DayOfWeek GetDayOfWeek(System.DayOfWeek dayOfWeek) { switch (dayOfWeek) { case System.DayOfWeek.Sunday: return(DayOfWeek.Sunday); case System.DayOfWeek.Monday: return(DayOfWeek.Monday); case System.DayOfWeek.Tuesday: return(DayOfWeek.Tuesday); case System.DayOfWeek.Wednesday: return(DayOfWeek.Wednesday); case System.DayOfWeek.Thursday: return(DayOfWeek.Thursday); case System.DayOfWeek.Friday: return(DayOfWeek.Friday); case System.DayOfWeek.Saturday: return(DayOfWeek.Saturday); } return(DayOfWeek.Sunday); }
static void Main() { DateTime day = DateTime.Now; System.DayOfWeek dayOfWeek = day.DayOfWeek; Console.WriteLine("Today is {0}", dayOfWeek); }
private static string GetWeekName(System.DayOfWeek dw) { switch (dw) { case DayOfWeek.Monday: return("星期一"); case DayOfWeek.Thursday: return("星期四"); case DayOfWeek.Friday: return("星期五"); case DayOfWeek.Saturday: return("星期六"); case DayOfWeek.Sunday: return("星期日"); case DayOfWeek.Tuesday: return("星期二"); case DayOfWeek.Wednesday: return("星期三"); default: return(""); } }
/// <summary> /// This method is used to calculate the date on which a floating day occurs (for example, the 4th /// Thursday in November). /// </summary> /// <param name="year">The year in which the day occurs.</param> /// <param name="month">The month in which the day occurs.</param> /// <param name="occur">The occurrence of the day of the week on which the day falls.</param> /// <param name="dowDay">The day of the week on which the day occurs.</param> /// <param name="offset">The number of days before or after the calculated date on which the day actually /// falls.</param> /// <returns>Returns a <see cref="DateTime" /> object that represents the date calculated from the /// settings.</returns> /// <remarks><para>Use a positive value for the <c>nOffset</c> parameter for a number of days after the /// calculated date or a negative number for a number of days before the calculated date.</para> /// /// <para>Normally, this value will be zero so that the calculated date is the actual date returned. /// However, in cases where a date is calculated in terms of the number of days before or after a given /// date, this can be set to the offset to adjust the calculated date.</para> /// /// <para>For example, to calculate the day after Thanksgiving, the value of this parameter would be set /// to 1 (one day after Thanksgiving, which is the 4th Thursday in November). You cannot use the 4th /// Friday to calculate the date because if the month starts on a Friday, the calculated date would be a /// week too early. As such, the <c>nOffset</c> parameter is used instead.</para></remarks> /// <example> /// <code language="cs"> /// // Returns 11/28/2002 (Thanksgiving) /// dtThanksgiving = DateUtils.CalculateFloatingDate(2002, 11, /// DayOccurrence.Fourth, DayOfWeek.Thursday, 0); /// /// // Returns 11/29/2002 (Day after Thanksgiving) /// dtDayAfterTG = DateUtils.CalculateFloatingDate(2002, 11, /// DayOccurrence.Fourth, DayOfWeek.Thursday, 1); /// /// // Returns 11/22/2002 (Fourth Friday isn't after the fourth /// // Thursday in 2002 hence the use of the nOffset parameter /// // in the call above). /// dtFourthFri = DateUtils.CalculateFloatingDate(2002, 11, /// DayOccurrence.Fourth, DayOfWeek.Friday, 0); /// </code> /// <code language="vbnet"> /// ' Returns 11/28/2002 (Thanksgiving) /// dtThanksgiving = DateUtils.CalculateFloatingDate(2002, 11, /// DayOccurrence.Fourth, DayOfWeek.Thursday, 0) /// /// ' Returns 11/29/2002 (Day after Thanksgiving) /// dtDayAfterTG = DateUtils.CalculateFloatingDate(2002, 11, /// DayOccurrence.Fourth, DayOfWeek.Thursday, 1) /// /// ' Returns 11/22/2002 (Fourth Friday isn't after the fourth /// ' Thursday in 2002 hence the use of the nOffset parameter /// ' in the call above). /// dtFourthFri = DateUtils.CalculateFloatingDate(2002, 11, /// DayOccurrence.Fourth, DayOfWeek.Friday, 0) /// </code> /// </example> /// <exception cref="ArgumentException">This is thrown if <c>None</c> is passed for the <c>DayOccurrence</c> /// parameter.</exception> public static DateTime CalculateFloatingDate(int year, int month, DayOccurrence occur, System.DayOfWeek dowDay, int offset) { DateTime dtDate; if (occur == DayOccurrence.None) { throw new ArgumentException(LR.GetString("ExDUOccurIsNone"), "occur"); } // Calculating a specific occurrence or the last one? if (occur != DayOccurrence.Last) { // Specific occurrence dtDate = new DateTime(year, month, 1); dtDate = dtDate.AddDays((((int)dowDay + 7 - (int)dtDate.DayOfWeek) % 7) + (((int)occur - 1) * 7)); } else { // Get the last occurrence of the month dtDate = new DateTime(year, month, DateTime.DaysInMonth(year, month)); dtDate = dtDate.AddDays(0 - (((int)dtDate.DayOfWeek + 7 - (int)dowDay) % 7)); } // Return the date plus any additional offset return(dtDate.AddDays(offset)); }
/// <summary> /// 曜日(int→DayoOfWeek) /// </summary> public static int DayOfWeek2Int(System.DayOfWeek weekday) { int wday = 0; if (weekday == System.DayOfWeek.Monday) { wday = tMonday; } else if (weekday == System.DayOfWeek.Tuesday) { wday = tTuesday; } else if (weekday == System.DayOfWeek.Wednesday) { wday = tWednesday; } else if (weekday == System.DayOfWeek.Thursday) { wday = tThursday; } else if (weekday == System.DayOfWeek.Friday) { wday = tFriday; } else if (weekday == System.DayOfWeek.Saturday) { wday = tSaturday; } else if (weekday == System.DayOfWeek.Sunday) { wday = tSunday; } return(wday); }
/// <summary> /// Computes a new date that is on a given day of the week, after a reference date. /// </summary> /// <param name="refDate">reference date</param> /// <param name="dayOfWeek">enum</param> /// <remarks>if the reference date's day of week matches dayOfWeek param, returns the following week's day of week</remark> /// <returns>a new date on the given day of week</returns> public static DateTime GetNextFutureDateOnDayOfWeek(DateTime refDate, System.DayOfWeek dayOfWeek) { // In this overload, the absence of an explicit matchingDOWReturnsRefDate param defaults to FALSE, // i.e., if the Day Of Week of the passed refDate matches the passed dayOfWeek param, then // the date returned excludes refDate and is the following DOW (next week's) return(GetNextFutureDateOnDayOfWeek(refDate, dayOfWeek, false)); }
private TimePoint(int Year, int Month, int Day, int Hour, int Minute, int Second, DayOfWeek Week, TimePointFrequency Frequency) { m_Frequency = Frequency; m_Range = DEFAULT_RANGE; switch (Frequency) { case TimePointFrequency.PerDay: m_BeginTime = new DateTime(4, 1, 1, Hour, Minute, Second); break; case TimePointFrequency.PerMonth: m_BeginTime = new DateTime(4, 1, Day, Hour, Minute, Second); break; case TimePointFrequency.PerYear: // 设成润年以容纳 2-29 m_BeginTime = new DateTime(4, Month, Day, Hour, Minute, Second); break; case TimePointFrequency.Once: m_BeginTime = new DateTime(Year, Month, Day, Hour, Minute, Second); break; case TimePointFrequency.PerWeek: m_BeginTime = new DateTime(1, 1, 1, Hour, Minute, Second); m_Week = Week; break; } }
public static void Main() { Console.WriteLine("enter a date and find out what day of the week it was one \n enter a month"); string stringMonth = Console.ReadLine(); Console.WriteLine("enter a day"); string stringDay = Console.ReadLine(); Console.WriteLine("enter a year"); string stringYear = Console.ReadLine(); int month = 0, day = 0, year = 0; try { month = int.Parse(stringMonth); day = int.Parse(stringDay); year = int.Parse(stringYear); } catch (Exception ex) { Console.WriteLine("Message = {0}", ex.Message); Console.WriteLine("Source = {0}", ex.Source); Console.WriteLine("StackTrace = {0}", ex.StackTrace); Console.WriteLine("TargetSite = {0}", ex.TargetSite); Console.WriteLine("nice try, wise guy!"); } DateTime dateTime = new DateTime(year, month, day); NewDateTime newDateTime = new NewDateTime(dateTime); System.DayOfWeek weekDay = newDateTime.FindDayOfWeek(); Console.WriteLine("the day of the week your selected day is : " + weekDay); }
public static int IntegerFromWeekday(System.DayOfWeek dow) { if (dow == System.DayOfWeek.Friday) { return(5); } if (dow == System.DayOfWeek.Monday) { return(1); } if (dow == System.DayOfWeek.Saturday) { return(6); } if (dow == System.DayOfWeek.Sunday) { return(0); } if (dow == System.DayOfWeek.Thursday) { return(4); } if (dow == System.DayOfWeek.Tuesday) { return(2); } return(3); }
/// <summary> /// 当天与该周星期日相差的天数 /// </summary> /// <param name="dw">指定天数</param> /// <!-- /// 创建人 : MaGuoFu /// 创建时间: 2009-03-03 /// --> public static int GetSundayNum(System.DayOfWeek dw) { int weeknow = Convert.ToInt32(dw); int sundayNum = 7 - weeknow; return(sundayNum); }
/// <summary> /// 当天与该周星期一相差的天数 /// </summary> /// <param name="dw">指定天数</param> /// <!-- /// 创建人 : MaGuoFu /// 创建时间: 2009-03-03 /// --> public static int GetModdaDNum(System.DayOfWeek dw) { int weeknow = Convert.ToInt32(dw); int moddayNum = (-1) * weeknow + 1; return(moddayNum); }
int DayOfWeekToNum(System.DayOfWeek dayOfWeek) { switch (dayOfWeek) { case System.DayOfWeek.Monday: return(1); case System.DayOfWeek.Tuesday: return(2); case System.DayOfWeek.Wednesday: return(3); case System.DayOfWeek.Thursday: return(4); case System.DayOfWeek.Friday: return(5); case System.DayOfWeek.Saturday: return(6); case System.DayOfWeek.Sunday: return(7); } return(0); }
/// <summary> /// Find the number corresponding to Day of Week /// 0..6 /// </summary> /// <param name="d"></param> /// <returns></returns> public int DayOffset(System.DayOfWeek d) { switch (d) { case DayOfWeek.Sunday: return(0); case DayOfWeek.Monday: return(1); case DayOfWeek.Tuesday: return(2); case DayOfWeek.Wednesday: return(3); case DayOfWeek.Thursday: return(4); case DayOfWeek.Friday: return(5); case DayOfWeek.Saturday: return(6); } return(-1); }
public IDataReader GetOrderCountByEtaWeek(Int32 companyid) { System.Globalization.CultureInfo _ci = System.Threading.Thread.CurrentThread.CurrentCulture; System.DayOfWeek _fd = _ci.DateTimeFormat.FirstDayOfWeek; DateTime _firstday = DateTime.Today.AddDays(-(DateTime.Today.DayOfWeek - _fd)); DateTime _lastday = _firstday.AddDays(4); //monday to friday + 4 Aggregate _agr1 = Aggregate.GroupBy(OrderTable.EtaColumn); Aggregate _agr2 = Aggregate.Count(OrderTable.OrderIDColumn, "SumOrderID"); Aggregate[] _agrs = { _agr1, _agr2 }; SubSonic.SqlQuery _qry = new SubSonic.SqlQuery(); if (companyid != -1) //restrict to specified company { _qry = new Select(_agrs).From(OrderTable.Schema). Where(OrderTable.CompanyIDColumn).IsEqualTo(companyid).And(OrderTable.EtaColumn).IsBetweenAnd(_firstday, _lastday); } else { _qry = new Select(_agrs).From(OrderTable.Schema). Where(OrderTable.EtaColumn).IsBetweenAnd(_firstday, _lastday); } IDataReader _rd = _qry.ExecuteReader(); return(_rd); }
private int DaysToAdd(System.DayOfWeek current, System.DayOfWeek desired) { int c = (int)current; int d = (int)desired; int n = (7 - c + d); return((n > 7) ? n % 7 : n); }
/// <summary> /// Devuelve el primer dia de la semana dada un fecha /// </summary> /// <param name="date"></param> /// <history> /// [vku] 05/Mar/2016 Created /// </history> public static System.DateTime GetStartWeek(DateTime date) { System.DayOfWeek dmon = System.DayOfWeek.Monday; int span = date.DayOfWeek - dmon; date = date.AddDays(-span); return(date); }
/// <summary> /// Computes a new date that is on a given day of the week, on or prior to a reference date. /// </summary> /// <param name="refDate">reference date</param> /// <param name="dayOfWeek">enum</param> /// <param name="matchingDOWReturnsRefDate">if the reference date's day of week matches dayOfWeek param, passing in true returns refDate, else returns the prior week's day of week</param> /// <returns>a new date on the given day of week</returns> public static DateTime GetMostRecentDateOnDayOfWeek(DateTime refDate, System.DayOfWeek dayOfWeek, bool matchingDOWReturnsRefDate) { int iReqDOW; iReqDOW = (int)dayOfWeek; // will be 0~6 (= Sun~Sat) return(GetMostRecentDateOnDayOfWeek(refDate, iReqDOW, matchingDOWReturnsRefDate)); }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); System.DayOfWeek o = (System.DayOfWeek)arg0; ToLua.Push(L, o); return(1); }
/// <summary> /// 获取日期中的周数 /// </summary> /// <param name="dt"></param> /// <returns></returns> public static int GetWeekCount(System.DateTime dt) { System.DateTime day = System.DateTime.Parse(dt.Year + "-1-1"); System.DayOfWeek dateTime = day.DayOfWeek; int DayCount = dt.DayOfYear; return((DayCount + WeekToInt(dateTime) - 2) / 7 + 1); }
private string DayOfWeekMask(System.DayOfWeek dow) { string mask = "0000000"; switch (dow) { case System.DayOfWeek.Friday: { mask = "0000100"; break; } case System.DayOfWeek.Monday: { mask = "1000000"; break; } case System.DayOfWeek.Saturday: { mask = "0000010"; break; } case System.DayOfWeek.Sunday: { mask = "0000001"; break; } case System.DayOfWeek.Thursday: { mask = "0001000"; break; } case System.DayOfWeek.Tuesday: { mask = "0100000"; break; } case System.DayOfWeek.Wednesday: { mask = "0010000"; break; } default: { mask = "0000000"; break; } } return(mask); }
private string CalculateDayOfWeek() { DateTime dt = GetDateG(); PersianCalendar pc = new PersianCalendar(); System.DayOfWeek day = pc.GetDayOfWeek(dt); return(DayOfWeek.GetDayofWeekName((int)day)); }
private IEnumerable <RotaSession> GetRotaSessions(DayOfWeek day) { return(RotaSessionsAndSpecifiedSessions.Where(rs => (int)rs.StartDayOfWeek == (int)day).Select(rs => new RotaSession() { OpeningTime = new TimeSpan(rs.StartTime.Hours, rs.StartTime.Minutes, 0), ClosingTime = new TimeSpan(rs.EndTime.Hours, rs.EndTime.Minutes, 0), Day = (DayOfWeek)rs.StartDayOfWeek, })); }
public static DateTime GetStartDateOfWeek(DateTime dt, int startOfWeek) { System.DayOfWeek fdow = System.DayOfWeek.Friday; switch (startOfWeek) { case 0: // Summary: // Indicates Sunday. fdow = System.DayOfWeek.Sunday; break; case 1: // // Summary: // Indicates Monday. fdow = System.DayOfWeek.Monday; break; case 2: // // Summary: // Indicates Tuesday. fdow = System.DayOfWeek.Tuesday; break; case 3: // // Summary: // Indicates Wednesday. fdow = System.DayOfWeek.Wednesday; break; case 4: // // Summary: // Indicates Thursday. fdow = System.DayOfWeek.Thursday; break; case 5: // // Summary: // Indicates Friday. fdow = System.DayOfWeek.Friday; break; case 6: // // Summary: // Indicates Saturday. fdow = System.DayOfWeek.Saturday; break; } System.DayOfWeek today = dt.DayOfWeek; return(DateTime.Now.AddDays(-(today - fdow)).Date); }
static DateTime GetNextWeekday(System.DayOfWeek day, int extraDay = 1) { DateTime result = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddDays(extraDay); while (result.DayOfWeek != day) { result = result.AddDays(1); } return(result); }
/// <summary> /// Returns a date that is on the specified <paramref name="nextDay"/> 1 week after the passed <paramref name="date"/> /// </summary> /// <param name="nextDay">The weekday to get the date for</param> /// <param name="date">The date to get the weekday for relative to</param> /// <returns>a new date 1 week after the passed date on the passed nextDay</returns> public static DateTime GetDateForNextWeekDay(System.DayOfWeek nextDay, DateTime date) { // get the number of days in between the date's day of the week and the passed nextDay DayOfWeek today = date.DayOfWeek; // formula to get the number of days until the specified next day = 7 - (today - nextDay) int numberOfDaysUntilNextDay = 7 - (today - nextDay); // create a new DateTime from the passed date so that we don't modify the passed date DateTime newDate = new DateTime(date.Ticks).AddDays(numberOfDaysUntilNextDay); return(newDate); }
/// <summary> /// Returns the value that should be used for sorting, using the most appropriate datatype /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">The value.</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override object SortValue(Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues) { int?intValue = value.AsIntegerOrNull(); if (intValue.HasValue) { System.DayOfWeek dayOfWeek = (System.DayOfWeek)intValue.Value; return(dayOfWeek); } return((System.DayOfWeek) 0); }
/* * /// <summary> * /// Returns localized week number * /// </summary> * /// <param name="dayOfWeek"></param> * /// <returns></returns> * internal static int LocalizedDayOfWeek(System.DayOfWeek dayOfWeek) * { * // Old way with auto detect based on localization * int day = dayOfWeek.GetHashCode() - System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek.GetHashCode(); * // New settings based on setting selected for control * // int day = dayOfWeek.GetHashCode() - System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek.GetHashCode(); * * if(day<0) * day+=7; * * return day; * } */ /// <summary> /// Returns localized week number /// </summary> /// <param name="dayOfWeek"></param> /// <returns></returns> public static int LocalizedDayOfWeek(System.DayOfWeek dayOfWeek, CalendarDayOfWeek firstDayOfWeek) { // New settings based on setting selected for control int day = dayOfWeek.GetHashCode() - GetDayOfWeek(firstDayOfWeek).GetHashCode(); if (day < 0) { day += 7; } return(day); }
/// <summary> /// Check if "System.DayOfWeek.???" is one of the days inside the enumeration "DaysOfTheWeek" /// This function is able to translate the .NET enum System.DayOfWeek to one of DaysOfTheWeek enum values /// </summary> /// <param name="dayOfWeek">The "System.DayOfWeek" value like: Sunday (0), Monday (1), Tuesday (2), Wednesday (3), Thursday (4), Friday (5) or Saturday (6)</param> /// <param name="daysOfTheWeek">An enumeration containing one or many week days values like None (0), Sunday (1), Monday (2), Tuesday (4), Wednesday (8), Thursday (16), Friday (32) or Saturday (64)</param> /// <returns>True if there is an equivalent "System.DayOfWeek" inside the "DaysOfTheWeek" enumeration, otherwise False</returns> static public bool ContainsDaysOfTheWeek(System.DayOfWeek dayOfWeek, DaysOfTheWeek daysOfTheWeek) { int dow = (int)dayOfWeek; DaysOfTheWeek test = (DaysOfTheWeek)(int)Math.Pow(2, dow); if ((test & daysOfTheWeek) != DaysOfTheWeek.None) { return(true); } return(false); }
private TriggerBuilder GetTriggerBuilder(JobDetail jd, TriggerDetail td) { var trigger = TriggerBuilder.Create(); trigger.WithIdentity(td.TriggerKey, jd.Group); trigger.ForJob(jd.JobKey); trigger.WithPriority(td.Priority); trigger.StartAt(td.StartTime); if (td.EndTime != null && !td.EndTime.Equals(DateTime.MinValue)) trigger.EndAt(td.EndTime); switch (td.ScheduleTypeValue.ToLower()) { case "seconds": if (td.RepeatInterval > 0) { if (td.RepeatCount > 0) { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInSeconds(td.RepeatInterval) .WithRepeatCount(td.RepeatCount) ); } else { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInSeconds(td.RepeatInterval) .RepeatForever() ); } } else Log.Warn(String.Format("Job {0} was configured with {1} schedule but no Repeat Interval mentioned. Please configure the Repeat Interval correctly !!", jd.JobKey, td.ScheduleType), this); Diagnostics.Log.Info(String.Format("ScheduleType {0} and Schedule : {1})", td.ScheduleType, trigger.ToString()), this); break; case "minutes": if (td.RepeatInterval > 0) { if (td.RepeatCount > 0) { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInMinutes(td.RepeatInterval) .WithRepeatCount(td.RepeatCount) ); } else { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInMinutes(td.RepeatInterval) .RepeatForever() ); } } else Log.Warn(String.Format("Job {0} was configured with {1} schedule but no Repeat Interval mentioned. Please configure the Repeat Interval correctly !!", jd.JobKey, td.ScheduleType), this); Diagnostics.Log.Info(String.Format("ScheduleType {0} and Schedule : {1})", td.ScheduleType, trigger.ToString()), this); break; case "hours": if (td.RepeatInterval > 0) { if (td.RepeatCount > 0) { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInHours(td.RepeatInterval) .WithRepeatCount(td.RepeatCount) ); } else { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInHours(td.RepeatInterval) .RepeatForever() ); } } else Log.Warn(String.Format("Job {0} was configured with {1} schedule but no Repeat Interval mentioned. Please configure the Repeat Interval correctly !!", jd.JobKey, td.ScheduleType), this); Diagnostics.Log.Info(String.Format("ScheduleType {0} and Schedule : {1})", td.ScheduleType, trigger.ToString()), this); break; case "daily": trigger.WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(td.StartTime.Hour, td.StartTime.Minute)); break; case "weekly": //Convert Sitecore DaysOfWeeks property to System.DaysOfWeek which is understood by Quartz.net if (td.DaysOfWeeks != null && td.DaysOfWeeks.Count > 0) { System.DayOfWeek[] dayOfWeeks = new System.DayOfWeek[td.DaysOfWeeks.Count]; for (int i = 0; i < td.DaysOfWeeks.Count; i++) { dayOfWeeks[i] = (System.DayOfWeek)Enum.Parse(typeof(System.DayOfWeek), td.DaysOfWeeks[i].DayOfWeekValue.ToString()); } trigger.WithSchedule(CronScheduleBuilder.AtHourAndMinuteOnGivenDaysOfWeek(td.StartTime.Hour, td.StartTime.Minute, dayOfWeeks)); } else { Log.Warn(String.Format("Job {0} was configured with {1} schedule but \"Day of Weeks\" was not set correctly. Please configure the trigger correctly !!", jd.JobKey, td.ScheduleType), this); } break; case "monthly": if (td.DayOfMonth > 0) trigger.WithSchedule(CronScheduleBuilder.MonthlyOnDayAndHourAndMinute(td.DayOfMonth, td.StartTime.Hour, td.StartTime.Minute)); else Log.Warn(String.Format("Job {0} was configured with {1} schedule but \"Day of Month\" was not set correctly. Please configure the trigger correctly !!", jd.JobKey, td.ScheduleType), this); break; case "custom": if (!String.IsNullOrEmpty(td.CronExpression)) trigger.WithSchedule(CronScheduleBuilder.CronSchedule(new CronExpression(td.CronExpression))); else Log.Warn(String.Format("Job {0} was configured with {1} schedule but \"Cron Expression\" was not set correctly. Please configure the trigger correctly !!", jd.JobKey, td.ScheduleType), this); break; } return trigger; }
/// <summary> /// Initializes a new instance of the <see cref="AppSetting" /> class. /// </summary> public AppSetting() { this.UserId = System.Guid.NewGuid(); this.password = string.Empty; this.email = string.Empty; this.serverSyncIPAddress = new IPAddress("192.168.1.100", 0x271a); this.UseBackgroundImageForMainPage = false; this.EnableAllAccountOverdraft = true; this.GlobleCurrencySymbolStyle = CurrencySymbolStyle.LongWithName; this.Profile = new UserProfile(); this.SubscibeNotification = false; this.AutoBackupWhenAppUp = true; this.DefaultAccount = System.Guid.Empty; this.dayOfWeekForEveryDayBackup = System.DayOfWeek.Sunday; this.showAssociatedAccountItemSummary = true; this.showCashAmountOnAsset = true; this.IncludeCreditCardAmountOnAsset = false; this.BudgetStatsicSettings = new BudgetStatsicSetting(); this._VoiceCommandSettingMaximumValue = 1999; this._VoiceCommandSettingMininumValue = 1; this._VoiceCommandSettingWithDigits = false; this.CategorySelectionMode = CategorySelectionModes.SubCategorySelectionEnabled; }
private static string GetDayOfWeek(DayOfWeek dayOfWeek) { return DateTimeFormatInfo.CurrentInfo.GetDayName(dayOfWeek); }