public void SetWeekday(Activity activity, WeekdayEnum weekday) { Activity parent = activity.Parent; if ((null != parent) && (parent is DaysOfWeekActivity)) { DaysOfWeekActivity.SetWeekday(activity, weekday); } }
public WeekdayEnum GetWeekday(Activity activity) { WeekdayEnum weekday = WeekdayEnum.None; Activity parent = activity.Parent; if ((null != parent) && (parent is DaysOfWeekActivity)) { weekday = (WeekdayEnum)DaysOfWeekActivity.GetWeekday(activity); } return(weekday); }
/// <summary> /// /// </summary> /// <param name="weekday"></param> /// <returns></returns> public static string GetWeekDayText(WeekdayEnum weekday) { string ret = string.Empty; switch (weekday) { case WeekdayEnum.SUNDAY: ret = "星期日"; break; case WeekdayEnum.MONDAY: ret = "星期一"; break; case WeekdayEnum.TUESDAY: ret = "星期二"; break; case WeekdayEnum.WEDNESDAY: ret = "星期三"; break; case WeekdayEnum.THURSDAY: ret = "星期四"; break; case WeekdayEnum.FRIDAY: ret = "星期五"; break; case WeekdayEnum.SATURDAY: ret = "星期六"; break; default: break; } return(ret); }
/// <summary> /// Execute the activity /// </summary> /// <param name="executionContext"></param> /// <returns>Exedcuting if any children are running, otherwise Closed</returns> protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { if (null == executionContext) { throw new ArgumentNullException("executionContext"); } this.IsExecuting = true; bool executingChildren = false; DateTime date = (this.Date == DateTime.MinValue) ? DateTime.Now : this.Date; // Get the day of the week from this activity & convert to a WeekdayEnum WeekdayEnum weekday = date.DayOfWeek == 0 ? WeekdayEnum.Sunday : (WeekdayEnum)(Convert.ToInt32(Math.Pow(2, (int)date.DayOfWeek))); for (int pos = 0; pos < base.EnabledActivities.Count; pos++) { SequenceActivity act = base.EnabledActivities[pos] as SequenceActivity; if (null != act) { // Get the attached Weekday property for the activity WeekdayEnum weekdays = (WeekdayEnum)GetWeekday(act); // Now check for a match if ((weekdays & weekday) != WeekdayEnum.None) { executingChildren = true; act.RegisterForStatusChange(Activity.ClosedEvent, this); executionContext.ExecuteActivity(act); } } } return(executingChildren ? ActivityExecutionStatus.Executing : ActivityExecutionStatus.Closed); }
public WeekDay(int dayNumber) { this.Day = (WeekdayEnum)(dayNumber % 7); }