개정판 9107c43b
issue #0000
dapper param 입력 제한으로
2000 개씩 조회해서 document 중복체크로직 변경
Change-Id: I68d48348cfe74f913658995a434497bd96198272
ID2.Manager/ID2.Manager.Dapper/Repository/DocumentRepository.cs | ||
---|---|---|
285 | 285 |
|
286 | 286 |
public int ExistsDocument(string projectGroupID, List<string> newDwgNos) |
287 | 287 |
{ |
288 |
var dynamicParameters = new DynamicParameters(); |
|
289 |
StringBuilder sbWhere = new StringBuilder(); |
|
290 |
var parameters = new Dictionary<string, object>(); |
|
291 |
if (!string.IsNullOrEmpty(projectGroupID)) |
|
292 |
{ |
|
293 |
sbWhere.Append(" and doc.RefProjectCode in (select Code from dbo.Projects where ParentID=@RefGroupID) "); |
|
294 |
parameters.Add("RefGroupID", projectGroupID); |
|
295 |
} |
|
288 |
int existCount = 0; |
|
296 | 289 |
|
297 |
if (newDwgNos.Count > 0) |
|
298 |
{ |
|
299 |
string dwgNoList = string.Join("','", newDwgNos.Where(x => !string.IsNullOrEmpty(x)).Select(x => x).ToList()); |
|
290 |
int paramMaxCount = 2000; |
|
291 |
int execCount = (newDwgNos.Count / paramMaxCount) + 1; |
|
300 | 292 |
|
301 |
if (dwgNoList.Length > 0) |
|
293 |
for (int i = 0; i < execCount; i++) |
|
294 |
{ |
|
295 |
var dynamicParameters = new DynamicParameters(); |
|
296 |
StringBuilder sbWhere = new StringBuilder(); |
|
297 |
var parameters = new Dictionary<string, object>(); |
|
298 |
if (!string.IsNullOrEmpty(projectGroupID)) |
|
302 | 299 |
{ |
303 |
if (!string.IsNullOrEmpty(projectGroupID)) |
|
304 |
{ |
|
305 |
sbWhere.Append($@" and doc.DocumentNo in ('{dwgNoList}') "); |
|
306 |
} |
|
300 |
sbWhere.Append(" and doc.RefProjectCode in (select Code from dbo.Projects where ParentID=@RefGroupID) "); |
|
301 |
parameters.Add("RefGroupID", projectGroupID); |
|
307 | 302 |
} |
308 |
} |
|
309 | 303 |
|
310 |
try |
|
311 |
{ |
|
312 |
string query = $@" |
|
304 |
var limitDwgNos = newDwgNos.Skip(paramMaxCount * i).Take(paramMaxCount).ToList(); |
|
305 |
sbWhere.Append($@" and doc.DocumentNo in @limitDwgNos "); |
|
306 |
parameters.Add("limitDwgNos", limitDwgNos); |
|
307 |
|
|
308 |
try |
|
309 |
{ |
|
310 |
string query = $@" |
|
313 | 311 |
select count(*) cnt |
314 | 312 |
from dbo.Documents doc |
315 | 313 |
where doc.IsDeleted=0 {sbWhere}"; |
316 | 314 |
|
317 |
if (parameters.Count > 0) |
|
315 |
if (parameters.Count > 0) |
|
316 |
{ |
|
317 |
dynamicParameters.AddDynamicParams(parameters); |
|
318 |
} |
|
319 |
|
|
320 |
existCount += ExecuteScalar<int>(query, dynamicParameters); |
|
321 |
} |
|
322 |
catch (Exception ex) |
|
318 | 323 |
{ |
319 |
dynamicParameters.AddDynamicParams(parameters);
|
|
324 |
throw ex;
|
|
320 | 325 |
} |
321 |
|
|
322 |
return ExecuteScalar<int>(query, dynamicParameters); |
|
323 |
} |
|
324 |
catch (Exception ex) |
|
325 |
{ |
|
326 |
throw ex; |
|
327 | 326 |
} |
327 |
|
|
328 |
return existCount; |
|
328 | 329 |
} |
329 | 330 |
|
330 | 331 |
public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId) |
내보내기 Unified diff