hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ 429bc8fa
이력 | 보기 | 이력해설 | 다운로드 (11.1 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 | fe57f64a | yoush97 | using ID2.Manager.Dapper; |
8 | 5898479a | yoush97 | using ID2.Manager.Data.Models; |
9 | using ID2.Manager.Dapper.Repository; |
||
10 | |||
11 | namespace ID2.Manager.Controller.Controllers |
||
12 | { |
||
13 | public class DocumentController : BaseController |
||
14 | { |
||
15 | 91e72bfe | yoush97 | public DocumentController() : base() { } |
16 | fe57f64a | yoush97 | |
17 | public DocumentController(ID2ProjectInfo id2Info) : base(id2Info) { } |
||
18 | |||
19 | a4a166e2 | yoush97 | public IEnumerable<Documents> GetAllDocuments(string projectGroupID) |
20 | 54977253 | yoush97 | { |
21 | 82705273 | yoush97 | try |
22 | 54977253 | yoush97 | { |
23 | 82705273 | yoush97 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
24 | { |
||
25 | a4a166e2 | yoush97 | return rep.GetAllDocuments(projectGroupID); |
26 | 82705273 | yoush97 | } |
27 | } |
||
28 | catch (Exception ex) |
||
29 | { |
||
30 | throw ex; |
||
31 | 54977253 | yoush97 | } |
32 | } |
||
33 | |||
34 | 3cc84cb6 | yoush97 | 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) |
35 | 5898479a | yoush97 | { |
36 | 82705273 | yoush97 | try |
37 | 5898479a | yoush97 | { |
38 | 82705273 | yoush97 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
39 | { |
||
40 | 3cc84cb6 | yoush97 | return rep.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem); |
41 | 82705273 | yoush97 | } |
42 | } |
||
43 | catch (Exception ex) |
||
44 | { |
||
45 | throw ex; |
||
46 | 5898479a | yoush97 | } |
47 | } |
||
48 | 709c1971 | yoush97 | |
49 | 3cc84cb6 | yoush97 | public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(List<ID2ProjectInfo> id2Infos, string projectGroupID, List<string> dateTypes, DateTime? frDate, DateTime? toDate, string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Issues, string id2Status, string avevaStatus, string avevaIssues, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem) |
50 | fe57f64a | yoush97 | { |
51 | 82705273 | yoush97 | try |
52 | fe57f64a | yoush97 | { |
53 | 3cc84cb6 | yoush97 | var (dwgs, totalCnt) = this.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem); |
54 | 904fbe46 | yoush97 | |
55 | IEnumerable<Documents> docs = dwgs; |
||
56 | 82705273 | yoush97 | List<ID2Drawings> id2docs = null; |
57 | |||
58 | if (id2Infos.Any()) |
||
59 | fe57f64a | yoush97 | { |
60 | 82705273 | yoush97 | id2docs = new List<ID2Drawings>(); |
61 | id2Infos.ForEach(x => |
||
62 | { |
||
63 | id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x)); |
||
64 | }); |
||
65 | } |
||
66 | fe57f64a | yoush97 | |
67 | 82705273 | yoush97 | if (docs != null && id2docs != null && docs.Any() && id2docs.Any()) |
68 | { |
||
69 | var result = from doc in docs |
||
70 | join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME } into gj |
||
71 | from dw in gj.DefaultIfEmpty() |
||
72 | select new Documents() |
||
73 | { |
||
74 | Seq = doc.Seq, |
||
75 | DocID = doc.DocID, |
||
76 | DocumentNo = doc.DocumentNo, |
||
77 | RevisonNo = doc.RevisonNo, |
||
78 | RefProjectCode = doc.RefProjectCode, |
||
79 | IsLatest = doc.IsLatest, |
||
80 | AutoCADFilie = doc.AutoCADFilie, |
||
81 | PDFFile = doc.PDFFile, |
||
82 | MarkupLink = doc.MarkupLink, |
||
83 | AVEVALink = doc.AVEVALink, |
||
84 | JobLevel = doc.JobLevel, |
||
85 | IsTypical = doc.IsTypical, |
||
86 | PersonInCharge = doc.PersonInCharge, |
||
87 | IsDeleted = doc.IsDeleted, |
||
88 | RegisteredDate = doc.RegisteredDate, |
||
89 | ModifiedDate = doc.ModifiedDate, |
||
90 | DeletedDate = doc.DeletedDate, |
||
91 | ToIsDiscussion = doc.ToIsDiscussion, |
||
92 | ToRemarks = doc.ToRemarks, |
||
93 | ToCreator = doc.ToCreator, |
||
94 | ToCapture = doc.ToCapture, |
||
95 | ToIsMarkup = doc.ToIsMarkup, |
||
96 | FrReviewStatus = doc.FrReviewStatus, |
||
97 | FrRemarks = doc.FrRemarks, |
||
98 | FrCreator = doc.FrCreator, |
||
99 | FrCapture = doc.FrCapture, |
||
100 | FrIsMarkup = doc.FrIsMarkup, |
||
101 | IsID2Work = doc.IsID2Work, |
||
102 | ID2Connection = doc.ID2Connection, |
||
103 | ID2StartDate = doc.ID2StartDate, |
||
104 | ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME), |
||
105 | ID2JobTime = doc.ID2JobTime, |
||
106 | ID2Status = doc.ID2Status, |
||
107 | ID2Issues = doc.ID2Issues, |
||
108 | AVEVAConnection = doc.AVEVAConnection, |
||
109 | AVEVAConvertDate = doc.AVEVAConvertDate, |
||
110 | AVEVAReviewDate = doc.AVEVAReviewDate, |
||
111 | AVEVAStatus = doc.AVEVAStatus, |
||
112 | AVEVAIssues = doc.AVEVAIssues, |
||
113 | ReviewFilePath = doc.ReviewFilePath, |
||
114 | ReviewFileName = doc.ReviewFileName, |
||
115 | ProdReviewer = doc.ProdReviewer, |
||
116 | ProdIsResult = doc.ProdIsResult, |
||
117 | ProdRemarks = doc.ProdRemarks, |
||
118 | ClientReviewer = doc.ClientReviewer, |
||
119 | ClientIsResult = doc.ClientIsResult, |
||
120 | ClientRemarks = doc.ClientRemarks, |
||
121 | DTIsGateWay = doc.DTIsGateWay, |
||
122 | DTIsImport = doc.DTIsImport, |
||
123 | DTIsRegSystem = doc.DTIsRegSystem, |
||
124 | DTRemarks = doc.DTRemarks, |
||
125 | e458a996 | taeseongkim | Markups = doc.Markups |
126 | 82705273 | yoush97 | }; |
127 | |||
128 | 904fbe46 | yoush97 | return (result, totalCnt); |
129 | fe57f64a | yoush97 | |
130 | 82705273 | yoush97 | } |
131 | 904fbe46 | yoush97 | return (dwgs, totalCnt); |
132 | 82705273 | yoush97 | } |
133 | catch (Exception ex) |
||
134 | { |
||
135 | throw ex; |
||
136 | fe57f64a | yoush97 | } |
137 | } |
||
138 | |||
139 | ff990784 | yoush97 | public int ExistsDocument(string projectGroupID, List<string> newDwgNos) |
140 | { |
||
141 | try |
||
142 | { |
||
143 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
144 | { |
||
145 | return rep.ExistsDocument(projectGroupID, newDwgNos); |
||
146 | } |
||
147 | } |
||
148 | catch (Exception ex) |
||
149 | { |
||
150 | throw ex; |
||
151 | } |
||
152 | } |
||
153 | |||
154 | 54977253 | yoush97 | public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId) |
155 | 709c1971 | yoush97 | { |
156 | 82705273 | yoush97 | try |
157 | { |
||
158 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
159 | { |
||
160 | return rep.SetDocumentData(docList, delDocList, userId); |
||
161 | } |
||
162 | } |
||
163 | catch (Exception ex) |
||
164 | 709c1971 | yoush97 | { |
165 | 82705273 | yoush97 | throw ex; |
166 | 709c1971 | yoush97 | } |
167 | } |
||
168 | 978488b0 | yoush97 | |
169 | 4b8d9ad9 | yoush97 | public Documents SetID2Worker(Documents doc, string userId) |
170 | { |
||
171 | 82705273 | yoush97 | try |
172 | { |
||
173 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
174 | { |
||
175 | return rep.SetDocumentDataField(doc, userId); |
||
176 | } |
||
177 | } |
||
178 | catch (Exception ex) |
||
179 | 4b8d9ad9 | yoush97 | { |
180 | 82705273 | yoush97 | throw ex; |
181 | 4b8d9ad9 | yoush97 | } |
182 | } |
||
183 | |||
184 | 978488b0 | yoush97 | public Documents SetDocumentDataField(Documents doc, string userId) |
185 | { |
||
186 | 82705273 | yoush97 | try |
187 | { |
||
188 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
189 | { |
||
190 | return rep.SetDocumentDataField(doc, userId); |
||
191 | } |
||
192 | } |
||
193 | catch (Exception ex) |
||
194 | 978488b0 | yoush97 | { |
195 | 82705273 | yoush97 | throw ex; |
196 | 978488b0 | yoush97 | } |
197 | } |
||
198 | fe57f64a | yoush97 | |
199 | |||
200 | //ID2 |
||
201 | public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info) |
||
202 | { |
||
203 | 82705273 | yoush97 | try |
204 | { |
||
205 | using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR)) |
||
206 | { |
||
207 | return rep.GetID2DrawingsByProject(id2Info); |
||
208 | } |
||
209 | } |
||
210 | catch (Exception ex) |
||
211 | fe57f64a | yoush97 | { |
212 | 82705273 | yoush97 | throw ex; |
213 | fe57f64a | yoush97 | } |
214 | } |
||
215 | 54977253 | yoush97 | |
216 | a4a166e2 | yoush97 | public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId) |
217 | 54977253 | yoush97 | { |
218 | bool isSuccess = false; |
||
219 | |||
220 | try |
||
221 | { |
||
222 | a4a166e2 | yoush97 | IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID); |
223 | 54977253 | yoush97 | List<ID2Drawings> id2docs = null; |
224 | |||
225 | if (id2Infos.Any()) |
||
226 | { |
||
227 | id2docs = new List<ID2Drawings>(); |
||
228 | id2Infos.ForEach(x => |
||
229 | { |
||
230 | id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x)); |
||
231 | }); |
||
232 | } |
||
233 | |||
234 | if (docs != null && id2docs != null && docs.Any() && id2docs.Any()) |
||
235 | { |
||
236 | var result = from doc in docs |
||
237 | join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME } |
||
238 | select new Documents() |
||
239 | { |
||
240 | DocID = doc.DocID, |
||
241 | ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME) |
||
242 | }; |
||
243 | |||
244 | if (result.Any()) |
||
245 | { |
||
246 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
247 | { |
||
248 | isSuccess = rep.SetDocumentDatasField(result.ToList(), userId); |
||
249 | } |
||
250 | } |
||
251 | } |
||
252 | } |
||
253 | catch (Exception ex) |
||
254 | { |
||
255 | throw ex; |
||
256 | } |
||
257 | |||
258 | return isSuccess; |
||
259 | } |
||
260 | 5898479a | yoush97 | } |
261 | } |