hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ fe310cac
이력 | 보기 | 이력해설 | 다운로드 (10.9 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 | ToIsMarkup = doc.ToIsMarkup, |
||
95 | FrReviewStatus = doc.FrReviewStatus, |
||
96 | FrRemarks = doc.FrRemarks, |
||
97 | FrCreator = doc.FrCreator, |
||
98 | FrIsMarkup = doc.FrIsMarkup, |
||
99 | IsID2Work = doc.IsID2Work, |
||
100 | ID2Connection = doc.ID2Connection, |
||
101 | ID2StartDate = doc.ID2StartDate, |
||
102 | ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME), |
||
103 | ID2Status = doc.ID2Status, |
||
104 | ID2Issues = doc.ID2Issues, |
||
105 | AVEVAConnection = doc.AVEVAConnection, |
||
106 | AVEVAConvertDate = doc.AVEVAConvertDate, |
||
107 | AVEVAReviewDate = doc.AVEVAReviewDate, |
||
108 | AVEVAStatus = doc.AVEVAStatus, |
||
109 | AVEVAIssues = doc.AVEVAIssues, |
||
110 | ReviewFilePath = doc.ReviewFilePath, |
||
111 | ReviewFileName = doc.ReviewFileName, |
||
112 | ProdReviewer = doc.ProdReviewer, |
||
113 | ProdIsResult = doc.ProdIsResult, |
||
114 | ProdRemarks = doc.ProdRemarks, |
||
115 | ClientReviewer = doc.ClientReviewer, |
||
116 | ClientIsResult = doc.ClientIsResult, |
||
117 | ClientRemarks = doc.ClientRemarks, |
||
118 | DTIsGateWay = doc.DTIsGateWay, |
||
119 | DTIsImport = doc.DTIsImport, |
||
120 | DTIsRegSystem = doc.DTIsRegSystem, |
||
121 | DTRemarks = doc.DTRemarks, |
||
122 | e458a996 | taeseongkim | Markups = doc.Markups |
123 | 82705273 | yoush97 | }; |
124 | |||
125 | 904fbe46 | yoush97 | return (result, totalCnt); |
126 | fe57f64a | yoush97 | |
127 | 82705273 | yoush97 | } |
128 | 904fbe46 | yoush97 | return (dwgs, totalCnt); |
129 | 82705273 | yoush97 | } |
130 | catch (Exception ex) |
||
131 | { |
||
132 | throw ex; |
||
133 | fe57f64a | yoush97 | } |
134 | } |
||
135 | |||
136 | ff990784 | yoush97 | public int ExistsDocument(string projectGroupID, List<string> newDwgNos) |
137 | { |
||
138 | try |
||
139 | { |
||
140 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
141 | { |
||
142 | return rep.ExistsDocument(projectGroupID, newDwgNos); |
||
143 | } |
||
144 | } |
||
145 | catch (Exception ex) |
||
146 | { |
||
147 | throw ex; |
||
148 | } |
||
149 | } |
||
150 | |||
151 | 54977253 | yoush97 | public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId) |
152 | 709c1971 | yoush97 | { |
153 | 82705273 | yoush97 | try |
154 | { |
||
155 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
156 | { |
||
157 | return rep.SetDocumentData(docList, delDocList, userId); |
||
158 | } |
||
159 | } |
||
160 | catch (Exception ex) |
||
161 | 709c1971 | yoush97 | { |
162 | 82705273 | yoush97 | throw ex; |
163 | 709c1971 | yoush97 | } |
164 | } |
||
165 | 978488b0 | yoush97 | |
166 | 4b8d9ad9 | yoush97 | public Documents SetID2Worker(Documents doc, string userId) |
167 | { |
||
168 | 82705273 | yoush97 | try |
169 | { |
||
170 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
171 | { |
||
172 | return rep.SetDocumentDataField(doc, userId); |
||
173 | } |
||
174 | } |
||
175 | catch (Exception ex) |
||
176 | 4b8d9ad9 | yoush97 | { |
177 | 82705273 | yoush97 | throw ex; |
178 | 4b8d9ad9 | yoush97 | } |
179 | } |
||
180 | |||
181 | 978488b0 | yoush97 | public Documents SetDocumentDataField(Documents doc, string userId) |
182 | { |
||
183 | 82705273 | yoush97 | try |
184 | { |
||
185 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
186 | { |
||
187 | return rep.SetDocumentDataField(doc, userId); |
||
188 | } |
||
189 | } |
||
190 | catch (Exception ex) |
||
191 | 978488b0 | yoush97 | { |
192 | 82705273 | yoush97 | throw ex; |
193 | 978488b0 | yoush97 | } |
194 | } |
||
195 | fe57f64a | yoush97 | |
196 | |||
197 | //ID2 |
||
198 | public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info) |
||
199 | { |
||
200 | 82705273 | yoush97 | try |
201 | { |
||
202 | using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR)) |
||
203 | { |
||
204 | return rep.GetID2DrawingsByProject(id2Info); |
||
205 | } |
||
206 | } |
||
207 | catch (Exception ex) |
||
208 | fe57f64a | yoush97 | { |
209 | 82705273 | yoush97 | throw ex; |
210 | fe57f64a | yoush97 | } |
211 | } |
||
212 | 54977253 | yoush97 | |
213 | a4a166e2 | yoush97 | public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId) |
214 | 54977253 | yoush97 | { |
215 | bool isSuccess = false; |
||
216 | |||
217 | try |
||
218 | { |
||
219 | a4a166e2 | yoush97 | IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID); |
220 | 54977253 | yoush97 | List<ID2Drawings> id2docs = null; |
221 | |||
222 | if (id2Infos.Any()) |
||
223 | { |
||
224 | id2docs = new List<ID2Drawings>(); |
||
225 | id2Infos.ForEach(x => |
||
226 | { |
||
227 | id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x)); |
||
228 | }); |
||
229 | } |
||
230 | |||
231 | if (docs != null && id2docs != null && docs.Any() && id2docs.Any()) |
||
232 | { |
||
233 | var result = from doc in docs |
||
234 | join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME } |
||
235 | select new Documents() |
||
236 | { |
||
237 | DocID = doc.DocID, |
||
238 | ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME) |
||
239 | }; |
||
240 | |||
241 | if (result.Any()) |
||
242 | { |
||
243 | using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR)) |
||
244 | { |
||
245 | isSuccess = rep.SetDocumentDatasField(result.ToList(), userId); |
||
246 | } |
||
247 | } |
||
248 | } |
||
249 | } |
||
250 | catch (Exception ex) |
||
251 | { |
||
252 | throw ex; |
||
253 | } |
||
254 | |||
255 | return isSuccess; |
||
256 | } |
||
257 | 5898479a | yoush97 | } |
258 | } |