프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ fe310cac

이력 | 보기 | 이력해설 | 다운로드 (24.1 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
    ,RefProjectCode
372
    ,JobLevel
373
    ,IsTypical
374
    ,PersonInCharge
375
    ,RegisteredDate
376
    ,RegisteredUser
377
    ,ToIsDiscussion
378
    ,ToRemarks
379
    ,ToCreator
380
    ,ToIsMarkup
381
    ,FrReviewStatus
382
    ,FrRemarks
383
    ,FrCreator
384
    ,FrIsMarkup
385
    ,IsID2Work
386
    ,ID2Connection
387
    ,ID2StartDate
388
    ,ID2EndDate
389
    ,ID2Status
390
    ,ID2Issues
391
    ,AVEVAConnection
392
    ,AVEVAConvertDate
393
    ,AVEVAReviewDate
394
    ,AVEVAStatus
395
    ,AVEVAIssues
396
    ,ReviewFilePath
397
    ,ReviewFileName
398
    ,ProdReviewer
399
    ,ProdIsResult
400
    ,ProdRemarks
401
    ,ClientReviewer
402
    ,ClientIsResult
403
    ,ClientRemarks
404
    ,DTIsGateWay
405
    ,DTIsImport
406
    ,DTIsRegSystem
407
    ,DTRemarks
408
)
409
output inserted.DocID into @tbdoc
410
values 
411
(
412
     lower(newid())
413
    ,@DocumentNo
414
    ,@RevisonNo
415
    ,@RefProjectCode
416
    ,@JobLevel
417
    ,@IsTypical
418
    ,@PersonInCharge
419
    ,getdate()
420
    ,@RegisteredUser
421
    ,@ToIsDiscussion
422
    ,@ToRemarks
423
    ,@ToCreator
424
    ,@ToIsMarkup
425
    ,@FrReviewStatus
426
    ,@FrRemarks
427
    ,@FrCreator
428
    ,@FrIsMarkup
429
    ,@IsID2Work
430
    ,@ID2Connection
431
    ,@ID2StartDate
432
    ,@ID2EndDate
433
    ,@ID2Status
434
    ,@ID2Issues
435
    ,@AVEVAConnection
436
    ,@AVEVAConvertDate
437
    ,@AVEVAReviewDate
438
    ,@AVEVAStatus
439
    ,@AVEVAIssues
440
    ,@ReviewFilePath
441
    ,@ReviewFileName
442
    ,@ProdReviewer
443
    ,@ProdIsResult
444
    ,@ProdRemarks
445
    ,@ClientReviewer
446
    ,@ClientIsResult
447
    ,@ClientRemarks
448
    ,@DTIsGateWay
449
    ,@DTIsImport
450
    ,@DTIsRegSystem
451
    ,@DTRemarks
452
)
453

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

    
509
if @@rowcount > 0
510
begin
511
    select @DocID
512
end
513
else
514
begin
515
    select ''
516
end;";
517
                        }
518
                        string refID = base.QueryFirstOrDefault<string>(query, doc, transaction);
519

    
520
                        if (doc.AttFiles != null && doc.AttFiles.Count > 0)
521
                        {
522
                            string attDelIDList = string.Join("','", doc.AttFiles.Where(x => !string.IsNullOrEmpty(x.FileID)).Select(x => x.FileID).ToList());
523

    
524
                            if (!string.IsNullOrEmpty(refID) && attDelIDList.Length > 0)
525
                            {
526
                                query = $@"
527
delete from dbo.AttachFIles
528
where  RefID=@RefID and FileID in ('{attDelIDList}');";
529
                                base.Execute(query, new { RefID = refID }, transaction);
530
                            }
531

    
532
                            foreach (AttFileInfo attFile in doc.AttFiles)
533
                            {
534
                                if (string.IsNullOrEmpty(attFile.RefID))
535
                                {
536
                                    attFile.RefID = refID;
537
                                    attFile.Creator = userId;
538

    
539
                                    query = $@"
540
insert into dbo.AttachFIles (FileID,RefID,Category,FileType,FileName,FilePath,FileExtension,FileData,Creator)
541
values
542
(
543
    lower(newid())
544
   ,@RefID
545
   ,@Category
546
   ,@FileType
547
   ,@FileName
548
   ,@FilePath
549
   ,@FileExtension
550
   ,@FileData
551
   ,@Creator
552
)";
553

    
554
                                    base.Execute(query, attFile, transaction);
555
                                }
556
                            }
557
                        }
558
                    }
559

    
560
                    transaction.Commit();
561
                    isSuccess = true;
562
                }
563
            }
564
            catch (Exception ex)
565
            {
566
                throw ex;
567
            }
568

    
569
            return isSuccess;
570
        }
571

    
572
        public Documents SetDocumentDataField(Documents doc, string userId)
573
        {
574
            Documents resultData = null;
575

    
576
            try
577
            {
578
                using (var transaction = base.BeginTransaction())
579
                {
580
                    string query = string.Empty;
581

    
582
                    if (!string.IsNullOrEmpty(doc.DocID))
583
                    {
584
                        StringBuilder sbSet = new StringBuilder();
585
                        var parameters = new Dictionary<string, object>();
586

    
587
                        #region Update 할 목록
588
                        if (doc.ID2StartDate != null)
589
                        {
590
                            sbSet.Append(" ,ID2StartDate=(case when ID2StartDate is null then @DateTimeNow else ID2StartDate end) ");
591
                            parameters.Add("ID2StartDate", doc.ID2StartDate);
592
                        }
593

    
594
                        if (doc.Worker != null)
595
                        {
596
                            sbSet.Append(" ,Worker=@Worker ");
597
                            parameters.Add("Worker", doc.Worker);
598
                        }
599
                        #endregion
600

    
601
                        if (parameters.Count > 0)
602
                        {
603
                            sbSet.Append(" ,ModifiedUser=@ModifiedUser ");
604
                            parameters.Add("ModifiedUser", userId);
605

    
606
                            parameters.Add("DocID", doc.DocID);
607

    
608
                            query = $@"
609
declare @DateTimeNow datetime
610
set @DateTimeNow = getdate()
611

    
612
update dbo.Documents
613
set    ModifiedDate=@DateTimeNow {sbSet}
614
where  [DocID]=@DocID
615

    
616
if @@rowcount > 0
617
begin
618
    select * from dbo.Documents where DocID=@DocID
619
end
620
else
621
begin
622
    select * from dbo.Documents where 1=2
623
end;";
624
                            resultData = base.QueryFirstOrDefault<Documents>(query, parameters, transaction);
625
                        }
626
                    }
627

    
628
                    transaction.Commit();
629
                }
630
            }
631
            catch (Exception ex)
632
            {
633
                throw ex;
634
            }
635

    
636
            return resultData;
637
        }
638

    
639
        public bool SetDocumentDatasField(List<Documents> docs, string userId)
640
        {
641
            bool isSuccess = false;
642

    
643
            try
644
            {
645
                using (var transaction = base.BeginTransaction())
646
                {
647
                    foreach (Documents doc in docs)
648
                    {
649
                        string query = string.Empty;
650

    
651
                        if (!string.IsNullOrEmpty(doc.DocID))
652
                        {
653
                            StringBuilder sbSet = new StringBuilder();
654
                            var parameters = new Dictionary<string, object>();
655

    
656
                            #region Update 할 목록
657
                            if (doc.ID2EndDate != null)
658
                            {
659
                                sbSet.Append(" ,ID2EndDate=@ID2EndDate ");
660
                                parameters.Add("ID2EndDate", doc.ID2EndDate);
661
                            }
662
                            #endregion
663

    
664
                            if (parameters.Count > 0)
665
                            {
666
                                sbSet.Append(" ,ModifiedUser=@ModifiedUser ");
667
                                parameters.Add("ModifiedUser", userId);
668

    
669
                                parameters.Add("DocID", doc.DocID);
670

    
671
                                query = $@"
672
update dbo.Documents
673
set    ModifiedDate=getdate() {sbSet}
674
where  [DocID]=@DocID;";
675
                                base.Execute(query, parameters, transaction);
676
                            }
677
                        }
678
                    }
679
                    transaction.Commit();
680
                    isSuccess = true;
681
                }
682
            }
683
            catch (Exception ex)
684
            {
685
                throw ex;
686
            }
687

    
688
            return isSuccess;
689
        }
690

    
691

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