-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLabelSpoolerService.cs
More file actions
72 lines (61 loc) · 2.03 KB
/
LabelSpoolerService.cs
File metadata and controls
72 lines (61 loc) · 2.03 KB
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
70
71
72
/**
* Author: Riccardo Bicelli <r.bicelli@gmail.com>>
* Created: 28.02.2020
*
* (c) Copyright Riccardo Bicelli.
**/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.IO;
using System.ServiceProcess;
using System.Text;
using IniParser;
using IniParser.Model;
using System.Reflection;
namespace LabelSpooler
{
public partial class LabelSpoolerService : ServiceBase
{
private SpoolMonitor _spoolMon;
public LabelSpoolerService()
{
_spoolMon = new SpoolMonitor();
Globals.initialize();
InitializeComponent();
}
protected override void OnStart(string[] args)
{
// Get assembly Version
if (_loadConfig())
{
_spoolMon.Run(Globals.pollIntervalms);
Globals.eventRecord("Service Started (Version " + Globals.appVersion + ")");
}
else
Globals.eventRecord("Unable to Start Service", EventLogEntryType.Error);
}
protected override void OnStop()
{
_spoolMon.Stop();
Globals.eventRecord("Service Stopped (Version" + Globals.appVersion + ")");
}
private bool _loadConfig()
{
//Load DB Data from INI File
DB.Server = Globals.iniData["database"]["server"];
DB.Database = Globals.iniData["database"]["database"];
DB.Username = Globals.iniData["database"]["username"];
DB.Password = Globals.iniData["database"]["password"];
if (!DB.Connect())
{
Globals.eventRecord("Unable to connect to Database",EventLogEntryType.Error);
return false;
}
return true;
}
}
}