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