Will anobody be able to help me?
I am creating a windows service that connects to a sql database and checks a date in the table and compares it to todays date and updates a field in that database for eg if the date is equal to todays date then the field will be set to true.
The problem I am having is that when i start the service it does not do that but when i do it in a normal form it works perfectly.
My code is below:
//System.Timers
Timer timer = new Timer();
protected override void OnStart(string[] args)
{
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = 60000;
timer.Enabled = true;
}
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
int campid = 0;
var campRes = new ROS.Process.CampaignServiceController().GetCampainInfo();
foreach (var s in campRes)
{
campid = s.CampaignId;
if (s.CampEndDate.Date < DateTime.Today.Date)
{
//WriteDataToFile("Not Active : " + campid.ToString());
new ROS.Process.CampaignServiceController().SetCampainStatusFalse(campid);
}
else
{
//WriteDataToFile("Active : " + campid.ToString());
new ROS.Process.CampaignServiceController().SetCampainStatusTrue(campid);
}
}
}
OnElapsedTime
is even running? – Vacillatory