프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / DocItemCheck / DocumentItemCheck.cs @ 42d49521

이력 | 보기 | 이력해설 | 다운로드 (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.Data.Entity.Core.Objects;
7
using System.Data.Entity.Infrastructure;
8
using System.Linq;
9
using System.Text;
10
using System.Threading.Tasks;
11

    
12
namespace DocItemCheck
13
{
14
    public class DocumentItemCheck : Markus.Service.Convert.Plugin.IPlugin
15
    {
16
        public string Name => nameof(DocItemCheck);
17

    
18
        public string Exception { get; set; }
19
        public string gConvertID;
20

    
21
        private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString";
22

    
23
        bool IPlugin.Do(string ConvertID, Dictionary<string, object> Parameters)
24
        {
25
            bool result = true;
26

    
27
            log4net.Config.BasicConfigurator.Configure();
28
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(DocumentItemCheck));
29

    
30
            try
31
            {
32
                if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0)
33
                {
34
                    string connectionString = Parameters[MARKUS_ConnectionString_KEY].ToString();
35
                    
36
                    using (var entities = new Markus.EntityModel.MarkusModel(Markus.Service.Extensions.Encrypt.AESEncrypter.Decrypt(connectionString)))
37
                    {
38
                        string sql = @"SELECT " +
39
                                      " doc.PROJECT_NO as PROJECT_NO " +
40
				                      " ,doc.DOCUMENT_ID as DOCUMENT_ID " +
41
				                      " ,doc.ORIGINAL_FILE as ORIGINAL_FILE " +
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 =  (entities as IObjectContextAdapter).ObjectContext.CreateQuery<System.Data.Common.DbDataRecord>(sql);
48

    
49
                        if (docItems.Count() > 0)
50
                        {
51
                            foreach (var dataRecord in docItems)
52
                            {
53
                                string projctNo = dataRecord["PROJECT_NO"]?.ToString().Trim();
54
                                string documentId = dataRecord["DOCUMENT_ID"]?.ToString().Trim();
55
                                string originalUrl = dataRecord["ORIGINAL_FILE"]?.ToString();
56

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

    
61
                                    var param = new [] {
62
                                        new System.Data.SqlClient.SqlParameter("ID",convertId),
63
                                        new System.Data.SqlClient.SqlParameter("PROJECT_NO",projctNo),
64
                                        new System.Data.SqlClient.SqlParameter("DOCUMENT_URL",originalUrl),
65
                                        new System.Data.SqlClient.SqlParameter( "DOCUMENT_ID",documentId)
66
                                    };
67

    
68
                                   (entities as IObjectContextAdapter).ObjectContext.ExecuteStoreQuery<object>("SELECT_CONVERT_INSERT @ID, @PROJECT_NO, @DOCUMENT_URL , @DOCUMENT_ID", param);
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)