hytos / ID2.Manager / ID2.Manager.Common / Helpers / ID2Excel.cs @ e17d4c6f
이력 | 보기 | 이력해설 | 다운로드 (41.8 KB)
1 |
using ID2.Manager.Data.Models; |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.Linq; |
5 |
using System.Text; |
6 |
using System.Threading.Tasks; |
7 |
|
8 |
using System.IO; |
9 |
using System.IO.Compression; |
10 |
|
11 |
using GemBox.Spreadsheet; |
12 |
|
13 |
namespace ID2.Manager.Common.Helpers |
14 |
{ |
15 |
public class ID2Excel : IDisposable |
16 |
{ |
17 |
readonly Informations informations = Informations.Instance; |
18 |
|
19 |
public void Dispose() |
20 |
{ |
21 |
try |
22 |
{ |
23 |
} |
24 |
catch (Exception) |
25 |
{ |
26 |
throw; |
27 |
} |
28 |
finally |
29 |
{ |
30 |
GC.Collect(2); |
31 |
GC.Collect(2); |
32 |
} |
33 |
} |
34 |
|
35 |
public ID2Excel() { } |
36 |
|
37 |
private ProjectInfo GetProject(string project) |
38 |
{ |
39 |
//List<ProjectInfo> projects = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList(); |
40 |
List<ProjectInfo> projects = (from allPrj in informations.ProjectList |
41 |
join actPrj in informations.ActiveProjects on allPrj.GroupID equals actPrj.ProjectID |
42 |
select allPrj).ToList(); |
43 |
|
44 |
ProjectInfo prjInfo = projects.FirstOrDefault(x => x.Code.Equals(project)); |
45 |
if (prjInfo != null) return prjInfo; |
46 |
|
47 |
prjInfo = projects.FirstOrDefault(x => x.Name.Equals(project)); |
48 |
if (prjInfo != null) return prjInfo; |
49 |
|
50 |
return prjInfo ?? new ProjectInfo(); |
51 |
} |
52 |
|
53 |
private UserInfo GetUser(string user) |
54 |
{ |
55 |
UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault(); |
56 |
if (userInfo != null) return userInfo; |
57 |
|
58 |
userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault(); |
59 |
if (userInfo != null) return userInfo; |
60 |
|
61 |
return userInfo ?? new UserInfo(); |
62 |
} |
63 |
|
64 |
private string GetColumnName(int column) |
65 |
{ |
66 |
int dividend = column; |
67 |
string columnName = string.Empty; |
68 |
|
69 |
while (dividend > 0) |
70 |
{ |
71 |
int modulo = (dividend - 1) % 26; |
72 |
columnName = Convert.ToChar(65 + modulo) + columnName; |
73 |
dividend = (dividend - modulo) / 26; |
74 |
} |
75 |
|
76 |
return columnName; |
77 |
} |
78 |
|
79 |
private System.Drawing.Image GetImage(string base64String) |
80 |
{ |
81 |
System.Drawing.Image result = null; |
82 |
|
83 |
var str = CompressHelper.DecompressString(base64String); |
84 |
|
85 |
byte[] imageBytes = Convert.FromBase64String(str); |
86 |
|
87 |
using (MemoryStream ms = new MemoryStream(imageBytes)) |
88 |
{ |
89 |
result = System.Drawing.Image.FromStream(ms); |
90 |
} |
91 |
|
92 |
return result; |
93 |
} |
94 |
|
95 |
private byte[] ExcelToImageData(string base64String) |
96 |
{ |
97 |
var str = CompressHelper.DecompressString(base64String); |
98 |
|
99 |
return Convert.FromBase64String(str); |
100 |
} |
101 |
|
102 |
|
103 |
public ImportResult ExcelDataImport(List<ExcelData> ExcelData) |
104 |
{ |
105 |
ImportResult result = new ImportResult(); |
106 |
|
107 |
StringBuilder sbErrMsg = new StringBuilder(); |
108 |
|
109 |
try |
110 |
{ |
111 |
int rowCount = ExcelData.Max(x => x.ROW_INDEX); |
112 |
int columnCount = ExcelData.Max(x => x.COUMMN_INDEX); |
113 |
int exRow = 9; |
114 |
|
115 |
#region Excel 유효성검사 |
116 |
|
117 |
//Excel 포멧체크 |
118 |
if (rowCount < 10 || columnCount != 51) |
119 |
{ |
120 |
result.Error = $"Please, check the excel.\n(rows:{rowCount}. cols:{columnCount})"; |
121 |
return result; |
122 |
} |
123 |
|
124 |
#region 엑셀 필수값 체크(9: ID2 Project, 12 : DWG_ID) |
125 |
//ExcelData.Where(col => col.ROW_INDEX > exRow) |
126 |
// .Where(col => col.COUMMN_INDEX > 8 && col.COUMMN_INDEX < 18 && col.ROW_INDEX > exRow && string.IsNullOrEmpty(col.VALUE)) |
127 |
// .ToList() |
128 |
// .ForEach(p => sbErrMsg.Append(", " + p.TopLeftCell)); |
129 |
|
130 |
ExcelData.Where(col => col.ROW_INDEX > exRow) |
131 |
.Where(col => (col.COUMMN_INDEX == 9 || col.COUMMN_INDEX == 12) && string.IsNullOrEmpty(col.VALUE)) |
132 |
.ToList() |
133 |
.ForEach(p => sbErrMsg.Append(", " + p.TopLeftCell)); |
134 |
|
135 |
if (sbErrMsg.Length > 0) |
136 |
{ |
137 |
string errMsg = sbErrMsg.ToString().Substring(2); |
138 |
if (errMsg.Length > 100) |
139 |
{ |
140 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
141 |
} |
142 |
|
143 |
result.Error = $"Please, check null value in excel.\n{errMsg}"; |
144 |
return result; |
145 |
} |
146 |
#endregion |
147 |
|
148 |
#region 엑셀 도면명 중복 값 체크 |
149 |
ExcelData.Where(col => col.COUMMN_INDEX == 12 && col.ROW_INDEX > exRow) |
150 |
.GroupBy(g => g.ROW_INDEX) |
151 |
.Select(p => new |
152 |
{ |
153 |
rowIndex = p.Key, |
154 |
docNo = p.Select(x => x.VALUE.ToString()).FirstOrDefault() |
155 |
}) |
156 |
.GroupBy(g => g.docNo) |
157 |
.Where(p => p.Count() > 1) |
158 |
.Select(p => p.Select(x => x.rowIndex.ToString()) |
159 |
.Aggregate((x, y) => x.ToString() + "," + y.ToString()) |
160 |
.ToString()) |
161 |
.ToList() |
162 |
.ForEach(p => sbErrMsg.Append("\n" + p.ToString())); |
163 |
|
164 |
if (sbErrMsg.Length > 0) |
165 |
{ |
166 |
sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : "); |
167 |
string errMsg = sbErrMsg.ToString(); |
168 |
if (errMsg.Length > 100) |
169 |
{ |
170 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
171 |
} |
172 |
|
173 |
result.Error = $"Please, check the duplicate value in excel.\n{errMsg}"; |
174 |
return result; |
175 |
} |
176 |
#endregion |
177 |
|
178 |
#endregion |
179 |
|
180 |
result.documents = new List<Documents>(); |
181 |
result.Images = new List<System.Drawing.Image>(); |
182 |
|
183 |
foreach (var row in ExcelData.Where(row => row.ROW_INDEX > exRow).GroupBy(x => x.ROW_INDEX)) |
184 |
{ |
185 |
var document = new Documents(); |
186 |
//document.DocID = Guid.NewGuid().ToString(); |
187 |
|
188 |
int toreview = 0; |
189 |
int frreview = 0; |
190 |
int id2work = 0; |
191 |
|
192 |
foreach (var cell in row.OrderBy(x => x.COUMMN_INDEX)) |
193 |
{ |
194 |
var value = cell.VALUE.DefalutValue(); |
195 |
|
196 |
switch (cell.COUMMN_INDEX) |
197 |
{ |
198 |
case 9: |
199 |
var prjInfo = this.GetProject(value); |
200 |
//document.RefProjectCode = prjInfo.Code; |
201 |
document.RefProjectCode = string.IsNullOrEmpty(value) ? value : value.Trim(); |
202 |
if (!string.IsNullOrEmpty(document.RefProjectCode)) |
203 |
{ |
204 |
document.Team = prjInfo.Team; |
205 |
} |
206 |
break; |
207 |
case 10: |
208 |
document.System = value; |
209 |
break; |
210 |
case 11: |
211 |
document.SubSystemCode = value; |
212 |
break; |
213 |
case 12: |
214 |
document.DocumentNo = string.IsNullOrEmpty(value) ? value : value.Trim(); |
215 |
break; |
216 |
case 13: |
217 |
document.PersonInCharge = this.GetUser(value).ID; |
218 |
break; |
219 |
case 14: |
220 |
document.Worker = this.GetUser(value).ID; |
221 |
break; |
222 |
case 15: |
223 |
document.AVEVAPersonInCharge = this.GetUser(value).ID; |
224 |
break; |
225 |
case 16: |
226 |
document.AVEVAWorker = this.GetUser(value).ID; |
227 |
break; |
228 |
case 17://유사도 |
229 |
break; |
230 |
case 18://유사도2 |
231 |
break; |
232 |
case 19://난이도 |
233 |
document.JobLevel = value; |
234 |
break; |
235 |
case 20: |
236 |
document.RevisonNo = value; |
237 |
break; |
238 |
case 21: |
239 |
document.ToIsDiscussion = value; |
240 |
break; |
241 |
case 22: |
242 |
document.ToRemarks = value; |
243 |
break; |
244 |
case 23: |
245 |
document.ToCreator = this.GetUser(value).ID; |
246 |
break; |
247 |
case 24: |
248 |
if (value != null) |
249 |
{ |
250 |
if (document.AttFiles == null) |
251 |
{ |
252 |
document.AttFiles = new List<AttFileInfo>(); |
253 |
} |
254 |
|
255 |
document.AttFiles.Add(new AttFileInfo |
256 |
{ |
257 |
FileID = Guid.NewGuid().ToString(), |
258 |
//RefID = document.DocID, |
259 |
Category = "toreview", |
260 |
FileType = "image/png", |
261 |
FileName = "ClipBoard", |
262 |
FilePath = "ClipBoard", |
263 |
FileExtension = ".png", |
264 |
CreatedDate = DateTime.Now, |
265 |
Creator = document.ToCreator, |
266 |
FileData = ExcelToImageData(value) |
267 |
|
268 |
}); |
269 |
|
270 |
document.ToCapture = ++toreview; |
271 |
} |
272 |
break; |
273 |
case 25: |
274 |
document.FrReviewStatus = value; |
275 |
break; |
276 |
case 26: |
277 |
document.FrRemarks = value; |
278 |
break; |
279 |
case 27: |
280 |
document.FrCreator = this.GetUser(value).ID; |
281 |
break; |
282 |
case 28: |
283 |
if (value != null) |
284 |
{ |
285 |
if (document.AttFiles == null) |
286 |
{ |
287 |
document.AttFiles = new List<AttFileInfo>(); |
288 |
} |
289 |
|
290 |
document.AttFiles.Add(new AttFileInfo |
291 |
{ |
292 |
FileID = Guid.NewGuid().ToString(), |
293 |
//RefID = document.DocID, |
294 |
Category = "frreview", |
295 |
FileType = "image/png", |
296 |
FileName = "ClipBoard", |
297 |
FilePath = "ClipBoard", |
298 |
FileExtension = ".png", |
299 |
CreatedDate = DateTime.Now, |
300 |
Creator = document.FrCreator, |
301 |
FileData = ExcelToImageData(value) |
302 |
|
303 |
}); |
304 |
|
305 |
document.FrCapture = ++frreview; |
306 |
} |
307 |
break; |
308 |
case 29: |
309 |
document.ID2StartDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value); |
310 |
break; |
311 |
case 30: |
312 |
document.ID2EndDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value); |
313 |
break; |
314 |
case 31: |
315 |
document.ID2Status = value; |
316 |
break; |
317 |
case 32: |
318 |
document.ID2Issues = value; |
319 |
break; |
320 |
case 33: |
321 |
if (value != null) |
322 |
{ |
323 |
if (document.AttFiles == null) |
324 |
{ |
325 |
document.AttFiles = new List<AttFileInfo>(); |
326 |
} |
327 |
|
328 |
document.AttFiles.Add(new AttFileInfo |
329 |
{ |
330 |
FileID = Guid.NewGuid().ToString(), |
331 |
//RefID = document.DocID, |
332 |
Category = "id2work", |
333 |
FileType = "image/png", |
334 |
FileName = "ClipBoard", |
335 |
FilePath = "ClipBoard", |
336 |
FileExtension = ".png", |
337 |
CreatedDate = DateTime.Now, |
338 |
Creator = document.FrCreator, |
339 |
FileData = ExcelToImageData(value) |
340 |
|
341 |
}); |
342 |
|
343 |
document.ID2Capture = ++id2work; |
344 |
} |
345 |
break; |
346 |
case 34: |
347 |
document.ReplyModifications = value; |
348 |
break; |
349 |
case 35: |
350 |
document.ReplyRequester = this.GetUser(value).ID; |
351 |
break; |
352 |
case 36: |
353 |
document.IsConvert = value; |
354 |
break; |
355 |
case 37: |
356 |
document.AVEVAConvertDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value); |
357 |
break; |
358 |
case 38: |
359 |
document.AVEVAWorkDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value); |
360 |
break; |
361 |
case 39: |
362 |
document.AVEVAStatus = value; |
363 |
break; |
364 |
case 40: |
365 |
document.AVEVAIssues = value; |
366 |
break; |
367 |
case 41: |
368 |
document.AVEVAReviewDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value); |
369 |
break; |
370 |
case 42: |
371 |
document.ProdReviewer = this.GetUser(value).ID; |
372 |
break; |
373 |
case 43: |
374 |
document.ProdIsResult = value; |
375 |
break; |
376 |
case 44: |
377 |
document.ProdRemarks = value; |
378 |
break; |
379 |
case 45: |
380 |
document.ClientReviewer = this.GetUser(value).ID; |
381 |
break; |
382 |
case 46: |
383 |
document.ClientIsResult = value; |
384 |
break; |
385 |
case 47: |
386 |
document.ClientRemarks = value; |
387 |
break; |
388 |
case 48: |
389 |
document.DTIsGateWay = value; |
390 |
break; |
391 |
case 49: |
392 |
document.DTIsImport = value; |
393 |
break; |
394 |
case 50: |
395 |
document.DTIsRegSystem = value; |
396 |
break; |
397 |
case 51: |
398 |
document.DTRemarks = value; |
399 |
break; |
400 |
} |
401 |
} |
402 |
|
403 |
result.documents.Add(document); |
404 |
} |
405 |
} |
406 |
catch (Exception) |
407 |
{ |
408 |
throw; |
409 |
} |
410 |
|
411 |
return result; |
412 |
} |
413 |
|
414 |
|
415 |
public ImportResult GemboxImport(string fileName) |
416 |
{ |
417 |
ImportResult result = new ImportResult(); |
418 |
|
419 |
StringBuilder sbErrMsg = new StringBuilder(); |
420 |
|
421 |
try |
422 |
{ |
423 |
var exFile = ExcelFile.Load(fileName); |
424 |
var ws = exFile.Worksheets[0]; |
425 |
|
426 |
int rowCount = ws.Rows.Count; |
427 |
int columnCount = ws.CalculateMaxUsedColumns(); |
428 |
int exRow = 8; |
429 |
|
430 |
#region Excel 유효성검사 |
431 |
|
432 |
//Excel 포멧체크 |
433 |
if (rowCount < 10 || columnCount != 51) |
434 |
{ |
435 |
result.Error = $"Please, check the excel.\n(rows:{rowCount}. cols:{columnCount})"; |
436 |
return result; |
437 |
} |
438 |
|
439 |
#region 엑셀 필수값 체크(도면 : 이름, 담당자, 난이도, Typical) -> 추후 gembox사용시 변경필요 |
440 |
ws.Rows.SelectMany(row => row.AllocatedCells) |
441 |
.Where(col => col.Column.Index > 8 && col.Column.Index < 18 && col.Row.Index > exRow && col.Value == null) |
442 |
.ToList() |
443 |
.ForEach(p => sbErrMsg.Append(", " + p.Column.Name + p.Row.Name)); |
444 |
|
445 |
if (sbErrMsg.Length > 0) |
446 |
{ |
447 |
string errMsg = sbErrMsg.ToString().Substring(2); |
448 |
if (errMsg.Length > 100) |
449 |
{ |
450 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
451 |
} |
452 |
|
453 |
result.Error = $"Please, check null value in excel.\n{errMsg}"; |
454 |
return result; |
455 |
} |
456 |
#endregion |
457 |
|
458 |
#region 엑셀 도면명 중복 값 체크 |
459 |
ws.Rows.SelectMany(row => row.AllocatedCells) |
460 |
.Where(col => col.Column.Index == 12 && col.Row.Index > exRow) |
461 |
.GroupBy(g => g.Row.Index) |
462 |
.Select(p => new |
463 |
{ |
464 |
rowIndex = p.Key, |
465 |
docNo = p.Select(x => x.Value.ToString()).FirstOrDefault() |
466 |
}) |
467 |
.GroupBy(g => g.docNo) |
468 |
.Where(p => p.Count() > 1) |
469 |
.Select(p => p.Select(x => (x.rowIndex + 1).ToString()) |
470 |
.Aggregate((x, y) => x.ToString() + "," + y.ToString()) |
471 |
.ToString()) |
472 |
.ToList() |
473 |
.ForEach(p => sbErrMsg.Append("\n" + p.ToString())); |
474 |
if (sbErrMsg.Length > 0) |
475 |
{ |
476 |
sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : "); |
477 |
string errMsg = sbErrMsg.ToString(); |
478 |
if (errMsg.Length > 100) |
479 |
{ |
480 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
481 |
} |
482 |
|
483 |
result.Error = $"Please, check the duplicate value in excel.\n{errMsg}"; |
484 |
return result; |
485 |
} |
486 |
#endregion |
487 |
|
488 |
#endregion |
489 |
|
490 |
result.documents = new List<Documents>(); |
491 |
|
492 |
ws.Rows.Where(row => row.Index > exRow) |
493 |
.ToList() |
494 |
.ForEach(p => |
495 |
{ |
496 |
try |
497 |
{ |
498 |
int colIndex = 9; |
499 |
var docInfo = new Documents(); |
500 |
docInfo.RefProjectCode = ws.Rows[p.Index].Cells[colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
501 |
docInfo.System = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
502 |
docInfo.SubSystemCode = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
503 |
docInfo.DocumentNo = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
504 |
docInfo.PersonInCharge = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
505 |
docInfo.Worker = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
506 |
docInfo.AVEVAPersonInCharge = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
507 |
docInfo.AVEVAWorker = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
508 |
docInfo.Simularity = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
509 |
docInfo.Simularity2 = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
510 |
docInfo.JobLevel = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
511 |
docInfo.RevisonNo = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
512 |
docInfo.ToIsDiscussion = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
513 |
docInfo.ToRemarks = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
514 |
docInfo.ToCreator = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
515 |
++colIndex;//toreview-24 |
516 |
docInfo.FrReviewStatus = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
517 |
docInfo.FrRemarks = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
518 |
docInfo.FrCreator = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
519 |
++colIndex;//frreview-28 |
520 |
docInfo.ID2StartDate = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[colIndex].Value?.ToString()); |
521 |
docInfo.ID2EndDate = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[colIndex].Value?.ToString()); |
522 |
docInfo.ID2Status = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
523 |
docInfo.ID2Issues = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
524 |
++colIndex;//id2work-33 |
525 |
docInfo.ReplyModifications = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
526 |
docInfo.ReplyRequester = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
527 |
docInfo.IsConvert = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
528 |
docInfo.AVEVAConvertDate = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[colIndex].Value.ToString()); |
529 |
docInfo.AVEVAWorkDate = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[colIndex].Value.ToString()); |
530 |
docInfo.AVEVAStatus = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
531 |
docInfo.AVEVAIssues = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
532 |
docInfo.AVEVAReviewDate = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[colIndex].Value.ToString()); |
533 |
docInfo.ProdReviewer = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
534 |
docInfo.ProdIsResult = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
535 |
docInfo.ProdRemarks = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
536 |
docInfo.ClientReviewer = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[colIndex].Value.ToString()).ID; |
537 |
docInfo.ClientIsResult = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
538 |
docInfo.ClientRemarks = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
539 |
docInfo.DTIsGateWay = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
540 |
docInfo.DTIsImport = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
541 |
docInfo.DTIsRegSystem = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
542 |
docInfo.DTRemarks = ws.Rows[p.Index].Cells[++colIndex].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[colIndex].Value.ToString(); |
543 |
result.documents.Add(docInfo); |
544 |
|
545 |
//result.documents.Add(new Documents() |
546 |
//{ |
547 |
/* |
548 |
RefProjectCode = ws.Rows[p.Index].Cells[9].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(), |
549 |
System = ws.Rows[p.Index].Cells[10].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(), |
550 |
SubSystemCode = ws.Rows[p.Index].Cells[11].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(), |
551 |
DocumentNo = ws.Rows[p.Index].Cells[12].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(), |
552 |
PersonInCharge = ws.Rows[p.Index].Cells[13].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID, |
553 |
Worker = ws.Rows[p.Index].Cells[14].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[14].Value.ToString()).ID, |
554 |
AVEVAPersonInCharge = ws.Rows[p.Index].Cells[15].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[15].Value.ToString()).ID, |
555 |
AVEVAWorker = ws.Rows[p.Index].Cells[16].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[16].Value.ToString()).ID, |
556 |
Simularity = ws.Rows[p.Index].Cells[17].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(), |
557 |
JobLevel = ws.Rows[p.Index].Cells[18].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[18].Value.ToString(), |
558 |
RevisonNo = ws.Rows[p.Index].Cells[19].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[19].Value.ToString(), |
559 |
ToIsDiscussion = ws.Rows[p.Index].Cells[20].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[20].Value.ToString(), |
560 |
ToRemarks = ws.Rows[p.Index].Cells[21].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(), |
561 |
ToCreator = ws.Rows[p.Index].Cells[22].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[22].Value.ToString()).ID, |
562 |
//toreview-23 |
563 |
FrReviewStatus = ws.Rows[p.Index].Cells[24].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[24].Value.ToString(), |
564 |
FrRemarks = ws.Rows[p.Index].Cells[25].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[25].Value.ToString(), |
565 |
FrCreator = ws.Rows[p.Index].Cells[26].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[26].Value.ToString()).ID, |
566 |
//frreview-27 |
567 |
ID2StartDate = ws.Rows[p.Index].Cells[28].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[28].Value?.ToString()), |
568 |
ID2EndDate = ws.Rows[p.Index].Cells[29].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value?.ToString()), |
569 |
ID2Status = ws.Rows[p.Index].Cells[30].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[30].Value.ToString(), |
570 |
ID2Issues = ws.Rows[p.Index].Cells[31].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(), |
571 |
//id2work-32 |
572 |
ReplyModifications = ws.Rows[p.Index].Cells[33].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[33].Value.ToString(), |
573 |
ReplyRequester = ws.Rows[p.Index].Cells[34].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[34].Value.ToString()).ID, |
574 |
IsConvert = ws.Rows[p.Index].Cells[35].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[35].Value.ToString(), |
575 |
AVEVAConvertDate = ws.Rows[p.Index].Cells[36].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[36].Value.ToString()), |
576 |
AVEVAWorkDate = ws.Rows[p.Index].Cells[37].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[37].Value.ToString()), |
577 |
AVEVAStatus = ws.Rows[p.Index].Cells[38].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[38].Value.ToString(), |
578 |
AVEVAIssues = ws.Rows[p.Index].Cells[39].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(), |
579 |
AVEVAReviewDate = ws.Rows[p.Index].Cells[40].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[40].Value.ToString()), |
580 |
ProdReviewer = ws.Rows[p.Index].Cells[41].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[41].Value.ToString()).ID, |
581 |
ProdIsResult = ws.Rows[p.Index].Cells[42].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(), |
582 |
ProdRemarks = ws.Rows[p.Index].Cells[43].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(), |
583 |
ClientReviewer = ws.Rows[p.Index].Cells[44].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[44].Value.ToString()).ID, |
584 |
ClientIsResult = ws.Rows[p.Index].Cells[45].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[45].Value.ToString(), |
585 |
ClientRemarks = ws.Rows[p.Index].Cells[46].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[46].Value.ToString(), |
586 |
DTIsGateWay = ws.Rows[p.Index].Cells[47].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[47].Value.ToString(), |
587 |
DTIsImport = ws.Rows[p.Index].Cells[48].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[48].Value.ToString(), |
588 |
DTIsRegSystem = ws.Rows[p.Index].Cells[49].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[49].Value.ToString(), |
589 |
DTRemarks = ws.Rows[p.Index].Cells[50].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[50].Value.ToString() |
590 |
*/ |
591 |
|
592 |
/* |
593 |
//UID = string.Empty, |
594 |
//Type = this.radTextBoxInsulationType.Text, |
595 |
//TempFrom = ws.Rows[exRow].Cells[p.Column.Index].IsNullOrEmpty() ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value), |
596 |
//TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].IsNullOrEmpty() ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value), |
597 |
//NPS = ws.Rows[p.Row.Index].Cells[0].IsNullOrEmpty() ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value), |
598 |
//Thickness = p.IsNullOrEmpty() ? 0 : Convert.ToSingle(p.Value) |
599 |
|
600 |
RefProjectCode = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
601 |
DocumentNo = ws.Rows[p.Index].Cells[6].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(), |
602 |
PersonInCharge = ws.Rows[p.Index].Cells[7].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID, |
603 |
JobLevel = ws.Rows[p.Index].Cells[8].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(), |
604 |
//IsTypical = ws.Rows[p.Index].Cells[9].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(), |
605 |
RevisonNo = ws.Rows[p.Index].Cells[10].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(), |
606 |
ToIsDiscussion = ws.Rows[p.Index].Cells[11].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(), |
607 |
ToRemarks = ws.Rows[p.Index].Cells[12].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(), |
608 |
ToCreator = ws.Rows[p.Index].Cells[13].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID, |
609 |
//ToCapture = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
610 |
//ToIsMarkup = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
611 |
FrReviewStatus = ws.Rows[p.Index].Cells[16].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(), |
612 |
FrRemarks = ws.Rows[p.Index].Cells[17].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(), |
613 |
FrCreator = ws.Rows[p.Index].Cells[18].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID, |
614 |
//FrCapture = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
615 |
//FrIsMarkup = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
616 |
//IsID2Work = ws.Rows[p.Index].Cells[21].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(), |
617 |
//ID2Connection = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
618 |
ID2StartDate = ws.Rows[p.Index].Cells[23].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()), |
619 |
ID2EndDate = ws.Rows[p.Index].Cells[24].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()), |
620 |
//ID2JobTime = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
621 |
ID2Status = ws.Rows[p.Index].Cells[26].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(), |
622 |
ID2Issues = ws.Rows[p.Index].Cells[27].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(), |
623 |
//AVEVAConnection = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
624 |
AVEVAConvertDate = ws.Rows[p.Index].Cells[29].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()), |
625 |
AVEVAReviewDate = ws.Rows[p.Index].Cells[30].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()), |
626 |
//AVEVAWorkDate 추가필요 |
627 |
AVEVAStatus = ws.Rows[p.Index].Cells[31].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(), |
628 |
AVEVAIssues = ws.Rows[p.Index].Cells[32].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(), |
629 |
ProdReviewer = ws.Rows[p.Index].Cells[35].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID, |
630 |
ProdIsResult = ws.Rows[p.Index].Cells[36].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(), |
631 |
ProdRemarks = ws.Rows[p.Index].Cells[37].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(), |
632 |
ClientReviewer = ws.Rows[p.Index].Cells[38].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID, |
633 |
ClientIsResult = ws.Rows[p.Index].Cells[39].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(), |
634 |
ClientRemarks = ws.Rows[p.Index].Cells[40].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(), |
635 |
DTIsGateWay = ws.Rows[p.Index].Cells[41].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(), |
636 |
DTIsImport = ws.Rows[p.Index].Cells[42].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(), |
637 |
DTIsRegSystem = ws.Rows[p.Index].Cells[43].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(), |
638 |
DTRemarks = ws.Rows[p.Index].Cells[44].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString() |
639 |
*/ |
640 |
//}); |
641 |
} |
642 |
catch (Exception ex) |
643 |
{ |
644 |
throw new Exception($"Excel Import Row :{p.Index} Error.", ex); |
645 |
} |
646 |
}); |
647 |
|
648 |
} |
649 |
catch (Exception) |
650 |
{ |
651 |
throw; |
652 |
} |
653 |
|
654 |
return result; |
655 |
} |
656 |
} |
657 |
} |