16. April 2012 13:04
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
namespace MobileWebservice
{
public partial class MobileWebservice : ServiceBase
{
System.Timers.Timer webServiceTimer;
public MobileWebservice()
{
InitializeComponent();
/* if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog");
}
MobileLog.Source = "MySource";
MobileLog.Log = "MyNewLog";*/
if (!System.Diagnostics.EventLog.SourceExists("Mobile"))
{
System.Diagnostics.EventLog.CreateEventSource("Mobile", "Mobile");
}
MobileLog.Source = "Mobile";
MobileLog.Log = "Mobile";
}
protected override void OnStart(string[] args)
{
MobileLog.WriteEntry("Service is started.");
webServiceTimer = new System.Timers.Timer(5000);
webServiceTimer.Elapsed += new ElapsedEventHandler(OnWebServiceTimerEvent);
webServiceTimer.Enabled = true;
MobileLog.WriteEntry("Timer wurde gestartet");
}
protected override void OnStop()
{
MobileLog.WriteEntry("Service is stoped.");
}
private void eventLog1_EntryWritten(object sender, EntryWrittenEventArgs e)
{
}
private void OnWebServiceTimerEvent(Object source, ElapsedEventArgs e)
{
MobileLog.WriteEntry("Timermethode läuft!");
webServiceStart();
}
private void webServiceStart()
{
MobileLog.WriteEntry("Webservice wird ausgeführt");
localhost.WebServiceTest wsT;
wsT = new localhost.WebServiceTest();
wsT.UseDefaultCredentials = true;
wsT.WebServiceMethod();
MobileLog.WriteEntry("Webservice wurde ausgeführt");
}
}
}
16. April 2012 14:53
16. April 2012 15:15