/// <inheritdoc /> protected override void Execute(Context context) { var dateString = DateString.Get(context); var format = DateFormat.Get(context); var date = string.IsNullOrWhiteSpace(format) ? DateTime.Parse(dateString, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault) : DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault); Result.Set(context, date); }
protected override void Execute(CodeActivityContext executionContext) { var dateString = DateString.Get <string>(executionContext); var dateFormat = DateFormat.Get <string>(executionContext); DateTime date; if (!String.IsNullOrWhiteSpace(dateString)) { var provider = CultureInfo.InvariantCulture; if (!DateTime.TryParseExact(dateString, dateFormat, provider, DateTimeStyles.None, out date)) { date = Date.Get <DateTime>(executionContext); } } else { date = Date.Get <DateTime>(executionContext); } bool am; var hour = date.Hour; Year.Set(executionContext, date.Year); YearText.Set(executionContext, date.Year.ToString()); Month.Set(executionContext, date.Month); Day.Set(executionContext, date.Day); Hour24.Set(executionContext, date.Hour); var cultureInfo = GetCultureInfo(executionContext, LanguageCode.Get <int>(executionContext)); MonthText.Set(executionContext, date.ToString("MMMM", cultureInfo.DateTimeFormat)); DayOfWeekString.Set(executionContext, date.ToString("dddd", cultureInfo.DateTimeFormat)); if (date.Hour >= 12) { am = false; hour = date.Hour - 12; } else { am = true; } Hour.Set(executionContext, hour); IsAM.Set(executionContext, am); IsPM.Set(executionContext, !am); Minute.Set(executionContext, date.Minute); DayOfWeek.Set(executionContext, (int)date.DayOfWeek); DayOfYear.Set(executionContext, date.DayOfYear); Week.Set(executionContext, GetWeek(date)); }
protected override void ExecuteInternal(LocalWorkflowContext context) { string dateString = DateString.Get(context.CodeActivityContext); string format = DateFormat.Get(context.CodeActivityContext); DateTime date = DateTime.Now; if (DateTime.TryParse(dateString, out date)) { FormattedDateString.Set(context.CodeActivityContext, date.ToString(format)); } else if (dateString.ToUpper() == "NOW") { FormattedDateString.Set(context.CodeActivityContext, DateTime.Now.ToString(format)); } else { FormattedDateString.Set(context.CodeActivityContext, dateString); } }
protected override void Execute(CodeActivityContext context) { DateTime date; String date_string = DateString.Get(context); if (date_string != null) { date = DateTime.Parse(date_string); DayOfWeek day = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(date); if (day >= DayOfWeek.Monday && day <= DayOfWeek.Wednesday) { date = date.AddDays(3); } WeekNb.Set(context, CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)); } }