프로젝트

일반

사용자정보

개정판 782ad7b1

ID782ad7b1ecee3dab94a5bcb3451d32f25f7febfc
상위 07385dd2
하위 b8435edd

김태성이(가) 4년 이상 전에 추가함

- Markus.Fonts/FontHelper.cs window service에서 resource를 못가져오는 문제 수정
uri 형식이 사용자UI와 틀림

Change-Id: Id98d35db2aab7cc990fd27a7da891dc5b00d97bd

차이점 보기:

FinalService/KCOM_FinalService/KCOM_FinalService.sln
21 21
EndProject
22 22
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectionStrEncrypt", "ConnectionStrEncrypt\ConnectionStrEncrypt.csproj", "{61F76FC9-A54E-4311-865F-05329DCACBDC}"
23 23
EndProject
24
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCOM_FinalService_Console", "KCOM_FinalService_Console\KCOM_FinalService_Console.csproj", "{35CC3A14-08A0-4828-9A29-61A3989ECE52}"
25
EndProject
26 24
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinalService_Config", "FinalService_Config\FinalService_Config.csproj", "{ADC39322-0E61-4B6E-89A3-6219F145F185}"
27 25
EndProject
28 26
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinalPDFClient", "FinalPDFClient\FinalPDFClient.csproj", "{DBD7598F-130F-4605-9B11-FE955A59FD4A}"
......
35 33
EndProject
36 34
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markus.Service.IWcfService", "Markus.Service.WcfService\Markus.Service.IWcfService.csproj", "{0523C15E-B197-4C34-83BA-D62B384E2B77}"
37 35
EndProject
36
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCOM_FinalServiceConsole", "KCOM_FinalServiceConsole\KCOM_FinalServiceConsole.csproj", "{824A4880-EDEA-4F50-9207-F8B9E3096375}"
37
EndProject
38 38
Global
39 39
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
40 40
		Debug|Any CPU = Debug|Any CPU
......
127 127
		{61F76FC9-A54E-4311-865F-05329DCACBDC}.Release|x64.Build.0 = Release|Any CPU
128 128
		{61F76FC9-A54E-4311-865F-05329DCACBDC}.Release|x86.ActiveCfg = Release|Any CPU
129 129
		{61F76FC9-A54E-4311-865F-05329DCACBDC}.Release|x86.Build.0 = Release|Any CPU
130
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
131
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Debug|Any CPU.Build.0 = Debug|Any CPU
132
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Debug|x64.ActiveCfg = Debug|Any CPU
133
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Debug|x64.Build.0 = Debug|Any CPU
134
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Debug|x86.ActiveCfg = Debug|Any CPU
135
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Debug|x86.Build.0 = Debug|Any CPU
136
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Release|Any CPU.ActiveCfg = Release|Any CPU
137
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Release|Any CPU.Build.0 = Release|Any CPU
138
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Release|x64.ActiveCfg = Release|Any CPU
139
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Release|x64.Build.0 = Release|Any CPU
140
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Release|x86.ActiveCfg = Release|Any CPU
141
		{35CC3A14-08A0-4828-9A29-61A3989ECE52}.Release|x86.Build.0 = Release|Any CPU
142 130
		{ADC39322-0E61-4B6E-89A3-6219F145F185}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
143 131
		{ADC39322-0E61-4B6E-89A3-6219F145F185}.Debug|Any CPU.Build.0 = Debug|Any CPU
144 132
		{ADC39322-0E61-4B6E-89A3-6219F145F185}.Debug|x64.ActiveCfg = Debug|Any CPU
......
205 193
		{0523C15E-B197-4C34-83BA-D62B384E2B77}.Release|x64.Build.0 = Release|x64
206 194
		{0523C15E-B197-4C34-83BA-D62B384E2B77}.Release|x86.ActiveCfg = Release|Any CPU
207 195
		{0523C15E-B197-4C34-83BA-D62B384E2B77}.Release|x86.Build.0 = Release|Any CPU
196
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
197
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Debug|Any CPU.Build.0 = Debug|Any CPU
198
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Debug|x64.ActiveCfg = Debug|Any CPU
199
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Debug|x64.Build.0 = Debug|Any CPU
200
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Debug|x86.ActiveCfg = Debug|Any CPU
201
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Debug|x86.Build.0 = Debug|Any CPU
202
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Release|Any CPU.ActiveCfg = Release|Any CPU
203
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Release|Any CPU.Build.0 = Release|Any CPU
204
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Release|x64.ActiveCfg = Release|Any CPU
205
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Release|x64.Build.0 = Release|Any CPU
206
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Release|x86.ActiveCfg = Release|Any CPU
207
		{824A4880-EDEA-4F50-9207-F8B9E3096375}.Release|x86.Build.0 = Release|Any CPU
208 208
	EndGlobalSection
209 209
	GlobalSection(SolutionProperties) = preSolution
210 210
		HideSolutionNode = FALSE
FinalService/KCOM_FinalService/KCOM_FinalService/Common/Logger.cs
1
using log4net;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Data;
6
using System.Diagnostics;
7
using System.Linq;
8
using System.ServiceProcess;
9
using System.Text;
10

  
11
namespace KCOM_FinalService.Common
12
{
13
    public class Logger
14
    {
15
        EventLog windowEventLog = null;
16
        public static ILog FileLogger = null;
17

  
18
        public void ServiceEventLog(EventLog Log, string SourceName, string LogName)
19
        {
20
            try
21
            {
22
                FileLogger = LogManager.GetLogger(typeof(KCOM_FinalService.MarkusFinalService));
23

  
24
                windowEventLog = Log;
25
                windowEventLog.Source = SourceName;
26
                windowEventLog.Log = LogName;
27

  
28
                if (!EventLog.SourceExists(SourceName))
29
                    EventLog.CreateEventSource(SourceName, "Application");
30
                
31
            }
32
            catch (Exception ex)
33
            {
34
                throw new Exception("Logger Initialize error",ex);
35
            }
36
        }
37
        public void Write(Exception exception)
38
        {
39
            if (FileLogger != null)
40
            {
41
                FileLogger.Error(exception);
42
            }
43

  
44
            var ex = $"Exception : {exception.ToString()} InnerException : {exception.InnerException?.ToString()}";
45

  
46
            if (windowEventLog != null)
47
            {
48
                windowEventLog.WriteEntry(ex, EventLogEntryType.Error);
49
            }
50

  
51
            if (Environment.UserInteractive)
52
            {
53
                Console.WriteLine(ex);
54
            }
55
        }
56

  
57
        public void Write(string Message, LogLevel level)
58
        {
59
            if(FileLogger != null)
60
            {
61
                switch (level)
62
                {
63
                    case LogLevel.Error:
64
                        FileLogger.Error(Message);
65
                        break;
66
                    case LogLevel.Info:
67
                        FileLogger.Info(Message);
68
                        break;
69
                    default:
70
                        FileLogger.Error(Message);
71
                        break;
72
                }
73
            }
74

  
75
            if (windowEventLog != null)
76
            {
77
                switch (level)
78
                {
79
                    case LogLevel.Error:
80
                        windowEventLog.WriteEntry(Message,EventLogEntryType.Error);
81
                        break;
82
                    case LogLevel.Info:
83
                        windowEventLog.WriteEntry(Message);
84
                        break;
85
                    default:
86
                        windowEventLog.WriteEntry(Message, EventLogEntryType.Error);
87
                        break;
88
                }
89
            }
90

  
91
            if (Environment.UserInteractive)
92
            {
93
                switch (level)
94
                {
95
                    case LogLevel.Error:
96
                        Console.ForegroundColor = ConsoleColor.Red;
97
                        break;
98
                    case LogLevel.Info:
99
                        Console.ForegroundColor = ConsoleColor.White;
100
                        break;
101
                    default:
102
                        Console.ForegroundColor = ConsoleColor.Red;
103
                        break;
104
                }
105
               
106
                Console.WriteLine(Message, Console.ForegroundColor);
107
            }
108
        }
109
    }
110

  
111
    public enum LogLevel
112
    {
113
        Error,Info
114
    }
115
}
FinalService/KCOM_FinalService/KCOM_FinalService/Common/Properties.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
#if CONSOLE
8
namespace KCOM_FinalService_Console
9
#else
10
namespace KCOM_FinalService
11
#endif
12
{
13
    public static class CommonProperties
14
    {
15
        public static KCOM_FinalService.Properties.Settings GetSettings
16
        {
17
            get
18
            {
19
                return KCOM_FinalService.Properties.Settings.Default;
20

  
21
            }
22
            private set {; }
23
        }
24
#endif
25

  
26
    }
27
}
FinalService/KCOM_FinalService/KCOM_FinalService/Common/ServiceEventLog.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Diagnostics;
6
using System.Linq;
7
using System.ServiceProcess;
8
using System.Text;
9

  
10
namespace KCOM_FinalService.Common
11
{
12
    public partial class ServiceEventLog : EventLog
13
    {
14
        public ServiceEventLog(EventLog Log, string SourceName, string LogName)
15
        {
16
            this.Source = SourceName;
17
            this.Log = LogName;
18

  
19
            if (!Environment.UserInteractive)
20
            {
21
                if (!EventLog.SourceExists(SourceName))
22
                    EventLog.CreateEventSource(SourceName, "Application");
23
            }
24
        }
25

  
26
        public void Write(string Message)
27
        {
28
            this.WriteEntry(Message);
29
        }
30
    }
31
}
FinalService/KCOM_FinalService/KCOM_FinalService/FinalService.cs
15 15
    public partial class MarkusFinalService : ServiceBase
16 16
    {
17 17
        #region PROPERTIES
18
        System.Timers.Timer _Timer = new System.Timers.Timer();
18
        System.Timers.Timer _Timer;
19 19
        RemFinalPDFStation _remotingFinal = null;
20
        ServiceEventLog _log = null;
21
        public ServiceEventLog Logger
22
        {
23
            get { return this._log; }
24
        }
25 20

  
21
        public Logger logger = null;
22
  
26 23
        Thread _FirewallOpenThread = null;
27 24
        #endregion
28 25

  
29
        public MarkusFinalService(string RemotingPort)
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()
30 45
        {
31 46
            InitializeComponent();
32 47

  
33
            _log = new Common.ServiceEventLog(this.EventLog, this.ServiceName, "Application");
48
            Init();
34 49

  
35
            /// 타이머가 없는 경우 서비스가 로직 완료 후 종료됨
36
            _Timer.Interval = 60000; 
37
            _Timer.Elapsed += _Timer_Elapsed;
38
            _remotingFinal = new RemFinalPDFStation(_log, RemotingPort);
50
            _remotingFinal = new RemFinalPDFStation(logger);
39 51
        }
40 52

  
41 53
        public void TestStartupAndStop(string[] args)
42 54
        {
43 55
            this.OnStart(args);
44
            Program.FileLogger.Debug("TestStartupAndStop");
56
            logger.Write("TestStartupAndStop",LogLevel.Info);
45 57

  
46 58
            Console.ReadLine();
47 59
            this.OnStop();
......
49 61

  
50 62
        private void _Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
51 63
        {
52
            Program.FileLogger.Debug("FinalService가 정상적으로 실행 중입니다");
64
            logger.Write("Final Service On", LogLevel.Info);
53 65
        }
54 66

  
55 67
        protected override void OnStart(string[] args)
FinalService/KCOM_FinalService/KCOM_FinalService/KCOM_FinalService.csproj
5 5
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 6
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 7
    <ProjectGuid>{2BE3F054-D494-4712-927F-47E2FFB52170}</ProjectGuid>
8
    <OutputType>WinExe</OutputType>
8
    <OutputType>Exe</OutputType>
9 9
    <RootNamespace>KCOM_FinalService</RootNamespace>
10 10
    <AssemblyName>KCOM_FinalService</AssemblyName>
11 11
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
......
56 56
    <Reference Include="System.Xml" />
57 57
  </ItemGroup>
58 58
  <ItemGroup>
59
    <Compile Include="Common\ServiceEventLog.cs">
60
      <SubType>Component</SubType>
61
    </Compile>
59
    <Compile Include="Common\Logger.cs" />
62 60
    <Compile Include="FinalService.cs">
63 61
      <SubType>Component</SubType>
64 62
    </Compile>
......
110 108
    <Content Include="FinalService.ini">
111 109
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
112 110
    </Content>
111
    <None Include="Log.config">
112
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
113
    </None>
113 114
    <None Include="packages.config" />
114 115
    <None Include="Properties\Settings.settings">
115 116
      <Generator>SettingsSingleFileGenerator</Generator>
FinalService/KCOM_FinalService/KCOM_FinalService/Log.config
1
<?xml version="1.0" encoding="utf-8"?>
2
<configuration>
3
  <configSections>
4
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
5
  </configSections>
6
  <log4net>
7
    <!--<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
8
      <applicationName value="ServiceStation"/>
9
      <layout type="log4net.Layout.PatternLayout">
10
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
11
      </layout>
12
    </appender>-->
13
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
14
      <file type="log4net.Util.PatternString" value="${programdata}\FinalService\Log\"/>
15
      <appendtofile value="true"/>
16
      <datepattern value="'Final_'yyyy-MM-dd'.log'"/>
17
      <staticlogfilename value="false"/>
18
      <rollingstyle value="Date"/>
19
      <layout type="log4net.Layout.PatternLayout">
20
        <conversionpattern value="%d [%t] %-5p - %m%n"/>
21
      </layout>
22
    </appender>
23
    <root>
24
      <level value="All" />
25
      <!-- <appender-ref ref="EventLogAppender" />-->
26
      <appender-ref ref="RollingFileAppender" />
27
    </root>
28
  </log4net>
29
</configuration>
FinalService/KCOM_FinalService/KCOM_FinalService/Program.cs
6 6
using System.Reflection;
7 7
using System.ServiceProcess;
8 8
using log4net;
9
using KCOM_FinalService.Common;
9 10

  
10
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
11 11
namespace KCOM_FinalService
12 12
{
13 13
    static class Program
......
23 23
            }
24 24
        }
25 25

  
26
        public static ILog FileLogger = null;
27 26
        public static ServiceBase[] ServicesToRun = null;
28 27

  
29 28
        public static MethodInfo UploadFinalPDFMethod { get; set; }
30 29
        public static object UploadFinalPDFInst { get; set; }
31 30

  
31
        static MarkusFinalService service = new MarkusFinalService();
32

  
32 33
        /// <summary>
33 34
        /// The main entry point for the application.
34 35
        /// </summary>
......
37 38
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
38 39

  
39 40
            log4net.GlobalContext.Properties["LogFilePath"] = Path.Combine(AppDataFolder, "Log", "FinalService.log");
40
            Program.FileLogger = LogManager.GetLogger("EventLogger");
41

  
41
         
42 42
            /// get legacy interface for upload final pdf file
43 43
            string UploadFinalDllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFinal.dll");
44 44
            if (File.Exists(UploadFinalDllPath))
......
56 56

  
57 57
            if (Environment.UserInteractive)
58 58
            {
59
                MarkusFinalService service = new MarkusFinalService("9092");
60
                service.TestStartupAndStop(args);
59
                try
60
                {
61
                    service.TestStartupAndStop(args);
62

  
63
                }
64
                catch (Exception ex)
65
                {
66
                    Console.WriteLine(ex);
67
                }
61 68
            }
62 69
            else
63 70
            {
64 71
                /// up to here
65 72
                ServicesToRun = new ServiceBase[]
66
                {  new MarkusFinalService("9092")
73
                {  new MarkusFinalService()
67 74
                };
68 75
                ServiceBase.Run(ServicesToRun);
69 76
            }
......
80 87
        {
81 88
            try
82 89
            {
83
                Program.FileLogger.Fatal(e.ExceptionObject as Exception);
90
                service.logger.Write(e.ExceptionObject as Exception);
84 91
            }
85 92
            catch (Exception ex)
86 93
            {
FinalService/KCOM_FinalService/KCOM_FinalService/Properties/AssemblyInfo.cs
34 34
// [assembly: AssemblyVersion("1.0.*")]
35 35
[assembly: AssemblyVersion("1.0.0.0")]
36 36
[assembly: AssemblyFileVersion("1.0.0.0")]
37
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log.config", Watch = true)]
FinalService/KCOM_FinalService/KCOM_FinalService/Remoting/RemFinalPDFStation.cs
17 17
    public class RemFinalPDFStation : InterfaceFinalPDF, IDisposable
18 18
    {
19 19
        #region Properties
20

  
21
        Logger _Logger = null;
22

  
20 23
        TcpChannel _Channel = null;
21
        ServiceEventLog _Log = null;
24
        
22 25
        string _NoticeMessageBase = null;
23 26
        string _NoticeTitleBase = null;
24 27
        string _MyIP = null;
......
29 32
        List<FINAL_PDF> WorkingList = new List<FINAL_PDF>();
30 33
        #endregion
31 34

  
32
        public RemFinalPDFStation(int MultipleFinalCount)
35
        public RemFinalPDFStation(Logger eventLog,int MultipleFinalCount)
36
        {
37
            _Logger = eventLog;
38

  
39
            Init();
40
        }
41

  
42
        public RemFinalPDFStation(Logger eventLog)
33 43
        {
34
            System.Diagnostics.EventLog _eventlog = new System.Diagnostics.EventLog();
35
            _Log = new ServiceEventLog(_eventlog, "MarkusFinalService", "Application");
44
            _Logger = eventLog;
36 45

  
37 46
            Init();
38 47
        }
39 48

  
40
        public RemFinalPDFStation(ServiceEventLog eventLog,string RemotingPort)
49
        public RemFinalPDFStation(Logger eventLog,string RemotingPort)
41 50
        {
42
            System.Diagnostics.EventLog _eventLog = new System.Diagnostics.EventLog();
43
            _Log = new ServiceEventLog(_eventLog, "MarkusFinalService", "Application");
51
            _Logger = eventLog;
44 52

  
45 53
            int port = -1;
46 54

  
......
52 60
                    Properties.Settings.Default.Save();
53 61
                }
54 62

  
55
                _Log = eventLog;
56

  
57 63
                Init();
58 64
            }
59 65
            else
60 66
            {
61
                Program.FileLogger.Debug($"RemotingPort Parse Error : {RemotingPort}");
67
                _Logger.Write($"RemotingPort Parse Error : {RemotingPort}",LogLevel.Error);
62 68

  
63 69
            }
64 70
        }
......
78 84
#endif
79 85
                }
80 86

  
87
                string endpoint = "remFinalPDF";
88

  
81 89
                _Channel = new TcpChannel(Properties.Settings.Default.RemotingPort);
82 90
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_Channel, false);
83
                System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemFinalPDFObject), "remFinalPDF", System.Runtime.Remoting.WellKnownObjectMode.Singleton);
91
                System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemFinalPDFObject), endpoint, System.Runtime.Remoting.WellKnownObjectMode.Singleton);
92

  
93
                foreach (var item in _Channel.GetUrlsForUri(endpoint))
94
                {
95
                    _Logger.Write($"Final Service Open Channel - {item}",LogLevel.Info);
96
                } 
84 97
            }
85 98
            catch (Exception ex)
86 99
            {
87
                Program.FileLogger.Fatal(ex);
100
                _Logger.Write(ex);
88 101
            }
89 102

  
90 103
            IFinalPDF.Cache.Attach(this);
......
164 177
            {
165 178
                try
166 179
                {
167
                    Program.FileLogger.Debug(pdf.ToString());
180
                    if(pdf != null)
181
                    {
182
                        var finalpdf = (FINAL_PDF)pdf;
183

  
184
                        _Logger.Write($"ID:{finalpdf.ID} / ProjectNo:{finalpdf.PROJECT_NO} / DocumentId:{finalpdf.DOCUMENT_ID} / MarkupInfoId:{finalpdf.MARKUPINFO_ID} / CreateUser:{finalpdf.CREATE_USER_ID}",LogLevel.Info);
185
                    }
186

  
168 187
                    if (((FINAL_PDF)pdf).STATUS == (int)FinalStatus.Insert)
169 188
                    {
170 189
                        /// 작업중이라고 데이타베이스에 저장한다
......
191 210
                }
192 211
                catch (Exception ex)
193 212
                {
194
                    Program.FileLogger.Fatal(ex);
213
                    _Logger.Write(ex);
195 214
                }
196 215
            });
197 216
        }
......
221 240
            }
222 241
            catch(Exception ex)
223 242
            {
224
                Program.FileLogger.Fatal(ex);
243
                _Logger.Write(ex);
225 244
                throw ex;
226 245
            }
227 246

  
......
235 254
        /// <param name="e"></param>
236 255
        void _markuptoPDF_EndFinal(object sender, MarkupToPDF.EndFinalEventArgs e)
237 256
        {
257
            _Logger.Write($"End Final FinalID:{e.FinalPDF.ID} / Output:{e.FinalPDFPath} / Message :{e.Message}", LogLevel.Info);
258

  
238 259
            var _T = WorkingList.Where(t => t == (sender as MarkupToPDF.MarkupToPDF).FinalItem);
239 260
            if (_T.Count() > 0)
240 261
            {
......
251 272
                    {
252 273
                        object[] parameters = new object[] { pdfpath, e.OriginPDFName, e.FinalPDF, soapurl };
253 274

  
254
                        //Program.FileLogger.Debug("Call Upload Final .." + filename + ",pdfname:" + e.OriginPDFName);
255

  
275
                        _Logger.Write("Call Upload Final .." + filename + ",pdfname:" + e.OriginPDFName,LogLevel.Info);
256 276

  
257 277
                        KeyValuePair<bool, string> result = (KeyValuePair<bool, string>)(Program.UploadFinalPDFMethod.Invoke(Program.UploadFinalPDFInst, parameters));
258 278

  
......
263 283
                        else
264 284
                        {
265 285
                            SetFinalState(_item.ID, FinalStatus.Error);
266
                            Program.FileLogger.Debug("Upload error .." + filename + ",pdfname:" + e.OriginPDFName);
286
                            _Logger.Write("Upload error  .." + filename + ",pdfname:" + e.OriginPDFName, LogLevel.Error);
267 287
                        }
268 288
                    }
269 289
                    else
......
279 299
                            System.IO.Directory.CreateDirectory(saveFolder);
280 300
                        }
281 301

  
282
                        Program.FileLogger.Debug(String.Format("saveFolder : {0}", saveFolder));
302
                        _Logger.Write(String.Format("saveFolder : {0}", saveFolder), LogLevel.Info);
283 303

  
284 304
                        try
285 305
                        {
286 306
                            System.IO.File.Copy(e.FinalPDFPath, saveFolder + e.OriginPDFName, true);
307

  
308
                            _Logger.Write($"End Final SaveFile :{saveFolder + e.OriginPDFName}", LogLevel.Info);
287 309
                        }
288 310
                        catch (Exception ex)
289 311
                        {
290
                            Program.FileLogger.Fatal(ex);
312
                            _Logger.Write(ex);
291 313
                        }
292 314

  
293 315
                        using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(_item.PROJECT_NO).ToString()))
......
300 322
                            {
301 323
                                item.RESULT_FILE = String.Format(resultpath, _item.PROJECT_NO, sFolder, _item.DOCUMENT_ID, e.OriginPDFName);
302 324
                            }
303
                            catch (Exception)
325
                            catch (Exception ex)
304 326
                            {
305
                                Program.FileLogger.Fatal(new Exception($"DebugResultUrlPath의 Index를 확인 하세요.{resultpath}"));
327
                                _Logger.Write(new Exception($"DebugResultUrlPath의 Index를 확인 하세요.{resultpath}",ex));
306 328
                            }
307 329

  
308
                            sendReqLog("RESULT_FILE_PATH", item.RESULT_FILE);
330
                            _Logger.Write($"End FinalId:{item.ID} RESULT_FILE_PATH:{item.RESULT_FILE}",LogLevel.Info);
309 331
                            _entity.SaveChanges();
310 332
                            SetFinalState(_item.ID, FinalStatus.Success);
311 333
                        }
......
314 336
                catch (Exception ex)
315 337
                {
316 338
                    SetFinalState(_item.ID, FinalStatus.Error);
317
                    Program.FileLogger.Fatal(ex);
339
                    _Logger.Write(ex);
318 340
                }
319 341
                finally
320 342
                {
......
379 401
            }
380 402
            catch (Exception ex)
381 403
            {
382
                Program.FileLogger.Fatal(ex);
404
                _Logger.Write(ex);
383 405
            }
384 406
        }
385 407

  
386 408
        void _markuptoPDF_FinalMakeError(object sender, MarkupToPDF.MakeFinalErrorArgs e)
387 409
        {
410
            _Logger.Write($"FinalID:{e.FinalID} / Message :{e.Message}",LogLevel.Info);
411

  
388 412
            SetError(e.FinalID, e.Message);
389 413

  
390 414
            var _T = WorkingList.Where(t => t == (sender as MarkupToPDF.MarkupToPDF).FinalItem);
FinalService/KCOM_FinalService/KCOM_FinalServiceConsole/App.config
1
<?xml version="1.0" encoding="utf-8" ?>
2
<configuration>
3
    <startup> 
4
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5
    </startup>
6
</configuration>
FinalService/KCOM_FinalService/KCOM_FinalServiceConsole/KCOM_FinalServiceConsole.csproj
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
  <PropertyGroup>
5
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
    <ProjectGuid>{824A4880-EDEA-4F50-9207-F8B9E3096375}</ProjectGuid>
8
    <OutputType>Exe</OutputType>
9
    <RootNamespace>KCOM_FinalService</RootNamespace>
10
    <AssemblyName>KCOM_FinalService</AssemblyName>
11
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12
    <FileAlignment>512</FileAlignment>
13
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14
    <Deterministic>true</Deterministic>
15
  </PropertyGroup>
16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17
    <PlatformTarget>AnyCPU</PlatformTarget>
18
    <DebugSymbols>true</DebugSymbols>
19
    <DebugType>full</DebugType>
20
    <Optimize>false</Optimize>
21
    <OutputPath>bin\Debug\</OutputPath>
22
    <DefineConstants>DEBUG;TRACE</DefineConstants>
23
    <ErrorReport>prompt</ErrorReport>
24
    <WarningLevel>4</WarningLevel>
25
  </PropertyGroup>
26
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27
    <PlatformTarget>AnyCPU</PlatformTarget>
28
    <DebugType>pdbonly</DebugType>
29
    <Optimize>true</Optimize>
30
    <OutputPath>bin\Release\</OutputPath>
31
    <DefineConstants>TRACE</DefineConstants>
32
    <ErrorReport>prompt</ErrorReport>
33
    <WarningLevel>4</WarningLevel>
34
  </PropertyGroup>
35
  <ItemGroup>
36
    <None Include="App.config" />
37
  </ItemGroup>
38
  <ItemGroup>
39
    <Compile Include="Program.cs" />
40
  </ItemGroup>
41
  <ItemGroup>
42
    <ProjectReference Include="..\KCOM_FinalService\KCOM_FinalService.csproj">
43
      <Project>{2be3f054-d494-4712-927f-47e2ffb52170}</Project>
44
      <Name>KCOM_FinalService</Name>
45
    </ProjectReference>
46
  </ItemGroup>
47
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
48
</Project>
FinalService/KCOM_FinalService/KCOM_FinalServiceConsole/Program.cs
1
#if DEBUG
2
using KCOMDataModel.DataModel;
3
#endif
4
using System;
5
using System.IO;
6
using System.Reflection;
7
using System.ServiceProcess;
8
using log4net;
9

  
10
namespace KCOM_FinalService
11
{
12
    static class Program
13
    {
14
        /// <summary>
15
        /// Application Data Folder
16
        /// </summary>
17
        public static string AppDataFolder
18
        {
19
            get
20
            {
21
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS");
22
            }
23
        }
24

  
25
        public static ILog FileLogger = null;
26
        public static ServiceBase[] ServicesToRun = null;
27

  
28
        public static MethodInfo UploadFinalPDFMethod { get; set; }
29
        public static object UploadFinalPDFInst { get; set; }
30

  
31
        /// <summary>
32
        /// The main entry point for the application.
33
        /// </summary>
34
        static void Main(string[] args)
35
        {
36
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
37

  
38
            log4net.GlobalContext.Properties["LogFilePath"] = Path.Combine(AppDataFolder, "Log", "FinalService.log");
39
            Program.FileLogger = LogManager.GetLogger("EventLogger");
40

  
41
            /// get legacy interface for upload final pdf file
42
            string UploadFinalDllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFinal.dll");
43
            if (File.Exists(UploadFinalDllPath))
44
            {
45
                Assembly asm = Assembly.LoadFrom(UploadFinalDllPath);
46
                Type _UploadFinalClassType = asm.GetType("UploadFinal.UploadFinal");
47

  
48
                //Legacy IF
49
                Program.UploadFinalPDFMethod = _UploadFinalClassType.GetMethod("UploadFinalPDF", new Type[] { typeof(string), typeof(string), typeof(KCOMDataModel.DataModel.FINAL_PDF), typeof(string) });
50
                if (null != Program.UploadFinalPDFMethod)
51
                {
52
                    Program.UploadFinalPDFInst = Activator.CreateInstance(_UploadFinalClassType, null);
53
                }
54
            }
55

  
56
            if (Environment.UserInteractive)
57
            {
58
                try
59
                {
60
                    MarkusFinalService service = new MarkusFinalService();
61
                    service.TestStartupAndStop(args);
62

  
63
                }
64
                catch (Exception ex)
65
                {
66
                    Console.WriteLine(ex);
67
                }
68
            }
69
            else
70
            {
71
                /// up to here
72
                ServicesToRun = new ServiceBase[]
73
                {  new MarkusFinalService()
74
                };
75
                ServiceBase.Run(ServicesToRun);
76
            }
77
        }
78

  
79
        /// <summary>
80
        /// log unhandled exception
81
        /// </summary>
82
        /// <author>humkyung</author>
83
        /// <date>2019.06.04</date>
84
        /// <param name="sender"></param>
85
        /// <param name="e"></param>
86
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
87
        {
88
            try
89
            {
90
                Program.FileLogger.Fatal(e.ExceptionObject as Exception);
91
            }
92
            catch (Exception ex)
93
            {
94
                Console.WriteLine(ex.InnerException.ToString());
95
            }
96
            finally
97
            {
98
            }
99
        }
100
    }
101
}
FinalService/KCOM_FinalService/KCOM_FinalService_Console/App.config
1
<?xml version="1.0" encoding="utf-8" ?>
2
<configuration>
3
    <configSections>
4
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5
            <section name="KCOM_FinalService_Console.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6
        </sectionGroup>
7
    </configSections>
8
    <startup> 
9
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
10
    </startup>
11
    <userSettings>
12
        <KCOM_FinalService_Console.Properties.Settings>
13
            <setting name="RemotingPort" serializeAs="String">
14
                <value>9092</value>
15
            </setting>
16
            <setting name="MultipleFinalCount" serializeAs="String">
17
                <value>15</value>
18
            </setting>
19
        </KCOM_FinalService_Console.Properties.Settings>
20
    </userSettings>
21
</configuration>
FinalService/KCOM_FinalService/KCOM_FinalService_Console/Common/ServiceEventLog.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Diagnostics;
6
using System.Linq;
7

  
8
using System.Text;
9

  
10
namespace KCOM_FinalService.Common
11
{
12
    public partial class ServiceEventLog 
13
    {
14
        public ServiceEventLog()
15
        {
16
           
17
        }
18

  
19
    
20
        public void Write(string Header, string Message)
21
        {
22
            Console.WriteLine(" {0} : {1} ", Header, Message);
23
        }
24

  
25
    }
26
}
FinalService/KCOM_FinalService/KCOM_FinalService_Console/FinalService.cs
1
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

  
10
using System.Text;
11
using System.Threading;
12

  
13
namespace KCOM_FinalService
14
{
15
    public partial class FinalService 
16
    {
17
        #region PROPERTIES
18
        System.Timers.Timer _Timer = new System.Timers.Timer();
19
        RemFinalPDFStation _remotingFinal = null;
20
        ServiceEventLog _log = null;
21
        public ServiceEventLog Logger
22
        {
23
            get { return this._log; }
24
        }
25

  
26
        Thread _FirewallOpenThread = null;
27
        #endregion
28

  
29
        public FinalService()
30
        {
31
            
32

  
33
            _log = new ServiceEventLog();
34
            _Timer.Interval = 60000; //잉 왜 60분으로 했더라..
35
            _Timer.Elapsed += _Timer_Elapsed;
36
            _remotingFinal = new RemFinalPDFStation(_log);
37
        }
38

  
39
        private void _Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
40
        {
41
            _log.Write("FinalService","FinalService가 정상적으로 실행 중입니다 " + DateTime.Now);
42
        }
43

  
44
        public void OnStart()
45
        {
46
            _log.Write("OnStart", "Service");
47
            _remotingFinal = new RemFinalPDFStation(_log);
48
            _Timer.Enabled = true;
49
        }
50

  
51
        public void OnStop()
52
        {
53
            _remotingFinal.Dispose();
54
        }
55
    }
56
}
FinalService/KCOM_FinalService/KCOM_FinalService_Console/KCOM_FinalService_Console.csproj
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
  <PropertyGroup>
5
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
    <ProjectGuid>{35CC3A14-08A0-4828-9A29-61A3989ECE52}</ProjectGuid>
8
    <OutputType>Exe</OutputType>
9
    <RootNamespace>KCOM_FinalService_Console</RootNamespace>
10
    <AssemblyName>KCOM_FinalService_Console</AssemblyName>
11
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12
    <FileAlignment>512</FileAlignment>
13
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14
    <Deterministic>true</Deterministic>
15
  </PropertyGroup>
16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17
    <PlatformTarget>AnyCPU</PlatformTarget>
18
    <DebugSymbols>true</DebugSymbols>
19
    <DebugType>full</DebugType>
20
    <Optimize>false</Optimize>
21
    <OutputPath>bin\Debug\</OutputPath>
22
    <DefineConstants>DEBUG;TRACE</DefineConstants>
23
    <ErrorReport>prompt</ErrorReport>
24
    <WarningLevel>4</WarningLevel>
25
  </PropertyGroup>
26
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27
    <PlatformTarget>AnyCPU</PlatformTarget>
28
    <DebugType>pdbonly</DebugType>
29
    <Optimize>true</Optimize>
30
    <OutputPath>bin\Release\</OutputPath>
31
    <DefineConstants>TRACE</DefineConstants>
32
    <ErrorReport>prompt</ErrorReport>
33
    <WarningLevel>4</WarningLevel>
34
  </PropertyGroup>
35
  <ItemGroup>
36
    <Reference Include="System" />
37
    <Reference Include="System.Core" />
38
    <Reference Include="System.Data.Entity" />
39
    <Reference Include="System.Runtime.Remoting" />
40
    <Reference Include="System.Xml.Linq" />
41
    <Reference Include="System.Data.DataSetExtensions" />
42
    <Reference Include="Microsoft.CSharp" />
43
    <Reference Include="System.Data" />
44
    <Reference Include="System.Net.Http" />
45
    <Reference Include="System.Xml" />
46
  </ItemGroup>
47
  <ItemGroup>
48
    <Compile Include="Common\ServiceEventLog.cs" />
49
    <Compile Include="FinalService.cs" />
50
    <Compile Include="Program.cs" />
51
    <Compile Include="Properties\AssemblyInfo.cs" />
52
    <Compile Include="Properties\Settings.Designer.cs">
53
      <AutoGen>True</AutoGen>
54
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
55
      <DependentUpon>Settings.settings</DependentUpon>
56
    </Compile>
57
    <Compile Include="Remoting\RemFinalPDFStation.cs" />
58
  </ItemGroup>
59
  <ItemGroup>
60
    <None Include="App.config" />
61
    <None Include="Properties\Settings.settings">
62
      <Generator>SettingsSingleFileGenerator</Generator>
63
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
64
    </None>
65
  </ItemGroup>
66
  <ItemGroup>
67
    <ProjectReference Include="..\CommonLib\CommonLib.csproj">
68
      <Project>{ee9aaabc-1678-43a4-878e-cedbb577cf01}</Project>
69
      <Name>CommonLib</Name>
70
    </ProjectReference>
71
    <ProjectReference Include="..\IFinalPDF\IFinalPDF.csproj">
72
      <Project>{784438be-2074-41ae-a692-24e1a4a67fe3}</Project>
73
      <Name>IFinalPDF</Name>
74
    </ProjectReference>
75
    <ProjectReference Include="..\KCOMDataModel\KCOMDataModel.csproj">
76
      <Project>{629dc8cd-d458-47ef-8f02-cd12c7001c3e}</Project>
77
      <Name>KCOMDataModel</Name>
78
    </ProjectReference>
79
    <ProjectReference Include="..\MarkupToPDF\MarkupToPDF.csproj">
80
      <Project>{a714bd67-8aac-4ed8-8ecf-7853c3549a68}</Project>
81
      <Name>MarkupToPDF</Name>
82
    </ProjectReference>
83
  </ItemGroup>
84
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85
</Project>
FinalService/KCOM_FinalService/KCOM_FinalService_Console/Program.cs
1
using KCOM_FinalService;
2
using KCOM_FinalService.Remoting;
3
using System;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8

  
9
namespace KCOM_FinalService_Console
10
{
11
    class Program
12
    {
13
        static void Main(string[] args)
14
        {
15
            var convertStartion = new FinalService();
16
#if Release
17
            ServiceBase[] ServicesToRun;
18
            ServicesToRun = new ServiceBase[] 
19
			{ 
20
				convertStartion
21
			};
22
            ServiceBase.Run(ServicesToRun);
23
#else
24
            Console.WriteLine("ConverterStation Start()");
25

  
26
            while (true)
27
            {
28
                convertStartion.OnStart();
29
                var item = Console.ReadLine();
30
            }
31
#endif
32
        }
33
    }
34
}
FinalService/KCOM_FinalService/KCOM_FinalService_Console/Properties/AssemblyInfo.cs
1
using System.Reflection;
2
using System.Runtime.CompilerServices;
3
using System.Runtime.InteropServices;
4

  
5
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 
6
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
7
// 이러한 특성 값을 변경하세요.
8
[assembly: AssemblyTitle("KCOM_FinalService_Console")]
9
[assembly: AssemblyDescription("")]
10
[assembly: AssemblyConfiguration("")]
11
[assembly: AssemblyCompany("")]
12
[assembly: AssemblyProduct("KCOM_FinalService_Console")]
13
[assembly: AssemblyCopyright("Copyright ©  2019")]
14
[assembly: AssemblyTrademark("")]
15
[assembly: AssemblyCulture("")]
16

  
17
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 
18
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
19
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
20
[assembly: ComVisible(false)]
21

  
22
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
23
[assembly: Guid("35cc3a14-08a0-4828-9a29-61a3989ece52")]
24

  
25
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
26
//
27
//      주 버전
28
//      부 버전 
29
//      빌드 번호
30
//      수정 버전
31
//
32
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로
33
// 지정되도록 할 수 있습니다.
34
// [assembly: AssemblyVersion("1.0.*")]
35
[assembly: AssemblyVersion("1.0.0.0")]
36
[assembly: AssemblyFileVersion("1.0.0.0")]
FinalService/KCOM_FinalService/KCOM_FinalService_Console/Properties/Settings.Designer.cs
1
//------------------------------------------------------------------------------
2
// <auto-generated>
3
//     이 코드는 도구를 사용하여 생성되었습니다.
4
//     런타임 버전:4.0.30319.42000
5
//
6
//     파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
7
//     이러한 변경 내용이 손실됩니다.
8
// </auto-generated>
9
//------------------------------------------------------------------------------
10

  
11
namespace KCOM_FinalService_Console.Properties {
12
    
13
    
14
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
16
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17
        
18
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19
        
20
        public static Settings Default {
21
            get {
22
                return defaultInstance;
23
            }
24
        }
25
        
26
        [global::System.Configuration.UserScopedSettingAttribute()]
27
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28
        [global::System.Configuration.DefaultSettingValueAttribute("9092")]
29
        public int RemotingPort {
30
            get {
31
                return ((int)(this["RemotingPort"]));
32
            }
33
            set {
34
                this["RemotingPort"] = value;
35
            }
36
        }
37
        
38
        [global::System.Configuration.UserScopedSettingAttribute()]
39
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
40
        [global::System.Configuration.DefaultSettingValueAttribute("15")]
41
        public int MultipleFinalCount {
42
            get {
43
                return ((int)(this["MultipleFinalCount"]));
44
            }
45
            set {
46
                this["MultipleFinalCount"] = value;
47
            }
48
        }
49
    }
50
}
FinalService/KCOM_FinalService/KCOM_FinalService_Console/Properties/Settings.settings
1
<?xml version='1.0' encoding='utf-8'?>
2
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="KCOM_FinalService_Console.Properties" GeneratedClassName="Settings">
3
  <Profiles />
4
  <Settings>
5
    <Setting Name="RemotingPort" Type="System.Int32" Scope="User">
6
      <Value Profile="(Default)">9092</Value>
7
    </Setting>
8
    <Setting Name="MultipleFinalCount" Type="System.Int32" Scope="User">
9
      <Value Profile="(Default)">15</Value>
10
    </Setting>
11
  </Settings>
12
</SettingsFile>
FinalService/KCOM_FinalService/KCOM_FinalService_Console/Remoting/RemFinalPDFStation.cs
1
using IFinalPDF;
2
using KCOM_FinalService.Common;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using System;
6
using System.Collections.Concurrent;
7
using System.Collections.Generic;
8
using System.IO;
9
using System.Linq;
10
using System.Reflection;
11
using System.Runtime.Remoting.Channels.Tcp;
12
using System.Threading;
13
using System.Threading.Tasks;
14

  
15
namespace KCOM_FinalService.Remoting
16
{
17
    public class RemFinalPDFStation : InterfaceFinalPDF, IDisposable
18
    {
19
        #region Properties
20
        TcpChannel _Channel = null;
21
        ServiceEventLog _Log = null;
22
        Thread _FinalPDFThread = null;
23
        string _NoticeMessageBase = null;
24
        string _NoticeTitleBase = null;
25
        string _MyIP = null;
26
        int _TypeName = 1;
27
        readonly KCOM_FinalService_Console.Properties.Settings _SettingPlace = null;
28

  
29
        //Queue<FINAL_PDF> _WorkItem = new Queue<FINAL_PDF>();
30
        ConcurrentQueue<FINAL_PDF> WorkingQueue = null;
31
        List<FINAL_PDF> WaitThread = null;
32
        List<FINAL_PDF> WorkingThread = null;
33

  
34
        private Type _UploadFinalType { get; set; }   /// upload final class type
35
            #endregion
36

  
37
        public RemFinalPDFStation()
38
        {
39
            System.Diagnostics.EventLog _eventLog = new System.Diagnostics.EventLog();
40
           
41

  
42
            /// get legacy interface for upload final pdf file
43
            string UploadFinalDllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFinal.dll");
44
           
45
            if (File.Exists(UploadFinalDllPath))
46
            {
47
                Assembly asm = Assembly.LoadFrom(UploadFinalDllPath);
48
                this._UploadFinalType = asm.GetType("UploadFinal.UploadFinal");
49
            }
50
            /// up to here
51

  
52
            Init();
53
        }
54

  
55
        public RemFinalPDFStation(int MultipleFinalCount)
56
        {
57
            System.Diagnostics.EventLog _eventlog = new System.Diagnostics.EventLog();
58
         
59

  
60
            /// get legacy interface for upload final pdf file
61
            string UploadFinalDllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFinal.dll");
62
         
63
            if (File.Exists(UploadFinalDllPath))
64
            {
65
                Assembly asm = Assembly.LoadFrom(UploadFinalDllPath);
66
                this._UploadFinalType = asm.GetType("UploadFinal.UploadFinal");
67
            }
68
            /// up to here
69

  
70
            Init();
71
        }
72

  
73
        public RemFinalPDFStation(ServiceEventLog eventLog)
74
        {
75
            _Log = eventLog;
76
            Init();
77
        }
78

  
79
      
80

  
81
        public void Init()
82
        {
83
            try
84
            {
85
                //_MyIP = System.Net.Dns.Resolve(System.Net.Dns.GetHostName()).AddressList[0].ToString();
86
                using (KCOMDataModel.DataModel.KCOMEntities _systemEntity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
87
                {
88
#if DEBUG
89
                    _TypeName = 1; //FINAL은 현재 타입이 1임
90
#else
91
                    _TypeName = 1;
92
                    ///TODO: check below code
93
                    ///_TypeName = _systemEntity.SERVICE_PROPERTIES.Where(data => data.SERVICE_ADDRESS == _MyIP).FirstOrDefault().SERVICET_TYPE;
94
#endif
95
                }
96
                _Log.Write("ConnectString :", KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString());
97
                _Channel = new TcpChannel(KCOM_FinalService_Console.Properties.Settings.Default.RemotingPort);
98
                _Log.Write("Port", KCOM_FinalService_Console.Properties.Settings.Default.RemotingPort.ToString());
99
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_Channel, false);
100
                System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemFinalPDFObject), "remFinalPDF", System.Runtime.Remoting.WellKnownObjectMode.Singleton);
101
                WorkingQueue = new ConcurrentQueue<FINAL_PDF>();                
102
                WorkingThread = new List<FINAL_PDF>();
103
                WaitThread = new List<FINAL_PDF>();
104
                if(WorkingQueue !=null)
105
                    _Log.Write("WorkingQueue : ", WorkingQueue.GetType().Name);
106
                else
107
                    _Log.Write("WorkingQueue : ", "null");
108
            }
109
            catch (Exception EX)
110
            {
111
                if (_Log != null)
112
                {
113
                
114
                }
115
            }
116
            IFinalPDF.Cache.Attach(this);
117
        }
118

  
119
        private void SetFinalState(string finalID, FinalStatus status)
120
        {
121
            _Log.Write("finalID : ", finalID);
122

  
123
            using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
124
            {
125
                var finalList = _entity.FINAL_PDF.Where(final => final.ID == finalID);
126

  
127
                if (finalList.Count() > 0)
128
                {
129
                    if (status == FinalStatus.Create)
130
                    {
131
                        finalList.First().START_DATETIME = DateTime.Now;
132
                    }
133
                    if (status == FinalStatus.Success)
134
                    {
135
                        finalList.First().END_DATETIME = DateTime.Now;
136
                    }
137

  
138
                    finalList.First().STATUS = (int)status;
139
                    _entity.SaveChanges();
140
                }
141
            };
142
        }
143

  
144
        public void Dispose()
145
        {
146
            if (_Channel != null)
147
            {
148
                System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(_Channel);
149
            }
150
        }
151
        private void FinalPDFEnqueue(FINAL_PDF pdf)
152
        {
153
            _Log.Write("FinalPDFEnqueue : ", pdf.MARKUPINFO_ID);
154
            Task tEnq = Task.Factory.StartNew(() =>
155
            {
156
                WorkingQueue.Enqueue(pdf);
157
                Thread.Sleep(100);                
158
            });
159
            FinalPDFDequeueThreadStart();
160
        }        
161
        private void FinalPDFDequeueThreadStart()
162
        {
163
            _FinalPDFThread = new Thread(new ThreadStart(FinalPDFDequeueandProcessing));
164
            _FinalPDFThread.SetApartmentState(ApartmentState.STA);
165
            _FinalPDFThread.Start();
166
        }        
167
        
168
        private void FinalPDFDequeueandProcessing()
169
        {
170
            Task tDeq = Task.Factory.StartNew(() =>
171
            {
172
                _Log.Write("FinalService", "StartNew()");
173

  
174
                FINAL_PDF _item = new FINAL_PDF();
175

  
176

  
177
                try
178
                {
179
                    if (WorkingQueue == null)
180
                    {
181
                        WorkingQueue = new ConcurrentQueue<FINAL_PDF>();
182
                    }
183
                    _Log.Write("WorkingQueue", WorkingQueue.Count.ToString());
184
                    while (WorkingQueue.Count > 0)
185
                    {
186

  
187
                        if (WorkingQueue.TryDequeue(out _item))
188
                        {
189
                            _Log.Write("TryDequeue _item", _item.ID);
190

  
191
                            if (WorkingThread.Count() < KCOM_FinalService_Console.Properties.Settings.Default.MultipleFinalCount)
192
                            {
193
                                if (_item.STATUS == (int)FinalStatus.Insert)
194
                                {
195
                                    _item.STATUS = (int)(FinalStatus.Wait);
196
                                    using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
197
                                    {
198
                                        var selectItem = _entity.FINAL_PDF.Where(data => data.ID == _item.ID).FirstOrDefault();
199

  
200
                                        selectItem.STATUS = (int)(FinalStatus.Wait);
201

  
202
                                        _entity.SaveChanges();
203
                                    }
204
                                }
205
                                var _identPathItem = WorkingThread.Where(item => item.DOCUMENT_ID == _item.DOCUMENT_ID);                                
206

  
207
                                if (_identPathItem.Count() > 0)
208
                                {
209
                                    WaitThread.Add(_item);
210
                                }
211
                                else
212
                                {
213
                                    MarkupToPDF.MarkupToPDF _markuptoPDF = new MarkupToPDF.MarkupToPDF();
214
                                    _markuptoPDF.FinalMakeError += new EventHandler<MarkupToPDF.MakeFinalErrorArgs>(_markuptoPDF_FinalMakeError);
215
                                    _markuptoPDF.EndFinal += new EventHandler<MarkupToPDF.EndFinalEventArgs>(_markuptoPDF_EndFinal);
216
                                    Thread _stathread = new Thread(new ParameterizedThreadStart(_markuptoPDF.MakeFinalPDF))
217
                                    {
218
                                        Name = _item.ID.ToString()
219
                                    };
220
                                    SetFinalState(_item.ID, IFinalPDF.FinalStatus.Create);
221
                                    //_stathread.Priority = ThreadPriority.Normal;
222
                                    _stathread.SetApartmentState(ApartmentState.STA);
223
                                    _stathread.Start(_item);
224
                                    WorkingThread.Add(_item);
225
                                }
226
                            }
227
                        }
228
                        Thread.Sleep(100);
229
                    }
230
                }
231
                catch (Exception ex)
232
                {
233
                    _Log.Write("FinalService", "FinalPDFDequeueandProcessing error:" + ex.ToString());
234
                }
235
                
236
            });
237
        }
238
        public FinalPDFResult Notify(string ProjectNo, string FinalID)
239
        {
240
            using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
241
            {
242
                var finalpdf = _entity.FINAL_PDF.Where(final => final.ID == FinalID).FirstOrDefault();
243
                FinalPDFEnqueue(finalpdf);
244
                //FinalPDFProcessStart(finalList.ToList());
245
            }            
246
            ///TODO: why return FinalPDFResult?
247
            return new FinalPDFResult();
248
        }
249

  
250
        void _markuptoPDF_EndFinal(object sender, MarkupToPDF.EndFinalEventArgs e)
251
        {
252
            var _T = WorkingThread.Where(t => t == (sender as MarkupToPDF.MarkupToPDF).FinalItem);
253

  
254
            if (_T.Count() > 0)
255
            {
256
                FINAL_PDF _item = _T.First();
257

  
258
                SetFinalState(_item.ID, FinalStatus.PdfStamp);
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)