Correct my Design approach for simple website with webservice?

First of all sorry for a lengthy question :(

I need to know the design approach that i need to follow for a simple website:

  • Project is for alert birthdays of users.
  • Users list and birthday details will be there in a XML file.
  • There should be web service running to send mail via SMTP Client and mail message.
  • There should be website to administer or configure the setting of birthdays like send alerts only for managers or only for some department

    What i designed is,

  • I created a asp.net website, where default page will have some check boxes to select the settings of the alert
  • I created a windows application which loops through all users which is parsed from the XML and send alert mail to the users using SMTP.
  • I register this service and is listed in services.msc

    But the problem is when i start the service, immediately its stops.

Below is the service code , is it wrong? I know it will loop only once, is it because service is stopping?

protected override void OnStart(string[] args) { for (int i = 0; i < 1; i++ ) { SmtpClient smtp = new SmtpClient(); smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "#fsdfsd"); MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("[email protected]"); mailMessage.To.Add("[email protected]"); mailMessage.Body = "This is a test body"; mailMessage.Subject = "This is a test subject"; smtp.Send(mailMessage); } //} }

Is there any design problem? which needs to be corrected?

When i thought of debugging it in visual studio and see the execution part of sending mail, break point is not reaching the code, in the function protected override void OnStart(string[] args)

but it is hitting at the main function which is the entry point below:

static void Main() { System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Birthday() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); } }

But after reachign the line System.ServiceProcess.ServiceBase.Run(ServicesToRun);

It says

Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.

So when i start the service , it automatically stops.

Can any one help?

Category:c# Views:1 Time:2018-09-24

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.261 (s). 11 q(s)