프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.DataBase.Test / DataBaseConvertDocPG.cs @ bede677a

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

1
using Dapper;
2
using NUnit.Framework;
3
using System;
4
using System.Collections.Generic;
5

    
6
namespace Markus.Service.DataBase.Test
7
{
8
    /// <summary>
9
    /// PostgreSQL
10
    /// </summary>
11
    public class DataBaseConvertDocPG : TestBasePG
12
    {
13
        public List<string> newConvertDocIDs = new List<string>();
14
        /// <summary>
15
        /// 완료
16
        /// </summary>
17
        [Test, Description("Craete Convert Doc Postgresql Test")]
18
        public void CreateConvertDocAsync()
19
        {
20
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
21
            {
22
                var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult();
23

    
24
                newConvertDocIDs.Add(newConvertDocID);
25
                Console.WriteLine($"new id : {newConvertDocID}");
26

    
27
                var newConvertDocID2 = repository.CreateAsync(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult();
28

    
29
                newConvertDocIDs.Add(newConvertDocID2);
30
                Console.WriteLine($"new id : {newConvertDocID2}");
31
            }
32

    
33
        }
34

    
35

    
36
        /// <summary>
37
        /// 완료
38
        /// </summary>
39
        [Test, Description("Craete Convert Doc MSSQL Test")]
40
        public void CreateConvertDoc()
41
        {
42
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
43
            {
44
                var newConvertDocID = repository.Create(ProjectNo, docUri, "111111").GetAwaiter().GetResult();
45

    
46
                newConvertDocIDs.Add(newConvertDocID);
47
                Console.WriteLine($"new id : {newConvertDocID}");
48

    
49
                var newConvertDocID2 = repository.Create(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult();
50

    
51
                newConvertDocIDs.Add(newConvertDocID2);
52
                Console.WriteLine($"new id : {newConvertDocID2}");
53
            }
54
        }
55

    
56
        /// <summary>
57
        /// 완료
58
        /// </summary>
59
        [Test, Description("GetConvertDocSingle Test")]
60
        public void GetConvertDocSingle()
61
        {
62
            this.CreateConvertDoc();
63

    
64
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
65
            {
66
                foreach (var convertDocID in newConvertDocIDs)
67
                {
68
                    var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: convertDocID).GetAwaiter().GetResult();
69

    
70
                    Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID}  ConvertPath:{convertDoc.ConvertPath}  ");
71
                }
72

    
73
            }
74
        }
75

    
76
        /// <summary>
77
        /// 완료
78
        /// </summary>
79
        [Test, Description("Select waitOrError PostgreSQL Test")]
80
        public void SelectWaitOrError()
81
        {
82
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
83
            {
84
                var items = repository.GetWaitorErrorAsync(2).GetAwaiter().GetResult();
85

    
86
                foreach (var item in items)
87
                {
88
                    Assert.Pass(item.ID);
89
                }
90
            }
91
        }
92

    
93

    
94
        /// <summary>
95
        /// 완료
96
        /// </summary>
97
        [Test, Description("Select Top 10 Convert Doc PostgreSQL Test")]
98
        public void SelectTop10ConvertDoc()
99
        {
100
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
101
            {
102
                string sql = @"SELECT ID, PROJECT_NO, DOCUMENT_URL, DOCUMENT_ID, CREATE_DATETIME, STATUS, TOTAL_PAGE, CURRENT_PAGE, EXCEPTION, END_DATETIME, START_DATETIME, SERVICE_ID,"
103
                             + "RECONVERTER FROM CONVERTER_DOC where CREATE_DATETIME >= @CREATE_DATETIME order by CREATE_DATETIME desc limit 10";
104
               
105
                var parameter = new List<sqlParameter>();
106
                parameter.Add(new sqlParameter("@CREATE_DATETIME", DateTime.Now.AddDays(-2), System.Data.DbType.DateTime));
107
  
108
               var items = repository.GetAsync<Markus.Service.DataBase.Entities.ConvertDoc>(sql, parameter).GetAwaiter().GetResult();
109

    
110
                foreach(var item in items)
111
                {
112
                    Assert.Pass(item.ID);
113
                }
114
            }
115
        }
116

    
117
        /// <summary>
118
        /// 완료
119
        /// </summary>
120
        [Test, Description("CONVERT_SELECT_CONVERTINGITEMS")]
121
        public void CONVERT_SELECT_CONVERTINGITEMS()
122
        {
123
            int TakeCount = 5;
124
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
125
            {
126
                var items = repository.GetConvertingItemAsync(TakeCount).GetAwaiter().GetResult();
127

    
128
                foreach (var item in items)
129
                {
130
                    Assert.Pass(item.ID);
131
                }
132
            }
133
        }
134

    
135
        /// <summary>
136
        /// 완료.
137
        /// </summary>
138
        [Test, Description("SetCleanUpItem PostgreSQL Test")]
139
        public void SelectSetCleanUpItem()
140
        {
141
            this.CreateConvertDoc();
142

    
143
            foreach (var item in newConvertDocIDs)
144
            {
145
                using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
146
                {
147
                    var items = repository.SetCleanUpItemAsync(item,1).GetAwaiter().GetResult();
148

    
149
                    Assert.Pass(item);
150
                }
151
            }
152
        }
153

    
154

    
155

    
156
        /// <summary>
157
        /// 완료.
158
        /// </summary>
159
        [Test, Description("UpdateStatusAsync")]
160
        public void UpdateStatusAsync()
161
        {
162
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
163
            {
164
                var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult();
165

    
166
                var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: newConvertDocID).GetAwaiter().GetResult();
167

    
168
                Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID}  ConvertPath:{convertDoc.ConvertPath}  ");
169

    
170
                var items = repository.UpdateStatusAsync("", convertDoc.ID, convertDoc.STATUS, convertDoc.TOTAL_PAGE, convertDoc.CURRENT_PAGE, "").GetAwaiter().GetResult();
171

    
172
               
173
            }
174
        }
175

    
176
    }
177
}
클립보드 이미지 추가 (최대 크기: 500 MB)