프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / DocItemCheck / DocumentItemCheck.cs @ 731c84b8

이력 | 보기 | 이력해설 | 다운로드 (4.21 KB)

1
using log4net;
2
using Markus.Service.Convert.Plugin;
3
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
using Markus.Service.DataBase.Entities;
10
using Markus.Service.DataBase.Repositories;
11
using Markus.Service.DataBase;
12

    
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
        private const string DBTYPE_KEY = "DBTYPE";
22
        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
            log4net.Config.BasicConfigurator.Configure();
29
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(DocumentItemCheck));
30

    
31
            try
32
            {
33
                if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0)
34
                {
35
                    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
                    string connectionString = Parameters[MARKUS_ConnectionString_KEY].ToString();
38
                    
39
                    using (BaseRepository repository = new Markus.Service.DataBase.Repositories.BaseRepository(Encrypt.AESEncrypter.Decrypt(connectionString), dbtype))
40
                    {
41
                        string sql = @"SELECT  doc.* " +
42
                                      " 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
                        var docItems = repository.GetAsync<DOCUMENTITEM>(sql,null).GetAwaiter().GetResult();
48

    
49
                        if (docItems.Count() > 0)
50
                        {
51
                            foreach (var item in docItems)
52
                            {
53
                                string projctNo = item.PROJECT_NO;
54
                                string documentId = item.DOCUMENT_ID;
55
                                string originalUrl = item.ORIGINAL_FILE;
56

    
57
                                if (!string.IsNullOrWhiteSpace(projctNo) && !string.IsNullOrWhiteSpace(documentId) && !string.IsNullOrWhiteSpace(originalUrl))
58
                                { 
59
                                    string convertId = GuidExtension.shortGuid();
60

    
61
                                    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
                                    };
67

    
68
                                    repository.SetAsync("SELECT_CONVERT_INSERT", param).GetAwaiter().GetResult();
69

    
70
                                    log.Warn($"[Insert Convert_Doc] ID : {convertId} / PROJECT_NO : {projctNo} / DOCUMENT_URL : {originalUrl} / DOCUMENT_ID : {documentId} ");
71
                                }
72
                            }
73
                        }
74
                        else
75
                        {
76
                            log.Info($"Document Item Check - Null");
77
                        }
78

    
79
                    }
80
                }
81
                else
82
                {
83
                    this.Exception = "MARKUS_ConnectionString SECTION Not Found";
84
                }
85
            }
86

    
87
            catch (Exception ex)
88
            {
89
                log.Error(ex);
90
                this.Exception = ex.ToString();
91
                result = false;
92
            }
93

    
94
            return result;
95
        }
96
    }
97
}
클립보드 이미지 추가 (최대 크기: 500 MB)