개정판 eeecdd4b
FinalProcess, Final Service 수정
Log Class -> Common Lib Class로 이동
Change-Id: Ib79cfd65f2e75699a6c2193575cf8cfa6ec42154
FinalService/KCOM_FinalService_DL/CommonLib/Common.cs | ||
---|---|---|
61 | 61 |
return Encoding.UTF8.GetString(plainText); |
62 | 62 |
} |
63 | 63 |
} |
64 |
|
|
65 |
public enum ELogLv |
|
66 |
{ |
|
67 |
info = 2, |
|
68 |
warn = 1, |
|
69 |
error = 0, |
|
70 |
} |
|
71 |
|
|
72 |
public class LogManager |
|
73 |
{ |
|
74 |
FileStream fileStream = null; |
|
75 |
StreamWriter streamWrite = null; |
|
76 |
public ELogLv eCurLogLv = ELogLv.info; |
|
77 |
|
|
78 |
public LogManager() |
|
79 |
{ |
|
80 |
CreateLogFile(); |
|
81 |
} |
|
82 |
|
|
83 |
public void CreateLogFile() |
|
84 |
{ |
|
85 |
string strNowTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); |
|
86 |
|
|
87 |
if (Directory.Exists("log") == false) |
|
88 |
Directory.CreateDirectory("log"); |
|
89 |
|
|
90 |
fileStream = new FileStream($"log\\log.{strNowTime}.txt", FileMode.CreateNew); |
|
91 |
streamWrite = new StreamWriter(fileStream, System.Text.Encoding.UTF8); |
|
92 |
} |
|
93 |
|
|
94 |
public void Log(ELogLv eLogLv, string desc) |
|
95 |
{ |
|
96 |
// eLogLv이 info이면 -> info, warn, error 로그 남김 |
|
97 |
// eLogLv이 warn이면 -> warn, error 로그 남김 |
|
98 |
// eLogLv이 error이면 -> error 로그 남김 |
|
99 |
if (eCurLogLv < eLogLv) |
|
100 |
return; |
|
101 |
|
|
102 |
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true); |
|
103 |
string funcName = stackFrame.GetMethod().Name; |
|
104 |
string fileName = stackFrame.GetFileName(); |
|
105 |
string fileLine = stackFrame.GetFileLineNumber().ToString(); |
|
106 |
|
|
107 |
// ,(콤마)는 .csv 파일에서 구분문자로 사용 |
|
108 |
desc = desc.Replace(",", "."); |
|
109 |
|
|
110 |
desc = $"{eLogLv.ToString()},\t{desc},\t{funcName},\t{fileName} {fileLine},\t{DateTime.Now}"; |
|
111 |
|
|
112 |
streamWrite.WriteLine(desc); |
|
113 |
streamWrite.Flush(); |
|
114 |
fileStream.Flush(); |
|
115 |
|
|
116 |
Int64 fileSize = fileStream.Length; |
|
117 |
|
|
118 |
// 파일 사이즈가 2메가가 넘으면 해당 파일 닫은 후 파일 생성 |
|
119 |
if (fileSize > 2097152) |
|
120 |
{ |
|
121 |
streamWrite.Close(); |
|
122 |
fileStream.Close(); |
|
123 |
CreateLogFile(); |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
64 | 127 |
} |
FinalService/KCOM_FinalService_DL/FinalProcess/FinalProcess.csproj | ||
---|---|---|
73 | 73 |
</PackageReference> |
74 | 74 |
</ItemGroup> |
75 | 75 |
<ItemGroup> |
76 |
<ProjectReference Include="..\CommonLib\CommonLib.csproj"> |
|
77 |
<Project>{ee9aaabc-1678-43a4-878e-cedbb577cf01}</Project> |
|
78 |
<Name>CommonLib</Name> |
|
79 |
</ProjectReference> |
|
76 | 80 |
<ProjectReference Include="..\IFinalPDF\IFinalPDF.csproj"> |
77 | 81 |
<Project>{784438be-2074-41ae-a692-24e1a4a67fe3}</Project> |
78 | 82 |
<Name>IFinalPDF</Name> |
FinalService/KCOM_FinalService_DL/FinalProcess/Program.cs | ||
---|---|---|
9 | 9 |
using System.Text; |
10 | 10 |
using System.Threading.Tasks; |
11 | 11 |
using System.Windows.Forms; |
12 |
using static System.Windows.Forms.AxHost; |
|
13 |
using static System.Windows.Forms.VisualStyles.VisualStyleElement; |
|
12 | 14 |
|
13 | 15 |
namespace FinalProcess |
14 | 16 |
{ |
... | ... | |
18 | 20 |
/// <summary> |
19 | 21 |
/// protected static ILog logger; |
20 | 22 |
/// </summary> |
21 |
public static LogManager logger { get; } = new LogManager();
|
|
23 |
public static CommonLib.LogManager logger { get; } = new CommonLib.LogManager();
|
|
22 | 24 |
public static FINAL_PDF finalPdf = null; |
23 | 25 |
public static string RemoteAddress = null; |
24 | 26 |
|
25 |
public enum ELogLv |
|
26 |
{ |
|
27 |
info = 2, |
|
28 |
warn = 1, |
|
29 |
error = 0, |
|
30 |
} |
|
31 |
|
|
32 |
public class LogManager |
|
33 |
{ |
|
34 |
FileStream fileStream = null; |
|
35 |
StreamWriter streamWrite = null; |
|
36 |
public ELogLv eCurLogLv = ELogLv.info; |
|
37 |
|
|
38 |
public LogManager() |
|
39 |
{ |
|
40 |
CreateLogFile(); |
|
41 |
} |
|
42 |
|
|
43 |
public void CreateLogFile() |
|
44 |
{ |
|
45 |
string strNowTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); |
|
46 |
|
|
47 |
if (Directory.Exists("log") == false) |
|
48 |
Directory.CreateDirectory("log"); |
|
49 |
|
|
50 |
fileStream = new FileStream($"log\\log.{strNowTime}.txt", FileMode.CreateNew); |
|
51 |
streamWrite = new StreamWriter(fileStream, System.Text.Encoding.UTF8); |
|
52 |
} |
|
53 |
|
|
54 |
public void Log(ELogLv eLogLv, string desc) |
|
55 |
{ |
|
56 |
// eLogLv이 info이면 -> info, warn, error 로그 남김 |
|
57 |
// eLogLv이 warn이면 -> warn, error 로그 남김 |
|
58 |
// eLogLv이 error이면 -> error 로그 남김 |
|
59 |
if (eCurLogLv < eLogLv) |
|
60 |
return; |
|
61 |
|
|
62 |
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true); |
|
63 |
string funcName = stackFrame.GetMethod().Name; |
|
64 |
string fileName = stackFrame.GetFileName(); |
|
65 |
string fileLine = stackFrame.GetFileLineNumber().ToString(); |
|
66 |
|
|
67 |
// ,(콤마)는 .csv 파일에서 구분문자로 사용 |
|
68 |
desc = desc.Replace(",", "."); |
|
69 |
|
|
70 |
desc = $"{eLogLv.ToString()},\t{desc},\t{funcName},\t{fileName} {fileLine},\t{DateTime.Now}"; |
|
71 |
|
|
72 |
streamWrite.WriteLine(desc); |
|
73 |
streamWrite.Flush(); |
|
74 |
fileStream.Flush(); |
|
75 |
|
|
76 |
Int64 fileSize = fileStream.Length; |
|
77 |
|
|
78 |
// 파일 사이즈가 2메가가 넘으면 해당 파일 닫은 후 파일 생성 |
|
79 |
if (fileSize > 2097152) |
|
80 |
{ |
|
81 |
streamWrite.Close(); |
|
82 |
fileStream.Close(); |
|
83 |
CreateLogFile(); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
27 |
#region CommonLib로 옮김 |
|
28 |
//public enum ELogLv |
|
29 |
//{ |
|
30 |
// info = 2, |
|
31 |
// warn = 1, |
|
32 |
// error = 0, |
|
33 |
//} |
|
34 |
|
|
35 |
//public class LogManager |
|
36 |
//{ |
|
37 |
// FileStream fileStream = null; |
|
38 |
// StreamWriter streamWrite = null; |
|
39 |
// public ELogLv eCurLogLv = ELogLv.info; |
|
40 |
|
|
41 |
// public LogManager() |
|
42 |
// { |
|
43 |
// CreateLogFile(); |
|
44 |
// } |
|
45 |
|
|
46 |
// public void CreateLogFile() |
|
47 |
// { |
|
48 |
// string strNowTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); |
|
49 |
|
|
50 |
// if (Directory.Exists("log") == false) |
|
51 |
// Directory.CreateDirectory("log"); |
|
52 |
|
|
53 |
// fileStream = new FileStream($"log\\log.{strNowTime}.txt", FileMode.CreateNew); |
|
54 |
// streamWrite = new StreamWriter(fileStream, System.Text.Encoding.UTF8); |
|
55 |
// } |
|
56 |
|
|
57 |
// public void Log(ELogLv eLogLv, string desc) |
|
58 |
// { |
|
59 |
// // eLogLv이 info이면 -> info, warn, error 로그 남김 |
|
60 |
// // eLogLv이 warn이면 -> warn, error 로그 남김 |
|
61 |
// // eLogLv이 error이면 -> error 로그 남김 |
|
62 |
// if (eCurLogLv < eLogLv) |
|
63 |
// return; |
|
64 |
|
|
65 |
// System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true); |
|
66 |
// string funcName = stackFrame.GetMethod().Name; |
|
67 |
// string fileName = stackFrame.GetFileName(); |
|
68 |
// string fileLine = stackFrame.GetFileLineNumber().ToString(); |
|
69 |
|
|
70 |
// // ,(콤마)는 .csv 파일에서 구분문자로 사용 |
|
71 |
// desc = desc.Replace(",", "."); |
|
72 |
|
|
73 |
// desc = $"{eLogLv.ToString()},\t{desc},\t{funcName},\t{fileName} {fileLine},\t{DateTime.Now}"; |
|
74 |
|
|
75 |
// streamWrite.WriteLine(desc); |
|
76 |
// streamWrite.Flush(); |
|
77 |
// fileStream.Flush(); |
|
78 |
|
|
79 |
// Int64 fileSize = fileStream.Length; |
|
80 |
|
|
81 |
// // 파일 사이즈가 2메가가 넘으면 해당 파일 닫은 후 파일 생성 |
|
82 |
// if (fileSize > 2097152) |
|
83 |
// { |
|
84 |
// streamWrite.Close(); |
|
85 |
// fileStream.Close(); |
|
86 |
// CreateLogFile(); |
|
87 |
// } |
|
88 |
// } |
|
89 |
//} |
|
90 |
#endregion |
|
87 | 91 |
|
88 | 92 |
static void Main(string[] args) |
89 | 93 |
{ |
... | ... | |
93 | 97 |
|
94 | 98 |
if (args.Length == 2) |
95 | 99 |
{ |
96 |
string finalID = args[0]; |
|
97 |
RemoteAddress = args[1]; |
|
100 |
string sFinalID = args[1]; |
|
101 |
string sProjectNo = args[0]; |
|
102 |
//RemoteAddress = args[1]; |
|
98 | 103 |
|
99 |
Program.logger.Log(ELogLv.info, $"FinalProcess Final ID : {args[0]}");
|
|
104 |
logger.Log(CommonLib.ELogLv.info, $"FinalProcess Final ID : {sFinalID}, Project No : {sProjectNo}");
|
|
100 | 105 |
|
101 |
MarkupToPDF.MarkupToPDF _markuptoPDF = new MarkupToPDF.MarkupToPDF(); |
|
106 |
MarkupToPDF.MarkupToPDF _markuptoPDF = new MarkupToPDF.MarkupToPDF(logger);
|
|
102 | 107 |
_markuptoPDF.FinalMakeError += new EventHandler<MarkupToPDF.MakeFinalErrorArgs>(_markuptoPDF_FinalMakeError); |
103 | 108 |
_markuptoPDF.StatusChanged += new EventHandler<MarkupToPDF.StatusChangedEventArgs>(_markuptoPDF_StatusChange); |
104 | 109 |
_markuptoPDF.EndFinal += _markuptoPDF_EndFinal; |
105 | 110 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
106 | 111 |
{ |
107 |
var items = _entity.FINAL_PDF.Where(x => x.ID == finalID);
|
|
112 |
var items = _entity.FINAL_PDF.Where(x => x.ID == sFinalID && x.PROJECT_NO == sProjectNo);
|
|
108 | 113 |
if(items.Count() > 0) |
109 | 114 |
{ |
110 | 115 |
finalPdf = items.First(); |
... | ... | |
118 | 123 |
} |
119 | 124 |
else |
120 | 125 |
{ |
121 |
Program.logger.Log(ELogLv.info, "Arguments is null");
|
|
126 |
logger.Log(CommonLib.ELogLv.info, "Arguments is null");
|
|
122 | 127 |
} |
123 | 128 |
} |
124 | 129 |
catch (Exception ex) |
125 | 130 |
{ |
126 |
Program.logger.Log(ELogLv.info, $"FinalProcess Final ID :{args[0]}");
|
|
131 |
logger.Log(CommonLib.ELogLv.error, $"FinalProcess Final ID : {args[1]}, Project No : {args[0]}{Environment.NewLine}Error Message : {ex.ToString()}{Environment.NewLine}Stack Trace : {ex.StackTrace}");
|
|
127 | 132 |
} |
128 | 133 |
finally |
129 | 134 |
{ |
... | ... | |
137 | 142 |
|
138 | 143 |
private static void _markuptoPDF_EndFinal(object sender, EndFinalEventArgs e) |
139 | 144 |
{ |
145 |
//using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
146 |
//{ |
|
147 |
// var items = _entity.FINAL_PDF.Where(x => x.ID == e.FinalPDF.ID); |
|
148 |
// if (items.Count() > 0) |
|
149 |
// { |
|
150 |
// if (string.IsNullOrEmpty(e.Error)) |
|
151 |
// { |
|
152 |
// items.First().STATUS = 4; |
|
153 |
// items.First().END_DATETIME = DateTime.Now; |
|
154 |
// } |
|
155 |
// } |
|
156 |
// _entity.SaveChanges(); |
|
157 |
//} |
|
158 |
|
|
159 |
logger.Log(CommonLib.ELogLv.info, $"Connection String : {KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()}"); |
|
160 |
|
|
140 | 161 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
141 | 162 |
{ |
142 |
var items = _entity.FINAL_PDF.Where(x => x.ID == e.FinalPDF.ID); |
|
143 |
if (items.Count() > 0) |
|
163 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == e.FinalPDF.ID && final.PROJECT_NO == e.FinalPDF.PROJECT_NO); |
|
164 |
|
|
165 |
if (finalList.Count() > 0) |
|
144 | 166 |
{ |
145 |
if (string.IsNullOrEmpty(e.Error))
|
|
167 |
if (e.FinalPDF.STATUS == (int)FinalStatus.Create)
|
|
146 | 168 |
{ |
147 |
items.First().STATUS = 4; |
|
148 |
items.First().END_DATETIME = DateTime.Now; |
|
169 |
var sb = new System.Text.StringBuilder(); |
|
170 |
sb.AppendLine("V3"); |
|
171 |
sb.AppendLine(finalList.First().EXCEPTION); |
|
172 |
|
|
173 |
finalList.First().EXCEPTION = sb.ToString(); |
|
174 |
finalList.First().START_DATETIME = DateTime.Now; |
|
175 |
} |
|
176 |
if (e.FinalPDF.STATUS == (int)FinalStatus.Success) |
|
177 |
{ |
|
178 |
finalList.First().END_DATETIME = DateTime.Now; |
|
179 |
StatusChange(FinalStatus.Success, ""); |
|
180 |
} |
|
181 |
if (e.FinalPDF.STATUS == (int)FinalStatus.PdfStamp && !string.IsNullOrWhiteSpace(e.Error)) |
|
182 |
{ |
|
183 |
var sb = new System.Text.StringBuilder(); |
|
184 |
sb.AppendLine(e.Message); |
|
185 |
sb.AppendLine(finalList.First().EXCEPTION); |
|
186 |
|
|
187 |
finalList.First().EXCEPTION = e.Message; |
|
149 | 188 |
} |
189 |
|
|
190 |
finalList.First().STATUS = e.FinalPDF.STATUS; |
|
191 |
|
|
192 |
logger.Log(CommonLib.ELogLv.info, $"Final PDF Before Status : {e.FinalPDF.STATUS}"); |
|
193 |
_entity.SaveChanges(); |
|
194 |
logger.Log(CommonLib.ELogLv.info, $"Final PDF After Status : {finalList.First().STATUS}"); |
|
150 | 195 |
} |
151 | 196 |
} |
152 | 197 |
|
FinalService/KCOM_FinalService_DL/KCOM_FinalService/FinalService.cs | ||
---|---|---|
67 | 67 |
if (_Timer == null) |
68 | 68 |
{ |
69 | 69 |
_Timer = new System.Timers.Timer(); |
70 |
_Timer.Interval = new TimeSpan(0, 0, 60).TotalMilliseconds;
|
|
70 |
_Timer.Interval = new TimeSpan(0, 0, 5).TotalMilliseconds;
|
|
71 | 71 |
_Timer.Elapsed += _Timer_Elapsed; |
72 | 72 |
} |
73 | 73 |
} |
... | ... | |
93 | 93 |
lock (FinalPDFAgentMap) |
94 | 94 |
{ |
95 | 95 |
FinalPDFAgentMap.Add(FinalID, new DocumentProcess($"{ProjectNo}-{FinalID}", -1)); |
96 |
|
|
97 |
LaunchFindPDFAgent(FinalID, ProjectNo, FinalID); |
|
96 | 98 |
} |
97 | 99 |
} |
98 | 100 |
|
... | ... | |
133 | 135 |
startInfo.RedirectStandardOutput = true; |
134 | 136 |
startInfo.UseShellExecute = false; |
135 | 137 |
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; |
136 |
startInfo.Arguments = $"\"{FinalID}\" \"{FinalID}\"";
|
|
138 |
startInfo.Arguments = $"\"{ProjectNo}\" \"{FinalID}\"";
|
|
137 | 139 |
var process = Process.Start(startInfo); |
138 | 140 |
if (process != null && FinalPDFAgentMap.ContainsKey(UID)) |
139 | 141 |
{ |
... | ... | |
157 | 159 |
var clone = FinalPDFAgentMap.ToDictionary(x => x.Key, x => new DocumentProcess(x.Value)); |
158 | 160 |
foreach (var kv in clone) |
159 | 161 |
{ |
160 |
if (kv.Value.Id == -1)
|
|
162 |
try
|
|
161 | 163 |
{ |
162 |
_Timer.Elapsed -= _Timer_Elapsed; |
|
163 |
var tokens = kv.Value.Document.Split('-'); |
|
164 |
LaunchFindPDFAgent(kv.Key, tokens[0], tokens[1]); |
|
165 |
_Timer.Elapsed += _Timer_Elapsed; |
|
164 |
#region 실행 중인 프로세스를 확인 |
|
165 |
var process = Process.GetProcessById(kv.Value.Id); |
|
166 |
#endregion |
|
166 | 167 |
} |
167 |
else
|
|
168 |
catch (ArgumentException ex)
|
|
168 | 169 |
{ |
169 |
try |
|
170 |
{ |
|
171 |
#region 실행 중인 프로세스를 확인 |
|
172 |
var process = Process.GetProcessById(kv.Value.Id); |
|
173 |
#endregion |
|
174 |
} |
|
175 |
catch (ArgumentException ex) |
|
170 |
var tokens = kv.Value.Document.Split('-'); |
|
171 |
string FinalID = tokens[1]; |
|
172 |
#region FinalPDF 완료 여부 확인 후 완료되지 않았으면 agent 실행 |
|
173 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
176 | 174 |
{ |
177 |
var tokens = kv.Value.Document.Split('-'); |
|
178 |
string FinalID = tokens[1]; |
|
179 |
#region FinalPDF 완료 여부 확인 후 완료되지 않았으면 agent 실행 |
|
180 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
175 |
var items = _entity.FINAL_PDF.Where(x => x.ID == FinalID); |
|
176 |
if (items.Any() && items.First().STATUS == 4) |
|
177 |
{ |
|
178 |
FinalPDFAgentMap.Remove(kv.Key); |
|
179 |
} |
|
180 |
else |
|
181 | 181 |
{ |
182 |
var items = _entity.FINAL_PDF.Where(x => x.ID == FinalID); |
|
183 |
if (items.Any() && items.First().STATUS == 4) |
|
184 |
{ |
|
185 |
FinalPDFAgentMap.Remove(kv.Key); |
|
186 |
} |
|
187 |
else |
|
188 |
{ |
|
189 |
LaunchFindPDFAgent(kv.Key, tokens[0], tokens[1]); |
|
190 |
} |
|
182 |
LaunchFindPDFAgent(kv.Key, tokens[0], tokens[1]); |
|
191 | 183 |
} |
192 |
#endregion |
|
193 | 184 |
} |
185 |
#endregion |
|
194 | 186 |
} |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
//if (kv.Value.Id == -1) |
|
194 |
//{ |
|
195 |
// //_Timer.Elapsed -= _Timer_Elapsed; |
|
196 |
// var tokens = kv.Value.Document.Split('-'); |
|
197 |
// using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
198 |
// { |
|
199 |
// string sID = tokens[1]; |
|
200 |
// string sProjectNo = tokens[0]; |
|
201 |
|
|
202 |
// var items = _entity.FINAL_PDF.Where(x => x.ID == sID && x.PROJECT_NO == sProjectNo); |
|
203 |
// if (items.Any() && items.First().STATUS == 0) |
|
204 |
// { |
|
205 |
// LaunchFindPDFAgent(kv.Key, tokens[0], tokens[1]); |
|
206 |
// } |
|
207 |
|
|
208 |
// } |
|
209 |
// //_Timer.Elapsed += _Timer_Elapsed; |
|
210 |
//} |
|
211 |
//else |
|
212 |
//{ |
|
213 |
// try |
|
214 |
// { |
|
215 |
// #region 실행 중인 프로세스를 확인 |
|
216 |
// var process = Process.GetProcessById(kv.Value.Id); |
|
217 |
// #endregion |
|
218 |
// } |
|
219 |
// catch (ArgumentException ex) |
|
220 |
// { |
|
221 |
// var tokens = kv.Value.Document.Split('-'); |
|
222 |
// string FinalID = tokens[1]; |
|
223 |
// #region FinalPDF 완료 여부 확인 후 완료되지 않았으면 agent 실행 |
|
224 |
// using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
225 |
// { |
|
226 |
// var items = _entity.FINAL_PDF.Where(x => x.ID == FinalID); |
|
227 |
// if (items.Any() && items.First().STATUS == 4) |
|
228 |
// { |
|
229 |
// FinalPDFAgentMap.Remove(kv.Key); |
|
230 |
// } |
|
231 |
// else |
|
232 |
// { |
|
233 |
// LaunchFindPDFAgent(kv.Key, tokens[0], tokens[1]); |
|
234 |
// } |
|
235 |
// } |
|
236 |
// #endregion |
|
237 |
// } |
|
238 |
//} |
|
195 | 239 |
} |
196 | 240 |
} |
197 | 241 |
|
FinalService/KCOM_FinalService_DL/KCOM_FinalService/Remoting/RemFinalPDFStation.cs | ||
---|---|---|
305 | 305 |
{ |
306 | 306 |
try |
307 | 307 |
{ |
308 |
if (OnAskFinalPDF != null) OnAskFinalPDF(ProjectNo, FinalID); |
|
308 |
if (OnAskFinalPDF != null) |
|
309 |
OnAskFinalPDF(ProjectNo, FinalID); |
|
309 | 310 |
//TODO: FinalPDFAgent로 옮겨야 함 |
310 | 311 |
/* |
311 | 312 |
using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
FinalService/KCOM_FinalService_DL/MarkupToPDF/MarkupToPDF.cs | ||
---|---|---|
22 | 22 |
{ |
23 | 23 |
public class MarkupToPDF : IDisposable |
24 | 24 |
{ |
25 |
public MarkupToPDF() |
|
25 |
public dynamic _LogManager = null; |
|
26 |
public MarkupToPDF(CommonLib.LogManager LogManager = null) |
|
26 | 27 |
{ |
28 |
if (LogManager != null) |
|
29 |
_LogManager = LogManager; |
|
27 | 30 |
} |
28 | 31 |
|
29 | 32 |
#region 초기 데이터 |
... | ... | |
82 | 85 |
} |
83 | 86 |
} |
84 | 87 |
|
88 |
private void SetFinalPDFLog(CommonLib.ELogLv logLv, string finalID, string projectNo, string message) |
|
89 |
{ |
|
90 |
if (_LogManager != null) |
|
91 |
_LogManager.Log(logLv, $"Final ID : {finalID}, Project No : {projectNo}, Message : {message}"); |
|
92 |
} |
|
93 |
|
|
85 | 94 |
private string GetFileName(string hrefLink) |
86 | 95 |
{ |
87 | 96 |
try |
... | ... | |
263 | 272 |
DOCUMENT_ITEM documentItem; |
264 | 273 |
FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF; |
265 | 274 |
FinalItem = FinalPDF; |
266 |
|
|
267 |
|
|
275 |
|
|
268 | 276 |
string PdfFilePathRoot = null; |
269 | 277 |
string TestFile = System.IO.Path.GetTempFileName(); |
270 | 278 |
|
... | ... | |
280 | 288 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0) |
281 | 289 |
{ |
282 | 290 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : TileSourcePath Not Found."); |
291 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "TileSourcePath Not Found."); |
|
283 | 292 |
return; |
284 | 293 |
} |
285 | 294 |
else |
... | ... | |
290 | 299 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).Count() == 0) |
291 | 300 |
{ |
292 | 301 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeLocal Not Found."); |
302 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "FinalPDFStorgeLocal Not Found."); |
|
293 | 303 |
return; |
294 | 304 |
} |
295 | 305 |
else |
... | ... | |
301 | 311 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).Count() == 0) |
302 | 312 |
{ |
303 | 313 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeRemote Not Found."); |
314 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "FinalPDFStorgeRemote Not Found."); |
|
304 | 315 |
return; |
305 | 316 |
} |
306 | 317 |
else |
... | ... | |
311 | 322 |
else |
312 | 323 |
{ |
313 | 324 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : Final PDF Properties Not Found."); |
325 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "Final PDF Properties Not Found."); |
|
314 | 326 |
return; |
315 | 327 |
} |
316 | 328 |
|
... | ... | |
328 | 340 |
catch (Exception ex) |
329 | 341 |
{ |
330 | 342 |
SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString()); |
343 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "프로퍼티 에러: " + ex.ToString()); |
|
331 | 344 |
return; |
332 | 345 |
} |
333 | 346 |
#endregion |
... | ... | |
353 | 366 |
|
354 | 367 |
if (infoItems.Count() == 0) |
355 | 368 |
{ |
369 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
|
356 | 370 |
throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
357 | 371 |
} |
358 | 372 |
else |
... | ... | |
369 | 383 |
} |
370 | 384 |
else |
371 | 385 |
{ |
386 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
|
372 | 387 |
throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
373 | 388 |
} |
374 | 389 |
} |
... | ... | |
376 | 391 |
documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault(); |
377 | 392 |
if (documentItem == null) |
378 | 393 |
{ |
394 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
|
379 | 395 |
throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
380 | 396 |
} |
381 | 397 |
|
... | ... | |
402 | 418 |
|
403 | 419 |
if (originalFile == null) |
404 | 420 |
{ |
421 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
|
405 | 422 |
throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
406 | 423 |
} |
407 | 424 |
else |
... | ... | |
413 | 430 |
} |
414 | 431 |
else |
415 | 432 |
{ |
433 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "PDF를 찾지 못하였습니다"); |
|
416 | 434 |
throw new FileNotFoundException("PDF를 찾지 못하였습니다"); |
417 | 435 |
} |
418 | 436 |
#endregion |
... | ... | |
420 | 438 |
#region 예외처리 |
421 | 439 |
if (PdfFilePath == null) |
422 | 440 |
{ |
441 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
|
423 | 442 |
throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
424 | 443 |
} |
425 | 444 |
if (!PdfFilePath.Exists) |
426 | 445 |
{ |
446 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "PDF원본이 존재하지 않습니다"); |
|
427 | 447 |
throw new Exception("PDF원본이 존재하지 않습니다"); |
428 | 448 |
} |
429 | 449 |
#endregion |
... | ... | |
431 | 451 |
} |
432 | 452 |
else |
433 | 453 |
{ |
454 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "일치하는 DocInfo가 없습니다"); |
|
434 | 455 |
throw new Exception("일치하는 DocInfo가 없습니다"); |
435 | 456 |
} |
436 | 457 |
} |
... | ... | |
439 | 460 |
{ |
440 | 461 |
if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다") |
441 | 462 |
{ |
463 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
|
442 | 464 |
SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
443 | 465 |
//System.Diagnostics.Process process = new System.Diagnostics.Process(); |
444 | 466 |
//process.StartInfo.FileName = "cmd"; |
... | ... | |
447 | 469 |
} |
448 | 470 |
else |
449 | 471 |
{ |
472 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "PDF를 Stamp 중 에러 : " + ex.Message); |
|
450 | 473 |
SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message); |
451 | 474 |
} |
452 | 475 |
} |
... | ... | |
471 | 494 |
} |
472 | 495 |
if (EndFinal != null) |
473 | 496 |
{ |
497 |
FinalItem.STATUS = (int)FinalStatus.Success; |
|
474 | 498 |
EndFinal(this, new EndFinalEventArgs |
475 | 499 |
{ |
476 | 500 |
FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name, |
... | ... | |
484 | 508 |
} |
485 | 509 |
catch (Exception ex) |
486 | 510 |
{ |
511 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalPDF.ID, FinalPDF.PROJECT_NO, "MarkFinalPDF Error : " + ex.Message); |
|
487 | 512 |
SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message); |
488 | 513 |
} |
489 | 514 |
} |
... | ... | |
676 | 701 |
catch (Exception ex) |
677 | 702 |
{ |
678 | 703 |
SetNotice(FinalItem.ID, "this pdf is not AcroForm."); |
704 |
SetFinalPDFLog(CommonLib.ELogLv.error, FinalItem.ID, FinalItem.PROJECT_NO, "this pdf is not AcroForm."); |
|
679 | 705 |
} |
680 | 706 |
|
681 | 707 |
string[] delimiterChars = { "|DZ|" }; |
... | ... | |
1339 | 1365 |
catch (Exception ex) |
1340 | 1366 |
{ |
1341 | 1367 |
SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString()); |
1368 |
SetFinalPDFLog(CommonLib.ELogLv.error, finaldata.ID, finaldata.PROJECT_NO, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString()); |
|
1342 | 1369 |
} |
1343 | 1370 |
|
1344 | 1371 |
return true; |
... | ... | |
1347 | 1374 |
catch (Exception ex) |
1348 | 1375 |
{ |
1349 | 1376 |
SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString()); |
1377 |
SetFinalPDFLog(CommonLib.ELogLv.error, finaldata.ID, finaldata.PROJECT_NO, "SetStempinPDF error: " + ex.ToString()); |
|
1350 | 1378 |
} |
1351 | 1379 |
return false; |
1352 | 1380 |
} |
내보내기 Unified diff