asp.Net毎日定点実行タスク

1210 ワード

 
  
public static void ClearCountByTime()
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(TimeEvent);
// 1
aTimer.Interval = 1000;
aTimer.Enabled = true;
}

private static void TimeEvent(object source, ElapsedEventArgs e)
{
// hour minute second
int intHour = e.SignalTime.Hour;
int intMinute = e.SignalTime.Minute;
int intSecond = e.SignalTime.Second;
// , 00:00:00
int iHour = 00;
int iMinute = 00;
int iSecond = 00;

// 00:00:00
if (intHour == iHour && intMinute == iMinute && intSecond == iSecond)
{
ClearCount();
}
}

public static void ClearCount()
{
string sql = " ";
int result=SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, sql);
if (result > 0)
{
//TodayCount !;
}
else
{
//TodayCount !;
}
}