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