프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / PemssDocumentInfo / DocumentInfoProcess.cs @ f363a40e

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

1 f363a40e taeseongkim
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.ServiceModel;
5
using System.Text;
6
using System.Threading.Tasks;
7
using Markus.Service.Convert.Plugin;
8
9
namespace PemssDocumentInfo
10
{
11
    public class DocumentInfoProcess : Markus.Service.Convert.Plugin.IPlugin
12
    {
13
        public string Name => "PemssDocumentInfo";
14
15
        public string Exception { get; set; }
16
17
        private const string PEMSS_SERVICE_KEY = "PEMSS_SERVICE";
18
        private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString";
19
        
20
21
        private string gConvertID;
22
23
        private string gPemssServiceUri;
24
25
        private PemssService.PemssServiceClient pemssServiceClient;
26
27
        bool IPlugin.Do(string ConvertID, Dictionary<string, object> Parameters)
28
        {
29
            bool result = false;
30
31
            gConvertID = ConvertID;
32
33
            try
34
            {
35
                if (Parameters.Keys.Count(x => x == PEMSS_SERVICE_KEY) > 0)
36
                {
37
                    gPemssServiceUri = Parameters[PEMSS_SERVICE_KEY].ToString();
38
39
                    BasicHttpBinding myBinding = new BasicHttpBinding();
40
                    EndpointAddress myEndpoint = new EndpointAddress(gPemssServiceUri);
41
42
                    pemssServiceClient = new PemssService.PemssServiceClient(myBinding, myEndpoint);
43
44
                    if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0)
45
                    {
46
                        string connectionString = Parameters[MARKUS_ConnectionString_KEY].ToString();
47
48
                        using (var entities = new Markus.EntityModel.MarkusModel(Markus.Service.Extensions.Encrypt.AESEncrypter.Decrypt(connectionString)))
49
                        {
50
                            var convertItems = entities.CONVERTER_DOC.Where(x => x.ID == ConvertID);
51
52
                            if (convertItems.Count() > 0)
53
                            {
54
                                var convertItem = convertItems.First();
55
56
                                string pID = convertItem.PROJECT_NO;
57
                                string dID = convertItem.DOCUMENT_ID;
58
59
                                var documentInfo = pemssServiceClient.GetDocumentInfo(pID,dID);
60
61
                                var docItems = entities.DOCUMENT_ITEM.Where(x => x.PROJECT_NO == pID && x.DOCUMENT_ID == dID);
62
63
                                if (docItems.Count() > 0)
64
                                {
65
                                    var docitem = docItems.First();
66
67
                                    docitem.DOCUMENT_NAME = documentInfo.docName;
68
                                    docitem.REVISION = documentInfo.revision;
69
                                    docitem.DOCUMENT_NO = documentInfo.slipNo;
70
                                    docitem.ORIGINAL_FILE = convertItem.DOCUMENT_URL;
71
72
                                }
73
                                else
74
                                {
75
                                    entities.DOCUMENT_ITEM.Add(new Markus.EntityModel.DOCUMENT_ITEM
76
                                    {
77
                                        DOCUMENT_NAME = documentInfo.docName,
78
                                        REVISION = documentInfo.revision,
79
                                        DOCUMENT_NO = documentInfo.slipNo,
80
                                        ORIGINAL_FILE = convertItem.DOCUMENT_URL
81
                                    });
82
                                }
83
84
                                entities.SaveChanges();
85
                            }
86
                            else
87
                            {
88
                                this.Exception = "ConvertItem Not Found";
89
                            }
90
                        }
91
                    }
92
                    else
93
                    {
94
                        this.Exception = "MARKUS_ConnectionString SECTION Not Found";
95
                    }
96
                }
97
                else
98
                {
99
                    this.Exception = "PEMSS_SERVICE SECTION Not Found";
100
                    return false;
101
                }
102
            }
103
104
            catch (Exception ex)
105
            {
106
                this.Exception = ex.ToString();
107
                result = false;
108
            }
109
110
            return result;
111
        }
112
    }
113
}
클립보드 이미지 추가 (최대 크기: 500 MB)