개정판 f6c94121
issue #00000 postgreSQL 연결 추가 및 Repositories 수정
Change-Id: I3808904f8c4bc89b5742ffc998a42e343038d733
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Markus.Service.DataBase.Dapper.csproj | ||
---|---|---|
89 | 89 |
<Compile Include="Entities\PROPERTIES.cs" /> |
90 | 90 |
<Compile Include="Entities\SERVICEPROPERTIES.cs" /> |
91 | 91 |
<Compile Include="Extensions.cs" /> |
92 |
<Compile Include="Handler\ParameterHandler.cs" /> |
|
92 | 93 |
<Compile Include="PropertiesTypeDefine.cs" /> |
93 | 94 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
94 | 95 |
<Compile Include="RepositoriesInterfaces\IConvertDocRepository.cs" /> |
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/BaseRepository.cs | ||
---|---|---|
12 | 12 |
{ |
13 | 13 |
public class BaseRepository : IDisposable |
14 | 14 |
{ |
15 |
public readonly IDbConnection Connection;
|
|
15 |
private readonly IDbConnection Connection;
|
|
16 | 16 |
public readonly DbConnectionStringBuilder dbConnectionString; |
17 | 17 |
public readonly DBMSType DBMS; |
18 | 18 |
|
... | ... | |
34 | 34 |
default: |
35 | 35 |
break; |
36 | 36 |
} |
37 |
|
|
38 |
SqlMapper.AddTypeHandler(new Handler.ParameterHandler<object>(DBMS)); |
|
39 |
|
|
37 | 40 |
Connection.Open(); |
38 | 41 |
} |
39 | 42 |
|
... | ... | |
65 | 68 |
return await Connection.QueryAsync<T>(SQL, parameter); |
66 | 69 |
} |
67 | 70 |
|
71 |
public async Task<IEnumerable<T>> QueryAsync<T>(string SQL, DynamicParameters parameters) |
|
72 |
{ |
|
73 |
if (Connection.State != System.Data.ConnectionState.Open) |
|
74 |
{ |
|
75 |
Connection.Open(); |
|
76 |
} |
|
77 |
|
|
78 |
return await Connection.QueryAsync<T>(SQL, parameters); |
|
79 |
} |
|
80 |
|
|
68 | 81 |
public async Task<T> GetSingleAsync<T>(string SQL, List<sqlParameter> parameters) |
69 | 82 |
{ |
70 | 83 |
if (Connection.State != System.Data.ConnectionState.Open) |
... | ... | |
78 | 91 |
return await Connection.QuerySingleAsync<T>(SQL, parameter); |
79 | 92 |
} |
80 | 93 |
|
81 |
public async Task<T> GetFirstAsync<T>(string SQL, List<sqlParameter> parameters) |
|
94 |
|
|
95 |
public async Task<IEnumerable<T>> QueryAsync<T>(string SQL, DynamicParameters parameters,CommandType commandType) |
|
82 | 96 |
{ |
83 | 97 |
if (Connection.State != System.Data.ConnectionState.Open) |
84 | 98 |
{ |
85 | 99 |
Connection.Open(); |
86 | 100 |
} |
87 | 101 |
|
88 |
var parameter = new DynamicParameters();
|
|
89 |
parameters.ForEach(x => parameter.Add(x.Name, x.Value, x.DbType));
|
|
102 |
return await Connection.QueryAsync<T>(SQL, parameters, commandType: commandType);
|
|
103 |
}
|
|
90 | 104 |
|
91 |
return await Connection.QueryFirstOrDefaultAsync<T>(SQL, parameter); |
|
105 |
public async Task<T> GetFirstAsync<T>(string SQL,DynamicParameters parameters) |
|
106 |
{ |
|
107 |
if (Connection.State != System.Data.ConnectionState.Open) |
|
108 |
{ |
|
109 |
Connection.Open(); |
|
110 |
} |
|
111 |
|
|
112 |
return await Connection.QueryFirstOrDefaultAsync<T>(SQL, parameters); |
|
92 | 113 |
} |
93 | 114 |
|
94 | 115 |
public async Task<int> SetAsync(string SQL, List<sqlParameter> parameters) |
... | ... | |
103 | 124 |
|
104 | 125 |
return await Connection.ExecuteAsync(SQL, parameters, commandType: CommandType.StoredProcedure); |
105 | 126 |
} |
127 |
|
|
128 |
public async Task<int> ExecuteAsync(string SQL, DynamicParameters parameters,IDbTransaction transaction, CommandType commandType) |
|
129 |
{ |
|
130 |
if (Connection.State != System.Data.ConnectionState.Open) |
|
131 |
{ |
|
132 |
Connection.Open(); |
|
133 |
} |
|
134 |
|
|
135 |
return await Connection.ExecuteAsync(SQL, parameters, transaction, commandType: CommandType.StoredProcedure); |
|
136 |
} |
|
106 | 137 |
} |
107 | 138 |
} |
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/ConvertDocRepository.cs | ||
---|---|---|
24 | 24 |
var parameters = new DynamicParameters(); |
25 | 25 |
parameters.Add("@P_TakeCount", TakeCount, DbType.Int32); |
26 | 26 |
|
27 |
var result = await Connection.QueryAsync<ConvertDoc>("CONVERT_SELECT_WAITorERROR", parameters, commandType: CommandType.StoredProcedure);
|
|
27 |
var result = await base.QueryAsync<ConvertDoc>("CONVERT_SELECT_WAITorERROR", parameters, commandType: CommandType.StoredProcedure);
|
|
28 | 28 |
if (result == null) return null; |
29 | 29 |
list = result.ToList(); |
30 | 30 |
|
... | ... | |
65 | 65 |
|
66 | 66 |
SQL = SQL + string.Join(" AND ", whereSQL.ToArray()); |
67 | 67 |
|
68 |
var convertItem = await Connection.QueryFirstOrDefaultAsync<Markus.Service.DataBase.Entities.ConvertDoc>(SQL, parameters);
|
|
68 |
var convertItem = await base.GetFirstAsync<Markus.Service.DataBase.Entities.ConvertDoc>(SQL, parameters);
|
|
69 | 69 |
|
70 | 70 |
if (convertItem != null) |
71 | 71 |
{ |
... | ... | |
95 | 95 |
var parameters = new DynamicParameters(); |
96 | 96 |
parameters.Add("@STATUS", status, System.Data.DbType.String); |
97 | 97 |
|
98 |
var convertItems = await Connection.QueryAsync<Markus.Service.DataBase.Entities.ConvertDoc>(SQL, parameters);
|
|
98 |
var convertItems = await base.QueryAsync<Markus.Service.DataBase.Entities.ConvertDoc>(SQL, parameters);
|
|
99 | 99 |
|
100 | 100 |
using (PROPERTIESRepository repository = new PROPERTIESRepository(dbConnectionString.ToString(), DBMS)) |
101 | 101 |
{ |
... | ... | |
134 | 134 |
var parameters = new DynamicParameters(); |
135 | 135 |
parameters.Add("@P_TakeCount", TakeCount, DbType.Int32); |
136 | 136 |
|
137 |
var result = await Connection.QueryAsync<ConvertDoc>("CONVERT_SELECT_CONVERTINGITEMS", parameters, commandType: CommandType.StoredProcedure);
|
|
137 |
var result = await base.QueryAsync<ConvertDoc>("CONVERT_SELECT_CONVERTINGITEMS", parameters, commandType: CommandType.StoredProcedure);
|
|
138 | 138 |
|
139 | 139 |
if (result == null) return null; |
140 | 140 |
list = result.ToList(); |
... | ... | |
146 | 146 |
public async Task<int> SetCleanUpItemAsync(string convertID, int ReConvert) |
147 | 147 |
{ |
148 | 148 |
int result = -1; |
149 |
var tran = Connection.BeginTransaction();
|
|
149 |
var tran = BeginTransaction(); |
|
150 | 150 |
|
151 | 151 |
var parameters = new DynamicParameters(); |
152 | 152 |
parameters.Add("@P_ConverterDocID", convertID, DbType.String); |
153 | 153 |
parameters.Add("@P_ReConvert", ReConvert, DbType.Int32); |
154 | 154 |
parameters.Add("@return", ReConvert, DbType.Int32, ParameterDirection.ReturnValue); |
155 | 155 |
|
156 |
|
|
157 |
await Connection.ExecuteAsync("CONVERT_UPDATE_CLEANUP_ITEM", parameters, tran, commandType: CommandType.StoredProcedure); |
|
156 |
await base.ExecuteAsync("CONVERT_UPDATE_CLEANUP_ITEM", parameters, tran, commandType: CommandType.StoredProcedure); |
|
158 | 157 |
|
159 | 158 |
result = parameters.Get<int>("@return"); |
160 | 159 |
tran.Commit(); |
... | ... | |
167 | 166 |
{ |
168 | 167 |
string result = null; |
169 | 168 |
try |
170 |
{ |
|
171 |
var tran = Connection.BeginTransaction();
|
|
172 |
|
|
169 |
{
|
|
170 |
var tran = BeginTransaction(); |
|
171 |
|
|
173 | 172 |
var parameters = new DynamicParameters(); |
174 | 173 |
parameters.Add("@PROJECT_NO", PROJECT_NO, DbType.String); |
175 | 174 |
parameters.Add("@DOCUMENT_URL", DOCUMENT_URL, DbType.String); |
176 | 175 |
parameters.Add("@DOCUMENT_ID", DOCUMENT_ID, DbType.String); |
177 | 176 |
parameters.Add("@NewID", dbType: DbType.String, direction: ParameterDirection.Output, size: 50); |
178 |
|
|
179 |
await Connection.ExecuteAsync("CONVERT_INSERT_CONVERTDOC", parameters, transaction: tran, commandType: CommandType.StoredProcedure);
|
|
177 |
|
|
178 |
await base.ExecuteAsync("CONVERT_INSERT_CONVERTDOC", parameters, transaction: tran, commandType: CommandType.StoredProcedure);
|
|
180 | 179 |
|
181 | 180 |
result = parameters.Get<string>("@NewID"); |
182 | 181 |
tran.Commit(); |
... | ... | |
193 | 192 |
{ |
194 | 193 |
int result = 0; |
195 | 194 |
|
196 |
var tran = Connection.BeginTransaction();
|
|
195 |
var tran = BeginTransaction(); |
|
197 | 196 |
|
198 | 197 |
var parameters = new DynamicParameters(); |
199 | 198 |
parameters.Add("@SERVICE_ID", ServiceID, DbType.String); |
... | ... | |
203 | 202 |
parameters.Add("@CURRENT_PAGE", currentPage, DbType.Int32); |
204 | 203 |
parameters.Add("@EXCEPTION", exception, DbType.String); |
205 | 204 |
|
206 |
result = await Connection.ExecuteAsync("CONVERT_UPDATE_STATUS", parameters, transaction: tran, commandType: CommandType.StoredProcedure);
|
|
205 |
result = await base.ExecuteAsync("CONVERT_UPDATE_STATUS", parameters, transaction: tran, commandType: CommandType.StoredProcedure);
|
|
207 | 206 |
tran.Commit(); |
208 | 207 |
return result; |
209 | 208 |
} |
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/DOCINFORepository.cs | ||
---|---|---|
24 | 24 |
public async Task<string> CreateAsync(string convertDocID, int PageCount) |
25 | 25 |
{ |
26 | 26 |
string result = ""; |
27 |
var tran = Connection.BeginTransaction();
|
|
27 |
var tran = BeginTransaction(); |
|
28 | 28 |
|
29 | 29 |
var parameters = new DynamicParameters(); |
30 | 30 |
parameters.Add("@CONVERT_ID", convertDocID, DbType.String); |
... | ... | |
33 | 33 |
parameters.Add("@ErrorCode", dbType: DbType.Int32, direction: ParameterDirection.Output); |
34 | 34 |
parameters.Add("@Error", dbType: DbType.String, direction: ParameterDirection.Output, size: 500); |
35 | 35 |
|
36 |
await Connection.ExecuteAsync("CONVERT_INSERT_DOCINFO", parameters, tran, commandType: CommandType.StoredProcedure);
|
|
36 |
await base.ExecuteAsync("CONVERT_INSERT_DOCINFO", parameters, tran, commandType: CommandType.StoredProcedure);
|
|
37 | 37 |
|
38 | 38 |
var errorCode = parameters.Get<int>("@ErrorCode"); |
39 | 39 |
var error = parameters.Get<string>("@Error"); |
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/DOCPAGERepository.cs | ||
---|---|---|
28 | 28 |
|
29 | 29 |
try |
30 | 30 |
{ |
31 |
var tran = Connection.BeginTransaction();
|
|
31 |
var tran = BeginTransaction(); |
|
32 | 32 |
var parameter = new DynamicParameters(); |
33 | 33 |
|
34 | 34 |
var items = docPages.Select(x => new InsertDocPage { DOCINFO_ID = x.DOCINFO_ID,PAGE_NUMBER = x.PAGE_NUMBER, PAGE_ANGLE = x.PAGE_ANGLE, PAGE_HEIGHT = x.PAGE_HEIGHT, PAGE_WIDTH = x.PAGE_WIDTH }).ToList(); |
... | ... | |
36 | 36 |
|
37 | 37 |
parameter.AddTable("@DOCPAGES", "TYPE_INSERT_DOCPAGE", items); |
38 | 38 |
|
39 |
var id = await Connection.ExecuteAsync("CONVERT_INSERT_DOCPAGE", parameter, tran, commandType: CommandType.StoredProcedure);
|
|
39 |
var id = await base.ExecuteAsync("CONVERT_INSERT_DOCPAGE", parameter, tran, commandType: CommandType.StoredProcedure);
|
|
40 | 40 |
|
41 | 41 |
tran.Commit(); |
42 | 42 |
|
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/DOCUMENTITEMRepository.cs | ||
---|---|---|
26 | 26 |
parameter.Add("@PROJECT_NO", projectNo, System.Data.DbType.String); |
27 | 27 |
parameter.Add("@DOCUMENT_ID", documentID, System.Data.DbType.String); |
28 | 28 |
|
29 |
return await Connection.QueryFirstOrDefaultAsync<DOCUMENTITEM>(SQL, parameter);
|
|
29 |
return await base.GetFirstAsync<DOCUMENTITEM>(SQL, parameter);
|
|
30 | 30 |
} |
31 | 31 |
|
32 | 32 |
/// <summary> |
... | ... | |
38 | 38 |
{ |
39 | 39 |
string result = null; |
40 | 40 |
|
41 |
var tran = Connection.BeginTransaction();
|
|
41 |
var tran = BeginTransaction(); |
|
42 | 42 |
var parameter = new DynamicParameters(); |
43 | 43 |
|
44 | 44 |
parameter.Add("@REVISION", documentItem.REVISION, DbType.String); |
... | ... | |
53 | 53 |
parameter.Add("@GROUP_NO", documentItem.GROUP_NO, DbType.String); |
54 | 54 |
parameter.Add("@NewID", dbType: DbType.String, direction: ParameterDirection.Output, size: 50); |
55 | 55 |
|
56 |
await Connection.ExecuteAsync("CONVERT_INSERT_DOCUMENTITEM", parameter, tran, commandType: CommandType.StoredProcedure);
|
|
56 |
await base.ExecuteAsync("CONVERT_INSERT_DOCUMENTITEM", parameter, tran, commandType: CommandType.StoredProcedure);
|
|
57 | 57 |
|
58 | 58 |
result = parameter.Get<string>("@NewID"); |
59 | 59 |
|
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/PROPERTIESRepository.cs | ||
---|---|---|
30 | 30 |
parameters.Add("@PROPERTY", PROPERTY, System.Data.DbType.String); |
31 | 31 |
parameters.Add("@TYPE", TYPE, System.Data.DbType.String); |
32 | 32 |
|
33 |
var result = await Connection.QueryAsync<PROPERTIES>(SQL, parameters);
|
|
33 |
var result = await base.QueryAsync<PROPERTIES>(SQL, parameters);
|
|
34 | 34 |
|
35 | 35 |
if (result == null) return null; |
36 | 36 |
list = result.ToList(); |
... | ... | |
44 | 44 |
parameters.Add("@PROPERTY", PROPERTY, System.Data.DbType.String); |
45 | 45 |
parameters.Add("@TYPE", TYPE, System.Data.DbType.String); |
46 | 46 |
|
47 |
return await Connection.QueryFirstOrDefaultAsync<PROPERTIES>(SQL, parameters);
|
|
47 |
return await base.GetFirstAsync<PROPERTIES>(SQL, parameters);
|
|
48 | 48 |
} |
49 | 49 |
} |
50 | 50 |
} |
ConvertService/ServiceBase/Markus.Service.DataBase.Dapper/Repositories/SERVICEPROPERTIESRepository.cs | ||
---|---|---|
27 | 27 |
|
28 | 28 |
string sql = "SELECT * FROM SERVICE_PROPERTIES"; |
29 | 29 |
|
30 |
var result = await Connection.QueryAsync<SERVICEPROPERTIES>(sql, null, commandType: CommandType.TableDirect);
|
|
30 |
var result = await base.QueryAsync<SERVICEPROPERTIES>(sql, null, commandType: CommandType.TableDirect);
|
|
31 | 31 |
if (result == null) return null; |
32 | 32 |
list = result.ToList(); |
33 | 33 |
|
... | ... | |
41 | 41 |
var parameter = new DynamicParameters(); |
42 | 42 |
parameter.Add("@SERVICE_ID", ServiceID, DbType.String); |
43 | 43 |
|
44 |
var result = await Connection.QuerySingleAsync<SERVICEPROPERTIES>(sql, parameter);
|
|
44 |
var result = await base.GetFirstAsync<SERVICEPROPERTIES>(sql, parameter);
|
|
45 | 45 |
|
46 | 46 |
if (result == null) |
47 | 47 |
{ |
ConvertService/ServiceBase/Markus.Service.DataBase.Test/DataBaseConvertDoc.cs | ||
---|---|---|
5 | 5 |
|
6 | 6 |
namespace Markus.Service.DataBase.Test |
7 | 7 |
{ |
8 |
public class DataBaseConvertDoc |
|
8 |
public class DataBaseConvertDoc : TestBaseMSSQL
|
|
9 | 9 |
{ |
10 |
public string ConnectionStr = "Data Source=cloud.devdoftech.co.kr,7777;Initial Catalog=markus;Persist Security Info=True;User ID=doftech;Password=dof1073#"; |
|
11 |
public Markus.Service.DataBase.DBMSType dbtype = DBMSType.MSSQL; |
|
12 |
public string ProjectNo = "000000"; |
|
13 |
public string docUri = "test://test"; |
|
14 |
|
|
15 | 10 |
public List<string> newConvertDocIDs = new List<string>(); |
16 | 11 |
|
17 | 12 |
[Test, Description("Craete Convert Doc MSSQL Test")] |
ConvertService/ServiceBase/Markus.Service.DataBase.Test/DataBaseConvertDocPG.cs | ||
---|---|---|
5 | 5 |
|
6 | 6 |
namespace Markus.Service.DataBase.Test |
7 | 7 |
{ |
8 |
public class DataBaseConvertDocPG |
|
8 |
public class DataBaseConvertDocPG : TestBasePG
|
|
9 | 9 |
{ |
10 |
public string ConnectionStr = "Host=192.168.0.67;Port=5432;Database=markus;User ID=doftech;Password=dof1073#"; |
|
11 |
public Markus.Service.DataBase.DBMSType dbtype = DBMSType.POSTGRESQL; |
|
12 |
public string ProjectNo = "000000"; |
|
13 |
public string docUri = "test://test"; |
|
14 |
|
|
15 | 10 |
public List<string> newConvertDocIDs = new List<string>(); |
11 |
[Test, Description("Craete Convert Doc MSSQL Test")] |
|
12 |
public void CreateConvertDoc() |
|
13 |
{ |
|
14 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
|
15 |
{ |
|
16 |
var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult(); |
|
17 |
|
|
18 |
newConvertDocIDs.Add(newConvertDocID); |
|
19 |
Console.WriteLine($"new id : {newConvertDocID}"); |
|
16 | 20 |
|
21 |
var newConvertDocID2 = repository.CreateAsync(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult(); |
|
22 |
|
|
23 |
newConvertDocIDs.Add(newConvertDocID2); |
|
24 |
Console.WriteLine($"new id : {newConvertDocID2}"); |
|
25 |
} |
|
26 |
|
|
27 |
GetConvertDocSingle(); |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
[Test, Description("GetConvertDocSingle Test")] |
|
32 |
private void GetConvertDocSingle() |
|
33 |
{ |
|
34 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
|
35 |
{ |
|
36 |
foreach (var convertDocID in newConvertDocIDs) |
|
37 |
{ |
|
38 |
var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: convertDocID).GetAwaiter().GetResult(); |
|
39 |
|
|
40 |
Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID} ConvertPath:{convertDoc.ConvertPath} "); |
|
41 |
} |
|
42 |
|
|
43 |
} |
|
44 |
} |
|
17 | 45 |
|
18 | 46 |
[Test, Description("Select Top 10 Convert Doc PostgreSQL Test")] |
19 | 47 |
public void SelectTop10ConvertDoc() |
... | ... | |
25 | 53 |
|
26 | 54 |
var parameter = new List<sqlParameter>(); |
27 | 55 |
parameter.Add(new sqlParameter("@CREATE_DATETIME", DateTime.Now.AddDays(-10), System.Data.DbType.DateTime)); |
28 |
|
|
56 |
|
|
29 | 57 |
var items = repository.GetAsync<Markus.Service.DataBase.Entities.ConvertDoc>(sql, parameter).GetAwaiter().GetResult(); |
30 | 58 |
|
31 | 59 |
foreach(var item in items) |
ConvertService/ServiceBase/Markus.Service.DataBase.Test/DataBaseDocPage.cs | ||
---|---|---|
4 | 4 |
|
5 | 5 |
namespace Markus.Service.DataBase.Test |
6 | 6 |
{ |
7 |
public class DataBaseDocPage |
|
7 |
public class DataBaseDocPage : TestBaseMSSQL
|
|
8 | 8 |
{ |
9 |
public string ConnectionStr = "Data Source=cloud.devdoftech.co.kr,7777;Initial Catalog=markus;Persist Security Info=True;User ID=doftech;Password=dof1073#"; |
|
10 |
public Markus.Service.DataBase.DBMSType dbtype = DBMSType.MSSQL; |
|
11 |
|
|
12 |
|
|
13 | 9 |
[Test, Description("")] |
14 | 10 |
public void DocPageInsert() |
15 | 11 |
{ |
ConvertService/ServiceBase/Markus.Service.DataBase.Test/Markus.Service.DataBase.Test.csproj | ||
---|---|---|
49 | 49 |
<Compile Include="DataBaseConvertDoc.cs" /> |
50 | 50 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
51 | 51 |
<Compile Include="DataBaseDocPage.cs" /> |
52 |
<Compile Include="TestBaseMSSQL.cs" /> |
|
53 |
<Compile Include="TestBasePG.cs" /> |
|
52 | 54 |
</ItemGroup> |
53 | 55 |
<ItemGroup> |
54 | 56 |
<ProjectReference Include="..\Markus.Service.DataBase.Dapper\Markus.Service.DataBase.Dapper.csproj"> |
내보내기 Unified diff