hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ d6a800c2
이력 | 보기 | 이력해설 | 다운로드 (18.6 KB)
1 | 5898479a | yoush97 | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | 54977253 | yoush97 | using System.Data; |
8 | |||
9 | 5898479a | yoush97 | using ID2.Manager.Data.Models; |
10 | |||
11 | 8e373ccf | yoush97 | using Dapper; |
12 | 08499f5f | taeseongkim | using System.ComponentModel; |
13 | using System.Reflection; |
||
14 | 8e373ccf | yoush97 | |
15 | 5898479a | yoush97 | namespace ID2.Manager.Dapper.Repository |
16 | { |
||
17 | public class DocumentRepository : BaseRepository |
||
18 | { |
||
19 | public DocumentRepository(string connectionStr) : base(connectionStr) { } |
||
20 | |||
21 | a4a166e2 | yoush97 | public IEnumerable<Documents> GetAllDocuments(string projectGroupID) |
22 | 5898479a | yoush97 | { |
23 | a4a166e2 | yoush97 | var dynamicParameters = new DynamicParameters(); |
24 | StringBuilder sbWhere = new StringBuilder(); |
||
25 | var parameters = new Dictionary<string, object>(); |
||
26 | if (!string.IsNullOrEmpty(projectGroupID)) |
||
27 | { |
||
28 | sbWhere.Append(" and doc.RefProjectCode in (select Code from dbo.Projects where ParentID=@RefGroupID) "); |
||
29 | parameters.Add("RefGroupID", projectGroupID); |
||
30 | } |
||
31 | |||
32 | 82705273 | yoush97 | try |
33 | { |
||
34 | string query = $@" |
||
35 | 54977253 | yoush97 | select doc.* |
36 | 7066b8a9 | yoush97 | from dbo.Documents doc |
37 | a4a166e2 | yoush97 | where doc.IsDeleted=0 {sbWhere} |
38 | 7066b8a9 | yoush97 | order by doc.Seq;"; |
39 | a4a166e2 | yoush97 | |
40 | if (parameters.Count > 0) |
||
41 | { |
||
42 | dynamicParameters.AddDynamicParams(parameters); |
||
43 | } |
||
44 | |||
45 | return Query<Documents>(query, dynamicParameters); |
||
46 | 82705273 | yoush97 | } |
47 | catch (Exception ex) |
||
48 | { |
||
49 | throw ex; |
||
50 | } |
||
51 | 7066b8a9 | yoush97 | } |
52 | 08499f5f | taeseongkim | static string GetDescriptionFromAttribute(MemberInfo member) |
53 | { |
||
54 | if (member == null) return null; |
||
55 | |||
56 | var attrib = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(DescriptionAttribute), false); |
||
57 | return (attrib?.Description ?? member.Name).ToLower(); |
||
58 | } |
||
59 | |||
60 | 7066b8a9 | yoush97 | |
61 | ee82162b | yoush97 | public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem) |
62 | 7066b8a9 | yoush97 | { |
63 | 08499f5f | taeseongkim | var map = new CustomPropertyTypeMap(typeof(AttFileInfo), (type, columnName) |
64 | => type.GetProperties().FirstOrDefault(prop => GetDescriptionFromAttribute(prop) == columnName.ToLower())); |
||
65 | SqlMapper.SetTypeMap(typeof(AttFileInfo), map); |
||
66 | |||
67 | |||
68 | 7066b8a9 | yoush97 | var dynamicParameters = new DynamicParameters(); |
69 | 54977253 | yoush97 | dynamicParameters.Add("Total", dbType: DbType.Int32, direction: ParameterDirection.Output); |
70 | 7066b8a9 | yoush97 | |
71 | 8e373ccf | yoush97 | StringBuilder sbWhere = new StringBuilder(); |
72 | bf7d1c08 | yoush97 | StringBuilder sbTotalWhere = new StringBuilder(); |
73 | 8e373ccf | yoush97 | var parameters = new Dictionary<string, object>(); |
74 | 36a31d25 | yoush97 | if (!string.IsNullOrEmpty(projectCode)) |
75 | 8e373ccf | yoush97 | { |
76 | 36a31d25 | yoush97 | sbWhere.Append(" and doc.RefProjectCode=@RefProjectCode "); |
77 | bf7d1c08 | yoush97 | sbTotalWhere.Append(" and doc.RefProjectCode=@RefProjectCode "); |
78 | 36a31d25 | yoush97 | parameters.Add("RefProjectCode", projectCode); |
79 | 8e373ccf | yoush97 | } |
80 | if (!string.IsNullOrEmpty(personIncharge)) |
||
81 | { |
||
82 | sbWhere.Append(" and doc.PersonInCharge=@PersonInCharge "); |
||
83 | parameters.Add("PersonInCharge", personIncharge); |
||
84 | } |
||
85 | 08ea0584 | yoush97 | if (!string.IsNullOrEmpty(jobLevel)) |
86 | { |
||
87 | sbWhere.Append(" and doc.JobLevel=@JobLevel "); |
||
88 | parameters.Add("JobLevel", jobLevel); |
||
89 | } |
||
90 | 8e373ccf | yoush97 | if (!string.IsNullOrEmpty(documentNo)) |
91 | { |
||
92 | sbWhere.Append(" and doc.DocumentNo like '%' + @DocumentNo +'%' "); |
||
93 | parameters.Add("DocumentNo", documentNo); |
||
94 | } |
||
95 | |||
96 | 296ffcbd | yoush97 | if (!string.IsNullOrEmpty(isToIsDiscussion)) |
97 | { |
||
98 | sbWhere.Append(" and doc.ToIsDiscussion=@ToIsDiscussion "); |
||
99 | parameters.Add("ToIsDiscussion", isToIsDiscussion); |
||
100 | } |
||
101 | |||
102 | if (!string.IsNullOrEmpty(isFrReviewStatus)) |
||
103 | { |
||
104 | sbWhere.Append(" and doc.FrReviewStatus=@FrReviewStatus "); |
||
105 | parameters.Add("FrReviewStatus", isFrReviewStatus); |
||
106 | } |
||
107 | |||
108 | 08ea0584 | yoush97 | if (!string.IsNullOrEmpty(isID2Work)) |
109 | { |
||
110 | sbWhere.Append(" and doc.IsID2Work=@IsID2Work "); |
||
111 | parameters.Add("IsID2Work", isID2Work); |
||
112 | } |
||
113 | |||
114 | if (!string.IsNullOrEmpty(id2Status)) |
||
115 | { |
||
116 | sbWhere.Append(" and doc.ID2Status=@ID2Status "); |
||
117 | parameters.Add("ID2Status", id2Status); |
||
118 | } |
||
119 | if (!string.IsNullOrEmpty(avevaStatus)) |
||
120 | { |
||
121 | sbWhere.Append(" and doc.AVEVAStatus=@AVEVAStatus "); |
||
122 | parameters.Add("AVEVAStatus", avevaStatus); |
||
123 | } |
||
124 | |||
125 | if (!string.IsNullOrEmpty(prodIsResult)) |
||
126 | { |
||
127 | sbWhere.Append(" and doc.ProdIsResult=@ProdIsResult "); |
||
128 | parameters.Add("ProdIsResult", prodIsResult); |
||
129 | } |
||
130 | if (!string.IsNullOrEmpty(clientIsResult)) |
||
131 | { |
||
132 | sbWhere.Append(" and doc.ClientIsResult=@ClientIsResult "); |
||
133 | parameters.Add("ClientIsResult", clientIsResult); |
||
134 | } |
||
135 | ee82162b | yoush97 | if (!string.IsNullOrEmpty(isGateWay)) |
136 | { |
||
137 | sbWhere.Append(" and doc.DTIsGateWay=@DTIsGateWay "); |
||
138 | parameters.Add("DTIsGateWay", isGateWay); |
||
139 | } |
||
140 | if (!string.IsNullOrEmpty(isRegSystem)) |
||
141 | { |
||
142 | sbWhere.Append(" and doc.DTIsRegSystem=@DTIsRegSystem "); |
||
143 | parameters.Add("DTIsRegSystem", isRegSystem); |
||
144 | } |
||
145 | 08ea0584 | yoush97 | |
146 | 82705273 | yoush97 | try |
147 | { |
||
148 | 08499f5f | taeseongkim | |
149 | //files.[FileID],files.[FileID] as AttFileID, files.RefID, files.Category, files.FileType, files.FileName, files.FilePath, files.FileExtension, files.FileData, files.Remark, files.CreatedDate, files.Creator, |
||
150 | string query = $@" |
||
151 | select doc.*, |
||
152 | files.[FileID] as FileID, files.*, |
||
153 | markus.MARKUP_DATA_ID as MARKUP_DATA_ID, markus.*, |
||
154 | datediff(SECOND, doc.ID2StartDate, doc.ID2EndDate) as ID2JobTime |
||
155 | e458a996 | taeseongkim | from dbo.Documents doc |
156 | 08499f5f | taeseongkim | LEFT OUTER JOIN AttachFIles files ON doc.DocID = fIles.RefID |
157 | e458a996 | taeseongkim | LEFT OUTER JOIN |
158 | 08499f5f | taeseongkim | (SELECT [MARKUP_DATA_ID] |
159 | ,[PROJECT_NO] as PROJECT_NO |
||
160 | e458a996 | taeseongkim | ,[DOCUMENT_ID] as DocumentNo |
161 | 08499f5f | taeseongkim | |
162 | e458a996 | taeseongkim | ,[PAGENUMBER] |
163 | ,[Text] as TEXT |
||
164 | ,[CREATE_DATE] as CREATE_DATE |
||
165 | ,[NAME] as CREATE_USER |
||
166 | 08499f5f | taeseongkim | FROM ViewMarkupData) markus |
167 | e458a996 | taeseongkim | ON doc.DocumentNo = markus.DocumentNo |
168 | where doc.IsDeleted=0 {sbWhere} |
||
169 | order by doc.Seq |
||
170 | 7066b8a9 | yoush97 | |
171 | 3ccb1a8d | yoush97 | select @Total=count(*) from dbo.Documents doc where doc.IsDeleted=0 {sbTotalWhere} |
172 | 7066b8a9 | yoush97 | select @Total;"; |
173 | 8e373ccf | yoush97 | |
174 | 82705273 | yoush97 | if (parameters.Count > 0) |
175 | { |
||
176 | dynamicParameters.AddDynamicParams(parameters); |
||
177 | } |
||
178 | 5898479a | yoush97 | |
179 | e458a996 | taeseongkim | var docDictionary = new Dictionary<string, Documents>(); |
180 | |||
181 | 08499f5f | taeseongkim | var ret = MultiQuery<Documents, AttFileInfo, MarkupText, Documents>(query, |
182 | (document, attfile, markusText) => |
||
183 | e458a996 | taeseongkim | { |
184 | Documents doc; |
||
185 | |||
186 | 08499f5f | taeseongkim | if (!docDictionary.TryGetValue(document.DocID, out doc)) |
187 | e458a996 | taeseongkim | { |
188 | doc = document; |
||
189 | 08499f5f | taeseongkim | docDictionary.Add(doc.DocID, doc); |
190 | } |
||
191 | |||
192 | if (markusText != null) |
||
193 | { |
||
194 | e458a996 | taeseongkim | doc.Markups = doc.Markups ?? new List<MarkupText>(); |
195 | 08499f5f | taeseongkim | |
196 | if (!doc.Markups.Any(x => x.MARKUP_DATA_ID == markusText.MARKUP_DATA_ID)) |
||
197 | { |
||
198 | doc.Markups.Add(markusText); |
||
199 | } |
||
200 | } |
||
201 | |||
202 | if (attfile != null) |
||
203 | { |
||
204 | doc.AttFiles = doc.AttFiles ?? new List<AttFileInfo>(); |
||
205 | System.Diagnostics.Debug.WriteLine(attfile.FileName); |
||
206 | if (!doc.AttFiles.Any(x => x.FileID == attfile.FileID)) |
||
207 | { |
||
208 | doc.AttFiles.Add(attfile); |
||
209 | } |
||
210 | e458a996 | taeseongkim | } |
211 | |||
212 | return doc; |
||
213 | |||
214 | 08499f5f | taeseongkim | }, dynamicParameters, splitOn: "DocID,FileID,MARKUP_DATA_ID").Distinct(); |
215 | 7066b8a9 | yoush97 | |
216 | 82705273 | yoush97 | int totalCount = dynamicParameters.Get<int>("Total"); |
217 | 7066b8a9 | yoush97 | |
218 | 82705273 | yoush97 | return (ret, totalCount); |
219 | } |
||
220 | catch (Exception ex) |
||
221 | { |
||
222 | throw ex; |
||
223 | } |
||
224 | 5898479a | yoush97 | } |
225 | 482f6326 | yoush97 | |
226 | 54977253 | yoush97 | public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId) |
227 | 482f6326 | yoush97 | { |
228 | bool isSuccess = false; |
||
229 | |||
230 | try |
||
231 | { |
||
232 | d2d4f84b | yoush97 | using (var transaction = base.BeginTransaction()) |
233 | 482f6326 | yoush97 | { |
234 | 709c1971 | yoush97 | string query = string.Empty; |
235 | |||
236 | if (delDocList.Count > 0) |
||
237 | 482f6326 | yoush97 | { |
238 | 709c1971 | yoush97 | string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList()); |
239 | |||
240 | if (docIDList.Length > 0) |
||
241 | { |
||
242 | 53fde692 | yoush97 | query = $@" |
243 | 74aa670a | yoush97 | update dbo.Documents |
244 | set IsDeleted=1 |
||
245 | 54977253 | yoush97 | ,DeletedDate=getdate(), |
246 | ,DeletedUser=@DeletedUser |
||
247 | where DocID in ('{docIDList}');"; |
||
248 | base.Execute(query, new { DeletedUser = userId }, transaction); |
||
249 | 709c1971 | yoush97 | } |
250 | } |
||
251 | 482f6326 | yoush97 | |
252 | foreach (Documents doc in docList) |
||
253 | { |
||
254 | if (string.IsNullOrEmpty(doc.DocID)) |
||
255 | { |
||
256 | 54977253 | yoush97 | doc.RegisteredUser = userId; |
257 | 482f6326 | yoush97 | query = $@" |
258 | insert into dbo.Documents |
||
259 | ( |
||
260 | 54977253 | yoush97 | DocID |
261 | ,DocumentNo |
||
262 | ,RevisonNo |
||
263 | ,RefProjectCode |
||
264 | ,DocFilePath |
||
265 | ,DocFileName |
||
266 | ,JobLevel |
||
267 | ,IsTypical |
||
268 | ,PersonInCharge |
||
269 | ,RegisteredDate |
||
270 | ,RegisteredUser |
||
271 | ,ToIsDiscussion |
||
272 | ,ToRemarks |
||
273 | ,ToCreator |
||
274 | ,ToCapture |
||
275 | ,ToIsMarkup |
||
276 | ,FrReviewStatus |
||
277 | ,FrRemarks |
||
278 | ,FrCreator |
||
279 | ,FrCapture |
||
280 | ,FrIsMarkup |
||
281 | ,IsID2Work |
||
282 | ,ID2Connection |
||
283 | ,ID2StartDate |
||
284 | ,ID2EndDate |
||
285 | ,ID2Status |
||
286 | ,ID2Issues |
||
287 | ,AVEVAConnection |
||
288 | ,AVEVAConvertDate |
||
289 | ,AVEVAReviewDate |
||
290 | ,AVEVAStatus |
||
291 | ,AVEVAIssues |
||
292 | ,ReviewFilePath |
||
293 | ,ReviewFileName |
||
294 | ,ProdReviewer |
||
295 | ,ProdIsResult |
||
296 | ,ProdRemarks |
||
297 | ,ClientReviewer |
||
298 | ,ClientIsResult |
||
299 | ,ClientRemarks |
||
300 | ,DTIsGateWay |
||
301 | ,DTIsImport |
||
302 | ,DTIsRegSystem |
||
303 | ,DTRemarks |
||
304 | 482f6326 | yoush97 | ) |
305 | values |
||
306 | ( |
||
307 | lower(newid()) |
||
308 | ,@DocumentNo |
||
309 | ,@RevisonNo |
||
310 | 36a31d25 | yoush97 | ,@RefProjectCode |
311 | 482f6326 | yoush97 | ,@DocFilePath |
312 | ,@DocFileName |
||
313 | ,@JobLevel |
||
314 | ,@IsTypical |
||
315 | ,@PersonInCharge |
||
316 | 54977253 | yoush97 | ,getdate() |
317 | ,@RegisteredUser |
||
318 | 482f6326 | yoush97 | ,@ToIsDiscussion |
319 | ,@ToRemarks |
||
320 | ,@ToCreator |
||
321 | 00d11333 | yoush97 | ,@ToCapture |
322 | 482f6326 | yoush97 | ,@ToIsMarkup |
323 | ,@FrReviewStatus |
||
324 | ,@FrRemarks |
||
325 | ,@FrCreator |
||
326 | 00d11333 | yoush97 | ,@FrCapture |
327 | 482f6326 | yoush97 | ,@FrIsMarkup |
328 | ,@IsID2Work |
||
329 | ,@ID2Connection |
||
330 | ,@ID2StartDate |
||
331 | ,@ID2EndDate |
||
332 | ,@ID2Status |
||
333 | ,@ID2Issues |
||
334 | ,@AVEVAConnection |
||
335 | ,@AVEVAConvertDate |
||
336 | ,@AVEVAReviewDate |
||
337 | ,@AVEVAStatus |
||
338 | ,@AVEVAIssues |
||
339 | ,@ReviewFilePath |
||
340 | ,@ReviewFileName |
||
341 | ,@ProdReviewer |
||
342 | ,@ProdIsResult |
||
343 | ,@ProdRemarks |
||
344 | ,@ClientReviewer |
||
345 | ,@ClientIsResult |
||
346 | ,@ClientRemarks |
||
347 | ,@DTIsGateWay |
||
348 | ,@DTIsImport |
||
349 | ,@DTIsRegSystem |
||
350 | ,@DTRemarks |
||
351 | 709c1971 | yoush97 | );"; |
352 | 482f6326 | yoush97 | } |
353 | else |
||
354 | { |
||
355 | 54977253 | yoush97 | doc.ModifiedUser = userId; |
356 | 482f6326 | yoush97 | query = $@" |
357 | update dbo.Documents |
||
358 | 54977253 | yoush97 | set DocumentNo=@DocumentNo |
359 | ,RevisonNo=@RevisonNo |
||
360 | ,RefProjectCode=@RefProjectCode |
||
361 | ,DocFilePath=@DocFilePath |
||
362 | ,DocFileName=@DocFileName |
||
363 | ,JobLevel=@JobLevel |
||
364 | ,IsTypical=@IsTypical |
||
365 | ,PersonInCharge=@PersonInCharge |
||
366 | ,ModifiedDate=getdate() |
||
367 | ,ModifiedUser=@ModifiedUser |
||
368 | ,ToIsDiscussion=@ToIsDiscussion |
||
369 | ,ToRemarks=@ToRemarks |
||
370 | ,ToCreator=@ToCreator |
||
371 | ,ToCapture=@ToCapture |
||
372 | ,ToIsMarkup=@ToIsMarkup |
||
373 | ,FrReviewStatus=@FrReviewStatus |
||
374 | ,FrRemarks=@FrRemarks |
||
375 | ,FrCreator=@FrCreator |
||
376 | ,FrCapture=@FrCapture |
||
377 | ,FrIsMarkup=@FrIsMarkup |
||
378 | ,IsID2Work=@IsID2Work |
||
379 | ,ID2Connection=@ID2Connection |
||
380 | ,ID2StartDate=@ID2StartDate |
||
381 | ,ID2EndDate=@ID2EndDate |
||
382 | ,ID2Status=@ID2Status |
||
383 | ,ID2Issues=@ID2Issues |
||
384 | ,AVEVAConnection=@AVEVAConnection |
||
385 | ,AVEVAConvertDate=@AVEVAConvertDate |
||
386 | ,AVEVAReviewDate=@AVEVAReviewDate |
||
387 | ,AVEVAStatus=@AVEVAStatus |
||
388 | ,AVEVAIssues=@AVEVAIssues |
||
389 | ,ReviewFilePath=@ReviewFilePath |
||
390 | ,ReviewFileName=@ReviewFileName |
||
391 | ,ProdReviewer=@ProdReviewer |
||
392 | ,ProdIsResult=@ProdIsResult |
||
393 | ,ProdRemarks=@ProdRemarks |
||
394 | ,ClientReviewer=@ClientReviewer |
||
395 | ,ClientIsResult=@ClientIsResult |
||
396 | ,ClientRemarks=@ClientRemarks |
||
397 | ,DTIsGateWay=@DTIsGateWay |
||
398 | ,DTIsImport=@DTIsImport |
||
399 | ,DTIsRegSystem=@DTIsRegSystem |
||
400 | ,DTRemarks=@DTRemarks |
||
401 | where DocID=@DocID;"; |
||
402 | 482f6326 | yoush97 | } |
403 | base.Execute(query, doc, transaction); |
||
404 | } |
||
405 | |||
406 | transaction.Commit(); |
||
407 | isSuccess = true; |
||
408 | } |
||
409 | } |
||
410 | catch (Exception ex) |
||
411 | { |
||
412 | throw ex; |
||
413 | } |
||
414 | |||
415 | return isSuccess; |
||
416 | } |
||
417 | 978488b0 | yoush97 | |
418 | public Documents SetDocumentDataField(Documents doc, string userId) |
||
419 | { |
||
420 | Documents resultData = null; |
||
421 | |||
422 | try |
||
423 | { |
||
424 | using (var transaction = base.BeginTransaction()) |
||
425 | { |
||
426 | string query = string.Empty; |
||
427 | |||
428 | if (!string.IsNullOrEmpty(doc.DocID)) |
||
429 | { |
||
430 | StringBuilder sbSet = new StringBuilder(); |
||
431 | var parameters = new Dictionary<string, object>(); |
||
432 | |||
433 | #region Update 할 목록 |
||
434 | if (doc.ID2StartDate != null) |
||
435 | { |
||
436 | 4b8d9ad9 | yoush97 | sbSet.Append(" ,ID2StartDate=(case when ID2StartDate is null then @DateTimeNow else ID2StartDate end) "); |
437 | 978488b0 | yoush97 | parameters.Add("ID2StartDate", doc.ID2StartDate); |
438 | } |
||
439 | 4b8d9ad9 | yoush97 | |
440 | if (doc.Worker != null) |
||
441 | { |
||
442 | sbSet.Append(" ,Worker=@Worker "); |
||
443 | parameters.Add("Worker", doc.Worker); |
||
444 | } |
||
445 | 978488b0 | yoush97 | #endregion |
446 | |||
447 | if (parameters.Count > 0) |
||
448 | { |
||
449 | sbSet.Append(" ,ModifiedUser=@ModifiedUser "); |
||
450 | parameters.Add("ModifiedUser", userId); |
||
451 | |||
452 | 54977253 | yoush97 | parameters.Add("DocID", doc.DocID); |
453 | |||
454 | 978488b0 | yoush97 | query = $@" |
455 | declare @DateTimeNow datetime |
||
456 | set @DateTimeNow = getdate() |
||
457 | |||
458 | update dbo.Documents |
||
459 | set ModifiedDate=@DateTimeNow {sbSet} |
||
460 | where [DocID]=@DocID |
||
461 | |||
462 | if @@rowcount > 0 |
||
463 | begin |
||
464 | c0420a29 | yoush97 | select *, datediff(SECOND, ID2StartDate, ID2EndDate) as ID2JobTime from dbo.Documents where DocID=@DocID |
465 | 978488b0 | yoush97 | end |
466 | else |
||
467 | begin |
||
468 | c0420a29 | yoush97 | select *, 0 as ID2JobTime from dbo.Documents where 1=2 |
469 | 978488b0 | yoush97 | end;"; |
470 | resultData = base.QueryFirstOrDefault<Documents>(query, parameters, transaction); |
||
471 | } |
||
472 | } |
||
473 | |||
474 | transaction.Commit(); |
||
475 | } |
||
476 | } |
||
477 | catch (Exception ex) |
||
478 | { |
||
479 | throw ex; |
||
480 | } |
||
481 | |||
482 | return resultData; |
||
483 | } |
||
484 | fe57f64a | yoush97 | |
485 | 54977253 | yoush97 | public bool SetDocumentDatasField(List<Documents> docs, string userId) |
486 | { |
||
487 | bool isSuccess = false; |
||
488 | |||
489 | try |
||
490 | { |
||
491 | using (var transaction = base.BeginTransaction()) |
||
492 | { |
||
493 | foreach (Documents doc in docs) |
||
494 | { |
||
495 | string query = string.Empty; |
||
496 | |||
497 | if (!string.IsNullOrEmpty(doc.DocID)) |
||
498 | { |
||
499 | StringBuilder sbSet = new StringBuilder(); |
||
500 | var parameters = new Dictionary<string, object>(); |
||
501 | |||
502 | #region Update 할 목록 |
||
503 | if (doc.ID2EndDate != null) |
||
504 | { |
||
505 | sbSet.Append(" ,ID2EndDate=@ID2EndDate "); |
||
506 | parameters.Add("ID2EndDate", doc.ID2EndDate); |
||
507 | } |
||
508 | #endregion |
||
509 | |||
510 | if (parameters.Count > 0) |
||
511 | { |
||
512 | sbSet.Append(" ,ModifiedUser=@ModifiedUser "); |
||
513 | parameters.Add("ModifiedUser", userId); |
||
514 | |||
515 | parameters.Add("DocID", doc.DocID); |
||
516 | |||
517 | query = $@" |
||
518 | update dbo.Documents |
||
519 | set ModifiedDate=getdate() {sbSet} |
||
520 | where [DocID]=@DocID;"; |
||
521 | e458a996 | taeseongkim | base.Execute(query, parameters, transaction); |
522 | 54977253 | yoush97 | } |
523 | } |
||
524 | } |
||
525 | transaction.Commit(); |
||
526 | isSuccess = true; |
||
527 | } |
||
528 | } |
||
529 | catch (Exception ex) |
||
530 | { |
||
531 | throw ex; |
||
532 | } |
||
533 | |||
534 | return isSuccess; |
||
535 | } |
||
536 | |||
537 | fe57f64a | yoush97 | |
538 | //ID2 |
||
539 | public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info) |
||
540 | { |
||
541 | 82705273 | yoush97 | try |
542 | { |
||
543 | string query = $@" |
||
544 | fe57f64a | yoush97 | select @Name PROJECTNAME |
545 | ,dw.[UID], dw.[NAME], left(dw.[NAME], len(dw.[NAME]) - dw.lastidx) DOCNAME |
||
546 | ,case when rtrim(ltrim(isnull(convert(varchar, dw.[DATETIME]),''))) = '' then null else convert(datetime, convert(varchar, dw.[DATETIME])) end [DATETIME] |
||
547 | ,dw.OCCUPIED, dw.[Image] |
||
548 | from |
||
549 | ( |
||
550 | select [UID], [NAME], [DATETIME], OCCUPIED, [Image], charindex('.', reverse([NAME])) lastidx |
||
551 | from dbo.Drawings |
||
552 | ) dw;"; |
||
553 | 82705273 | yoush97 | return Query<ID2Drawings>(query, id2Info); |
554 | } |
||
555 | catch (Exception ex) |
||
556 | { |
||
557 | throw ex; |
||
558 | } |
||
559 | fe57f64a | yoush97 | } |
560 | 5898479a | yoush97 | } |
561 | d2d4f84b | yoush97 | } |