프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ 74aa670a

이력 | 보기 | 이력해설 | 다운로드 (5.37 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 ID2.Manager.Data.Models;
8

    
9
namespace ID2.Manager.Dapper.Repository
10
{
11
    public class DocumentRepository : BaseRepository
12
    {
13
        public DocumentRepository(string connectionStr) : base(connectionStr) { }
14

    
15
        public IEnumerable<Documents> GetAllDocuments()
16
        {
17
            string query = $@"
18
select   doc.*
19
from     dbo.Documents doc
20
where    IsDeleted=0
21
order by doc.Seq";
22

    
23
            return Query<Documents>(query);
24
        }
25

    
26
        public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList)
27
        {
28
            bool isSuccess = false;
29

    
30
            try
31
            {
32
                using (var transaction = base.BeginTransaction())
33
                {
34
                    string query = string.Empty;
35

    
36
                    if (delDocList.Count > 0)
37
                    {
38
                        string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList());
39

    
40
                        if (docIDList.Length > 0)
41
                        {
42
                            query = $@"
43
update dbo.Documents
44
set    IsDeleted=1
45
      ,DeletedDate=getdate()
46
where  [DocID] in ('{docIDList}');";
47
                            base.Execute(query, transaction);
48
                        }
49
                    }
50

    
51
                    foreach (Documents doc in docList)
52
                    {
53
                        if (string.IsNullOrEmpty(doc.DocID))
54
                        {
55
                            query = $@"
56
insert into dbo.Documents
57
(
58
     [DocID]
59
    ,[DocumentNo]
60
    ,[RevisonNo]
61
    ,[RefProjectID]
62
    ,[DocFilePath]
63
    ,[DocFileName]
64
    ,[Place]
65
    ,[JobLevel]
66
    ,[IsTypical]
67
    ,[PersonInCharge]
68
    ,[ToIsDiscussion]
69
    ,[ToRemarks]
70
    ,[ToCreator]
71
    ,[ToModifier]
72
    ,[ToCapturePath]
73
    ,[ToIsMarkup]
74
    ,[FrReviewStatus]
75
    ,[FrRemarks]
76
    ,[FrCreator]
77
    ,[FrModifier]
78
    ,[FrCapturePath]
79
    ,[FrIsMarkup]
80
    ,[IsID2Work]
81
    ,[ID2Connection]
82
    ,[ID2StartDate]
83
    ,[ID2EndDate]
84
    ,[ID2JobTime]
85
    ,[ID2Status]
86
    ,[ID2Issues]
87
    ,[AVEVAConnection]
88
    ,[AVEVAConvertDate]
89
    ,[AVEVAReviewDate]
90
    ,[AVEVAStatus]
91
    ,[AVEVAIssues]
92
    ,[ReviewFilePath]
93
    ,[ReviewFileName]
94
    ,[ProdReviewer]
95
    ,[ProdIsResult]
96
    ,[ProdRemarks]
97
    ,[ClientReviewer]
98
    ,[ClientIsResult]
99
    ,[ClientRemarks]
100
    ,[DTIsGateWay]
101
    ,[DTIsImport]
102
    ,[DTIsRegSystem]
103
    ,[DTRemarks]
104
)
105
values 
106
(
107
     lower(newid())
108
    ,@DocumentNo
109
    ,@RevisonNo
110
    ,@RefProjectID
111
    ,@DocFilePath
112
    ,@DocFileName
113
    ,@Place
114
    ,@JobLevel
115
    ,@IsTypical
116
    ,@PersonInCharge
117
    ,@ToIsDiscussion
118
    ,@ToRemarks
119
    ,@ToCreator
120
    ,@ToModifier
121
    ,@ToCapturePath
122
    ,@ToIsMarkup
123
    ,@FrReviewStatus
124
    ,@FrRemarks
125
    ,@FrCreator
126
    ,@FrModifier
127
    ,@FrCapturePath
128
    ,@FrIsMarkup
129
    ,@IsID2Work
130
    ,@ID2Connection
131
    ,@ID2StartDate
132
    ,@ID2EndDate
133
    ,@ID2JobTime
134
    ,@ID2Status
135
    ,@ID2Issues
136
    ,@AVEVAConnection
137
    ,@AVEVAConvertDate
138
    ,@AVEVAReviewDate
139
    ,@AVEVAStatus
140
    ,@AVEVAIssues
141
    ,@ReviewFilePath
142
    ,@ReviewFileName
143
    ,@ProdReviewer
144
    ,@ProdIsResult
145
    ,@ProdRemarks
146
    ,@ClientReviewer
147
    ,@ClientIsResult
148
    ,@ClientRemarks
149
    ,@DTIsGateWay
150
    ,@DTIsImport
151
    ,@DTIsRegSystem
152
    ,@DTRemarks
153
);";
154
                        }
155
                        else
156
                        {
157
                            query = $@"
158
update dbo.Documents
159
set    [DocumentNo]=@DocumentNo
160
      ,[RevisonNo]=@RevisonNo
161
      ,[RefProjectID]=@RefProjectID
162
      ,[DocFilePath]=@DocFilePath
163
      ,[DocFileName]=@DocFileName
164
      ,[Place]=@Place
165
      ,[JobLevel]=@JobLevel
166
      ,[IsTypical]=@IsTypical
167
      ,[PersonInCharge]=@PersonInCharge
168
      ,[ModifiedDate]=getdate()
169
      ,[ToIsDiscussion]=@ToIsDiscussion
170
      ,[ToRemarks]=@ToRemarks
171
      ,[ToCreator]=@ToCreator
172
      ,[ToModifier]=@ToModifier
173
      ,[ToCapturePath]=@ToCapturePath
174
      ,[ToIsMarkup]=@ToIsMarkup
175
      ,[FrReviewStatus]=@FrReviewStatus
176
      ,[FrRemarks]=@FrRemarks
177
      ,[FrCreator]=@FrCreator
178
      ,[FrModifier]=@FrModifier
179
      ,[FrCapturePath]=@FrCapturePath
180
      ,[FrIsMarkup]=@FrIsMarkup
181
      ,[IsID2Work]=@IsID2Work
182
      ,[ID2Connection]=@ID2Connection
183
      ,[ID2StartDate]=@ID2StartDate
184
      ,[ID2EndDate]=@ID2EndDate
185
      ,[ID2JobTime]=@ID2JobTime
186
      ,[ID2Status]=@ID2Status
187
      ,[ID2Issues]=@ID2Issues
188
      ,[AVEVAConnection]=@AVEVAConnection
189
      ,[AVEVAConvertDate]=@AVEVAConvertDate
190
      ,[AVEVAReviewDate]=@AVEVAReviewDate
191
      ,[AVEVAStatus]=@AVEVAStatus
192
      ,[AVEVAIssues]=@AVEVAIssues
193
      ,[ReviewFilePath]=@ReviewFilePath
194
      ,[ReviewFileName]=@ReviewFileName
195
      ,[ProdReviewer]=@ProdReviewer
196
      ,[ProdIsResult]=@ProdIsResult
197
      ,[ProdRemarks]=@ProdRemarks
198
      ,[ClientReviewer]=@ClientReviewer
199
      ,[ClientIsResult]=@ClientIsResult
200
      ,[ClientRemarks]=@ClientRemarks
201
      ,[DTIsGateWay]=@DTIsGateWay
202
      ,[DTIsImport]=@DTIsImport
203
      ,[DTIsRegSystem]=@DTIsRegSystem
204
      ,[DTRemarks]=@DTRemarks
205
where  [DocID]=@DocID;";
206
                        }
207
                        base.Execute(query, doc, transaction);
208
                    }
209

    
210
                    transaction.Commit();
211
                    isSuccess = true;
212
                }
213
            }
214
            catch (Exception ex)
215
            {
216
                throw ex;
217
            }
218

    
219
            return isSuccess;
220
        }
221
    }
222
}
클립보드 이미지 추가 (최대 크기: 500 MB)