hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ d2d4f84b
이력 | 보기 | 이력해설 | 다운로드 (4.97 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 |
order by doc.Seq"; |
21 |
|
22 |
return Query<Documents>(query); |
23 |
} |
24 |
|
25 |
public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList) |
26 |
{ |
27 |
bool isSuccess = false; |
28 |
|
29 |
try |
30 |
{ |
31 |
using (var transaction = base.BeginTransaction()) |
32 |
{ |
33 |
string query = string.Empty; |
34 |
|
35 |
if (delDocList.Count > 0) |
36 |
{ |
37 |
string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList()); |
38 |
|
39 |
if (docIDList.Length > 0) |
40 |
{ |
41 |
query = $@"delete from dbo.Documents where [DocID] in ('{docIDList}');"; |
42 |
base.Execute(query, transaction); |
43 |
} |
44 |
} |
45 |
|
46 |
foreach (Documents doc in docList) |
47 |
{ |
48 |
if (string.IsNullOrEmpty(doc.DocID)) |
49 |
{ |
50 |
query = $@" |
51 |
insert into dbo.Documents |
52 |
( |
53 |
[DocID] |
54 |
,[DocumentNo] |
55 |
,[RevisonNo] |
56 |
,[RefProjectID] |
57 |
,[IsLatest] |
58 |
,[DocFilePath] |
59 |
,[DocFileName] |
60 |
,[Place] |
61 |
,[JobLevel] |
62 |
,[IsTypical] |
63 |
,[PersonInCharge] |
64 |
,[IsDeleted] |
65 |
,[RegisteredDate] |
66 |
,[ModifiedDate] |
67 |
,[DeletedDate] |
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 |
,@IsLatest |
112 |
,@DocFilePath |
113 |
,@DocFileName |
114 |
,@Place |
115 |
,@JobLevel |
116 |
,@IsTypical |
117 |
,@PersonInCharge |
118 |
,@IsDeleted |
119 |
,getdate() |
120 |
,@ModifiedDate |
121 |
,@DeletedDate |
122 |
,@ToIsDiscussion |
123 |
,@ToRemarks |
124 |
,@ToCreator |
125 |
,@ToModifier |
126 |
,@ToCapturePath |
127 |
,@ToIsMarkup |
128 |
,@FrReviewStatus |
129 |
,@FrRemarks |
130 |
,@FrCreator |
131 |
,@FrModifier |
132 |
,@FrCapturePath |
133 |
,@FrIsMarkup |
134 |
,@IsID2Work |
135 |
,@ID2Connection |
136 |
,@ID2StartDate |
137 |
,@ID2EndDate |
138 |
,@ID2JobTime |
139 |
,@ID2Status |
140 |
,@ID2Issues |
141 |
,@AVEVAConnection |
142 |
,@AVEVAConvertDate |
143 |
,@AVEVAReviewDate |
144 |
,@AVEVAStatus |
145 |
,@AVEVAIssues |
146 |
,@ReviewFilePath |
147 |
,@ReviewFileName |
148 |
,@ProdReviewer |
149 |
,@ProdIsResult |
150 |
,@ProdRemarks |
151 |
,@ClientReviewer |
152 |
,@ClientIsResult |
153 |
,@ClientRemarks |
154 |
,@DTIsGateWay |
155 |
,@DTIsImport |
156 |
,@DTIsRegSystem |
157 |
,@DTRemarks |
158 |
);"; |
159 |
} |
160 |
else |
161 |
{ |
162 |
query = $@" |
163 |
update dbo.Documents |
164 |
set [DocumentNo] |
165 |
,[RevisonNo] |
166 |
,[RefProjectID] |
167 |
,[IsLatest] |
168 |
,[DocFilePath] |
169 |
,[DocFileName] |
170 |
,[Place] |
171 |
,[JobLevel] |
172 |
,[IsTypical] |
173 |
,[PersonInCharge] |
174 |
,[IsDeleted] |
175 |
,[RegisteredDate] |
176 |
,[ModifiedDate] |
177 |
,[DeletedDate] |
178 |
,[ToIsDiscussion] |
179 |
,[ToRemarks] |
180 |
,[ToCreator] |
181 |
,[ToModifier] |
182 |
,[ToCapturePath] |
183 |
,[ToIsMarkup] |
184 |
,[FrReviewStatus] |
185 |
,[FrRemarks] |
186 |
,[FrCreator] |
187 |
,[FrModifier] |
188 |
,[FrCapturePath] |
189 |
,[FrIsMarkup] |
190 |
,[IsID2Work] |
191 |
,[ID2Connection] |
192 |
,[ID2StartDate] |
193 |
,[ID2EndDate] |
194 |
,[ID2JobTime] |
195 |
,[ID2Status] |
196 |
,[ID2Issues] |
197 |
,[AVEVAConnection] |
198 |
,[AVEVAConvertDate] |
199 |
,[AVEVAReviewDate] |
200 |
,[AVEVAStatus] |
201 |
,[AVEVAIssues] |
202 |
,[ReviewFilePath] |
203 |
,[ReviewFileName] |
204 |
,[ProdReviewer] |
205 |
,[ProdIsResult] |
206 |
,[ProdRemarks] |
207 |
,[ClientReviewer] |
208 |
,[ClientIsResult] |
209 |
,[ClientRemarks] |
210 |
,[DTIsGateWay] |
211 |
,[DTIsImport] |
212 |
,[DTIsRegSystem] |
213 |
,[DTRemarks] |
214 |
where [DocID]=@DocID;"; |
215 |
} |
216 |
base.Execute(query, doc, transaction); |
217 |
} |
218 |
|
219 |
transaction.Commit(); |
220 |
isSuccess = true; |
221 |
} |
222 |
} |
223 |
catch (Exception ex) |
224 |
{ |
225 |
throw ex; |
226 |
} |
227 |
|
228 |
return isSuccess; |
229 |
} |
230 |
} |
231 |
} |