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