markus / ConvertService / ServiceBase / ConvertResultBSENG / ResultProcess.cs @ 77cdac33
이력 | 보기 | 이력해설 | 다운로드 (3.76 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using RestSharp; |
7 |
|
8 |
namespace ConvertResultBSENG |
9 |
{ |
10 |
public class ResultProcess : Markus.Service.Convert.Plugin.IPlugin |
11 |
{ |
12 |
public string Name => nameof(ConvertResultBSENG); |
13 |
|
14 |
public string Exception { get; set; } |
15 |
|
16 |
private const string UPLOAD_API_KEY = "UPLOAD_API"; |
17 |
|
18 |
private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString"; |
19 |
private string connectioString; |
20 |
|
21 |
public bool Do(string ConvertID, Dictionary<string, object> Parameters) |
22 |
{ |
23 |
bool result = false; |
24 |
Exception = ""; |
25 |
|
26 |
try |
27 |
{ |
28 |
if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0) |
29 |
{ |
30 |
connectioString = Markus.Service.Extensions.Encrypt.AESEncrypter.Decrypt(Parameters[MARKUS_ConnectionString_KEY].ToString()); |
31 |
string uploadUrl = Parameters[UPLOAD_API_KEY].ToString(); |
32 |
|
33 |
using (var entities = new Markus.EntityModel.MarkusModel(connectioString)) |
34 |
{ |
35 |
|
36 |
var convertItems = entities.CONVERTER_DOC.Where(x => x.ID == ConvertID); |
37 |
|
38 |
if (convertItems.Count() > 0) |
39 |
{ |
40 |
var convertItem = convertItems.First(); |
41 |
|
42 |
string documentId = convertItem.DOCUMENT_ID; |
43 |
|
44 |
var docitems = entities.DOCUMENT_ITEM.Where(x => x.DOCUMENT_ID == documentId); |
45 |
|
46 |
string uri = null; |
47 |
|
48 |
if (docitems.Count() > 0) |
49 |
{ |
50 |
var docitem = docitems.First(); |
51 |
|
52 |
//http://210.94.128.124/markus/markusRes.do?prj_No={prj_No}&document_Id={document_Id}&document_No={document_No}&document_Name=(document_Name)&group_No={group_No}&rev_No={rev_No} |
53 |
|
54 |
uri = $"http://{uploadUrl}/markus/markusRes.do?" |
55 |
+ $"prj_No={docitem.PROJECT_NO}&document_Id={docitem.ID}&document_No={docitem.DOCUMENT_NO}" |
56 |
+ $"&document_Name={docitem.DOCUMENT_NAME}&group_No={docitem.GROUP_NO}&rev_No={docitem.REVISION}"; |
57 |
|
58 |
var value = SendData(uri); |
59 |
|
60 |
if (string.IsNullOrEmpty(value) || Convert.ToBoolean(value)) |
61 |
{ |
62 |
result = true; |
63 |
} |
64 |
else |
65 |
{ |
66 |
this.Exception = uri; |
67 |
result = false; |
68 |
} |
69 |
|
70 |
} |
71 |
else |
72 |
{ |
73 |
this.Exception = "document Item Not Found " + uri; |
74 |
} |
75 |
} |
76 |
else |
77 |
{ |
78 |
this.Exception = "Convert_Doc Not Found"; |
79 |
} |
80 |
} |
81 |
} |
82 |
} |
83 |
catch (Exception ex) |
84 |
{ |
85 |
this.Exception = this.Exception + ex.ToString() + ex.InnerException?.ToString(); |
86 |
result = false; |
87 |
} |
88 |
|
89 |
return result; |
90 |
} |
91 |
|
92 |
|
93 |
private string SendData(string uri) |
94 |
{ |
95 |
var client = new RestClient(uri); |
96 |
client.Timeout = -1; |
97 |
var request = new RestRequest(Method.GET); |
98 |
var result = client.Get<string>(request); |
99 |
|
100 |
return result.Content; |
101 |
} |
102 |
} |
103 |
} |