开发者

Windows service logic [closed]

开发者 https://www.devze.com 2023-03-02 21:28 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

i need to send mails to the user once an incdient is reported. the mail should be se开发者_运维百科nt for 30 minutes after incident reported time and then 105 minutes after incident reporeted time and then 225 minutes after incident reported time.

I am using window service and C#, but i just need a condition for the serivce to execute the code.

here is my code.

protected override void OnStart(string[] args)
{
  timer1 = new Timer(1800000);
  timer1.Enabled = true;
  timer1.Elapsed += new ElapsedEventHandler(Timer1_Event);
}


public void Timer1_Event(object source, ElapsedEventArgs e)
{
  if(datetime.now==incidentreportedtime+30mim)
  {
    //Send mail to user
  }
}

My question is incident can raise at any time and that time may not be eaual to the time at which service executes the code.

For example, incident raised time is at 12.45pm and the mail to be sent at 1.15pm. the serivce might have started at 12.50pm and again starts at 1.20pm which is not equal to 1.15pm. there can be few incidents with the same time as 1.20pm but not all the incidents can be considered to send mail.

Help me.


public void Timer1_Event(object source, ElapsedEventArgs e)
{
  if(DateTime.Now.Substract(incidentreportedtime).TotalMinutes == 30)
  {
    //Send mail to user
  }
}

And make sure the timer runs once each minute..

to send a mail google some thing like .net Send Mail my first hit: http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消