프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ 79d7836e

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

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

    
7
using System.Data;
8

    
9
using ID2.Manager.Data.Models;
10

    
11
using Dapper;
12
using System.ComponentModel;
13
using System.Reflection;
14

    
15
namespace ID2.Manager.Dapper.Repository
16
{
17
    public class DocumentRepository : BaseRepository
18
    {
19
        public DocumentRepository(string connectionStr) : base(connectionStr) { }
20

    
21
        public IEnumerable<Documents> GetAllDocuments(string projectGroupID)
22
        {
23
            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
            try
33
            {
34
                string query = $@"
35
select   doc.*
36
from     dbo.Documents doc
37
where    doc.IsDeleted=0 {sbWhere}
38
order by doc.Seq;";
39

    
40
                if (parameters.Count > 0)
41
                {
42
                    dynamicParameters.AddDynamicParams(parameters);
43
                }
44

    
45
                return Query<Documents>(query, dynamicParameters);
46
            }
47
            catch (Exception ex)
48
            {
49
                throw ex;
50
            }
51
        }
52
        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

    
61
        public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(string projectGroupID, List<string> dateTypes, DateTime? frDate, DateTime? toDate, string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string id2Issues, string avevaStatus, string avevaIssues, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem)
62
        {
63
            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
            var dynamicParameters = new DynamicParameters();
69
            dynamicParameters.Add("Total", dbType: DbType.Int32, direction: ParameterDirection.Output);
70

    
71
            StringBuilder sbWhere = new StringBuilder();
72
            StringBuilder sbTotalWhere = new StringBuilder();
73
            var parameters = new Dictionary<string, object>();
74
            if (dateTypes.Count > 0 && (frDate != null || toDate != null))
75
            {
76
                List<string> subWheres = new List<string>();
77
                foreach (string dateType in dateTypes)
78
                {
79
                    StringBuilder sbSubWhere = new StringBuilder();
80
                    if (frDate != null)
81
                    {
82
                        sbSubWhere.Insert(0, $@"convert(datetime, '{Convert.ToDateTime(frDate).AddDays(-1):yyyy-MM-dd 23:59:59.997}') < doc.{dateType}");
83
                    }
84
                    if (toDate != null)
85
                    {
86
                        if (frDate != null)
87
                            sbSubWhere.Append($@" and ");
88
                        sbSubWhere.Append($@"doc.{dateType} < convert(datetime, '{Convert.ToDateTime(toDate).AddDays(1):yyyy-MM-dd 00:00:00.000}')");
89
                    }
90

    
91
                    if (sbSubWhere.Length > 0)
92
                    {
93
                        subWheres.Add("(" + sbSubWhere.ToString() + ")");
94
                    }
95
                }
96

    
97
                if (subWheres.Count > 0)
98
                {
99
                    sbWhere.Append(" and (" + string.Join(" or ", subWheres) + ") ");
100
                }
101
            }
102
            if (string.IsNullOrEmpty(projectCode))
103
            {
104
                sbWhere.Append(" and isnull(doc.RefProjectCode,'') in (select Code from dbo.Projects where ParentID=@RefGroupID union all select '') ");
105
                sbTotalWhere.Append(" and isnull(doc.RefProjectCode,'') in (select Code from dbo.Projects where ParentID=@RefGroupID union all select '') ");
106
                parameters.Add("RefGroupID", projectGroupID);
107
            }
108
            else
109
            {
110
                sbTotalWhere.Append(" and isnull(doc.RefProjectCode,'') in (select Code from dbo.Projects where ParentID=@RefGroupID union all select '') ");
111
                parameters.Add("RefGroupID", projectGroupID);
112

    
113
                sbWhere.Append(" and doc.RefProjectCode=@RefProjectCode ");
114
                parameters.Add("RefProjectCode", projectCode);
115
            }
116
            if (!string.IsNullOrEmpty(personIncharge))
117
            {
118
                sbWhere.Append(" and doc.PersonInCharge=@PersonInCharge ");
119
                parameters.Add("PersonInCharge", personIncharge);
120
            }
121
            if (!string.IsNullOrEmpty(jobLevel))
122
            {
123
                sbWhere.Append(" and doc.JobLevel=@JobLevel ");
124
                parameters.Add("JobLevel", jobLevel);
125
            }
126
            if (!string.IsNullOrEmpty(documentNo))
127
            {
128
                sbWhere.Append(" and doc.DocumentNo like '%' + @DocumentNo +'%' ");
129
                parameters.Add("DocumentNo", documentNo);
130
            }
131

    
132
            if (!string.IsNullOrEmpty(isToIsDiscussion))
133
            {
134
                sbWhere.Append(" and doc.ToIsDiscussion=@ToIsDiscussion ");
135
                parameters.Add("ToIsDiscussion", isToIsDiscussion);
136
            }
137

    
138
            if (!string.IsNullOrEmpty(isFrReviewStatus))
139
            {
140
                sbWhere.Append(" and doc.FrReviewStatus=@FrReviewStatus ");
141
                parameters.Add("FrReviewStatus", isFrReviewStatus);
142
            }
143

    
144
            if (!string.IsNullOrEmpty(isID2Work))
145
            {
146
                sbWhere.Append(" and doc.IsID2Work=@IsID2Work ");
147
                parameters.Add("IsID2Work", isID2Work);
148
            }
149

    
150
            if (!string.IsNullOrEmpty(id2Status))
151
            {
152
                sbWhere.Append(" and doc.ID2Status=@ID2Status ");
153
                parameters.Add("ID2Status", id2Status);
154
            }
155

    
156
            if (!string.IsNullOrEmpty(id2Issues))
157
            {
158
                sbWhere.Append(" and (case when isnull(ltrim(rtrim(doc.ID2Issues)),'') = '' then 'No' else 'Yes' end)=@ID2Issues ");
159
                parameters.Add("ID2Issues", id2Issues);
160
            }
161
            
162
            if (!string.IsNullOrEmpty(avevaStatus))
163
            {
164
                sbWhere.Append(" and doc.AVEVAStatus=@AVEVAStatus ");
165
                parameters.Add("AVEVAStatus", avevaStatus);
166
            }
167

    
168
            if (!string.IsNullOrEmpty(avevaIssues))
169
            {
170
                sbWhere.Append(" and (case when isnull(ltrim(rtrim(doc.AVEVAIssues)),'') = '' then 'No' else 'Yes' end)=@AVEVAIssues ");
171
                parameters.Add("AVEVAIssues", avevaIssues);
172
            }
173

    
174
            if (!string.IsNullOrEmpty(prodIsResult))
175
            {
176
                sbWhere.Append(" and doc.ProdIsResult=@ProdIsResult ");
177
                parameters.Add("ProdIsResult", prodIsResult);
178
            }
179
            if (!string.IsNullOrEmpty(clientIsResult))
180
            {
181
                sbWhere.Append(" and doc.ClientIsResult=@ClientIsResult ");
182
                parameters.Add("ClientIsResult", clientIsResult);
183
            }
184
            if (!string.IsNullOrEmpty(isGateWay))
185
            {
186
                sbWhere.Append(" and doc.DTIsGateWay=@DTIsGateWay ");
187
                parameters.Add("DTIsGateWay", isGateWay);
188
            }
189
            if (!string.IsNullOrEmpty(isRegSystem))
190
            {
191
                sbWhere.Append(" and doc.DTIsRegSystem=@DTIsRegSystem ");
192
                parameters.Add("DTIsRegSystem", isRegSystem);
193
            }
194

    
195
            try
196
            {
197

    
198
                //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,
199
                string query = $@"
200
select  doc.*,
201
files.[FileID] as FileID, files.*,
202
markus.PROJECT_NO as PROJECT_NO, markus.*
203
from     dbo.Documents doc
204
LEFT OUTER JOIN AttachFIles files ON doc.DocID = fIles.RefID 
205
LEFT OUTER JOIN 
206
        (SELECT [PROJECT_NO] as PROJECT_NO
207
                ,[DOCUMENT_ID] as DocumentNo
208
                                          
209
                ,[PAGENUMBER]
210
                ,[Text] as TEXT
211
                ,[CREATE_DATE] as CREATE_DATE
212
                ,[NAME] as CREATE_USER
213
            FROM ViewMarkupData) markus 
214
ON doc.DocumentNo = markus.DocumentNo
215
where    doc.IsDeleted=0 {sbWhere}
216
order by doc.Seq
217

    
218
select @Total=count(*) from dbo.Documents doc where doc.IsDeleted=0 {sbTotalWhere}
219
select @Total;";
220

    
221
                if (parameters.Count > 0)
222
                {
223
                    dynamicParameters.AddDynamicParams(parameters);
224
                }
225

    
226
                var docDictionary = new Dictionary<string, Documents>();
227

    
228
                var ret = MultiQuery<Documents, AttFileInfo, MarkupText, Documents>(query,
229
                                (document, attfile, markusText) =>
230
                                {
231
                                    Documents doc;
232

    
233
                                    if (!docDictionary.TryGetValue(document.DocID, out doc))
234
                                    {
235
                                        doc = document;
236
                                        docDictionary.Add(doc.DocID, doc);
237
                                    }
238

    
239
                                    if (markusText != null)
240
                                    {
241
                                        doc.Markups = doc.Markups ?? new List<MarkupText>();
242

    
243
                                        if (!doc.Markups.Any(x => x.Equals(markusText)))
244
                                        {
245
                                            doc.Markups.Add(markusText);
246
                                        }
247
                                    }
248

    
249
                                    if (attfile != null)
250
                                    {
251
                                        doc.AttFiles = doc.AttFiles ?? new List<AttFileInfo>();
252
                                        System.Diagnostics.Debug.WriteLine(attfile.FileName);
253
                                        if (!doc.AttFiles.Any(x => x.FileID == attfile.FileID))
254
                                        {
255
                                            switch (attfile.Category)
256
                                            {
257
                                                case "toreview":
258
                                                    doc.ToCapture++;
259
                                                    break;
260
                                                case "frreview":
261
                                                    doc.FrCapture++;
262
                                                    break;
263
                                                case "prodvalidation":
264
                                                    doc.ProdCapture++;
265
                                                    break;
266
                                                case "clientvalidation":
267
                                                    doc.ClientCapture++;
268
                                                    break;
269
                                            }
270

    
271
                                            doc.AttFiles.Add(attfile);
272
                                        }
273
                                    }
274

    
275
                                    return doc;
276

    
277
                                }, dynamicParameters, splitOn: "DocID,FileID,PROJECT_NO").Distinct();
278

    
279
                int totalCount = dynamicParameters.Get<int>("Total");
280

    
281
                return (ret, totalCount);
282
            }
283
            catch (Exception ex)
284
            {
285
                throw ex;
286
            }
287
        }
288

    
289
        public int ExistsDocument(string projectGroupID, List<string> newDwgNos)
290
        {
291
            var dynamicParameters = new DynamicParameters();
292
            StringBuilder sbWhere = new StringBuilder();
293
            var parameters = new Dictionary<string, object>();
294
            if (!string.IsNullOrEmpty(projectGroupID))
295
            {
296
                sbWhere.Append(" and doc.RefProjectCode in (select Code from dbo.Projects where ParentID=@RefGroupID) ");
297
                parameters.Add("RefGroupID", projectGroupID);
298
            }
299

    
300
            if (newDwgNos.Count > 0)
301
            {
302
                string dwgNoList = string.Join("','", newDwgNos.Where(x => !string.IsNullOrEmpty(x)).Select(x => x).ToList());
303

    
304
                if (dwgNoList.Length > 0)
305
                {
306
                    if (!string.IsNullOrEmpty(projectGroupID))
307
                    {
308
                        sbWhere.Append($@" and doc.DocumentNo in ('{dwgNoList}') ");
309
                    }
310
                }
311
            }
312

    
313
            try
314
            {
315
                string query = $@"
316
select   count(*) cnt
317
from     dbo.Documents doc
318
where    doc.IsDeleted=0 {sbWhere}";
319

    
320
                if (parameters.Count > 0)
321
                {
322
                    dynamicParameters.AddDynamicParams(parameters);
323
                }
324

    
325
                return ExecuteScalar<int>(query, dynamicParameters);
326
            }
327
            catch (Exception ex)
328
            {
329
                throw ex;
330
            }
331
        }
332

    
333
        public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId)
334
        {
335
            bool isSuccess = false;
336

    
337
            try
338
            {
339
                using (var transaction = base.BeginTransaction())
340
                {
341
                    string query = string.Empty;
342

    
343
                    if (delDocList.Count > 0)
344
                    {
345
                        string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList());
346

    
347
                        if (docIDList.Length > 0)
348
                        {
349
                            query = $@"
350
update dbo.Documents
351
set    IsDeleted=1
352
      ,DeletedDate=getdate(),
353
      ,DeletedUser=@DeletedUser
354
where  DocID in ('{docIDList}');";
355
                            base.Execute(query, new { DeletedUser = userId }, transaction);
356
                        }
357
                    }
358

    
359
                    foreach (Documents doc in docList)
360
                    {
361
                        if (string.IsNullOrEmpty(doc.DocID))
362
                        {
363
                            doc.RegisteredUser = userId;
364
                            query = $@"
365
declare @tbdoc table(docid varchar(36))
366
insert into dbo.Documents
367
(
368
     DocID
369
    ,DocumentNo
370
    ,RevisonNo
371
    ,System
372
    ,SubSystemCode
373
    ,RefProjectCode
374
    ,JobLevel
375
    ,IsTypical
376
    ,PersonInCharge
377
    ,RegisteredDate
378
    ,RegisteredUser
379
    ,ToIsDiscussion
380
    ,ToRemarks
381
    ,ToCreator
382
    ,ToIsMarkup
383
    ,FrReviewStatus
384
    ,FrRemarks
385
    ,FrCreator
386
    ,FrIsMarkup
387
    ,IsID2Work
388
    ,ID2Connection
389
    ,ID2StartDate
390
    ,ID2EndDate
391
    ,ID2Status
392
    ,ID2Issues
393
    ,AVEVAConnection
394
    ,AVEVAConvertDate
395
    ,AVEVAReviewDate
396
    ,AVEVAStatus
397
    ,AVEVAIssues
398
    ,ReviewFilePath
399
    ,ReviewFileName
400
    ,ProdReviewer
401
    ,ProdIsResult
402
    ,ProdRemarks
403
    ,ClientReviewer
404
    ,ClientIsResult
405
    ,ClientRemarks
406
    ,DTIsGateWay
407
    ,DTIsImport
408
    ,DTIsRegSystem
409
    ,DTRemarks
410
)
411
output inserted.DocID into @tbdoc
412
values 
413
(
414
     lower(newid())
415
    ,@DocumentNo
416
    ,@RevisonNo
417
    ,@System
418
    ,@SubSystemCode
419
    ,@RefProjectCode
420
    ,@JobLevel
421
    ,@IsTypical
422
    ,@PersonInCharge
423
    ,getdate()
424
    ,@RegisteredUser
425
    ,@ToIsDiscussion
426
    ,@ToRemarks
427
    ,@ToCreator
428
    ,@ToIsMarkup
429
    ,@FrReviewStatus
430
    ,@FrRemarks
431
    ,@FrCreator
432
    ,@FrIsMarkup
433
    ,@IsID2Work
434
    ,@ID2Connection
435
    ,@ID2StartDate
436
    ,@ID2EndDate
437
    ,@ID2Status
438
    ,@ID2Issues
439
    ,@AVEVAConnection
440
    ,@AVEVAConvertDate
441
    ,@AVEVAReviewDate
442
    ,@AVEVAStatus
443
    ,@AVEVAIssues
444
    ,@ReviewFilePath
445
    ,@ReviewFileName
446
    ,@ProdReviewer
447
    ,@ProdIsResult
448
    ,@ProdRemarks
449
    ,@ClientReviewer
450
    ,@ClientIsResult
451
    ,@ClientRemarks
452
    ,@DTIsGateWay
453
    ,@DTIsImport
454
    ,@DTIsRegSystem
455
    ,@DTRemarks
456
)
457

    
458
if @@rowcount > 0
459
begin
460
    select docid from @tbdoc
461
end
462
else
463
begin
464
    select ''
465
end;";
466
                        }
467
                        else
468
                        {
469
                            doc.ModifiedUser = userId;
470
                            query = $@"
471
update dbo.Documents
472
set    DocumentNo=@DocumentNo
473
      ,RevisonNo=@RevisonNo
474
      ,System=@System
475
      ,SubSystemCode=@SubSystemCode
476
      ,RefProjectCode=@RefProjectCode
477
      ,JobLevel=@JobLevel
478
      ,IsTypical=@IsTypical
479
      ,PersonInCharge=@PersonInCharge
480
      ,ModifiedDate=getdate()
481
      ,ModifiedUser=@ModifiedUser
482
      ,ToIsDiscussion=@ToIsDiscussion
483
      ,ToRemarks=@ToRemarks
484
      ,ToCreator=@ToCreator
485
      ,ToIsMarkup=@ToIsMarkup
486
      ,FrReviewStatus=@FrReviewStatus
487
      ,FrRemarks=@FrRemarks
488
      ,FrCreator=@FrCreator
489
      ,FrIsMarkup=@FrIsMarkup
490
      ,IsID2Work=@IsID2Work
491
      ,ID2Connection=@ID2Connection
492
      ,ID2StartDate=@ID2StartDate
493
      ,ID2EndDate=@ID2EndDate
494
      ,ID2Status=@ID2Status
495
      ,ID2Issues=@ID2Issues
496
      ,AVEVAConnection=@AVEVAConnection
497
      ,AVEVAConvertDate=@AVEVAConvertDate
498
      ,AVEVAReviewDate=@AVEVAReviewDate
499
      ,AVEVAStatus=@AVEVAStatus
500
      ,AVEVAIssues=@AVEVAIssues
501
      ,ReviewFilePath=@ReviewFilePath
502
      ,ReviewFileName=@ReviewFileName
503
      ,ProdReviewer=@ProdReviewer
504
      ,ProdIsResult=@ProdIsResult
505
      ,ProdRemarks=@ProdRemarks
506
      ,ClientReviewer=@ClientReviewer
507
      ,ClientIsResult=@ClientIsResult
508
      ,ClientRemarks=@ClientRemarks
509
      ,DTIsGateWay=@DTIsGateWay
510
      ,DTIsImport=@DTIsImport
511
      ,DTIsRegSystem=@DTIsRegSystem
512
      ,DTRemarks=@DTRemarks
513
where  DocID=@DocID
514

    
515
if @@rowcount > 0
516
begin
517
    select @DocID
518
end
519
else
520
begin
521
    select ''
522
end;";
523
                        }
524
                        string refID = base.QueryFirstOrDefault<string>(query, doc, transaction);
525

    
526
                        if (doc.AttFiles != null && doc.AttFiles.Count > 0)
527
                        {
528
                            string attDelIDList = string.Join("','", doc.AttFiles.Where(x => !string.IsNullOrEmpty(x.FileID)).Select(x => x.FileID).ToList());
529

    
530
                            if (!string.IsNullOrEmpty(refID) && attDelIDList.Length > 0)
531
                            {
532
                                query = $@"
533
delete from dbo.AttachFIles
534
where  RefID=@RefID and FileID in ('{attDelIDList}');";
535
                                base.Execute(query, new { RefID = refID }, transaction);
536
                            }
537

    
538
                            foreach (AttFileInfo attFile in doc.AttFiles)
539
                            {
540
                                if (string.IsNullOrEmpty(attFile.RefID))
541
                                {
542
                                    attFile.RefID = refID;
543
                                    attFile.Creator = userId;
544

    
545
                                    query = $@"
546
insert into dbo.AttachFIles (FileID,RefID,Category,FileType,FileName,FilePath,FileExtension,FileData,Creator)
547
values
548
(
549
    lower(newid())
550
   ,@RefID
551
   ,@Category
552
   ,@FileType
553
   ,@FileName
554
   ,@FilePath
555
   ,@FileExtension
556
   ,@FileData
557
   ,@Creator
558
)";
559

    
560
                                    base.Execute(query, attFile, transaction);
561
                                }
562
                            }
563
                        }
564
                    }
565

    
566
                    transaction.Commit();
567
                    isSuccess = true;
568
                }
569
            }
570
            catch (Exception ex)
571
            {
572
                throw ex;
573
            }
574

    
575
            return isSuccess;
576
        }
577

    
578
        public Documents SetDocumentDataField(Documents doc, string userId)
579
        {
580
            Documents resultData = null;
581

    
582
            try
583
            {
584
                using (var transaction = base.BeginTransaction())
585
                {
586
                    string query = string.Empty;
587

    
588
                    if (!string.IsNullOrEmpty(doc.DocID))
589
                    {
590
                        StringBuilder sbSet = new StringBuilder();
591
                        var parameters = new Dictionary<string, object>();
592

    
593
                        #region Update 할 목록
594
                        if (doc.ID2StartDate != null)
595
                        {
596
                            sbSet.Append(" ,ID2StartDate=(case when ID2StartDate is null then @DateTimeNow else ID2StartDate end) ");
597
                            parameters.Add("ID2StartDate", doc.ID2StartDate);
598
                        }
599

    
600
                        if (doc.Worker != null)
601
                        {
602
                            sbSet.Append(" ,Worker=@Worker ");
603
                            parameters.Add("Worker", doc.Worker);
604
                        }
605
                        #endregion
606

    
607
                        if (parameters.Count > 0)
608
                        {
609
                            sbSet.Append(" ,ModifiedUser=@ModifiedUser ");
610
                            parameters.Add("ModifiedUser", userId);
611

    
612
                            parameters.Add("DocID", doc.DocID);
613

    
614
                            query = $@"
615
declare @DateTimeNow datetime
616
set @DateTimeNow = getdate()
617

    
618
update dbo.Documents
619
set    ModifiedDate=@DateTimeNow {sbSet}
620
where  [DocID]=@DocID
621

    
622
if @@rowcount > 0
623
begin
624
    select * from dbo.Documents where DocID=@DocID
625
end
626
else
627
begin
628
    select * from dbo.Documents where 1=2
629
end;";
630
                            resultData = base.QueryFirstOrDefault<Documents>(query, parameters, transaction);
631
                        }
632
                    }
633

    
634
                    transaction.Commit();
635
                }
636
            }
637
            catch (Exception ex)
638
            {
639
                throw ex;
640
            }
641

    
642
            return resultData;
643
        }
644

    
645
        public bool SetDocumentDatasField(List<Documents> docs, string userId)
646
        {
647
            bool isSuccess = false;
648

    
649
            try
650
            {
651
                using (var transaction = base.BeginTransaction())
652
                {
653
                    foreach (Documents doc in docs)
654
                    {
655
                        string query = string.Empty;
656

    
657
                        if (!string.IsNullOrEmpty(doc.DocID))
658
                        {
659
                            StringBuilder sbSet = new StringBuilder();
660
                            var parameters = new Dictionary<string, object>();
661

    
662
                            #region Update 할 목록
663
                            if (doc.ID2EndDate != null)
664
                            {
665
                                sbSet.Append(" ,ID2EndDate=@ID2EndDate ");
666
                                parameters.Add("ID2EndDate", doc.ID2EndDate);
667
                            }
668
                            #endregion
669

    
670
                            if (parameters.Count > 0)
671
                            {
672
                                sbSet.Append(" ,ModifiedUser=@ModifiedUser ");
673
                                parameters.Add("ModifiedUser", userId);
674

    
675
                                parameters.Add("DocID", doc.DocID);
676

    
677
                                query = $@"
678
update dbo.Documents
679
set    ModifiedDate=getdate() {sbSet}
680
where  [DocID]=@DocID;";
681
                                base.Execute(query, parameters, transaction);
682
                            }
683
                        }
684
                    }
685
                    transaction.Commit();
686
                    isSuccess = true;
687
                }
688
            }
689
            catch (Exception ex)
690
            {
691
                throw ex;
692
            }
693

    
694
            return isSuccess;
695
        }
696

    
697

    
698
        //ID2
699
        public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info)
700
        {
701
            try
702
            {
703
                string query = $@"
704
select @Name PROJECTNAME
705
      ,dw.[UID], dw.[NAME], left(dw.[NAME], len(dw.[NAME]) - dw.lastidx) DOCNAME
706
      ,case when rtrim(ltrim(isnull(convert(varchar, dw.[DATETIME]),''))) = '' then null else convert(datetime, convert(varchar, dw.[DATETIME])) end [DATETIME]
707
      ,dw.OCCUPIED, dw.[Image]
708
from
709
(
710
    select [UID], [NAME], [DATETIME], OCCUPIED, [Image], charindex('.', reverse([NAME])) lastidx
711
    from   dbo.Drawings
712
) dw;";
713
                return Query<ID2Drawings>(query, id2Info);
714
            }
715
            catch (Exception ex)
716
            {
717
                throw ex;
718
            }
719
        }
720
    }
721
}
클립보드 이미지 추가 (최대 크기: 500 MB)