markus / FinalService / KCOM_FinalService / ConsoleApp1 / Program.cs @ f7a2b3e1
이력 | 보기 | 이력해설 | 다운로드 (7.38 KB)
1 | e05bed4e | djkim | using IFinalPDF; |
---|---|---|---|
2 | using KCOMDataModel; |
||
3 | 7ca218b3 | KangIngu | using KCOMDataModel.Common; |
4 | using KCOMDataModel.DataModel; |
||
5 | abaa85b4 | djkim | using MarkupToPDF.Common; |
6 | 7ca218b3 | KangIngu | using System; |
7 | using System.Collections.Generic; |
||
8 | using System.IO; |
||
9 | using System.Linq; |
||
10 | using System.Text; |
||
11 | |||
12 | namespace ConsoleApp1 |
||
13 | { |
||
14 | e05bed4e | djkim | static class Program |
15 | 7ca218b3 | KangIngu | { |
16 | static void Main(string[] args) |
||
17 | { |
||
18 | string PdfFilePathRoot = ""; |
||
19 | string _FinalPDFStorgeLocal = ""; |
||
20 | string _FinalPDFStorgeRemote = ""; |
||
21 | |||
22 | //using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
23 | //{ |
||
24 | // var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == "000000"); |
||
25 | |||
26 | // if (_properties.Count() > 0) |
||
27 | // { |
||
28 | // PdfFilePathRoot = _properties.Where(t => t.TYPE == MarkupToPDF.PropertiesType.Const_TileSorcePath).First().VALUE; |
||
29 | // _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == MarkupToPDF.PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE; |
||
30 | // _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == MarkupToPDF.PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE; |
||
31 | // } |
||
32 | //} |
||
33 | // using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString("000000").ToString())) |
||
34 | //{ |
||
35 | // var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == "e16c382e-5c33-3883-d45b-47e4f4d4c23f"); |
||
36 | |||
37 | // if (_DOCINFO.Count() > 0) |
||
38 | // { |
||
39 | // var DocInfoItem = _DOCINFO.FirstOrDefault(); |
||
40 | |||
41 | // PdfFilePathRoot = PdfFilePathRoot + @"\" + "000000" + "_Tile" + @"\" |
||
42 | // + (System.Convert.ToInt64("11111111") / 100).ToString() |
||
43 | // + @"\" + "11111111" + @"\"; |
||
44 | // } |
||
45 | //} |
||
46 | e05bed4e | djkim | try |
47 | 7ca218b3 | KangIngu | { |
48 | e05bed4e | djkim | Console.WriteLine("Test Process..."); |
49 | Console.WriteLine("Insert Final PDF id :"); |
||
50 | string inputstr = Console.ReadLine(); |
||
51 | dcff9cd4 | djkim | using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
52 | e05bed4e | djkim | { |
53 | dcff9cd4 | djkim | //FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "ngKwBgMotw8d56dea3839120d").FirstOrDefault(); |
54 | FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == inputstr).FirstOrDefault(); |
||
55 | if (item != null) |
||
56 | e05bed4e | djkim | { |
57 | Console.WriteLine("final pdf start"); |
||
58 | MarkupToPDF.MarkupToPDF pdf = new MarkupToPDF.MarkupToPDF(); |
||
59 | pdf.EndFinal += Pdf_EndFinal; |
||
60 | dcff9cd4 | djkim | pdf.FinalMakeError += Pdf_FinalMakeError; |
61 | //pdf.MakeFinalPDF(_entity.FINAL_PDF.FirstOrDefault()); |
||
62 | pdf.MakeFinalPDF(item); |
||
63 | //_Thread.Add(item); |
||
64 | e05bed4e | djkim | } |
65 | else |
||
66 | { |
||
67 | Console.WriteLine("item is null"); |
||
68 | } |
||
69 | dcff9cd4 | djkim | |
70 | } |
||
71 | 7ca218b3 | KangIngu | |
72 | } |
||
73 | e05bed4e | djkim | catch (Exception ex) |
74 | { |
||
75 | Console.WriteLine("error: "+ ex.ToString()); |
||
76 | } |
||
77 | |||
78 | 7ca218b3 | KangIngu | } |
79 | |||
80 | private static void Pdf_FinalMakeError(object sender, MarkupToPDF.MakeFinalErrorArgs e) |
||
81 | { |
||
82 | |||
83 | } |
||
84 | abaa85b4 | djkim | static List<CommonLib.MARKUS_API.FINAL_PDF> _Thread = new List<CommonLib.MARKUS_API.FINAL_PDF>(); |
85 | 7ca218b3 | KangIngu | private static void Pdf_EndFinal(object sender, MarkupToPDF.EndFinalEventArgs e) |
86 | { |
||
87 | 8c3a888c | djkim | FINAL_PDF _item = (sender as MarkupToPDF.MarkupToPDF).FinalItem; |
88 | e05bed4e | djkim | |
89 | SetFinalState(_item.ID, FinalStatus.PdfStamp); |
||
90 | |||
91 | try |
||
92 | { |
||
93 | Console.WriteLine("final pdf end"); |
||
94 | abaa85b4 | djkim | string soapurl = CommonLib.Common.GetConfigString("UpLoadServiceUrl", "URL", ""); |
95 | e05bed4e | djkim | Console.WriteLine("soapurl:"+soapurl); |
96 | if (!string.IsNullOrEmpty(soapurl)) |
||
97 | { |
||
98 | //Legacy IF |
||
99 | KeyValuePair<bool, string> result = UploadFinal.UploadFinal.UploadFinalPDF(e.FinalPDFPath.Replace(@"\\172.20.121.220\comment3\finalPDF\", ""), e.OriginPDFName, e.FinalPDF, soapurl); |
||
100 | if (result.Key) |
||
101 | { |
||
102 | SetFinalState(_item.ID, FinalStatus.Success); |
||
103 | } |
||
104 | else |
||
105 | { |
||
106 | SetFinalState(_item.ID, FinalStatus.Error); |
||
107 | Console.WriteLine("pram1:"+ e.FinalPDFPath.Replace(@"\\172.20.121.220\comment3\finalPDF\", "")+",pram2:"+ e.OriginPDFName); |
||
108 | //_Log.Write("Upload error .." + e.FinalPDFPath + ",pdfname:" + e.OriginPDFName); |
||
109 | } |
||
110 | } |
||
111 | else |
||
112 | { |
||
113 | ///TODO: 저장할 폴더 위치를 configuration으로 빼주세요 |
||
114 | ///Local Test 용 저장 위치 |
||
115 | string savepath = CommonLib.Common.GetConfigString("DebugSavePath", "URL", ""); |
||
116 | |||
117 | string saveFolder = String.Format(savepath, _item.PROJECT_NO, Convert.ToInt32(_item.DOCUMENT_ID) / 100, _item.DOCUMENT_ID); |
||
118 | if (!System.IO.Directory.Exists(saveFolder)) |
||
119 | { |
||
120 | System.IO.Directory.CreateDirectory(saveFolder); |
||
121 | } |
||
122 | |||
123 | //this._Log.Write(String.Format("saveFolder : {0}", saveFolder) + DateTime.Now); |
||
124 | System.IO.File.Copy(e.FinalPDFPath, saveFolder + e.OriginPDFName, true); |
||
125 | abaa85b4 | djkim | using (DataController dataController = new DataController()) |
126 | e05bed4e | djkim | { |
127 | string resultpath = CommonLib.Common.GetConfigString("DebugResultUrlPath", "URL", ""); |
||
128 | abaa85b4 | djkim | string url = String.Format(resultpath, _item.PROJECT_NO, Convert.ToInt32(_item.DOCUMENT_ID) / 100, _item.DOCUMENT_ID, e.OriginPDFName); |
129 | var result = dataController.SetFinalPDFUrl(_item.PROJECT_NO, _item.DOCUMENT_ID, url); |
||
130 | e05bed4e | djkim | |
131 | SetFinalState(_item.ID, FinalStatus.Success); |
||
132 | abaa85b4 | djkim | } |
133 | e05bed4e | djkim | } |
134 | } |
||
135 | catch (Exception ex) |
||
136 | { |
||
137 | SetFinalState(_item.ID, FinalStatus.Error); |
||
138 | //_Log.Write("에러 .." + ex.Message); |
||
139 | //_Thread.Remove(_T.First()); |
||
140 | } |
||
141 | } |
||
142 | private static void SetFinalState(string finalID, FinalStatus status) |
||
143 | { |
||
144 | using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
145 | { |
||
146 | var finalList = _entity.FINAL_PDF.Where(final => final.ID == finalID); |
||
147 | |||
148 | if (finalList.Count() > 0) |
||
149 | { |
||
150 | if (status == FinalStatus.Create) |
||
151 | { |
||
152 | finalList.First().START_DATETIME = DateTime.Now; |
||
153 | } |
||
154 | if (status == FinalStatus.Success) |
||
155 | { |
||
156 | finalList.First().END_DATETIME = DateTime.Now; |
||
157 | } |
||
158 | 7ca218b3 | KangIngu | |
159 | e05bed4e | djkim | finalList.First().STATUS = (int)status; |
160 | _entity.SaveChanges(); |
||
161 | } |
||
162 | }; |
||
163 | 7ca218b3 | KangIngu | } |
164 | } |
||
165 | } |