markus / ConvertService / ServiceBase / TestDocumentInfo / DocumentInfoProcess.cs @ c7555c83
이력 | 보기 | 이력해설 | 다운로드 (4.48 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.Convert.Plugin; |
7 |
using Markus.Service.DataBase.Entities; |
8 |
using Markus.Service.DataBase.Repositories; |
9 |
using Markus.Service.Extensions; |
10 |
|
11 |
namespace TestDocumentInfo |
12 |
{ |
13 |
public class DocumentInfoProcess : Markus.Service.Convert.Plugin.IPlugin |
14 |
{ |
15 |
public string Name => "TestDocumentInfo"; |
16 |
|
17 |
public string Exception { get; set; } |
18 |
public string gConvertID; |
19 |
|
20 |
private const string DBTYPE_KEY = "DBTYPE"; |
21 |
private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString"; |
22 |
|
23 |
bool IPlugin.Do(string ConvertID, Dictionary<string, object> Parameters) |
24 |
{ |
25 |
bool result = false; |
26 |
|
27 |
gConvertID = ConvertID; |
28 |
|
29 |
try |
30 |
{ |
31 |
|
32 |
if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0) |
33 |
{ |
34 |
Parameters.TryGetValue(DBTYPE_KEY, out object dbtypeStr); |
35 |
Markus.Service.DataBase.DBMSType dbtype = (Markus.Service.DataBase.DBMSType)Enum.Parse(typeof(Markus.Service.DataBase.DBMSType), dbtypeStr.ToString()); |
36 |
|
37 |
string connectionString = Markus.Service.Extensions.Encrypt.AESEncrypter.Decrypt(Parameters[MARKUS_ConnectionString_KEY].ToString()); |
38 |
|
39 |
using (ConvertDocRepository database = new ConvertDocRepository(connectionString, dbtype)) |
40 |
{ |
41 |
var convertItem = database.GetConvertDocSingleAsync(ConvertID: ConvertID).GetAwaiter().GetResult(); |
42 |
|
43 |
if (convertItem != null) |
44 |
{ |
45 |
string projectNo = convertItem.PROJECT_NO; |
46 |
string documentId = convertItem.DOCUMENT_ID; |
47 |
|
48 |
using (DOCUMENTITEMRepository repository = new DOCUMENTITEMRepository(connectionString,dbtype)) |
49 |
{ |
50 |
DOCUMENTITEM documentItem = repository.GetFirstAsync(projectNo, documentId).GetAwaiter().GetResult(); |
51 |
|
52 |
if (documentItem != null) |
53 |
{ |
54 |
documentItem.DOCUMENT_NAME = documentItem.DOCUMENT_NAME; |
55 |
documentItem.REVISION = documentItem.REVISION; |
56 |
documentItem.DOCUMENT_NO = documentItem.DOCUMENT_NO; |
57 |
documentItem.ORIGINAL_FILE = convertItem.DOCUMENT_URL; |
58 |
} |
59 |
else |
60 |
{ |
61 |
string docNo = ""; |
62 |
|
63 |
var filename = convertItem.DOCUMENT_URL.Split('/').LastOrDefault(); |
64 |
|
65 |
if (filename.Contains('.')) |
66 |
{ |
67 |
docNo = filename.Split('.').First(); |
68 |
} |
69 |
|
70 |
documentItem = new DOCUMENTITEM |
71 |
{ |
72 |
ID = new Guid().CreateUniqueGuid().ToString(), |
73 |
DOCUMENT_NO = docNo, |
74 |
REVISION = "A", |
75 |
DOCUMENT_NAME = docNo, |
76 |
GROUP_NO = "11", |
77 |
ORIGINAL_FILE = convertItem.DOCUMENT_URL, |
78 |
DOCUMENT_ID = documentId, |
79 |
PROJECT_NO = projectNo, |
80 |
Link = convertItem.DOCUMENT_URL |
81 |
}; |
82 |
} |
83 |
|
84 |
var id = repository.CreateOrUPdateAsync(documentItem).GetAwaiter().GetResult(); |
85 |
|
86 |
if(id != null) |
87 |
{ |
88 |
result = true; |
89 |
} |
90 |
} |
91 |
} |
92 |
} |
93 |
|
94 |
} |
95 |
else |
96 |
{ |
97 |
this.Exception = "MARKUS_ConnectionString SECTION Not Found"; |
98 |
} |
99 |
} |
100 |
|
101 |
catch (Exception ex) |
102 |
{ |
103 |
this.Exception = ex.ToString(); |
104 |
result = false; |
105 |
} |
106 |
|
107 |
return result; |
108 |
} |
109 |
} |
110 |
} |