ChrisCompleteCodeTrunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
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.Threading;
using System.IO;
using System.Configuration;
namespace EmailAndFaxWithStmt
{
class TimerState
{
public int Counter = 0;
public Timer ServiceTimer;
public int Interval = 0;
}
public partial class EFService : ServiceBase
{
//private System.Windows.Forms.NotifyIcon iconSysTray;
private static TimerState s;
public EFService()
{
InitializeComponent();
s = new TimerState();
}
protected override void OnStart(string[] args)
{
s.Interval = int.Parse(ConfigurationManager.AppSettings["PollingInterval"]);
TimerCallback timerDelegate = new TimerCallback(onElapsedTime);
Timer timer = new Timer(timerDelegate, s, 1000, s.Interval);
s.ServiceTimer = timer;
}
protected override void OnStop()
{
s.ServiceTimer.Dispose();
s.ServiceTimer = null;
}
static void onElapsedTime(Object state)
{
try
{
if (Configuration.LogLevel >= EventLogLevel.Information)
EventLog.WriteEntry(Configuration.LogSource, "Timer Elapsed. Rerunning the services", EventLogEntryType.Information);
s.ServiceTimer.Change(Timeout.Infinite, s.Interval);
EmailFaxLib.ProcessNewDocuments();
s.ServiceTimer.Change(s.Interval, s.Interval);
}
catch (Exception ex)
{
EventLog.WriteEntry(Configuration.LogSource, ex.Message, EventLogEntryType.Error);
}
}
}
}
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|