12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Configuration;
- using System.Linq;
- using System.Net.WebSockets;
- using System.Runtime.Remoting.Messaging;
- using System.ServiceProcess;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Xml;
- namespace AipGateway.FileJob.Scheduler
- {
- internal static class Program
- {
- /// <summary>
- /// 해당 애플리케이션의 주 진입점입니다.
- /// </summary>
- static void Main()
- {
- ReadSettingsFromConfig();
- loadConfiguration();
- ServiceBase[] ServicesToRun;
- ServicesToRun = new ServiceBase[]
- {
- new Service()
- };
- ServiceBase.Run(ServicesToRun);
- }
- private static void loadConfiguration()
- {
- const string settingDeleteMinute = "DeleteMinute";
- const string settingDeletePathCount = "DeletePathCount";
- const string settingDeletePath = "DeletePath";
- int DeleteMinute = 60 * 24;
- string[] DeletePathsToWatch;
- NameValueCollection nvc;
- DeletePathsToWatch = null;
- nvc = (NameValueCollection)ConfigurationManager.AppSettings;
- if (nvc.AllKeys.Contains(settingDeleteMinute))
- {
- string tmpMinute = nvc[settingDeleteMinute];
- DeleteMinute = Helper.TryInt(tmpMinute, DeleteMinute);
- if (DeleteMinute < 30)
- {
- Console.WriteLine($"삭제할 파일 생성 시간 기준이 너무작아 [{DeleteMinute}] 최소값인 30분으로 다시 설정합니다.");
- DeleteMinute = 30;
- }
- }
- if (nvc.AllKeys.Contains(settingDeletePathCount))
- {
- int pathCount = Helper.TryInt(nvc[settingDeletePathCount], 0);
- if (pathCount > 0)
- {
- string[] tmpDeletePathsToWatch = new string[pathCount];
- for (int ii = 0; ii < pathCount; ii++)
- {
- string key = settingDeletePath + (ii + 1).ToString();
- if (nvc.AllKeys.Contains(key))
- {
- tmpDeletePathsToWatch[ii] = nvc[key];
- }
- }
- DeletePathsToWatch = tmpDeletePathsToWatch;
- }
- }
- }
- private static void ReadSettingsFromConfig()
- {
- var applicationSettings = ConfigurationManager.GetSection("deleteSettings") as NameValueCollection;
- if (applicationSettings.Count == 0)
- {
- Console.WriteLine("Application Settings are not defined");
- }
- else
- {
- foreach (var key in applicationSettings.AllKeys)
- {
- Console.WriteLine(key + " = " + applicationSettings[key]);
- }
- }
- }
- }
- }
|