我的Web应用程序在表1中插入报告的计划详细信息。计划详细信息与任务计划中的完全相同。
我打算创建一个批处理过程,
我不需要在任务调度程序中创建任何触发器。我需要的是根据已设置为计划的报告计算报告的下一个运行日期。
任何帮助都会很棒。我需要
我的尝试:
[Flags]
public enum DaysOfWeek
{
Sunday = 1,
Monday = 2,
Tuesday = 4,
Wednesday = 8,
Thursday = 16,
Friday = 32,
Saturday = 64
}
private void CalculateNextRunTime()
{
CultureInfo provider = CultureInfo.InvariantCulture;
DateTime nextRun;
DateTime dtStart = DateTime.ParseExact("01/05/2014", "mm/dd/yyyy", provider);
DateTime dtLastRun = DateTime.ParseExact("01/06/2014", "mm/dd/yyyy", provider);;
int recurNo = 2;
string recurFrequency = "Monday|Wednesday|Friday";
DateTime dtEnd = DateTime.ParseExact("01/06/2015", "mm/dd/yyyy", provider);
//store the weekdays in an array
ArrayList weekList = new ArrayList();
string[] weekDays = recurFrequency.Split('|');
foreach (string weekDay in weekDays)
weekList.Add(weekDay);
DateTime now;
if (dtLastRun != null)
now = dtLastRun;
else
now = dtStart;
DaysOfWeek DaysToRun = DaysOfWeek.Monday | DaysOfWeek.Wednesday | DaysOfWeek.Friday;
DaysOfWeek Day = (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), now.DayOfWeek.ToString());
if (DaysToRun.HasFlag(Day))
{
// get next run date (should be Wednesday 01/08/2014)
if (dtLastRun.DayOfWeek == DayOfWeek.Monday)
{
nextRun = dtLastRun.AddDays(2);
}
}
}
答案 0 :(得分:0)
据我了解您的问题,您希望在Web应用程序上创建批处理以更新报告时间。但是,如果没有任何外部应用程序,则无法执行此操作,因为Web应用程序操作将在请求到一个选项可能是您可以打开Web浏览器并创建一个定期调用UpdateRecords()
或类似内容的ajax请求。