프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / FinalService / FinalServiceBase / KCOM_FinalService / FinalService.cs @ 2b1f30fe

이력 | 보기 | 이력해설 | 다운로드 (1.95 KB)

1 42d49521 taeseongkim
using KCOM_FinalService.Common;
2
using KCOM_FinalService.Remoting;
3
using System;
4
using System.Collections.Generic;
5
using System.ComponentModel;
6
using System.Data;
7
using System.Diagnostics;
8
using System.Linq;
9
using System.ServiceProcess;
10
using System.Text;
11
using System.Threading;
12
13
namespace KCOM_FinalService
14
{
15
    public partial class MarkusFinalService : ServiceBase
16
    {
17
        #region PROPERTIES
18
        System.Timers.Timer _Timer;
19
        RemFinalPDFStation _remotingFinal = null;
20
21
        public Logger logger = null;
22
  
23
        Thread _FirewallOpenThread = null;
24
        #endregion
25
26
27
        private void Init()
28
        {
29
            if (logger == null)
30
            {
31
                logger = new Common.Logger();
32
                logger.ServiceEventLog(this.EventLog, this.ServiceName, "Application");
33
            }
34
35
            /// 타이머가 없는 경우 서비스가 로직 완료 후 종료됨
36
            if (_Timer == null)
37
            {
38
                _Timer = new System.Timers.Timer();
39
                _Timer.Interval = 60000;
40
                _Timer.Elapsed += _Timer_Elapsed;
41
            }
42
        }
43
44
        public MarkusFinalService()
45
        {
46
            InitializeComponent();
47
48
            Init();
49
50
            _remotingFinal = new RemFinalPDFStation(logger);
51
        }
52
53
        public void TestStartupAndStop(string[] args)
54
        {
55
            this.OnStart(args);
56
            logger.Write("TestStartupAndStop",LogLevel.Info);
57
58
            Console.ReadLine();
59
            this.OnStop();
60
        }
61
62
        private void _Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
63
        {
64
            logger.Write("Final Service On", LogLevel.Info);
65
        }
66
67
        protected override void OnStart(string[] args)
68
        {
69
            base.OnStart(args);
70
            _Timer.Start();
71
        }
72
73
        protected override void OnStop()
74
        {
75
            _remotingFinal.Dispose();
76
77
            base.OnShutdown();
78
            _Timer.Stop();
79
        }
80
    }
81
}
클립보드 이미지 추가 (최대 크기: 500 MB)