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