using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.ServiceProcess; using System.Text; namespace JobLabeler { public partial class Service1 : ServiceBase { private JobLabeler _JobLabeler = null; public Service1() { InitializeComponent(); } protected override void OnStart(string[] args) { // TODO: Add code here to start your service. LoadConfig(); timerRun.Enabled = true; timerRun.Start(); } protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. } private void timerRun_Tick(object sender, EventArgs e) { this.EventLog.WriteEntry("running"); //Disable the timer in case there are long-running jobs... we don't want them to queue up timerRun.Enabled = false; try { _JobLabeler.RunLabeler(this.EventLog); } catch (Exception err) { this.EventLog.WriteEntry(String.Format("Error running JobLabeler.\n{0}", err.Message), EventLogEntryType.Error); } // re-enable the timer timerRun.Enabled = true; timerRun.Start(); } private void LoadConfig() { System.Configuration.AppSettingsReader ar = new System.Configuration.AppSettingsReader(); string P4Port = (string)ar.GetValue("P4PORT", typeof(string)); string P4User= (string)ar.GetValue("P4USER", typeof(string)); string P4Password= (string)ar.GetValue("P4PASSWORD", typeof(string)); string LabelTemplate= (string)ar.GetValue("LabelTemplate", typeof(string)); string P4Counter= (string)ar.GetValue("P4Counter", typeof(string)); string LabelNameFormat= (string)ar.GetValue("LabelNameFormat", typeof(string)); bool UseLogin = ("true"==(string)ar.GetValue("P4UseLogin", typeof(string))); timerRun.Interval = 1000 * (int)ar.GetValue("SleepTime", typeof(int)); _JobLabeler = new JobLabeler(P4Port, P4User, P4Password, LabelTemplate, P4Counter, LabelNameFormat, UseLogin); this.EventLog.WriteEntry(string.Format("timer interval: {0}", timerRun.Interval) ); return; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 5830 | Shawn Hladky | P4.Net: reorg to support release branches | ||
#2 | 5798 | Shawn Hladky |
P4.Net... still not ready for beta Added license to all files Added several doc files Misc bugs |
||
#1 | 5427 | Shawn Hladky | P4.Net -- several fixes and added sample application |