hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ 53fde692
이력 | 보기 | 이력해설 | 다운로드 (5.42 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 | 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 | 90ae20f6 | yoush97 | select doc.* |
19 | 5898479a | yoush97 | from dbo.Documents doc |
20 | 53fde692 | yoush97 | where IsDeleted=0 |
21 | 90ae20f6 | yoush97 | order by doc.Seq"; |
22 | 5898479a | yoush97 | |
23 | return Query<Documents>(query); |
||
24 | } |
||
25 | 482f6326 | yoush97 | |
26 | 709c1971 | yoush97 | public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList) |
27 | 482f6326 | yoush97 | { |
28 | bool isSuccess = false; |
||
29 | |||
30 | try |
||
31 | { |
||
32 | d2d4f84b | yoush97 | using (var transaction = base.BeginTransaction()) |
33 | 482f6326 | yoush97 | { |
34 | 709c1971 | yoush97 | string query = string.Empty; |
35 | |||
36 | if (delDocList.Count > 0) |
||
37 | 482f6326 | yoush97 | { |
38 | 709c1971 | yoush97 | string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList()); |
39 | |||
40 | if (docIDList.Length > 0) |
||
41 | { |
||
42 | 53fde692 | yoush97 | query = $@" |
43 | update from dbo.Documents |
||
44 | set IsDeleted=1 |
||
45 | ,DeletedDate=getdate() |
||
46 | where [DocID] in ('{docIDList}');"; |
||
47 | 709c1971 | yoush97 | base.Execute(query, transaction); |
48 | } |
||
49 | } |
||
50 | 482f6326 | yoush97 | |
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 | 709c1971 | yoush97 | );"; |
154 | 482f6326 | yoush97 | } |
155 | else |
||
156 | { |
||
157 | query = $@" |
||
158 | update dbo.Documents |
||
159 | 53fde692 | yoush97 | 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 | 709c1971 | yoush97 | where [DocID]=@DocID;"; |
206 | 482f6326 | yoush97 | } |
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 | 5898479a | yoush97 | } |
222 | d2d4f84b | yoush97 | } |