forked from jjxtra/UrlMonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUrlMonitorApp.cs
61 lines (55 loc) · 1.62 KB
/
UrlMonitorApp.cs
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
#region Imports
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Permissions;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Xml;
using System.Text.RegularExpressions;
#endregion Imports
namespace UrlMonitor
{
/// <summary>
/// Main app
/// </summary>
public class UrlMonitorApp
{
public static void RunService(string[] args)
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new UrlMonitorService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
public static void RunConsole(string[] args)
{
UrlMonitorService svc = new UrlMonitorService();
svc.Start(args);
Console.WriteLine("Press ENTER to quit");
Console.ReadLine();
svc.Stop();
}
public static void Main(string[] args)
{
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
if (args.Length != 0 && args[0] == "debug")
{
RunConsole(args);
}
else
{
RunService(args);
}
}
}
}