프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Common / Helpers / ID2Excel.cs @ 3af65061

이력 | 보기 | 이력해설 | 다운로드 (33.9 KB)

1 057ca09a taeseongkim
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 b6abb7b8 yoush97
8 43ceb5b3 taeseongkim
using System.IO;
9
using System.IO.Compression;
10 8eca8767 taeseongkim
11 b6abb7b8 yoush97
using GemBox.Spreadsheet;
12
13 057ca09a taeseongkim
namespace ID2.Manager.Common.Helpers
14
{
15 d0a1d373 yoush97
    public class ID2Excel : IDisposable
16 057ca09a taeseongkim
    {
17 61124f6c yoush97
        readonly Informations informations = Informations.Instance;
18 057ca09a taeseongkim
19
        public void Dispose()
20
        {
21 8eca8767 taeseongkim
            try
22
            {
23
            }
24
            catch (Exception)
25
            {
26
                throw;
27
            }
28
            finally
29
            {
30
                GC.Collect(2);
31
                GC.Collect(2);
32
            }
33 057ca09a taeseongkim
        }
34
35 61124f6c yoush97
        public ID2Excel() { }
36
37 88c542dd yoush97
        private ProjectInfo GetProject(string project)
38 057ca09a taeseongkim
        {
39 d65eb9b2 yoush97
            //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 61124f6c yoush97
44 88c542dd yoush97
            ProjectInfo prjInfo = projects.FirstOrDefault(x => x.Code.Equals(project));
45
            if (prjInfo != null) return prjInfo;
46 61124f6c yoush97
47 88c542dd yoush97
            prjInfo = projects.FirstOrDefault(x => x.Name.Equals(project));
48
            if (prjInfo != null) return prjInfo;
49
50
            return prjInfo ?? new ProjectInfo();
51 057ca09a taeseongkim
        }
52
53
        private UserInfo GetUser(string user)
54
        {
55 61124f6c yoush97
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
56 057ca09a taeseongkim
            if (userInfo != null) return userInfo;
57
58 61124f6c yoush97
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
59 057ca09a taeseongkim
            if (userInfo != null) return userInfo;
60
61
            return userInfo ?? new UserInfo();
62
        }
63
64 8eca8767 taeseongkim
        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 56f7f16e taeseongkim
        private System.Drawing.Image GetImage(string base64String)
80 43ceb5b3 taeseongkim
        {
81 56f7f16e taeseongkim
            System.Drawing.Image result = null;
82 d0a1d373 yoush97
83
            var str = CompressHelper.DecompressString(base64String);
84 43ceb5b3 taeseongkim
85
            byte[] imageBytes = Convert.FromBase64String(str);
86
87
            using (MemoryStream ms = new MemoryStream(imageBytes))
88
            {
89 56f7f16e taeseongkim
                result = System.Drawing.Image.FromStream(ms);
90 43ceb5b3 taeseongkim
            }
91
92
            return result;
93
        }
94 8eca8767 taeseongkim
95 422f620d taeseongkim
        private byte[] ExcelToImageData(string base64String)
96
        {
97
            var str = CompressHelper.DecompressString(base64String);
98
99
            return Convert.FromBase64String(str);
100
        }
101
102 8eca8767 taeseongkim
103
        public ImportResult ExcelDataImport(List<ExcelData> ExcelData)
104
        {
105
            ImportResult result = new ImportResult();
106
107
            StringBuilder sbErrMsg = new StringBuilder();
108
109
            try
110
            {
111 d0a1d373 yoush97
                int rowCount = ExcelData.Max(x => x.ROW_INDEX);
112 8eca8767 taeseongkim
                int columnCount = ExcelData.Max(x => x.COUMMN_INDEX);
113
                int exRow = 9;
114
115
                #region Excel 유효성검사
116
117
                //Excel 포멧체크
118 7d73b57c yoush97
                if (rowCount < 10 || columnCount != 49)
119 8eca8767 taeseongkim
                {
120
                    result.Error = "Please, check the excel.";
121
                    return result;
122
                }
123
124 386286fa yoush97
                #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 8eca8767 taeseongkim
                ExcelData.Where(col => col.ROW_INDEX > exRow)
131 386286fa yoush97
                         .Where(col => (col.COUMMN_INDEX == 9 || col.COUMMN_INDEX == 12) && string.IsNullOrEmpty(col.VALUE))
132 7d73b57c yoush97
                         .ToList()
133
                         .ForEach(p => sbErrMsg.Append(", " + p.TopLeftCell));
134 8eca8767 taeseongkim
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 4b9f349c yoush97
                #region 엑셀 도면명 중복 값 체크
149 7d73b57c yoush97
                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 8eca8767 taeseongkim
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 56f7f16e taeseongkim
                result.Images = new List<System.Drawing.Image>();
182 8eca8767 taeseongkim
183
                foreach (var row in ExcelData.Where(row => row.ROW_INDEX > exRow).GroupBy(x => x.ROW_INDEX))
184
                {
185
                    var document = new Documents();
186 49ab10bd taeseongkim
                    //document.DocID = Guid.NewGuid().ToString();
187 8eca8767 taeseongkim
188 57ea162e yoush97
                    int toreview = 0;
189
                    int frreview = 0;
190
                    int id2work = 0;
191
192 d0a1d373 yoush97
                    foreach (var cell in row.OrderBy(x => x.COUMMN_INDEX))
193 8eca8767 taeseongkim
                    {
194
                        var value = cell.VALUE.DefalutValue();
195
196
                        switch (cell.COUMMN_INDEX)
197
                        {
198 7d73b57c yoush97
                            case 9:
199 d0a1d373 yoush97
                                var prjInfo = this.GetProject(value);
200 416979ec yoush97
                                //document.RefProjectCode = prjInfo.Code;
201
                                document.RefProjectCode = string.IsNullOrEmpty(value) ? value : value.Trim();
202 7d73b57c yoush97
                                if (!string.IsNullOrEmpty(document.RefProjectCode))
203
                                {
204 d0a1d373 yoush97
                                    document.Team = prjInfo.Team;
205 7d73b57c yoush97
                                }
206 8eca8767 taeseongkim
                                break;
207 7d73b57c yoush97
                            case 10:
208 4b9f349c yoush97
                                document.System = value;
209
                                break;
210 7d73b57c yoush97
                            case 11:
211 4b9f349c yoush97
                                document.SubSystemCode = value;
212
                                break;
213 7d73b57c yoush97
                            case 12:
214 416979ec yoush97
                                document.DocumentNo = string.IsNullOrEmpty(value) ? value : value.Trim();
215 8eca8767 taeseongkim
                                break;
216 7d73b57c yoush97
                            case 13:
217 8eca8767 taeseongkim
                                document.PersonInCharge = this.GetUser(value).ID;
218
                                break;
219 7d73b57c yoush97
                            case 14:
220 4b9f349c yoush97
                                document.Worker = this.GetUser(value).ID;
221
                                break;
222 7d73b57c yoush97
                            case 15:
223 4b9f349c yoush97
                                document.AVEVAPersonInCharge = this.GetUser(value).ID;
224
                                break;
225 7d73b57c yoush97
                            case 16:
226 4b9f349c yoush97
                                document.AVEVAWorker = this.GetUser(value).ID;
227
                                break;
228 7d73b57c yoush97
                            case 17:
229 8eca8767 taeseongkim
                                document.JobLevel = value;
230
                                break;
231 7d73b57c yoush97
                            case 18:
232 8eca8767 taeseongkim
                                document.RevisonNo = value;
233
                                break;
234 7d73b57c yoush97
                            case 19:
235 8eca8767 taeseongkim
                                document.ToIsDiscussion = value;
236
                                break;
237 7d73b57c yoush97
                            case 20:
238 8eca8767 taeseongkim
                                document.ToRemarks = value;
239
                                break;
240 7d73b57c yoush97
                            case 21:
241 8eca8767 taeseongkim
                                document.ToCreator = this.GetUser(value).ID;
242
                                break;
243 7d73b57c yoush97
                            case 22:
244 422f620d taeseongkim
                                if (value != null)
245
                                {
246
                                    if (document.AttFiles == null)
247
                                    {
248
                                        document.AttFiles = new List<AttFileInfo>();
249
                                    }
250
251
                                    document.AttFiles.Add(new AttFileInfo
252
                                    {
253
                                        FileID = Guid.NewGuid().ToString(),
254 49ab10bd taeseongkim
                                        //RefID = document.DocID,
255 422f620d taeseongkim
                                        Category = "toreview",
256
                                        FileType = "image/png",
257
                                        FileName = "ClipBoard",
258
                                        FilePath = "ClipBoard",
259
                                        FileExtension = ".png",
260
                                        CreatedDate = DateTime.Now,
261
                                        Creator = document.ToCreator,
262
                                        FileData = ExcelToImageData(value)
263
264
                                    });
265 57ea162e yoush97
266
                                    document.ToCapture = ++toreview;
267 422f620d taeseongkim
                                }
268 43ceb5b3 taeseongkim
                                break;
269 7d73b57c yoush97
                            case 23:
270 8eca8767 taeseongkim
                                document.FrReviewStatus = value;
271
                                break;
272 7d73b57c yoush97
                            case 24:
273 8eca8767 taeseongkim
                                document.FrRemarks = value;
274
                                break;
275 7d73b57c yoush97
                            case 25:
276 8eca8767 taeseongkim
                                document.FrCreator = this.GetUser(value).ID;
277
                                break;
278 7d73b57c yoush97
                            case 26:
279 422f620d taeseongkim
                                if (value != null)
280
                                {
281
                                    if (document.AttFiles == null)
282
                                    {
283
                                        document.AttFiles = new List<AttFileInfo>();
284
                                    }
285
286
                                    document.AttFiles.Add(new AttFileInfo
287
                                    {
288
                                        FileID = Guid.NewGuid().ToString(),
289 49ab10bd taeseongkim
                                        //RefID = document.DocID,
290 422f620d taeseongkim
                                        Category = "frreview",
291
                                        FileType = "image/png",
292
                                        FileName = "ClipBoard",
293
                                        FilePath = "ClipBoard",
294
                                        FileExtension = ".png",
295
                                        CreatedDate = DateTime.Now,
296
                                        Creator = document.FrCreator,
297
                                        FileData = ExcelToImageData(value)
298
299
                                    });
300 57ea162e yoush97
301
                                    document.FrCapture = ++frreview;
302 422f620d taeseongkim
                                }
303
                                break;
304 7d73b57c yoush97
                            case 27:
305 8eca8767 taeseongkim
                                document.ID2StartDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
306
                                break;
307 7d73b57c yoush97
                            case 28:
308 8eca8767 taeseongkim
                                document.ID2EndDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
309
                                break;
310 7d73b57c yoush97
                            case 29:
311 8eca8767 taeseongkim
                                document.ID2Status = value;
312
                                break;
313 7d73b57c yoush97
                            case 30:
314 8eca8767 taeseongkim
                                document.ID2Issues = value;
315
                                break;
316 7d73b57c yoush97
                            case 31:
317 4b9f349c yoush97
                                if (value != null)
318
                                {
319
                                    if (document.AttFiles == null)
320
                                    {
321
                                        document.AttFiles = new List<AttFileInfo>();
322
                                    }
323
324
                                    document.AttFiles.Add(new AttFileInfo
325
                                    {
326
                                        FileID = Guid.NewGuid().ToString(),
327
                                        //RefID = document.DocID,
328
                                        Category = "id2work",
329
                                        FileType = "image/png",
330
                                        FileName = "ClipBoard",
331
                                        FilePath = "ClipBoard",
332
                                        FileExtension = ".png",
333
                                        CreatedDate = DateTime.Now,
334
                                        Creator = document.FrCreator,
335
                                        FileData = ExcelToImageData(value)
336
337
                                    });
338 57ea162e yoush97
339
                                    document.ID2Capture = ++id2work;
340 4b9f349c yoush97
                                }
341 8eca8767 taeseongkim
                                break;
342
                            case 32:
343 7d73b57c yoush97
                                document.ReplyModifications = value;
344 8eca8767 taeseongkim
                                break;
345
                            case 33:
346 7d73b57c yoush97
                                document.ReplyRequester = this.GetUser(value).ID;
347 4b9f349c yoush97
                                break;
348
                            case 34:
349 7d73b57c yoush97
                                document.IsConvert = value;
350 4b9f349c yoush97
                                break;
351
                            case 35:
352 7d73b57c yoush97
                                document.AVEVAConvertDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
353 8eca8767 taeseongkim
                                break;
354
                            case 36:
355 7d73b57c yoush97
                                document.AVEVAWorkDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
356 8eca8767 taeseongkim
                                break;
357
                            case 37:
358 7d73b57c yoush97
                                document.AVEVAStatus = value;
359 8eca8767 taeseongkim
                                break;
360
                            case 38:
361 7d73b57c yoush97
                                document.AVEVAIssues = value;
362 8eca8767 taeseongkim
                                break;
363
                            case 39:
364 7d73b57c yoush97
                                document.AVEVAReviewDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
365 8eca8767 taeseongkim
                                break;
366
                            case 40:
367 7d73b57c yoush97
                                document.ProdReviewer = this.GetUser(value).ID;
368 8eca8767 taeseongkim
                                break;
369
                            case 41:
370 7d73b57c yoush97
                                document.ProdIsResult = value;
371 8eca8767 taeseongkim
                                break;
372
                            case 42:
373 7d73b57c yoush97
                                document.ProdRemarks = value;
374 8eca8767 taeseongkim
                                break;
375
                            case 43:
376 7d73b57c yoush97
                                document.ClientReviewer = this.GetUser(value).ID;
377 8eca8767 taeseongkim
                                break;
378
                            case 44:
379 7d73b57c yoush97
                                document.ClientIsResult = value;
380 8eca8767 taeseongkim
                                break;
381
                            case 45:
382 7d73b57c yoush97
                                document.ClientRemarks = value;
383 4b9f349c yoush97
                                break;
384
                            case 46:
385 7d73b57c yoush97
                                document.DTIsGateWay = value;
386 4b9f349c yoush97
                                break;
387
                            case 47:
388 7d73b57c yoush97
                                document.DTIsImport = value;
389 4b9f349c yoush97
                                break;
390
                            case 48:
391 7d73b57c yoush97
                                document.DTIsRegSystem = value;
392
                                break;
393
                            case 49:
394 8eca8767 taeseongkim
                                document.DTRemarks = value;
395
                                break;
396
                        }
397
                    }
398
399
                    result.documents.Add(document);
400
                }
401
            }
402
            catch (Exception)
403
            {
404
                throw;
405
            }
406
407
            return result;
408
        }
409
410
411 057ca09a taeseongkim
        public ImportResult GemboxImport(string fileName)
412
        {
413
            ImportResult result = new ImportResult();
414
415
            StringBuilder sbErrMsg = new StringBuilder();
416
417
            try
418
            {
419
                var exFile = ExcelFile.Load(fileName);
420
                var ws = exFile.Worksheets[0];
421
422
                int rowCount = ws.Rows.Count;
423
                int columnCount = ws.CalculateMaxUsedColumns();
424
                int exRow = 8;
425
426
                #region Excel 유효성검사
427
428
                //Excel 포멧체크
429 d0a1d373 yoush97
                if (rowCount < 10 || columnCount != 49)
430 057ca09a taeseongkim
                {
431
                    result.Error = "Please, check the excel.";
432
                    return result;
433
                }
434
435
                #region 엑셀 필수값 체크(도면 : 이름,담당자, 난이도, Typical)
436
                ws.Rows.SelectMany(row => row.AllocatedCells)
437 d0a1d373 yoush97
                       .Where(col => col.Column.Index > 8 && col.Column.Index < 18 && col.Row.Index > exRow && col.Value == null)
438 057ca09a taeseongkim
                       .ToList()
439
                       .ForEach(p => sbErrMsg.Append(", " + p.Column.Name + p.Row.Name));
440
441
                if (sbErrMsg.Length > 0)
442
                {
443
                    string errMsg = sbErrMsg.ToString().Substring(2);
444
                    if (errMsg.Length > 100)
445
                    {
446
                        errMsg = $"{errMsg.Substring(0, 100)}...";
447
                    }
448
449
                    result.Error = $"Please, check null value in excel.\n{errMsg}";
450
                    return result;
451
                }
452
                #endregion
453
454 4b9f349c yoush97
                #region 엑셀 도면명 중복 값 체크
455 057ca09a taeseongkim
                ws.Rows.SelectMany(row => row.AllocatedCells)
456 d0a1d373 yoush97
                                             .Where(col => col.Column.Index == 12 && col.Row.Index > exRow)
457 057ca09a taeseongkim
                                             .GroupBy(g => g.Row.Index)
458
                                             .Select(p => new
459
                                             {
460
                                                 rowIndex = p.Key,
461
                                                 docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
462
                                             })
463
                                             .GroupBy(g => g.docNo)
464
                                             .Where(p => p.Count() > 1)
465
                                             .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
466 d0a1d373 yoush97
                                                           .Aggregate((x, y) => x.ToString() + "," + y.ToString())
467
                                                           .ToString())
468
                                             .ToList()
469
                                             .ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
470 057ca09a taeseongkim
                if (sbErrMsg.Length > 0)
471
                {
472
                    sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
473
                    string errMsg = sbErrMsg.ToString();
474
                    if (errMsg.Length > 100)
475
                    {
476
                        errMsg = $"{errMsg.Substring(0, 100)}...";
477
                    }
478
479
                    result.Error = $"Please, check the duplicate value in excel.\n{errMsg}";
480
                    return result;
481
                }
482
                #endregion
483
484
                #endregion
485
486
                result.documents = new List<Documents>();
487
488
                ws.Rows.Where(row => row.Index > exRow)
489
                       .ToList()
490
                       .ForEach(p =>
491
                       {
492
                           try
493
                           {
494
                               result.documents.Add(new Documents()
495
                               {
496 d0a1d373 yoush97
                                   RefProjectCode = ws.Rows[p.Index].Cells[8].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
497
                                   System = ws.Rows[p.Index].Cells[9].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
498
                                   SubSystemCode = ws.Rows[p.Index].Cells[10].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
499
                                   DocumentNo = ws.Rows[p.Index].Cells[11].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
500
                                   PersonInCharge = ws.Rows[p.Index].Cells[12].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[12].Value.ToString()).ID,
501
                                   Worker = ws.Rows[p.Index].Cells[13].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
502
                                   AVEVAPersonInCharge = ws.Rows[p.Index].Cells[14].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[14].Value.ToString()).ID,
503
                                   AVEVAWorker = ws.Rows[p.Index].Cells[15].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[15].Value.ToString()).ID,
504
                                   JobLevel = ws.Rows[p.Index].Cells[16].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
505
                                   RevisonNo = ws.Rows[p.Index].Cells[17].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
506
                                   ToIsDiscussion = ws.Rows[p.Index].Cells[18].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[18].Value.ToString(),
507
                                   ToRemarks = ws.Rows[p.Index].Cells[19].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[19].Value.ToString(),
508
                                   ToCreator = ws.Rows[p.Index].Cells[20].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[20].Value.ToString()).ID,
509
                                   //toreview-21
510
                                   FrReviewStatus = ws.Rows[p.Index].Cells[22].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[22].Value.ToString(),
511
                                   FrRemarks = ws.Rows[p.Index].Cells[23].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[23].Value.ToString(),
512
                                   FrCreator = ws.Rows[p.Index].Cells[24].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[24].Value.ToString()).ID,
513
                                   //frreview-25
514
                                   ID2StartDate = ws.Rows[p.Index].Cells[26].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[26].Value?.ToString()),
515
                                   ID2EndDate = ws.Rows[p.Index].Cells[27].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[27].Value?.ToString()),
516
                                   ID2Status = ws.Rows[p.Index].Cells[28].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[28].Value.ToString(),
517
                                   ID2Issues = ws.Rows[p.Index].Cells[29].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[29].Value.ToString(),
518
                                   //id2work-30
519
                                   ReplyModifications = ws.Rows[p.Index].Cells[31].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
520
                                   ReplyRequester = ws.Rows[p.Index].Cells[32].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[32].Value.ToString()).ID,
521
                                   IsConvert = ws.Rows[p.Index].Cells[33].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[33].Value.ToString(),
522
                                   AVEVAConvertDate = ws.Rows[p.Index].Cells[34].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[34].Value.ToString()),
523
                                   AVEVAWorkDate = ws.Rows[p.Index].Cells[35].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[35].Value.ToString()),
524
                                   AVEVAStatus = ws.Rows[p.Index].Cells[36].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
525
                                   AVEVAIssues = ws.Rows[p.Index].Cells[37].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
526
                                   AVEVAReviewDate = ws.Rows[p.Index].Cells[38].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[38].Value.ToString()),
527
                                   ProdReviewer = ws.Rows[p.Index].Cells[39].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[39].Value.ToString()).ID,
528
                                   ProdIsResult = ws.Rows[p.Index].Cells[40].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
529
                                   ProdRemarks = ws.Rows[p.Index].Cells[41].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
530
                                   ClientReviewer = ws.Rows[p.Index].Cells[42].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[42].Value.ToString()).ID,
531
                                   ClientIsResult = ws.Rows[p.Index].Cells[43].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
532
                                   ClientRemarks = ws.Rows[p.Index].Cells[44].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString(),
533
                                   DTIsGateWay = ws.Rows[p.Index].Cells[45].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[45].Value.ToString(),
534
                                   DTIsImport = ws.Rows[p.Index].Cells[46].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[46].Value.ToString(),
535
                                   DTIsRegSystem = ws.Rows[p.Index].Cells[47].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[47].Value.ToString(),
536
                                   DTRemarks = ws.Rows[p.Index].Cells[48].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[48].Value.ToString()
537 4b9f349c yoush97
538
                                   /*
539 057ca09a taeseongkim
                                   //UID = string.Empty,
540
                                   //Type = this.radTextBoxInsulationType.Text,
541
                                   //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].IsNullOrEmpty() ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
542
                                   //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].IsNullOrEmpty() ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
543
                                   //NPS = ws.Rows[p.Row.Index].Cells[0].IsNullOrEmpty() ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
544
                                   //Thickness = p.IsNullOrEmpty() ? 0 : Convert.ToSingle(p.Value)
545
546
                                   RefProjectCode = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
547
                                   DocumentNo = ws.Rows[p.Index].Cells[6].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
548
                                   PersonInCharge = ws.Rows[p.Index].Cells[7].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
549
                                   JobLevel = ws.Rows[p.Index].Cells[8].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
550 d9949772 yoush97
                                   //IsTypical = ws.Rows[p.Index].Cells[9].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
551 057ca09a taeseongkim
                                   RevisonNo = ws.Rows[p.Index].Cells[10].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
552
                                   ToIsDiscussion = ws.Rows[p.Index].Cells[11].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
553
                                   ToRemarks = ws.Rows[p.Index].Cells[12].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
554
                                   ToCreator = ws.Rows[p.Index].Cells[13].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
555
                                   //ToCapture = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
556
                                   //ToIsMarkup = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
557
                                   FrReviewStatus = ws.Rows[p.Index].Cells[16].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
558
                                   FrRemarks = ws.Rows[p.Index].Cells[17].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
559
                                   FrCreator = ws.Rows[p.Index].Cells[18].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
560
                                   //FrCapture = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
561
                                   //FrIsMarkup = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
562 2aa2a446 yoush97
                                   //IsID2Work = ws.Rows[p.Index].Cells[21].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
563 057ca09a taeseongkim
                                   //ID2Connection = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
564
                                   ID2StartDate = ws.Rows[p.Index].Cells[23].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
565
                                   ID2EndDate = ws.Rows[p.Index].Cells[24].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
566
                                   //ID2JobTime = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
567
                                   ID2Status = ws.Rows[p.Index].Cells[26].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
568
                                   ID2Issues = ws.Rows[p.Index].Cells[27].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
569
                                   //AVEVAConnection = ws.Rows[p.Index].Cells[5].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
570
                                   AVEVAConvertDate = ws.Rows[p.Index].Cells[29].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
571
                                   AVEVAReviewDate = ws.Rows[p.Index].Cells[30].IsNullOrEmpty() ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
572 ab3c1c74 yoush97
                                   //AVEVAWorkDate 추가필요
573 057ca09a taeseongkim
                                   AVEVAStatus = ws.Rows[p.Index].Cells[31].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
574
                                   AVEVAIssues = ws.Rows[p.Index].Cells[32].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
575
                                   ProdReviewer = ws.Rows[p.Index].Cells[35].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
576
                                   ProdIsResult = ws.Rows[p.Index].Cells[36].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
577
                                   ProdRemarks = ws.Rows[p.Index].Cells[37].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
578
                                   ClientReviewer = ws.Rows[p.Index].Cells[38].IsNullOrEmpty() ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
579
                                   ClientIsResult = ws.Rows[p.Index].Cells[39].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
580
                                   ClientRemarks = ws.Rows[p.Index].Cells[40].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
581
                                   DTIsGateWay = ws.Rows[p.Index].Cells[41].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
582
                                   DTIsImport = ws.Rows[p.Index].Cells[42].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
583
                                   DTIsRegSystem = ws.Rows[p.Index].Cells[43].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
584
                                   DTRemarks = ws.Rows[p.Index].Cells[44].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
585 4b9f349c yoush97
                                   */
586 057ca09a taeseongkim
                               });
587 d0a1d373 yoush97
                           }
588 057ca09a taeseongkim
                           catch (Exception ex)
589
                           {
590 d0a1d373 yoush97
                               throw new Exception($"Excel Import Row :{p.Index} Error.", ex);
591 057ca09a taeseongkim
                           }
592
                       });
593
594
            }
595
            catch (Exception)
596
            {
597
                throw;
598
            }
599
600
            return result;
601
        }
602
    }
603
}
클립보드 이미지 추가 (최대 크기: 500 MB)