프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / ConvertResultBSENG / ResultProcess.cs @ 731c84b8

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

1 77cdac33 taeseongkim
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6 a5e5fff6 taeseongkim
using Markus.Service.DataBase.Repositories;
7 77cdac33 taeseongkim
using RestSharp;
8
9
namespace ConvertResultBSENG
10
{
11
    public class ResultProcess : Markus.Service.Convert.Plugin.IPlugin
12
    {
13
        public string Name => nameof(ConvertResultBSENG);
14
15
        public string Exception { get; set; }
16
17
        private const string UPLOAD_API_KEY = "UPLOAD_API";
18
19
        private const string MARKUS_ConnectionString_KEY = "MARKUS_ConnectionString";
20 731c84b8 taeseongkim
        private const string DBTYPE_KEY = "DBTYPE";
21
22 77cdac33 taeseongkim
        private string connectioString;
23
24
        public bool Do(string ConvertID, Dictionary<string, object> Parameters)
25
        {
26
            bool result = false;
27
            Exception = "";
28
29
            try
30
            {
31
                if (Parameters.Keys.Count(x => x == MARKUS_ConnectionString_KEY) > 0)
32
                {
33 731c84b8 taeseongkim
                    Parameters.TryGetValue(DBTYPE_KEY, out object dbtypeStr);
34
                    Markus.Service.DataBase.DBMSType dbtype = (Markus.Service.DataBase.DBMSType)Enum.Parse(typeof(Markus.Service.DataBase.DBMSType), dbtypeStr.ToString());
35
36 77cdac33 taeseongkim
                    connectioString = Markus.Service.Extensions.Encrypt.AESEncrypter.Decrypt(Parameters[MARKUS_ConnectionString_KEY].ToString());
37
                    string uploadUrl = Parameters[UPLOAD_API_KEY].ToString();
38
39 731c84b8 taeseongkim
                    using (ConvertDocRepository database = new ConvertDocRepository(connectioString, dbtype))
40 77cdac33 taeseongkim
                    {
41 a5e5fff6 taeseongkim
                        var convertItem = database.GetConvertDocSingleAsync(ConvertID: ConvertID).GetAwaiter().GetResult();
42 77cdac33 taeseongkim
43 a5e5fff6 taeseongkim
                        if (convertItem != null)
44 77cdac33 taeseongkim
                        {
45 731c84b8 taeseongkim
                            using (DOCUMENTITEMRepository repository = new DOCUMENTITEMRepository(connectioString, dbtype))
46 a5e5fff6 taeseongkim
                            {
47
                                var docitem = repository.GetFirstAsync(convertItem.PROJECT_NO,convertItem.DOCUMENT_ID).GetAwaiter().GetResult();
48 77cdac33 taeseongkim
49 a5e5fff6 taeseongkim
                                string uri = null;
50 77cdac33 taeseongkim
51 a5e5fff6 taeseongkim
                                if (docitem != null)
52
                                {
53
                                    //http://210.94.128.124/markus/markusRes.do?prj_No={prj_No}&document_Id={document_Id}&document_No={document_No}&document_Name=(document_Name)&group_No={group_No}&rev_No={rev_No}
54 77cdac33 taeseongkim
55 a5e5fff6 taeseongkim
                                    uri = $"http://{uploadUrl}/markus/markusRes.do?"
56
                                                 + $"prj_No={docitem.PROJECT_NO}&document_Id={docitem.ID}&document_No={docitem.DOCUMENT_NO}"
57
                                                 + $"&document_Name={docitem.DOCUMENT_NAME}&group_No={docitem.GROUP_NO}&rev_No={docitem.REVISION}";
58 77cdac33 taeseongkim
59 a5e5fff6 taeseongkim
                                    var value = SendData(uri);
60 77cdac33 taeseongkim
61 a5e5fff6 taeseongkim
                                    if (string.IsNullOrEmpty(value) || Convert.ToBoolean(value))
62
                                    {
63
                                        result = true;
64
                                    }
65
                                    else
66
                                    {
67
                                        this.Exception = uri;
68
                                        result = false;
69
                                    }
70 77cdac33 taeseongkim
71
                                }
72
                                else
73
                                {
74 a5e5fff6 taeseongkim
                                    this.Exception = "document Item Not Found " + uri;
75 77cdac33 taeseongkim
                                }
76
                            }
77
                        }
78
                        else
79
                        {
80
                            this.Exception = "Convert_Doc Not Found";
81
                        }
82
                    }
83
                }
84
            }
85
            catch (Exception ex)
86
            {
87
                this.Exception = this.Exception +  ex.ToString() + ex.InnerException?.ToString();
88
                result = false;
89
            }
90
91
            return result;
92
        }
93
94
95
        private string SendData(string uri)
96
        {
97
            var client = new RestClient(uri);
98
            client.Timeout = -1;
99
            var request = new RestRequest(Method.GET);
100
            var result =  client.Get<string>(request);
101
102
            return result.Content;
103
        }
104
    }
105
}
클립보드 이미지 추가 (최대 크기: 500 MB)