markus / ConvertService / ServiceBase / PemssDocumentInfo / DocumentInfoProcess.cs @ 30d84e1a
이력 | 보기 | 이력해설 | 다운로드 (4.97 KB)
1 | f363a40e | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.ServiceModel; |
||
5 | using System.Text; |
||
6 | using System.Threading.Tasks; |
||
7 | a5e5fff6 | taeseongkim | using Markus.EntityModel; |
8 | f363a40e | taeseongkim | using Markus.Service.Convert.Plugin; |
9 | a0341bef | taeseongkim | using Markus.Service.Extensions; |
10 | f363a40e | taeseongkim | |
11 | namespace PemssDocumentInfo |
||
12 | { |
||
13 | public class DocumentInfoProcess : Markus.Service.Convert.Plugin.IPlugin |
||
14 | { |
||
15 | public string Name => "PemssDocumentInfo"; |
||
16 | |||
17 | public string Exception { get; set; } |
||
18 | |||
19 | private const string PEMSS_SERVICE_KEY = "PEMSS_SERVICE"; |
||
20 | private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString"; |
||
21 | |||
22 | |||
23 | private string gConvertID; |
||
24 | |||
25 | private string gPemssServiceUri; |
||
26 | |||
27 | private PemssService.PemssServiceClient pemssServiceClient; |
||
28 | |||
29 | bool IPlugin.Do(string ConvertID, Dictionary<string, object> Parameters) |
||
30 | { |
||
31 | bool result = false; |
||
32 | |||
33 | gConvertID = ConvertID; |
||
34 | |||
35 | try |
||
36 | { |
||
37 | if (Parameters.Keys.Count(x => x == PEMSS_SERVICE_KEY) > 0) |
||
38 | { |
||
39 | gPemssServiceUri = Parameters[PEMSS_SERVICE_KEY].ToString(); |
||
40 | |||
41 | BasicHttpBinding myBinding = new BasicHttpBinding(); |
||
42 | EndpointAddress myEndpoint = new EndpointAddress(gPemssServiceUri); |
||
43 | |||
44 | pemssServiceClient = new PemssService.PemssServiceClient(myBinding, myEndpoint); |
||
45 | |||
46 | if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0) |
||
47 | { |
||
48 | string connectionString = Parameters[MARKUS_ConnectionString_KEY].ToString(); |
||
49 | |||
50 | a5e5fff6 | taeseongkim | using (var entities = new MarkusModel(Markus.Service.Extensions.Encrypt.AESEncrypter.Decrypt(connectionString))) |
51 | f363a40e | taeseongkim | { |
52 | var convertItems = entities.CONVERTER_DOC.Where(x => x.ID == ConvertID); |
||
53 | |||
54 | if (convertItems.Count() > 0) |
||
55 | { |
||
56 | var convertItem = convertItems.First(); |
||
57 | |||
58 | string pID = convertItem.PROJECT_NO; |
||
59 | string dID = convertItem.DOCUMENT_ID; |
||
60 | |||
61 | var documentInfo = pemssServiceClient.GetDocumentInfo(pID,dID); |
||
62 | |||
63 | a0341bef | taeseongkim | if (documentInfo != null) |
64 | f363a40e | taeseongkim | { |
65 | a0341bef | taeseongkim | var docItems = entities.DOCUMENT_ITEM.Where(x => x.PROJECT_NO == pID && x.DOCUMENT_ID == dID); |
66 | |||
67 | if (docItems.Count() > 0) |
||
68 | { |
||
69 | var docitem = docItems.First(); |
||
70 | f363a40e | taeseongkim | |
71 | a0341bef | taeseongkim | docitem.DOCUMENT_NAME = documentInfo.docName; |
72 | docitem.REVISION = documentInfo.revision; |
||
73 | docitem.DOCUMENT_NO = documentInfo.slipNo; |
||
74 | docitem.ORIGINAL_FILE = convertItem.DOCUMENT_URL; |
||
75 | f363a40e | taeseongkim | |
76 | a0341bef | taeseongkim | } |
77 | else |
||
78 | { |
||
79 | entities.DOCUMENT_ITEM.Add(new Markus.EntityModel.DOCUMENT_ITEM |
||
80 | { |
||
81 | ID = new Guid().CreateUniqueGuid().ToString(), |
||
82 | DOCUMENT_NO = documentInfo.slipNo, |
||
83 | REVISION = documentInfo.revision, |
||
84 | DOCUMENT_NAME = documentInfo.docName, |
||
85 | GROUP_NO = documentInfo.slipNo, |
||
86 | ORIGINAL_FILE = convertItem.DOCUMENT_URL, |
||
87 | DOCUMENT_ID = dID, |
||
88 | PROJECT_NO = pID |
||
89 | }); |
||
90 | } |
||
91 | |||
92 | entities.SaveChanges(); |
||
93 | result = true; |
||
94 | f363a40e | taeseongkim | } |
95 | else |
||
96 | { |
||
97 | a0341bef | taeseongkim | this.Exception = $"PEMSS API GetDocumentInfo null pID : {pID} dID : {dID}"; |
98 | f363a40e | taeseongkim | } |
99 | } |
||
100 | else |
||
101 | { |
||
102 | this.Exception = "ConvertItem Not Found"; |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 | else |
||
107 | { |
||
108 | this.Exception = "MARKUS_ConnectionString SECTION Not Found"; |
||
109 | } |
||
110 | } |
||
111 | else |
||
112 | { |
||
113 | this.Exception = "PEMSS_SERVICE SECTION Not Found"; |
||
114 | } |
||
115 | } |
||
116 | |||
117 | catch (Exception ex) |
||
118 | { |
||
119 | this.Exception = ex.ToString(); |
||
120 | result = false; |
||
121 | } |
||
122 | |||
123 | return result; |
||
124 | } |
||
125 | } |
||
126 | } |