프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Common / Helpers / ID2Excel.cs @ e17d4c6f

이력 | 보기 | 이력해설 | 다운로드 (41.8 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 ee0dfabe yoush97
                if (rowCount < 10 || columnCount != 51)
119 8eca8767 taeseongkim
                {
120 ee0dfabe yoush97
                    result.Error = $"Please, check the excel.\n(rows:{rowCount}. cols:{columnCount})";
121 8eca8767 taeseongkim
                    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 28907ead yoush97
                            case 17://유사도
229
                                break;
230 b45e552e yoush97
                            case 18://유사도2
231
                                break;
232
                            case 19://난이도
233 8eca8767 taeseongkim
                                document.JobLevel = value;
234
                                break;
235 b45e552e yoush97
                            case 20:
236 8eca8767 taeseongkim
                                document.RevisonNo = value;
237
                                break;
238 b45e552e yoush97
                            case 21:
239 8eca8767 taeseongkim
                                document.ToIsDiscussion = value;
240
                                break;
241 b45e552e yoush97
                            case 22:
242 8eca8767 taeseongkim
                                document.ToRemarks = value;
243
                                break;
244 b45e552e yoush97
                            case 23:
245 8eca8767 taeseongkim
                                document.ToCreator = this.GetUser(value).ID;
246
                                break;
247 b45e552e yoush97
                            case 24:
248 422f620d taeseongkim
                                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 49ab10bd taeseongkim
                                        //RefID = document.DocID,
259 422f620d taeseongkim
                                        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 57ea162e yoush97
270
                                    document.ToCapture = ++toreview;
271 422f620d taeseongkim
                                }
272 43ceb5b3 taeseongkim
                                break;
273 b45e552e yoush97
                            case 25:
274 8eca8767 taeseongkim
                                document.FrReviewStatus = value;
275
                                break;
276 b45e552e yoush97
                            case 26:
277 8eca8767 taeseongkim
                                document.FrRemarks = value;
278
                                break;
279 b45e552e yoush97
                            case 27:
280 8eca8767 taeseongkim
                                document.FrCreator = this.GetUser(value).ID;
281
                                break;
282 b45e552e yoush97
                            case 28:
283 422f620d taeseongkim
                                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 49ab10bd taeseongkim
                                        //RefID = document.DocID,
294 422f620d taeseongkim
                                        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 57ea162e yoush97
305
                                    document.FrCapture = ++frreview;
306 422f620d taeseongkim
                                }
307
                                break;
308 b45e552e yoush97
                            case 29:
309 8eca8767 taeseongkim
                                document.ID2StartDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
310
                                break;
311 b45e552e yoush97
                            case 30:
312 8eca8767 taeseongkim
                                document.ID2EndDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
313
                                break;
314 b45e552e yoush97
                            case 31:
315 8eca8767 taeseongkim
                                document.ID2Status = value;
316
                                break;
317 b45e552e yoush97
                            case 32:
318 8eca8767 taeseongkim
                                document.ID2Issues = value;
319
                                break;
320 b45e552e yoush97
                            case 33:
321 4b9f349c yoush97
                                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 57ea162e yoush97
343
                                    document.ID2Capture = ++id2work;
344 4b9f349c yoush97
                                }
345 8eca8767 taeseongkim
                                break;
346 b45e552e yoush97
                            case 34:
347 7d73b57c yoush97
                                document.ReplyModifications = value;
348 8eca8767 taeseongkim
                                break;
349 b45e552e yoush97
                            case 35:
350 7d73b57c yoush97
                                document.ReplyRequester = this.GetUser(value).ID;
351 4b9f349c yoush97
                                break;
352 b45e552e yoush97
                            case 36:
353 7d73b57c yoush97
                                document.IsConvert = value;
354 4b9f349c yoush97
                                break;
355 b45e552e yoush97
                            case 37:
356 7d73b57c yoush97
                                document.AVEVAConvertDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
357 8eca8767 taeseongkim
                                break;
358 b45e552e yoush97
                            case 38:
359 7d73b57c yoush97
                                document.AVEVAWorkDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
360 8eca8767 taeseongkim
                                break;
361 b45e552e yoush97
                            case 39:
362 7d73b57c yoush97
                                document.AVEVAStatus = value;
363 8eca8767 taeseongkim
                                break;
364 b45e552e yoush97
                            case 40:
365 7d73b57c yoush97
                                document.AVEVAIssues = value;
366 8eca8767 taeseongkim
                                break;
367 b45e552e yoush97
                            case 41:
368 7d73b57c yoush97
                                document.AVEVAReviewDate = string.IsNullOrEmpty(value) ? (DateTime?)null : Convert.ToDateTime(value);
369 8eca8767 taeseongkim
                                break;
370 b45e552e yoush97
                            case 42:
371 7d73b57c yoush97
                                document.ProdReviewer = this.GetUser(value).ID;
372 8eca8767 taeseongkim
                                break;
373 b45e552e yoush97
                            case 43:
374 7d73b57c yoush97
                                document.ProdIsResult = value;
375 8eca8767 taeseongkim
                                break;
376 b45e552e yoush97
                            case 44:
377 7d73b57c yoush97
                                document.ProdRemarks = value;
378 8eca8767 taeseongkim
                                break;
379 b45e552e yoush97
                            case 45:
380 7d73b57c yoush97
                                document.ClientReviewer = this.GetUser(value).ID;
381 8eca8767 taeseongkim
                                break;
382 b45e552e yoush97
                            case 46:
383 7d73b57c yoush97
                                document.ClientIsResult = value;
384 8eca8767 taeseongkim
                                break;
385 b45e552e yoush97
                            case 47:
386 7d73b57c yoush97
                                document.ClientRemarks = value;
387 4b9f349c yoush97
                                break;
388 b45e552e yoush97
                            case 48:
389 7d73b57c yoush97
                                document.DTIsGateWay = value;
390 4b9f349c yoush97
                                break;
391 b45e552e yoush97
                            case 49:
392 7d73b57c yoush97
                                document.DTIsImport = value;
393 4b9f349c yoush97
                                break;
394 b45e552e yoush97
                            case 50:
395 7d73b57c yoush97
                                document.DTIsRegSystem = value;
396
                                break;
397 b45e552e yoush97
                            case 51:
398 8eca8767 taeseongkim
                                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 057ca09a taeseongkim
        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 ee0dfabe yoush97
                if (rowCount < 10 || columnCount != 51)
434 057ca09a taeseongkim
                {
435 ee0dfabe yoush97
                    result.Error = $"Please, check the excel.\n(rows:{rowCount}. cols:{columnCount})";
436 057ca09a taeseongkim
                    return result;
437
                }
438
439 28907ead yoush97
                #region 엑셀 필수값 체크(도면 : 이름, 담당자, 난이도, Typical) -> 추후 gembox사용시 변경필요
440 057ca09a taeseongkim
                ws.Rows.SelectMany(row => row.AllocatedCells)
441 d0a1d373 yoush97
                       .Where(col => col.Column.Index > 8 && col.Column.Index < 18 && col.Row.Index > exRow && col.Value == null)
442 057ca09a taeseongkim
                       .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 4b9f349c yoush97
                #region 엑셀 도면명 중복 값 체크
459 057ca09a taeseongkim
                ws.Rows.SelectMany(row => row.AllocatedCells)
460 d0a1d373 yoush97
                                             .Where(col => col.Column.Index == 12 && col.Row.Index > exRow)
461 057ca09a taeseongkim
                                             .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 d0a1d373 yoush97
                                                           .Aggregate((x, y) => x.ToString() + "," + y.ToString())
471
                                                           .ToString())
472
                                             .ToList()
473
                                             .ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
474 057ca09a taeseongkim
                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 be38bb2e yoush97
                               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 28907ead yoush97
                                   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 be38bb2e yoush97
                                   */
591 4b9f349c yoush97
592
                                   /*
593 057ca09a taeseongkim
                                   //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 d9949772 yoush97
                                   //IsTypical = ws.Rows[p.Index].Cells[9].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
605 057ca09a taeseongkim
                                   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 2aa2a446 yoush97
                                   //IsID2Work = ws.Rows[p.Index].Cells[21].IsNullOrEmpty() ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
617 057ca09a taeseongkim
                                   //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 ab3c1c74 yoush97
                                   //AVEVAWorkDate 추가필요
627 057ca09a taeseongkim
                                   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 4b9f349c yoush97
                                   */
640 be38bb2e yoush97
                               //});
641 d0a1d373 yoush97
                           }
642 057ca09a taeseongkim
                           catch (Exception ex)
643
                           {
644 d0a1d373 yoush97
                               throw new Exception($"Excel Import Row :{p.Index} Error.", ex);
645 057ca09a taeseongkim
                           }
646
                       });
647
648
            }
649
            catch (Exception)
650
            {
651
                throw;
652
            }
653
654
            return result;
655
        }
656
    }
657
}
클립보드 이미지 추가 (최대 크기: 500 MB)