markus / ConvertService / ServiceBase / DocItemCheck / DocumentItemCheck.cs @ f333dcc2
이력 | 보기 | 이력해설 | 다운로드 (4.21 KB)
1 | c740ccc7 | taeseongkim | using log4net; |
---|---|---|---|
2 | using Markus.Service.Convert.Plugin; |
||
3 | a72d2650 | taeseongkim | using Markus.Service.Extensions; |
4 | using System; |
||
5 | using System.Collections.Generic; |
||
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | using System.Threading.Tasks; |
||
9 | a5e5fff6 | taeseongkim | using Markus.Service.DataBase.Entities; |
10 | using Markus.Service.DataBase.Repositories; |
||
11 | using Markus.Service.DataBase; |
||
12 | a72d2650 | taeseongkim | |
13 | namespace DocItemCheck |
||
14 | { |
||
15 | public class DocumentItemCheck : Markus.Service.Convert.Plugin.IPlugin |
||
16 | { |
||
17 | public string Name => nameof(DocItemCheck); |
||
18 | |||
19 | public string Exception { get; set; } |
||
20 | public string gConvertID; |
||
21 | 731c84b8 | taeseongkim | private const string DBTYPE_KEY = "DBTYPE"; |
22 | a72d2650 | taeseongkim | private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString"; |
23 | |||
24 | bool IPlugin.Do(string ConvertID, Dictionary<string, object> Parameters) |
||
25 | { |
||
26 | bool result = true; |
||
27 | |||
28 | c740ccc7 | taeseongkim | log4net.Config.BasicConfigurator.Configure(); |
29 | log4net.ILog log = log4net.LogManager.GetLogger(typeof(DocumentItemCheck)); |
||
30 | a72d2650 | taeseongkim | |
31 | try |
||
32 | { |
||
33 | if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0) |
||
34 | { |
||
35 | 731c84b8 | taeseongkim | Parameters.TryGetValue(DBTYPE_KEY, out object dbtypeStr); |
36 | Markus.Service.DataBase.DBMSType dbtype = (Markus.Service.DataBase.DBMSType)Enum.Parse(typeof(Markus.Service.DataBase.DBMSType), dbtypeStr.ToString()); |
||
37 | a72d2650 | taeseongkim | string connectionString = Parameters[MARKUS_ConnectionString_KEY].ToString(); |
38 | |||
39 | 731c84b8 | taeseongkim | using (BaseRepository repository = new Markus.Service.DataBase.Repositories.BaseRepository(Encrypt.AESEncrypter.Decrypt(connectionString), dbtype)) |
40 | a72d2650 | taeseongkim | { |
41 | a5e5fff6 | taeseongkim | string sql = @"SELECT doc.* " + |
42 | a72d2650 | taeseongkim | " FROM MarkusModel.DOCUMENT_ITEM as doc " + |
43 | " LEFT OUTER JOIN MarkusModel.CONVERTER_DOC as con " + |
||
44 | " ON doc.DOCUMENT_ID = con.DOCUMENT_ID and doc.PROJECT_NO = con.PROJECT_NO " + |
||
45 | " where con.DOCUMENT_ID is null"; |
||
46 | |||
47 | a5e5fff6 | taeseongkim | var docItems = repository.GetAsync<DOCUMENTITEM>(sql,null).GetAwaiter().GetResult(); |
48 | a72d2650 | taeseongkim | |
49 | if (docItems.Count() > 0) |
||
50 | { |
||
51 | a5e5fff6 | taeseongkim | foreach (var item in docItems) |
52 | a72d2650 | taeseongkim | { |
53 | a5e5fff6 | taeseongkim | string projctNo = item.PROJECT_NO; |
54 | string documentId = item.DOCUMENT_ID; |
||
55 | string originalUrl = item.ORIGINAL_FILE; |
||
56 | a72d2650 | taeseongkim | |
57 | if (!string.IsNullOrWhiteSpace(projctNo) && !string.IsNullOrWhiteSpace(documentId) && !string.IsNullOrWhiteSpace(originalUrl)) |
||
58 | { |
||
59 | string convertId = GuidExtension.shortGuid(); |
||
60 | |||
61 | a5e5fff6 | taeseongkim | var param = new List<sqlParameter> { |
62 | new sqlParameter("@ID",convertId,System.Data.DbType.String), |
||
63 | new sqlParameter("@PROJECT_NO",projctNo,System.Data.DbType.String), |
||
64 | new sqlParameter("@DOCUMENT_URL",originalUrl,System.Data.DbType.String), |
||
65 | new sqlParameter( "@DOCUMENT_ID",documentId,System.Data.DbType.String) |
||
66 | a72d2650 | taeseongkim | }; |
67 | |||
68 | a5e5fff6 | taeseongkim | repository.SetAsync("SELECT_CONVERT_INSERT", param).GetAwaiter().GetResult(); |
69 | c740ccc7 | taeseongkim | |
70 | log.Warn($"[Insert Convert_Doc] ID : {convertId} / PROJECT_NO : {projctNo} / DOCUMENT_URL : {originalUrl} / DOCUMENT_ID : {documentId} "); |
||
71 | a72d2650 | taeseongkim | } |
72 | } |
||
73 | } |
||
74 | c740ccc7 | taeseongkim | else |
75 | { |
||
76 | log.Info($"Document Item Check - Null"); |
||
77 | } |
||
78 | |||
79 | a72d2650 | taeseongkim | } |
80 | } |
||
81 | else |
||
82 | { |
||
83 | this.Exception = "MARKUS_ConnectionString SECTION Not Found"; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | catch (Exception ex) |
||
88 | { |
||
89 | c740ccc7 | taeseongkim | log.Error(ex); |
90 | a72d2650 | taeseongkim | this.Exception = ex.ToString(); |
91 | result = false; |
||
92 | } |
||
93 | |||
94 | return result; |
||
95 | } |
||
96 | } |
||
97 | } |