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