Hos Computerworld it-jobbank er vi stolte af at fortsætte det gode partnerskab med folkene bag IT-DAY – efter vores mening Danmarks bedste karrieremesse for unge og erfarne it-kandidater.
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.ServiceProcess; using System.IO; using NORDDATA;
public filelistener_service() { // This call is required by the Windows.Forms Component Designer. InitializeComponent();
// TODO: Add any initialization after the InitComponent call }
// The main entry point for the process static void Main() { System.ServiceProcess.ServiceBase[] ServicesToRun;
// More than one user Service may run within the same process. To add // another service to this process, change the following line to // create a second service object. For example, // // ServicesToRun = new System.ServiceProcess.ServiceBase[] {new filelistener_service(), new MySecondUserService()}; // ServicesToRun = new System.ServiceProcess.ServiceBase[] { new filelistener_service() };
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); this.fileSystemWatcher1 = new System.IO.FileSystemWatcher(); this.eventLog1 = new System.Diagnostics.EventLog(); ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit(); // // fileSystemWatcher1 // this.fileSystemWatcher1.EnableRaisingEvents = true; this.fileSystemWatcher1.Filter = ((string)(configurationAppSettings.GetValue("fileSystemWatcher1.Filter", typeof(string)))); this.fileSystemWatcher1.Path = ((string)(configurationAppSettings.GetValue("fileSystemWatcher1.Path", typeof(string)))); this.fileSystemWatcher1.Created += new System.IO.FileSystemEventHandler(this.fileSystemWatcher1_Created); // // eventLog1 // this.eventLog1.Log = ((string)(configurationAppSettings.GetValue("eventLog1.Log", typeof(string)))); this.eventLog1.Source = ((string)(configurationAppSettings.GetValue("eventLog1.Source", typeof(string)))); ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit(); // egne this.ftpcpy_dir = ((string)(configurationAppSettings.GetValue("backupdir", typeof(string)))); this.logfil = ((string)(configurationAppSettings.GetValue("logfil", typeof(string)))); this.logfil_dir = ((string)(configurationAppSettings.GetValue("logfildir", typeof(string)))); this.logdato = ((string)(configurationAppSettings.GetValue("logdato", typeof(string)))); this.logtid = ((string)(configurationAppSettings.GetValue("logtid", typeof(string)))); this.logmedie = ((string)(configurationAppSettings.GetValue("logmedie", typeof(string)))); this.logfilinterval = ((string)(configurationAppSettings.GetValue("logfilinterval", typeof(string)))); this.mqmanagername = ((string)(configurationAppSettings.GetValue("mqmanagername", typeof(string)))); this.mqquename = ((string)(configurationAppSettings.GetValue("mqquename", typeof(string)))); this.mqquetype = ((string)(configurationAppSettings.GetValue("mqquetype", typeof(string)))); this.fillogging = ((string)(configurationAppSettings.GetValue("fillogging", typeof(string)))); this.eventlogging = ((string)(configurationAppSettings.GetValue("eventlogging", typeof(string)))); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }
/// <summary> /// Set things in motion so your service can do its work. /// </summary> protected override void OnStart(string[] args) { //initialisering af log objektet
if (this.fillogging=="yes") {
LogObj = new logClass();
//skal datoen angives ved logning LogObj.Logdato = (this.logdato == "yes");
//skal tiden angives ved logning LogObj.Logtid = (this.logtid == "yes");
//logobjektet sættes til at logge i en fil if (this.logmedie=="fil") { LogObj.logfildir = this.logfil_dir; LogObj.Filnavn = this.logfil; };
this.loggit("Logfil initialiseret",0,1); }
this.loggit("Listener service kører",0,2);
}
/// <summary> /// Stop this service. /// </summary> protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. this.loggit("Listener service stoppet",0,3); }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.