728eb959688f5e75c0a73d875193c4837d0c3adc
[reactos.git] / irc / TechBot / TechBot / ServiceThread.cs
1 using System;
2 using System.Configuration;
3 using System.Diagnostics;
4 using TechBot.Library;
5
6 namespace TechBot
7 {
8 public class ServiceThread
9 {
10 private string IRCServerHostName;
11 private int IRCServerHostPort;
12 private string IRCChannelNames;
13 private string IRCBotName;
14 private string ChmPath;
15 private string MainChm;
16 private string NtstatusXml;
17 private string HresultXml;
18 private string WinerrorXml;
19 private string SvnCommand;
20 private EventLog eventLog;
21
22 public ServiceThread(EventLog eventLog)
23 {
24 this.eventLog = eventLog;
25 }
26
27 private void SetupConfiguration()
28 {
29 IRCServerHostName = ConfigurationSettings.AppSettings["IRCServerHostName"];
30 IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
31 IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
32 IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
33 ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
34 MainChm = ConfigurationSettings.AppSettings["MainChm"];
35 NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
36 HresultXml = ConfigurationSettings.AppSettings["HresultXml"];
37 WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];
38 SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];
39 }
40
41 public void Run()
42 {
43 SetupConfiguration();
44 System.Console.WriteLine("TechBot irc service...");
45
46 IrcService ircService = new IrcService(IRCServerHostName,
47 IRCServerHostPort,
48 IRCChannelNames,
49 IRCBotName,
50 ChmPath,
51 MainChm,
52 NtstatusXml,
53 WinerrorXml,
54 HresultXml,
55 SvnCommand);
56 ircService.Run();
57 }
58
59 public void Start()
60 {
61 try
62 {
63 Run();
64 }
65 catch (Exception ex)
66 {
67 eventLog.WriteEntry(String.Format("Ex. {0}", ex));
68 }
69 }
70 }
71 }