hytos / ID2.Manager / ID2.Manager / Main.cs @ b254f8e9
이력 | 보기 | 이력해설 | 다운로드 (102 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Data; |
5 |
using System.Drawing; |
6 |
using System.Linq; |
7 |
using System.Text; |
8 |
using System.Threading.Tasks; |
9 |
using System.Windows.Forms; |
10 |
|
11 |
using System.IO; |
12 |
using System.Reflection; |
13 |
|
14 |
using ID2.Manager.Controls; |
15 |
using ID2.Manager.Common; |
16 |
using ID2.Manager.Classes; |
17 |
using ID2.Manager.Data.Models; |
18 |
using ID2.Manager.Forms; |
19 |
using ID2.Manager.Controller.Controllers; |
20 |
|
21 |
using Telerik.WinControls; |
22 |
using Telerik.WinControls.UI; |
23 |
using Telerik.WinControls.Data; |
24 |
|
25 |
using GemBox.Spreadsheet; |
26 |
|
27 |
using Newtonsoft.Json; |
28 |
using System.Diagnostics; |
29 |
using ID2.Manager.Common.Helpers; |
30 |
using Telerik.WinControls.UI.Docking; |
31 |
|
32 |
namespace ID2.Manager |
33 |
{ |
34 |
public partial class Main : RadRibbonForm |
35 |
{ |
36 |
protected override CreateParams CreateParams |
37 |
{ |
38 |
get |
39 |
{ |
40 |
CreateParams cp = base.CreateParams; |
41 |
cp.ExStyle |= 0x02000000; |
42 |
return cp; |
43 |
} |
44 |
} |
45 |
|
46 |
private string dockLayoutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName, |
47 |
"dock.xml"); |
48 |
|
49 |
readonly Informations informations = Informations.Instance; |
50 |
bool IsID2Manager = false; |
51 |
List<Documents> documents = new List<Documents>(); |
52 |
List<System.Drawing.Image> importImages = new List<System.Drawing.Image>(); |
53 |
|
54 |
List<Documents> orgDocuments = null; |
55 |
int TotalCount = 0; |
56 |
|
57 |
BriefAndImages briefAndImagesReview = new BriefAndImages { Dock = DockStyle.Fill }; |
58 |
BriefAndImages briefAndImagesValidation = new BriefAndImages { Dock = DockStyle.Fill }; |
59 |
|
60 |
#if DEBUG |
61 |
Telerik.WinControls.RadControlSpy.RadControlSpyForm radControlSpyForm = new Telerik.WinControls.RadControlSpy.RadControlSpyForm(); |
62 |
#endif |
63 |
private readonly Color _SummaryColor = Color.FromArgb(255, 108, 55); |
64 |
|
65 |
public Main() |
66 |
{ |
67 |
InitializeComponent(); |
68 |
this.LayoutValidation.Controls.Add(new Controls.Verification() { Dock = DockStyle.Fill }); |
69 |
this.DockMainTabStrip.Select(); |
70 |
|
71 |
var appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName); |
72 |
|
73 |
if(!Directory.Exists(appDataPath)) |
74 |
{ |
75 |
Directory.CreateDirectory(appDataPath); |
76 |
} |
77 |
|
78 |
ID2.Manager.Common.Helpers.TableLayoutPanelHelper.SetDoubleBuffered(this); |
79 |
|
80 |
this.FormClosing += Main_FormClosing; |
81 |
this.radButtonElementRefreshCommand.Click += RadButtonElementRefreshCommand_Click; |
82 |
this.radButtonElementSaveCommand.Click += RadButtonElementSaveCommand_Click; |
83 |
this.btnDockLayoutReset.Click += BtnDockLayoutReset_Click; |
84 |
this.radButtonElementSave.Click += RadButtonElementSave_Click; |
85 |
this.radButtonElementSync.Click += RadButtonElementSync_Click; |
86 |
this.radButtonElementNotice.Click += RadButtonElementNotice_Click; |
87 |
this.radButtonElementNoticeUpload.Click += RadButtonElementNoticeUpload_Click; |
88 |
this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click; |
89 |
this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click; |
90 |
|
91 |
this.radCheckBox1.CheckStateChanged += RadCheckBox_CheckStateChanged; |
92 |
this.radCheckBox2.CheckStateChanged += RadCheckBox_CheckStateChanged; |
93 |
this.radCheckBox3.CheckStateChanged += RadCheckBox_CheckStateChanged; |
94 |
this.radCheckBox4.CheckStateChanged += RadCheckBox_CheckStateChanged; |
95 |
this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown; |
96 |
this.radButtonSearch.Click += RadButtonSearch_Click; |
97 |
|
98 |
this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged; |
99 |
this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting; |
100 |
this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo; |
101 |
this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit; |
102 |
this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick; |
103 |
this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged; |
104 |
this.radGridViewDocuments.FilterChanged += RadGridViewDocuments_FilterChanged; |
105 |
|
106 |
this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36; |
107 |
this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36; |
108 |
//this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ; |
109 |
this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false; |
110 |
|
111 |
var openProjectView = new OpenProjectView() |
112 |
{ |
113 |
Dock = DockStyle.Fill |
114 |
}; |
115 |
|
116 |
this.backstageViewPageOpenProject.Controls.Add(openProjectView); |
117 |
openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick; |
118 |
openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick; |
119 |
this.backstageButtonItemSelectDB.Click += BackstageButtonItemSelectDB_Click; |
120 |
this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click; |
121 |
this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click; |
122 |
this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened; |
123 |
this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed; |
124 |
|
125 |
this.InitColumnGroupsViewDefinition(this.radGridViewDocuments); |
126 |
|
127 |
this.radPageViewPageReview.Controls.Add(briefAndImagesReview); |
128 |
this.radPageViewPageValidation.Controls.Add(briefAndImagesValidation); |
129 |
|
130 |
briefAndImagesReview.RemoveImage += BriefAndImages_RemoveImage; |
131 |
briefAndImagesValidation.RemoveImage += BriefAndImages_RemoveImage; |
132 |
this.Initialize(); |
133 |
} |
134 |
|
135 |
private void BtnDockLayoutReset_Click(object sender, EventArgs e) |
136 |
{ |
137 |
this.LoadDockingLayout(true); |
138 |
} |
139 |
|
140 |
private void BriefAndImages_RemoveImage(object sender, AttImageInfo e) |
141 |
{ |
142 |
try |
143 |
{ |
144 |
|
145 |
if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc) |
146 |
{ |
147 |
var reslut = doc.AttFiles.RemoveAll(x => x.FileID == e.ID); |
148 |
|
149 |
if (reslut > 0) |
150 |
{ |
151 |
|
152 |
} |
153 |
else |
154 |
{ |
155 |
MessageBox.Show("삭제오류"); |
156 |
} |
157 |
} |
158 |
} |
159 |
catch (Exception ex) |
160 |
{ |
161 |
Program.logger.Error("BriefAndImages_RemoveImage",ex); |
162 |
} |
163 |
} |
164 |
|
165 |
private void SaveDockingLayout() |
166 |
{ |
167 |
try |
168 |
{ |
169 |
this.DockMain.SaveToXml(dockLayoutPath); |
170 |
} |
171 |
catch (Exception ex) |
172 |
{ |
173 |
System.Diagnostics.Debug.WriteLine("SaveDockingLayout Error.", ex); |
174 |
} |
175 |
} |
176 |
|
177 |
private void LoadDockingLayout(bool IsDefaultLayoutLoad = false) |
178 |
{ |
179 |
try |
180 |
{ |
181 |
bool IsUseLayoutLoad = false; |
182 |
|
183 |
try |
184 |
{ |
185 |
var dockLayoutFile = new FileInfo(dockLayoutPath); |
186 |
|
187 |
|
188 |
if (!IsDefaultLayoutLoad && dockLayoutFile.Exists) |
189 |
{ |
190 |
this.DockMain.LoadFromXml(dockLayoutPath); |
191 |
IsUseLayoutLoad = true; |
192 |
} |
193 |
|
194 |
} |
195 |
catch (Exception ex) |
196 |
{ |
197 |
Program.logger.Error($"dock Layout File load Error. File Path : {dockLayoutPath}", ex); |
198 |
} |
199 |
|
200 |
if(!IsUseLayoutLoad) |
201 |
{ |
202 |
var layout = Properties.Resources.DefalutDockLayout; |
203 |
|
204 |
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(layout))) |
205 |
{ |
206 |
this.DockMain.LoadFromXml(stream); |
207 |
} |
208 |
} |
209 |
|
210 |
this.DockMain.DocumentTabsVisible = true; |
211 |
|
212 |
this.DockMain.DockWindows.ForAll(x => |
213 |
{ |
214 |
x.DockManager.ShowDocumentPinButton = false; |
215 |
x.DockManager.ShowDocumentCloseButton = false; |
216 |
}); |
217 |
|
218 |
this.DockMain.AutoHideWindowDisplaying += DockMain_AutoHideWindowDisplaying; |
219 |
|
220 |
this.DockMain.DockStateChanged+=(snd,evt)=> |
221 |
{ |
222 |
if (evt.DockWindow.Name == DockWindowMain.Name || evt.DockWindow.Name == DockValidation.Name) |
223 |
{ |
224 |
|
225 |
} |
226 |
|
227 |
}; |
228 |
|
229 |
this.DockMain.DockWindowClosed += (snd, evt) => |
230 |
{ |
231 |
evt.DockWindow.DockState = Telerik.WinControls.UI.Docking.DockState.AutoHide; |
232 |
|
233 |
//Telerik.WinControls.UI.Docking.AutoHidePosition tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Right; |
234 |
|
235 |
|
236 |
//List<DockWindow> dockWindows = new List<DockWindow>(); |
237 |
|
238 |
//var autoHideWindows = this.DockMain.DockWindows.Where(x => x.DockState == Telerik.WinControls.UI.Docking.DockState.AutoHide).ToList(); |
239 |
|
240 |
|
241 |
//if (evt.DockWindow.AccessibleName == DockWindowMain.AccessibleName || evt.DockWindow.Name == DockValidation.AccessibleName) |
242 |
//{ |
243 |
// dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName == DockWindowMain.AccessibleName && evt.DockWindow.Name == DockValidation.AccessibleName)); |
244 |
|
245 |
// tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Bottom; |
246 |
|
247 |
// dockWindows.Add(evt.DockWindow); |
248 |
//} |
249 |
//else |
250 |
//{ |
251 |
// dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName != DockWindowMain.AccessibleName || evt.DockWindow.Name != DockValidation.AccessibleName)); |
252 |
|
253 |
// dockWindows.Add(evt.DockWindow); |
254 |
//} |
255 |
|
256 |
|
257 |
//this.DockMain.AutoHideWindows(dockWindows, tabPosition); |
258 |
}; |
259 |
} |
260 |
catch (Exception ex) |
261 |
{ |
262 |
Program.logger.Error($"dock Layout load Error. File Path : {dockLayoutPath}", ex); |
263 |
} |
264 |
} |
265 |
|
266 |
private void DockMain_AutoHideWindowDisplaying(object sender, Telerik.WinControls.UI.Docking.AutoHideWindowDisplayingEventArgs e) |
267 |
{ |
268 |
|
269 |
} |
270 |
|
271 |
private void Main_FormClosing(object sender, FormClosingEventArgs e) |
272 |
{ |
273 |
SaveDockingLayout(); |
274 |
} |
275 |
|
276 |
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) |
277 |
{ |
278 |
if (keyData == (Keys.F10 | Keys.Control)) |
279 |
{ |
280 |
#if DEBUG |
281 |
radControlSpyForm.Show(); |
282 |
#endif |
283 |
} |
284 |
|
285 |
if (keyData == (Keys.V | Keys.Control)) |
286 |
{ |
287 |
System.Diagnostics.Debug.WriteLine("KeyDown CTRL + V"); |
288 |
|
289 |
if(Clipboard.ContainsImage()) |
290 |
{ |
291 |
var IsDoftech = true; |
292 |
var selectReview = true; |
293 |
string category = ""; |
294 |
byte[] imageBytes = null; |
295 |
|
296 |
Image clipboardImage = Clipboard.GetImage(); |
297 |
|
298 |
using (MemoryStream stream = new MemoryStream()) |
299 |
{ |
300 |
clipboardImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png); |
301 |
imageBytes = stream.ToArray(); |
302 |
} |
303 |
|
304 |
if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc) |
305 |
{ |
306 |
|
307 |
/// 도프텍 or 삼성 |
308 |
if (!string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
309 |
{ |
310 |
IsDoftech = false; |
311 |
} |
312 |
|
313 |
/// 검토 or 검증 |
314 |
if (radPageViewComment.SelectedPage != radPageViewPageReview) |
315 |
{ |
316 |
selectReview = false; |
317 |
} |
318 |
|
319 |
if (IsDoftech && selectReview) |
320 |
{ |
321 |
category = "toreview"; |
322 |
} |
323 |
else if (!IsDoftech && selectReview) |
324 |
{ |
325 |
category = "frreview"; |
326 |
} |
327 |
else if (IsDoftech && !selectReview) |
328 |
{ |
329 |
category = "prodvalidation"; |
330 |
} |
331 |
else |
332 |
{ |
333 |
category = "clientvalidation"; |
334 |
} |
335 |
|
336 |
|
337 |
AttFileInfo newFile = new AttFileInfo |
338 |
{ |
339 |
FileID = Guid.NewGuid().ToString(), |
340 |
Category = category, |
341 |
FileType = "image/png", |
342 |
FileName = "ClipBoard", |
343 |
FilePath = "ClipBoard", |
344 |
FileExtension = ".png", |
345 |
CreatedDate = DateTime.Now, |
346 |
Creator = informations.ActiveUser.ID, |
347 |
FileData = imageBytes |
348 |
|
349 |
}; |
350 |
|
351 |
if (doc.AttFiles == null) |
352 |
{ |
353 |
doc.AttFiles = new List<AttFileInfo>(); |
354 |
} |
355 |
|
356 |
doc.AttFiles.Add(newFile); |
357 |
|
358 |
var imageInfo = new AttImageInfo { ID = newFile.FileID, Data = newFile.FileData }; |
359 |
|
360 |
switch (category) |
361 |
{ |
362 |
case "toreview": |
363 |
briefAndImagesReview.AddToImage(imageInfo, true); |
364 |
break; |
365 |
case "frreview": |
366 |
briefAndImagesReview.AddFrImage(imageInfo, true); |
367 |
break; |
368 |
case "prodvalidation": |
369 |
briefAndImagesValidation.AddToImage(imageInfo, true); |
370 |
break; |
371 |
case "clientvalidation": |
372 |
briefAndImagesValidation.AddFrImage(imageInfo, true); |
373 |
break; |
374 |
} |
375 |
} |
376 |
} |
377 |
} |
378 |
|
379 |
return base.ProcessCmdKey(ref msg, keyData); |
380 |
} |
381 |
|
382 |
private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e) |
383 |
{ |
384 |
if (e.RowInfo is GridViewSearchRowInfo) |
385 |
{ |
386 |
e.RowInfo = new SearchRow(e.ViewInfo); |
387 |
} |
388 |
|
389 |
System.Diagnostics.Debug.WriteLine(e.RowInfo.GetType().Name); |
390 |
} |
391 |
|
392 |
private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e) |
393 |
{ |
394 |
if (e.SearchFinished) |
395 |
{ |
396 |
|
397 |
} |
398 |
} |
399 |
|
400 |
/// <summary> |
401 |
/// 선택된 행의 AutoCAD와 PDF 파일을 보여준다. |
402 |
/// </summary> |
403 |
/// <param name="sender"></param> |
404 |
/// <param name="e"></param> |
405 |
private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e) |
406 |
{ |
407 |
if (this.radGridViewDocuments.SelectedRows.Any() && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc) |
408 |
{ |
409 |
//if (informations.ActiveUser.ID != doc.PersonInCharge) |
410 |
//{ |
411 |
// var row = this.radGridViewDocuments.SelectedRows.First(); |
412 |
// foreach(var cell in row.Cells) |
413 |
// { |
414 |
// cell.ReadOnly = true; |
415 |
// } |
416 |
//} |
417 |
|
418 |
briefAndImagesReview.Clear(); |
419 |
briefAndImagesValidation.Clear(); |
420 |
|
421 |
//FrRemarks 추가 |
422 |
|
423 |
briefAndImagesReview.DataBindings.Add(new Binding("BriefDoftech", doc, "ToRemarks", false, DataSourceUpdateMode.OnValidation, null)); |
424 |
///briefAndImagesReview.DataBindings.Add(new Binding("BriefSec", doc, "ToRemarks", false, DataSourceUpdateMode.OnValidation, null)); |
425 |
|
426 |
briefAndImagesValidation.DataBindings.Add(new Binding("BriefDoftech", doc, "ClientRemarks", false,DataSourceUpdateMode.OnValidation,null)); |
427 |
|
428 |
if (doc.AttFiles != null) |
429 |
{ |
430 |
if (doc.AttFiles.Count(x => x.Category == "toreview") > 0) |
431 |
{ |
432 |
var images = doc.AttFiles.Where(x => x.Category == "toreview").Select(x =>new AttImageInfo { ID = x.FileID, Data = x.FileData }); |
433 |
briefAndImagesReview.SetToImages(images.ToList()); |
434 |
} |
435 |
|
436 |
if (doc.AttFiles.Count(x => x.Category == "frreview") > 0) |
437 |
{ |
438 |
var images = doc.AttFiles.Where(x => x.Category == "frreview").Select(x => new AttImageInfo { ID = x.FileID, Data = x.FileData }); |
439 |
briefAndImagesReview.SetFrImages(images.ToList()); |
440 |
} |
441 |
|
442 |
if (doc.AttFiles.Count(x => x.Category == "prodvalidation") > 0) |
443 |
{ |
444 |
var images = doc.AttFiles.Where(x => x.Category == "prodvalidation").Select(x => new AttImageInfo { ID = x.FileID, Data = x.FileData }); |
445 |
briefAndImagesValidation.SetToImages(images.ToList()); |
446 |
} |
447 |
|
448 |
if (doc.AttFiles.Count(x => x.Category == "clientvalidation") > 0) |
449 |
{ |
450 |
var images = doc.AttFiles.Where(x => x.Category == "clientvalidation").Select(x => new AttImageInfo { ID = x.FileID, Data = x.FileData }); |
451 |
briefAndImagesValidation.SetFrImages(images.ToList()); |
452 |
} |
453 |
} |
454 |
} |
455 |
} |
456 |
|
457 |
#region Init, Load |
458 |
private void Initialize() |
459 |
{ |
460 |
this.Text = Globals.Name; |
461 |
|
462 |
this.ID2ManagerRadRibbonBar.Expanded = false; |
463 |
|
464 |
this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}"; |
465 |
} |
466 |
|
467 |
protected override void OnLoad(EventArgs e) |
468 |
{ |
469 |
try |
470 |
{ |
471 |
LoadDockingLayout(); |
472 |
InitializeGrid(); |
473 |
|
474 |
bool isID2 = this.IsID2Connection(); |
475 |
this.SetMenus(isID2); |
476 |
|
477 |
if (isID2) |
478 |
{ |
479 |
if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
480 |
{ |
481 |
informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID); |
482 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
483 |
|
484 |
this.LoadProject(); |
485 |
} |
486 |
else |
487 |
{ |
488 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
489 |
|
490 |
foreach (Control ctrl in this.backstageViewPageOpenProject.Controls) |
491 |
{ |
492 |
if (ctrl is OpenProjectView) |
493 |
{ |
494 |
var openProjectView = ctrl as OpenProjectView; |
495 |
openProjectView.GetProjectGroups(); |
496 |
break; |
497 |
} |
498 |
} |
499 |
|
500 |
this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement); |
501 |
} |
502 |
} |
503 |
else |
504 |
{ |
505 |
this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement); |
506 |
RadMessageBox.Show(this, $"Please select db file.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info); |
507 |
} |
508 |
} |
509 |
catch (Exception ex) |
510 |
{ |
511 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
512 |
RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
513 |
} |
514 |
|
515 |
base.OnLoad(e); |
516 |
} |
517 |
|
518 |
private bool IsID2Connection() |
519 |
{ |
520 |
bool isSuccess = false; |
521 |
|
522 |
isSuccess = Globals.IsProjectDBConnstr(); |
523 |
try |
524 |
{ |
525 |
var id2Project = new ID2Controller().GetID2ProjectList(); |
526 |
} |
527 |
catch |
528 |
{ |
529 |
isSuccess = false; |
530 |
} |
531 |
|
532 |
return isSuccess; |
533 |
} |
534 |
|
535 |
private void SetMenus(bool isid2) |
536 |
{ |
537 |
if (isid2) |
538 |
{ |
539 |
this.IsID2Manager = (new string[] { "Admin", "Manager" }).Contains(informations.ActiveUser.Role) && string.IsNullOrEmpty(informations.ActiveUser.RefProjectID); |
540 |
|
541 |
if (this.IsID2Manager) |
542 |
{ |
543 |
this.radButtonElementNoticeUpload.Enabled = true; |
544 |
|
545 |
this.backstageViewPageOpenProject.Controls[0].Visible = true; |
546 |
this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible; |
547 |
this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible; |
548 |
} |
549 |
else |
550 |
{ |
551 |
this.radButtonElementNoticeUpload.Enabled = false; |
552 |
|
553 |
if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
554 |
{ |
555 |
this.backstageViewPageOpenProject.Controls[0].Visible = true; |
556 |
} |
557 |
else |
558 |
{ |
559 |
foreach (Control ctrl in this.backstageViewPageOpenProject.Controls) |
560 |
{ |
561 |
ctrl.Visible = false; |
562 |
} |
563 |
} |
564 |
this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed; |
565 |
this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed; |
566 |
} |
567 |
} |
568 |
else |
569 |
{ |
570 |
this.radButtonElementNoticeUpload.Enabled = false; |
571 |
|
572 |
this.backstageButtonItemSelectDB.Visibility = ElementVisibility.Visible; |
573 |
foreach (Control ctrl in this.backstageViewPageOpenProject.Controls) |
574 |
{ |
575 |
ctrl.Visible = false; |
576 |
} |
577 |
this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed; |
578 |
this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed; |
579 |
} |
580 |
} |
581 |
|
582 |
public Point GetBackstageLocation() |
583 |
{ |
584 |
Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location; |
585 |
location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height)); |
586 |
location.Offset(this.ID2ManagerRadRibbonBar.Location); |
587 |
|
588 |
return location; |
589 |
} |
590 |
|
591 |
private void InitializeGrid() |
592 |
{ |
593 |
InitializeSearch(); |
594 |
InitializeGridViewDetail(); |
595 |
|
596 |
//this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents); |
597 |
} |
598 |
|
599 |
private void InitializeSearch() |
600 |
{ |
601 |
var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI"); |
602 |
|
603 |
lbSearch.Text = "\ue13E"; |
604 |
btnSearchNext.Text = "\ue006"; |
605 |
btnSearchPrevious.Text = "\ue004"; |
606 |
|
607 |
var chkbox = new RadCheckBoxElement(); |
608 |
chkbox.Text = "Match Case"; |
609 |
chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; }; |
610 |
|
611 |
btnMatchCase.HostedItem = chkbox; |
612 |
|
613 |
var chkbox1 = new RadCheckBoxElement(); |
614 |
chkbox1.Text = "Show All Detail"; |
615 |
chkbox1.CheckStateChanged += (snd, evt) => |
616 |
{ |
617 |
radGridViewDocuments.MasterView.ChildRows.ForAll(x=>x.IsExpanded = chkbox1.Checked); |
618 |
}; |
619 |
|
620 |
btnShowAllDetail.HostedItem = chkbox1; |
621 |
|
622 |
var chkbox2 = new RadCheckBoxElement(); |
623 |
chkbox2.Text = "Search from current position"; |
624 |
chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; }; |
625 |
|
626 |
btnSearchFormCurrent.HostedItem = chkbox2; |
627 |
|
628 |
var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x => |
629 |
new FilterColumn |
630 |
{ |
631 |
Name = x.HeaderText, |
632 |
FieldName = x.FieldName, |
633 |
IsSelect = x.AllowSearching |
634 |
}); |
635 |
|
636 |
var panel = new StackLayoutElement(); |
637 |
panel.Orientation = Orientation.Vertical; |
638 |
|
639 |
var btnComboColumns = new RadCheckedDropDownListElement(); |
640 |
btnComboColumns.ShowCheckAllItems = true; |
641 |
btnComboColumns.CheckAllItem.Checked = true; |
642 |
btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns"; |
643 |
btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true; |
644 |
btnComboColumns.DropDownMinSize = new Size(200, 200); |
645 |
btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom; |
646 |
btnComboColumns.DisplayMember = "Name"; |
647 |
btnComboColumns.CheckedMember = "IsSelect"; |
648 |
btnComboColumns.ValueMember = "FieldName"; |
649 |
btnComboColumns.TextBox.CustomFont = font1.Name; |
650 |
btnComboColumns.TextBox.Text = "\ue13A"; |
651 |
|
652 |
btnComboColumns.DataSource = columns; |
653 |
|
654 |
txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) => |
655 |
{ |
656 |
radGridViewDocuments.MasterTemplate.Refresh(null); |
657 |
}; |
658 |
|
659 |
btnComboColumns.PopupOpening += (snd, evt) => |
660 |
{ |
661 |
(snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect); |
662 |
}; |
663 |
|
664 |
btnComboColumns.PopupClosed += (snd, evt) => |
665 |
{ |
666 |
foreach (RadCheckedListDataItem item in btnComboColumns.Items) |
667 |
{ |
668 |
if (radGridViewDocuments.Columns[item.Value.ToString()] != null) |
669 |
{ |
670 |
radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked; |
671 |
} |
672 |
} |
673 |
}; |
674 |
|
675 |
btnFilters.HostedItem = btnComboColumns; |
676 |
} |
677 |
|
678 |
private void InitializeGridViewDetail() |
679 |
{ |
680 |
DetailGridViewTemplate markupList = new DetailGridViewTemplate(); |
681 |
|
682 |
markupList.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None; |
683 |
|
684 |
GridViewTextBoxColumn userColumn = new GridViewTextBoxColumn("CREATE_USER"); |
685 |
GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("TEXT"); |
686 |
|
687 |
userColumn.AutoSizeMode = BestFitColumnMode.AllCells; |
688 |
textColumn.AutoSizeMode = BestFitColumnMode.AllCells; |
689 |
|
690 |
markupList.Columns.AddRange(userColumn, textColumn); |
691 |
this.radGridViewDocuments.MasterTemplate.Templates.Add(markupList); |
692 |
markupList.HierarchyDataProvider = new GridViewEventDataProvider(markupList); |
693 |
|
694 |
this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded; |
695 |
this.radGridViewDocuments.RowSourceNeeded += RadGridViewDocuments_RowSourceNeeded; |
696 |
} |
697 |
|
698 |
private void RadGridViewDocuments_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e) |
699 |
{ |
700 |
if (e.Template.HierarchyLevel == 1) |
701 |
{ |
702 |
if (e.ParentRow.DataBoundItem is Documents documents) |
703 |
{ |
704 |
if (documents.Markups != null) |
705 |
{ |
706 |
foreach (var makrup in documents.Markups) |
707 |
{ |
708 |
GridViewRowInfo row = e.Template.Rows.NewRow(); |
709 |
|
710 |
row.Cells["CREATE_USER"].Value = makrup.CREATE_USER; |
711 |
row.Cells["TEXT"].Value = makrup.TEXT; |
712 |
e.SourceCollection.Add(row); |
713 |
} |
714 |
|
715 |
e.Template.BestFitColumns(); |
716 |
} |
717 |
} |
718 |
} |
719 |
} |
720 |
|
721 |
private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e) |
722 |
{ |
723 |
} |
724 |
|
725 |
#endregion |
726 |
|
727 |
private void OpenProjectView_OpenProjectClick(object sender, EventArgs e) |
728 |
{ |
729 |
this.radRibbonBarBackstageViewID2Manager.Tag = e; |
730 |
this.radRibbonBarBackstageViewID2Manager.HidePopup(); |
731 |
} |
732 |
|
733 |
private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e) |
734 |
{ |
735 |
this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject; |
736 |
|
737 |
foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls) |
738 |
{ |
739 |
if (ctrl is OpenProjectView) |
740 |
{ |
741 |
var openProjectView = ctrl as OpenProjectView; |
742 |
openProjectView.GetProjectGroups(); |
743 |
break; |
744 |
} |
745 |
} |
746 |
} |
747 |
|
748 |
private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e) |
749 |
{ |
750 |
try |
751 |
{ |
752 |
if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs) |
753 |
{ |
754 |
var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs; |
755 |
|
756 |
informations.ActiveProject = prjArgs.ProjectInfo; |
757 |
|
758 |
this.radRibbonBarBackstageViewID2Manager.Tag = null; |
759 |
|
760 |
this.LoadProject(); |
761 |
} |
762 |
} |
763 |
catch (Exception ex) |
764 |
{ |
765 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
766 |
RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
767 |
} |
768 |
} |
769 |
|
770 |
private void LoadProject() |
771 |
{ |
772 |
try |
773 |
{ |
774 |
#region 도면 |
775 |
//Project List |
776 |
if (this.radDropDownListProject.Items.Count > 0) |
777 |
this.radDropDownListProject.Items.Clear(); |
778 |
informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList() |
779 |
.ForEach(x => |
780 |
{ |
781 |
this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code)); |
782 |
}); |
783 |
var allProject = new RadListDataItem("== 전체 ==", string.Empty); |
784 |
this.radDropDownListProject.Items.Insert(0, allProject); |
785 |
allProject.Selected = true; |
786 |
|
787 |
//담당자 List |
788 |
if (this.radDropDownListPersonInCharge.Items.Count > 0) |
789 |
this.radDropDownListPersonInCharge.Items.Clear(); |
790 |
informations.UserList.ForEach(x => |
791 |
{ |
792 |
if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID)) |
793 |
this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID)); |
794 |
}); |
795 |
var allUser = new RadListDataItem("== 전체 ==", string.Empty); |
796 |
this.radDropDownListPersonInCharge.Items.Insert(0, allUser); |
797 |
allUser.Selected = true; |
798 |
|
799 |
//난이도 |
800 |
if (this.radDropDownListJobLevel.Items.Count > 0) |
801 |
this.radDropDownListJobLevel.Items.Clear(); |
802 |
informations.JobLevel.ForEach(x => |
803 |
{ |
804 |
this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x)); |
805 |
}); |
806 |
var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty); |
807 |
this.radDropDownListJobLevel.Items.Insert(0, allJobLevel); |
808 |
allJobLevel.Selected = true; |
809 |
|
810 |
//도면번호 조회조건 |
811 |
this.radTextBoxDocumentNo.Text = string.Empty; |
812 |
#endregion |
813 |
|
814 |
#region 검토 |
815 |
//문의(DOF) |
816 |
if (this.radDropDownListToIsDiscussion.Items.Count > 0) |
817 |
this.radDropDownListToIsDiscussion.Items.Clear(); |
818 |
informations.IsYesNo.ForEach(x => |
819 |
{ |
820 |
this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x)); |
821 |
}); |
822 |
var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty); |
823 |
this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion); |
824 |
allToIsDiscussion.Selected = true; |
825 |
|
826 |
//회신(DS) |
827 |
if (this.radDropDownListFrReviewStatus.Items.Count > 0) |
828 |
this.radDropDownListFrReviewStatus.Items.Clear(); |
829 |
informations.ClientStatus.ForEach(x => |
830 |
{ |
831 |
this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x)); |
832 |
}); |
833 |
var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty); |
834 |
this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus); |
835 |
allFrReviewStatus.Selected = true; |
836 |
|
837 |
//ID2 작업가능 |
838 |
if (this.radDropDownListIsID2Work.Items.Count > 0) |
839 |
this.radDropDownListIsID2Work.Items.Clear(); |
840 |
informations.IsYesNo.ForEach(x => |
841 |
{ |
842 |
var item = new RadListDataItem(x, x); |
843 |
if (x.Equals("Yes")) |
844 |
item.Selected = true; |
845 |
this.radDropDownListIsID2Work.Items.Add(item); |
846 |
|
847 |
}); |
848 |
var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty); |
849 |
this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work); |
850 |
#endregion |
851 |
|
852 |
#region 작업 |
853 |
//ID2 Status |
854 |
if (this.radDropDownListID2Status.Items.Count > 0) |
855 |
this.radDropDownListID2Status.Items.Clear(); |
856 |
informations.JobStatus.ForEach(x => |
857 |
{ |
858 |
this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x)); |
859 |
}); |
860 |
var allID2Status = new RadListDataItem("== 전체 ==", string.Empty); |
861 |
this.radDropDownListID2Status.Items.Insert(0, allID2Status); |
862 |
allID2Status.Selected = true; |
863 |
|
864 |
//AVEVA Status |
865 |
if (this.radDropDownListAVEVAStatus.Items.Count > 0) |
866 |
this.radDropDownListAVEVAStatus.Items.Clear(); |
867 |
informations.JobStatus.ForEach(x => |
868 |
{ |
869 |
this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x)); |
870 |
}); |
871 |
var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty); |
872 |
this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus); |
873 |
allAVEVAStatus.Selected = true; |
874 |
#endregion |
875 |
|
876 |
#region 검수 |
877 |
//도프텍 결과 |
878 |
if (this.radDropDownListProdIsResult.Items.Count > 0) |
879 |
this.radDropDownListProdIsResult.Items.Clear(); |
880 |
informations.ValidationResult.ForEach(x => |
881 |
{ |
882 |
this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x)); |
883 |
}); |
884 |
var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty); |
885 |
this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult); |
886 |
allProdIsResult.Selected = true; |
887 |
|
888 |
//삼성 결과 |
889 |
if (this.radDropDownListClientIsResult.Items.Count > 0) |
890 |
this.radDropDownListClientIsResult.Items.Clear(); |
891 |
informations.ValidationResult.ForEach(x => |
892 |
{ |
893 |
this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x)); |
894 |
}); |
895 |
var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty); |
896 |
this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult); |
897 |
allClientIsResult.Selected = true; |
898 |
#endregion |
899 |
|
900 |
#region AVEVA |
901 |
//Gateway |
902 |
if (this.radDropDownListGateway.Items.Count > 0) |
903 |
this.radDropDownListGateway.Items.Clear(); |
904 |
informations.IsSuccess.ForEach(x => |
905 |
{ |
906 |
this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x)); |
907 |
}); |
908 |
var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty); |
909 |
this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay); |
910 |
allDTIsGateWay.Selected = true; |
911 |
|
912 |
//Registration |
913 |
if (this.radDropDownListRegistration.Items.Count > 0) |
914 |
this.radDropDownListRegistration.Items.Clear(); |
915 |
informations.IsSuccess.ForEach(x => |
916 |
{ |
917 |
this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x)); |
918 |
}); |
919 |
var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty); |
920 |
this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem); |
921 |
allDTIsRegSystem.Selected = true; |
922 |
#endregion |
923 |
|
924 |
this.GetDocList(); |
925 |
} |
926 |
catch (Exception ex) |
927 |
{ |
928 |
throw ex; |
929 |
} |
930 |
finally |
931 |
{ |
932 |
|
933 |
this.Cursor = Cursors.Default; |
934 |
|
935 |
} |
936 |
|
937 |
} |
938 |
|
939 |
#region Document List 조회 |
940 |
public void GetDocList() |
941 |
{ |
942 |
try |
943 |
{ |
944 |
if (this.radDropDownListProject.SelectedValue != null) |
945 |
{ |
946 |
string projectCode = this.radDropDownListProject.SelectedValue.ToString(); |
947 |
string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString(); |
948 |
string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString(); |
949 |
string documentNo = this.radTextBoxDocumentNo.Text.Trim(); |
950 |
|
951 |
string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString(); |
952 |
string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString(); |
953 |
string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString(); |
954 |
|
955 |
string id2Status = this.radDropDownListID2Status.SelectedValue.ToString(); |
956 |
string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString(); |
957 |
|
958 |
string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString(); |
959 |
string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString(); |
960 |
|
961 |
string isGateWay = this.radDropDownListGateway.SelectedValue.ToString(); |
962 |
string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString(); |
963 |
|
964 |
var worker = new LoadDocumentsWorker(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments); |
965 |
worker.OnWorkCompletedHandler += (e) => |
966 |
{ |
967 |
var docData = e.Result as DocumentsResult; |
968 |
|
969 |
this.documents = docData.Dwgs; |
970 |
this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs)); |
971 |
this.TotalCount = docData.TotalCount; |
972 |
|
973 |
List<string> projectCodes = new List<string>(); |
974 |
|
975 |
if (!string.IsNullOrWhiteSpace(projectCode)) |
976 |
{ |
977 |
projectCodes.Add(projectCode); |
978 |
} |
979 |
else |
980 |
{ |
981 |
projectCodes = informations.ProjectList.Select(x => x.Code).ToList(); |
982 |
} |
983 |
|
984 |
this.DocumentListBinding(); |
985 |
}; |
986 |
worker.StartWork(); |
987 |
} |
988 |
} |
989 |
catch (Exception ex) |
990 |
{ |
991 |
throw ex; |
992 |
} |
993 |
} |
994 |
|
995 |
public void DocumentListBinding() |
996 |
{ |
997 |
try |
998 |
{ |
999 |
GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn; |
1000 |
ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList(); |
1001 |
ColProjects.DisplayMember = "Name"; |
1002 |
ColProjects.ValueMember = "Code"; |
1003 |
|
1004 |
var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID)); |
1005 |
var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID)); |
1006 |
|
1007 |
GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn; |
1008 |
ColPersonInCharge.DataSource = workUsers; |
1009 |
ColPersonInCharge.DisplayMember = "Name"; |
1010 |
ColPersonInCharge.ValueMember = "ID"; |
1011 |
|
1012 |
GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn; |
1013 |
ColWorker.DataSource = workUsers; |
1014 |
ColWorker.DisplayMember = "Name"; |
1015 |
ColWorker.ValueMember = "ID"; |
1016 |
|
1017 |
GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn; |
1018 |
ColToCreator.DataSource = workUsers; |
1019 |
ColToCreator.DisplayMember = "Name"; |
1020 |
ColToCreator.ValueMember = "ID"; |
1021 |
|
1022 |
GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn; |
1023 |
ColFrCreator.DataSource = clientUsers; |
1024 |
ColFrCreator.DisplayMember = "Name"; |
1025 |
ColFrCreator.ValueMember = "ID"; |
1026 |
|
1027 |
GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn; |
1028 |
ColProdReviewer.DataSource = workUsers; |
1029 |
ColProdReviewer.DisplayMember = "Name"; |
1030 |
ColProdReviewer.ValueMember = "ID"; |
1031 |
|
1032 |
GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn; |
1033 |
ColClientReviewer.DataSource = clientUsers; |
1034 |
ColClientReviewer.DisplayMember = "Name"; |
1035 |
ColClientReviewer.ValueMember = "ID"; |
1036 |
|
1037 |
//Data |
1038 |
if (this.radGridViewDocuments.DataSource != null) |
1039 |
this.radGridViewDocuments.DataSource = null; |
1040 |
|
1041 |
/* |
1042 |
var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info; |
1043 |
var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info); |
1044 |
var test = from doc in this.documents |
1045 |
join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj |
1046 |
from docs in gj.DefaultIfEmpty() |
1047 |
select new Documents() |
1048 |
{ |
1049 |
DocumentNo = doc.DocumentNo, |
1050 |
ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME) |
1051 |
//ProdRemarks = docs.DATETIME ?? null |
1052 |
}; |
1053 |
*/ |
1054 |
|
1055 |
this.radGridViewDocuments.FilterDescriptors.Clear(); |
1056 |
this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents); |
1057 |
this.lbSelectAndTotal.Text = $"{this.documents.Count} / {this.TotalCount} (Selected / Total)"; |
1058 |
|
1059 |
var verification = this.LayoutValidation.Controls[0] as Verification; |
1060 |
verification.DocumentListBinding(this.documents); |
1061 |
} |
1062 |
catch (Exception ex) |
1063 |
{ |
1064 |
throw ex; |
1065 |
} |
1066 |
} |
1067 |
#endregion |
1068 |
|
1069 |
#region Button, Checkbox event |
1070 |
private void RadCheckBox_CheckStateChanged(object sender, EventArgs e) |
1071 |
{ |
1072 |
if (sender is RadCheckBox) |
1073 |
{ |
1074 |
RadCheckBox checkBox = sender as RadCheckBox; |
1075 |
|
1076 |
if (checkBox.Tag != null) |
1077 |
{ |
1078 |
ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition; |
1079 |
GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault(); |
1080 |
if (colGroup != null) |
1081 |
colGroup.IsVisible = checkBox.Checked; |
1082 |
} |
1083 |
} |
1084 |
|
1085 |
//ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView; |
1086 |
} |
1087 |
|
1088 |
private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e) |
1089 |
{ |
1090 |
if (e.KeyCode == Keys.Enter) |
1091 |
{ |
1092 |
this.radButtonSearch.Focus(); |
1093 |
this.radButtonSearch.PerformClick(); |
1094 |
} |
1095 |
} |
1096 |
|
1097 |
private void RadButtonSearch_Click(object sender, EventArgs e) |
1098 |
{ |
1099 |
try |
1100 |
{ |
1101 |
this.GetDocList(); |
1102 |
} |
1103 |
catch (Exception ex) |
1104 |
{ |
1105 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
1106 |
RadMessageBox.Show("DWG search failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1107 |
} |
1108 |
} |
1109 |
|
1110 |
private void BackstageButtonItemSelectDB_Click(object sender, EventArgs e) |
1111 |
{ |
1112 |
using (var frm = new SetID2ProjectDB()) |
1113 |
{ |
1114 |
if (frm.ShowDialog(this) == DialogResult.OK) |
1115 |
{ |
1116 |
if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
1117 |
{ |
1118 |
this.radRibbonBarBackstageViewID2Manager.HidePopup(); |
1119 |
|
1120 |
informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID); |
1121 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
1122 |
|
1123 |
this.LoadProject(); |
1124 |
} |
1125 |
else |
1126 |
{ |
1127 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
1128 |
bool isID2 = this.IsID2Connection(); |
1129 |
this.SetMenus(isID2); |
1130 |
|
1131 |
foreach (Control ctrl in this.backstageViewPageOpenProject.Controls) |
1132 |
{ |
1133 |
if (ctrl is OpenProjectView) |
1134 |
{ |
1135 |
var openProjectView = ctrl as OpenProjectView; |
1136 |
openProjectView.GetProjectGroups(); |
1137 |
break; |
1138 |
} |
1139 |
} |
1140 |
} |
1141 |
} |
1142 |
} |
1143 |
} |
1144 |
|
1145 |
private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e) |
1146 |
{ |
1147 |
using (var frm = new SetupUser()) |
1148 |
{ |
1149 |
if (frm.ShowDialog(this) == DialogResult.OK) |
1150 |
{ |
1151 |
|
1152 |
} |
1153 |
} |
1154 |
} |
1155 |
|
1156 |
private void BackstageButtonItemExit_Click(object sender, EventArgs e) |
1157 |
{ |
1158 |
Application.Exit(); |
1159 |
} |
1160 |
#endregion |
1161 |
|
1162 |
#region Grid event |
1163 |
private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e) |
1164 |
{ |
1165 |
if (e.Row is GridViewNewRowInfo) |
1166 |
{ |
1167 |
|
1168 |
} |
1169 |
else |
1170 |
{ |
1171 |
string extension = string.Empty; |
1172 |
|
1173 |
switch (e.Column.Name) |
1174 |
{ |
1175 |
case "MarkupLink": |
1176 |
{ |
1177 |
if (e.Row.DataBoundItem is Documents doc) |
1178 |
{ |
1179 |
if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID)) |
1180 |
{ |
1181 |
bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID); |
1182 |
} |
1183 |
} |
1184 |
} |
1185 |
break; |
1186 |
case "AVEVALink": |
1187 |
case "AVEVAConnection": |
1188 |
MessageBox.Show($"{e.Column.Name} 실행"); |
1189 |
break; |
1190 |
case "ReviewFileName"://일단주석 |
1191 |
MessageBox.Show($"{e.Column.Name} 실행"); |
1192 |
break; |
1193 |
case "SystemLink": |
1194 |
MessageBox.Show($"{e.Column.Name} 실행"); |
1195 |
break; |
1196 |
case "ID2Connection": |
1197 |
try |
1198 |
{ |
1199 |
if (e.Row.DataBoundItem is Documents doc) |
1200 |
{ |
1201 |
ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port); |
1202 |
|
1203 |
try |
1204 |
{ |
1205 |
var returnDoc = new DocumentController().SetID2Worker(new Documents() |
1206 |
{ |
1207 |
DocID = doc.DocID, |
1208 |
ID2StartDate = DateTime.Now, |
1209 |
Worker = informations.ActiveUser.ID |
1210 |
}, informations.ActiveUser.ID); |
1211 |
|
1212 |
if (returnDoc != null) |
1213 |
{ |
1214 |
doc.ID2StartDate = returnDoc.ID2StartDate; |
1215 |
doc.Worker = returnDoc.Worker; |
1216 |
doc.ID2JobTime = returnDoc.ID2JobTime; |
1217 |
} |
1218 |
} |
1219 |
catch { } |
1220 |
} |
1221 |
} |
1222 |
catch (Exception ex) |
1223 |
{ |
1224 |
RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error); |
1225 |
} |
1226 |
break; |
1227 |
} |
1228 |
} |
1229 |
} |
1230 |
|
1231 |
private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) |
1232 |
{ |
1233 |
if (e.ActiveEditor is RadDropDownListEditor) |
1234 |
{ |
1235 |
switch (e.Column.Name) |
1236 |
{ |
1237 |
case "JobLevel": |
1238 |
GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
1239 |
colJobLevel.DataSource = informations.JobLevel; |
1240 |
break; |
1241 |
case "IsTypical": |
1242 |
case "ToIsDiscussion": |
1243 |
case "ToIsMarkup": |
1244 |
case "FrIsMarkup": |
1245 |
case "IsID2Work": |
1246 |
case "DTIsImport": |
1247 |
GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
1248 |
colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo); |
1249 |
break; |
1250 |
case "DTIsGateWay": |
1251 |
case "DTIsRegSystem": |
1252 |
GridViewComboBoxColumn colSuccess = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
1253 |
colSuccess.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsSuccess); |
1254 |
break; |
1255 |
case "ID2Status": |
1256 |
case "AVEVAStatus": |
1257 |
GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
1258 |
ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus); |
1259 |
break; |
1260 |
case "FrReviewStatus"://삼성의견status |
1261 |
GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
1262 |
ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus); |
1263 |
break; |
1264 |
case "ProdIsResult": |
1265 |
case "ClientIsResult": |
1266 |
GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
1267 |
ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult); |
1268 |
break; |
1269 |
} |
1270 |
} |
1271 |
} |
1272 |
|
1273 |
private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e) |
1274 |
{ |
1275 |
if (e.Row is GridViewDataRowInfo) |
1276 |
{ |
1277 |
if (e.CellElement is GridRowHeaderCellElement) |
1278 |
{ |
1279 |
// if (e.CellElement.RowIndex > -1) |
1280 |
// e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString(); |
1281 |
} |
1282 |
else if (e.CellElement is GridGroupExpanderCellElement expanderCellElement) |
1283 |
{ |
1284 |
if((e.Row.DataBoundItem as Documents).Markups == null) |
1285 |
{ |
1286 |
expanderCellElement.Enabled = false; |
1287 |
} |
1288 |
} |
1289 |
else |
1290 |
{ |
1291 |
var result = e.Row.DataBoundItem as Documents; |
1292 |
if (result != null || e.Row is GridViewNewRowInfo) |
1293 |
{ |
1294 |
switch (e.CellElement.ColumnInfo.Name) |
1295 |
{ |
1296 |
case "AutoCADLink": |
1297 |
case "PDFLink": |
1298 |
case "MarkupLink": |
1299 |
case "AVEVALink": |
1300 |
case "AVEVAConnection": |
1301 |
case "ReviewFileName"://일단주석 |
1302 |
case "SystemLink": |
1303 |
case "ID2Connection": |
1304 |
this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name); |
1305 |
break; |
1306 |
case "ToCapture": |
1307 |
if (result.ToCapture > 0) |
1308 |
{ |
1309 |
e.CellElement.Image = Properties.Resources.files18; |
1310 |
} |
1311 |
break; |
1312 |
case "FrCapture": |
1313 |
if (result.FrCapture > 0) |
1314 |
{ |
1315 |
e.CellElement.Image = Properties.Resources.files18; |
1316 |
} |
1317 |
break; |
1318 |
case "ProdCapture": |
1319 |
if (result.ProdCapture > 0) |
1320 |
{ |
1321 |
e.CellElement.Image = Properties.Resources.files18; |
1322 |
} |
1323 |
break; |
1324 |
case "ClientCapture": |
1325 |
if (result.ClientCapture > 0) |
1326 |
{ |
1327 |
e.CellElement.Image = Properties.Resources.files18; |
1328 |
} |
1329 |
break; |
1330 |
} |
1331 |
} |
1332 |
else |
1333 |
{ |
1334 |
|
1335 |
} |
1336 |
} |
1337 |
} |
1338 |
else if(e.Row is GridViewDetailsRowInfo) |
1339 |
{ |
1340 |
if (e.CellElement is GridDetailViewCellElement detailViewCellElement) |
1341 |
{ |
1342 |
detailViewCellElement.Padding = new Padding(2); |
1343 |
} |
1344 |
} |
1345 |
//else if (e.Row is GridViewSummaryRowInfo) |
1346 |
//{ |
1347 |
// if (e.CellElement is GridRowHeaderCellElement) |
1348 |
// { |
1349 |
// e.CellElement.Text = "Count"; |
1350 |
// } |
1351 |
// else if (e.CellElement is GridSummaryCellElement) |
1352 |
// { |
1353 |
// e.CellElement.ForeColor = this._SummaryColor; |
1354 |
// e.CellElement.TextAlignment = ContentAlignment.BottomRight; |
1355 |
// e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold); |
1356 |
// } |
1357 |
// else |
1358 |
// { |
1359 |
|
1360 |
// } |
1361 |
//} |
1362 |
else |
1363 |
{ |
1364 |
|
1365 |
} |
1366 |
} |
1367 |
|
1368 |
private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName) |
1369 |
{ |
1370 |
RadButtonElement btnElem = null; |
1371 |
Bitmap bitmap = null; ; |
1372 |
|
1373 |
switch (colName) |
1374 |
{ |
1375 |
case "AutoCADLink": |
1376 |
bitmap = new Bitmap(Properties.Resources.cad18); |
1377 |
break; |
1378 |
case "PDFLink": |
1379 |
bitmap = new Bitmap(Properties.Resources.pdf18); |
1380 |
break; |
1381 |
case "MarkupLink": |
1382 |
bitmap = new Bitmap(Properties.Resources.markus18); |
1383 |
break; |
1384 |
case "AVEVALink": |
1385 |
case "AVEVAConnection": |
1386 |
bitmap = new Bitmap(Properties.Resources.aveva_net18); |
1387 |
break; |
1388 |
case "ReviewFileName"://일단주석 |
1389 |
bitmap = new Bitmap(Properties.Resources.pdf18); |
1390 |
break; |
1391 |
case "SystemLink": |
1392 |
bitmap = new Bitmap(Properties.Resources.link18_yellow); |
1393 |
break; |
1394 |
case "ToCapture": |
1395 |
case "FrCapture": |
1396 |
bitmap = new Bitmap(Properties.Resources.files18); |
1397 |
break; |
1398 |
case "ID2Connection": |
1399 |
bitmap = new Bitmap(Properties.Resources.id218); |
1400 |
break; |
1401 |
} |
1402 |
|
1403 |
switch (colName) |
1404 |
{ |
1405 |
case "AutoCADLink": |
1406 |
case "PDFLink": |
1407 |
case "MarkupLink": |
1408 |
case "AVEVALink": |
1409 |
case "AVEVAConnection": |
1410 |
case "ReviewFileName"://일단주석 |
1411 |
case "SystemLink": |
1412 |
case "ToCapture": |
1413 |
case "FrCapture": |
1414 |
case "ID2Connection": |
1415 |
btnElem = (RadButtonElement)elem; |
1416 |
btnElem.Margin = new Padding(0); |
1417 |
btnElem.Padding = new Padding(0); |
1418 |
btnElem.BorderElement.Opacity = 0; |
1419 |
btnElem.Alignment = ContentAlignment.MiddleCenter; |
1420 |
btnElem.DisplayStyle = DisplayStyle.Image; |
1421 |
btnElem.Image = bitmap; |
1422 |
btnElem.ImageAlignment = ContentAlignment.MiddleCenter; |
1423 |
btnElem.MaxSize = bitmap.Size; |
1424 |
break; |
1425 |
} |
1426 |
|
1427 |
return btnElem; |
1428 |
} |
1429 |
|
1430 |
private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e) |
1431 |
{ |
1432 |
this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)"; |
1433 |
} |
1434 |
#endregion |
1435 |
|
1436 |
#region Excel |
1437 |
private UserInfo GetUser(string user) |
1438 |
{ |
1439 |
UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault(); |
1440 |
if (userInfo != null) return userInfo; |
1441 |
|
1442 |
userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault(); |
1443 |
if (userInfo != null) return userInfo; |
1444 |
|
1445 |
return userInfo ?? new UserInfo(); |
1446 |
} |
1447 |
|
1448 |
private ProjectInfo GetProject(string project) |
1449 |
{ |
1450 |
ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault(); |
1451 |
if (prjInfo != null) return prjInfo; |
1452 |
|
1453 |
prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project)); |
1454 |
if (prjInfo != null) return prjInfo; |
1455 |
|
1456 |
return prjInfo ?? new ProjectInfo(); |
1457 |
} |
1458 |
|
1459 |
private void RadButtonElementExcelImport_Click(object sender, EventArgs e) |
1460 |
{ |
1461 |
var form = new Forms.SelectExcelData(); |
1462 |
|
1463 |
var dialogResult = form.ShowDialog(); |
1464 |
|
1465 |
if (dialogResult == DialogResult.OK) |
1466 |
{ |
1467 |
using (ID2Excel excel = new ID2Excel(informations.UserList.ToList())) |
1468 |
{ |
1469 |
var result = excel.ExcelDataImport(form.SelectItems); |
1470 |
|
1471 |
if (result.Error != null) |
1472 |
{ |
1473 |
|
1474 |
RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
1475 |
} |
1476 |
else |
1477 |
{ |
1478 |
this.importImages = result.Images; |
1479 |
this.documents.AddRange(result.documents); |
1480 |
if (this.orgDocuments == null) this.orgDocuments = new List<Documents>(); |
1481 |
this.DocumentListBinding(); |
1482 |
//briefAndImagesReview.SetImages(this.importImages); |
1483 |
} |
1484 |
|
1485 |
} |
1486 |
} |
1487 |
} |
1488 |
|
1489 |
private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e) |
1490 |
{ |
1491 |
using (OpenFileDialog ofd = new OpenFileDialog() |
1492 |
{ |
1493 |
Filter = "Excel files (*.xlsx)|*.xlsx", |
1494 |
Title = "Open an Excel File", |
1495 |
RestoreDirectory = true |
1496 |
}) |
1497 |
{ |
1498 |
if (ofd.ShowDialog() == DialogResult.OK) |
1499 |
{ |
1500 |
//Error Message |
1501 |
StringBuilder sbErrMsg = new StringBuilder(); |
1502 |
|
1503 |
using(ID2Excel excel = new ID2Excel(informations.UserList.ToList())) |
1504 |
{ |
1505 |
var result = excel.GemboxImport(ofd.FileName); |
1506 |
|
1507 |
if(result.Error != null) |
1508 |
{ |
1509 |
|
1510 |
RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
1511 |
} |
1512 |
else |
1513 |
{ |
1514 |
this.documents.AddRange(result.documents); |
1515 |
if (this.orgDocuments == null) this.orgDocuments = new List<Documents>(); |
1516 |
this.DocumentListBinding(); |
1517 |
} |
1518 |
|
1519 |
} |
1520 |
|
1521 |
|
1522 |
//foreach (Documents appDoc in appendDocuments) |
1523 |
//{ |
1524 |
// GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew(); |
1525 |
|
1526 |
// foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
1527 |
// { |
1528 |
// if (fieldInfo.GetValue(appDoc) != null) |
1529 |
// { |
1530 |
// var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>")); |
1531 |
|
1532 |
// if (cols.Any()) |
1533 |
// { |
1534 |
// cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc); |
1535 |
// } |
1536 |
// } |
1537 |
// } |
1538 |
//} |
1539 |
} |
1540 |
} |
1541 |
} |
1542 |
|
1543 |
private void RadButtonElementExcelImport_Click_old(object sender, EventArgs e) |
1544 |
{ |
1545 |
using (OpenFileDialog ofd = new OpenFileDialog() |
1546 |
{ |
1547 |
Filter = "Excel files (*.xlsx)|*.xlsx", |
1548 |
Title = "Open an Excel File", |
1549 |
RestoreDirectory = true |
1550 |
}) |
1551 |
{ |
1552 |
if (ofd.ShowDialog() == DialogResult.OK) |
1553 |
{ |
1554 |
//Error Message |
1555 |
StringBuilder sbErrMsg = new StringBuilder(); |
1556 |
|
1557 |
var exFile = ExcelFile.Load(ofd.FileName); |
1558 |
var ws = exFile.Worksheets[0]; |
1559 |
|
1560 |
int rowCount = ws.Rows.Count; |
1561 |
int columnCount = ws.CalculateMaxUsedColumns(); |
1562 |
int exRow = 8; |
1563 |
|
1564 |
#region Excel 유효성검사 |
1565 |
|
1566 |
//Excel 포멧체크 |
1567 |
if (rowCount < 10 || columnCount != 45) |
1568 |
{ |
1569 |
RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
1570 |
return; |
1571 |
} |
1572 |
|
1573 |
#region 엑셀 필수값 체크(도면 : 이름,담당자, 난이도, Typical) |
1574 |
ws.Rows.SelectMany(row => row.AllocatedCells) |
1575 |
.Where(col => col.Column.Index > 5 && col.Column.Index < 10 && col.Row.Index > exRow && col.Value == null) |
1576 |
.ToList() |
1577 |
.ForEach(p => sbErrMsg.Append(", " + p.Column.Name + p.Row.Name)); |
1578 |
|
1579 |
if (sbErrMsg.Length > 0) |
1580 |
{ |
1581 |
string errMsg = sbErrMsg.ToString().Substring(2); |
1582 |
if (errMsg.Length > 100) |
1583 |
{ |
1584 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
1585 |
} |
1586 |
|
1587 |
RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
1588 |
return; |
1589 |
} |
1590 |
#endregion |
1591 |
|
1592 |
#region 엑셀 도명명 중복 값 체크 |
1593 |
ws.Rows.SelectMany(row => row.AllocatedCells) |
1594 |
.Where(col => col.Column.Index == 6 && col.Row.Index > exRow) |
1595 |
.GroupBy(g => g.Row.Index) |
1596 |
.Select(p => new { |
1597 |
rowIndex = p.Key, |
1598 |
docNo = p.Select(x => x.Value.ToString()).FirstOrDefault() |
1599 |
}) |
1600 |
.GroupBy(g => g.docNo) |
1601 |
.Where(p => p.Count() > 1) |
1602 |
.Select(p => p.Select(x => (x.rowIndex + 1).ToString()) |
1603 |
.Aggregate((x, y) => x.ToString() + "," + y.ToString()) |
1604 |
.ToString()) |
1605 |
.ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString())); |
1606 |
if (sbErrMsg.Length > 0) |
1607 |
{ |
1608 |
sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : "); |
1609 |
string errMsg = sbErrMsg.ToString(); |
1610 |
if (errMsg.Length > 100) |
1611 |
{ |
1612 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
1613 |
} |
1614 |
|
1615 |
RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
1616 |
return; |
1617 |
} |
1618 |
#endregion |
1619 |
|
1620 |
#endregion |
1621 |
|
1622 |
List<Documents> appendDocuments = new List<Documents>(); |
1623 |
|
1624 |
ws.Rows.Where(row => row.Index > exRow) |
1625 |
.ToList() |
1626 |
.ForEach(p => appendDocuments.Add(new Documents() |
1627 |
{ |
1628 |
//UID = string.Empty, |
1629 |
//Type = this.radTextBoxInsulationType.Text, |
1630 |
//TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value), |
1631 |
//TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value), |
1632 |
//NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value), |
1633 |
//Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value) |
1634 |
|
1635 |
RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1636 |
DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(), |
1637 |
PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID, |
1638 |
JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(), |
1639 |
IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(), |
1640 |
RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(), |
1641 |
ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(), |
1642 |
ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(), |
1643 |
ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID, |
1644 |
//ToCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1645 |
//ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1646 |
FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(), |
1647 |
FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(), |
1648 |
FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID, |
1649 |
//FrCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1650 |
//FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1651 |
IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(), |
1652 |
//ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1653 |
ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()), |
1654 |
ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()), |
1655 |
//ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1656 |
ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(), |
1657 |
ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(), |
1658 |
//AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
1659 |
AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()), |
1660 |
AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()), |
1661 |
AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(), |
1662 |
AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(), |
1663 |
ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID, |
1664 |
ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(), |
1665 |
ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(), |
1666 |
ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID, |
1667 |
ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(), |
1668 |
ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(), |
1669 |
DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(), |
1670 |
DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(), |
1671 |
DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(), |
1672 |
DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString() |
1673 |
})); |
1674 |
|
1675 |
this.documents.AddRange(appendDocuments); |
1676 |
if (this.orgDocuments == null) this.orgDocuments = new List<Documents>(); |
1677 |
this.DocumentListBinding(); |
1678 |
|
1679 |
//foreach (Documents appDoc in appendDocuments) |
1680 |
//{ |
1681 |
// GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew(); |
1682 |
|
1683 |
// foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
1684 |
// { |
1685 |
// if (fieldInfo.GetValue(appDoc) != null) |
1686 |
// { |
1687 |
// var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>")); |
1688 |
|
1689 |
// if (cols.Any()) |
1690 |
// { |
1691 |
// cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc); |
1692 |
// } |
1693 |
// } |
1694 |
// } |
1695 |
//} |
1696 |
} |
1697 |
} |
1698 |
} |
1699 |
|
1700 |
private void RadButtonElementExcelExport_Click(object sender, EventArgs e) |
1701 |
{ |
1702 |
string sPrefixName = "Samsung Elec Task Management"; |
1703 |
string extension = ".xlsx"; |
1704 |
|
1705 |
using (SaveFileDialog sfd = new SaveFileDialog() |
1706 |
{ |
1707 |
FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}", |
1708 |
Filter = "Excel|*.xlsx", |
1709 |
Title = "Save an Excel File", |
1710 |
CheckFileExists = false, |
1711 |
CheckPathExists = true, |
1712 |
OverwritePrompt = true |
1713 |
}) |
1714 |
{ |
1715 |
if (sfd.ShowDialog() == DialogResult.OK) |
1716 |
{ |
1717 |
string fileName = $"{sPrefixName}{extension}"; |
1718 |
string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template"); |
1719 |
string templateFilePath = Path.Combine(templateFolder, fileName); |
1720 |
if (!File.Exists(templateFilePath)) |
1721 |
{ |
1722 |
RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error); |
1723 |
return; |
1724 |
} |
1725 |
|
1726 |
if (this.radGridViewDocuments.Rows.Count > 0) |
1727 |
{ |
1728 |
var templateExcelFile = ExcelFile.Load(templateFilePath); |
1729 |
var templateWorksheets = templateExcelFile.Worksheets; |
1730 |
var templateWorksheet = templateWorksheets[0]; |
1731 |
|
1732 |
int rowIndex = 9; |
1733 |
//int colIndex = 1; |
1734 |
|
1735 |
foreach (var row in this.radGridViewDocuments.Rows) |
1736 |
{ |
1737 |
var doc = row.DataBoundItem as Documents; |
1738 |
|
1739 |
templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq; |
1740 |
//templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo; |
1741 |
//templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo; |
1742 |
//templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo; |
1743 |
//templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo; |
1744 |
templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode; |
1745 |
templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo; |
1746 |
templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name; |
1747 |
templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel; |
1748 |
templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical; |
1749 |
templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo; |
1750 |
templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion; |
1751 |
templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks; |
1752 |
templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name; |
1753 |
templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture; |
1754 |
templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup; |
1755 |
templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus; |
1756 |
templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks; |
1757 |
templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name; |
1758 |
templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture; |
1759 |
templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup; |
1760 |
templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work; |
1761 |
templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection; |
1762 |
templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}"; |
1763 |
templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}"; |
1764 |
templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime; |
1765 |
templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status; |
1766 |
templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues; |
1767 |
templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection; |
1768 |
templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}"; |
1769 |
templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}"; |
1770 |
templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus; |
1771 |
templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues; |
1772 |
//templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo; |
1773 |
//templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo; |
1774 |
templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name; |
1775 |
templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult; |
1776 |
templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks; |
1777 |
templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name; |
1778 |
templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult; |
1779 |
templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks; |
1780 |
templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay; |
1781 |
templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport; |
1782 |
templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem; |
1783 |
templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks; |
1784 |
rowIndex++; |
1785 |
} |
1786 |
|
1787 |
templateExcelFile.Save(sfd.FileName); |
1788 |
RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
1789 |
} |
1790 |
} |
1791 |
} |
1792 |
} |
1793 |
#endregion |
1794 |
|
1795 |
#region Save event |
1796 |
|
1797 |
private void SetSaved() |
1798 |
{ |
1799 |
try |
1800 |
{ |
1801 |
if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) |
1802 |
{ |
1803 |
var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments); |
1804 |
worker.OnWorkCompletedHandler += (e) => |
1805 |
{ |
1806 |
bool result = (bool)e.Result; |
1807 |
|
1808 |
bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents); |
1809 |
|
1810 |
bool markusMembersResult = new MarkusInfoController().SetMembers(informations.UserList); |
1811 |
|
1812 |
if (result && markusResult && markusMembersResult) |
1813 |
{ |
1814 |
RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
1815 |
|
1816 |
this.GetDocList(); |
1817 |
} |
1818 |
else if (!result) |
1819 |
{ |
1820 |
RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1821 |
} |
1822 |
else if (!markusResult) |
1823 |
{ |
1824 |
RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1825 |
} |
1826 |
else if (!markusMembersResult) |
1827 |
{ |
1828 |
RadMessageBox.Show("Markus Members Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1829 |
} |
1830 |
}; |
1831 |
worker.StartWork(); |
1832 |
} |
1833 |
} |
1834 |
catch (Exception ex) |
1835 |
{ |
1836 |
throw ex; |
1837 |
} |
1838 |
} |
1839 |
|
1840 |
private void RadButtonElementSaveCommand_Click(object sender, EventArgs e) |
1841 |
{ |
1842 |
try |
1843 |
{ |
1844 |
this.SetSaved(); |
1845 |
} |
1846 |
catch (Exception ex) |
1847 |
{ |
1848 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
1849 |
RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1850 |
} |
1851 |
} |
1852 |
|
1853 |
private void RadButtonElementSave_Click(object sender, EventArgs e) |
1854 |
{ |
1855 |
try |
1856 |
{ |
1857 |
this.SetSaved(); |
1858 |
} |
1859 |
catch (Exception ex) |
1860 |
{ |
1861 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
1862 |
RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1863 |
} |
1864 |
} |
1865 |
|
1866 |
private void RadButtonElementSync_Click(object sender, EventArgs e) |
1867 |
{ |
1868 |
try |
1869 |
{ |
1870 |
if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) |
1871 |
{ |
1872 |
var worker = new SyncDocumentsWorker(this.radGridViewDocuments); |
1873 |
worker.OnWorkCompletedHandler += (arg) => |
1874 |
{ |
1875 |
if ((bool)arg.Result) |
1876 |
{ |
1877 |
this.GetDocList(); |
1878 |
|
1879 |
RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
1880 |
} |
1881 |
}; |
1882 |
worker.StartWork(); |
1883 |
} |
1884 |
} |
1885 |
catch (Exception ex) |
1886 |
{ |
1887 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
1888 |
RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1889 |
} |
1890 |
} |
1891 |
|
1892 |
private void RadButtonElementNotice_Click(object sender, EventArgs e) |
1893 |
{ |
1894 |
try |
1895 |
{ |
1896 |
AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProject.ProjectID, "notice"); |
1897 |
|
1898 |
if (notiFileInfo == null) |
1899 |
{ |
1900 |
RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
1901 |
} |
1902 |
else |
1903 |
{ |
1904 |
string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles"); |
1905 |
string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}"); |
1906 |
|
1907 |
FileInfo finfo = new FileInfo(noticeFileFullName); |
1908 |
|
1909 |
if (!finfo.Directory.Exists) |
1910 |
{ |
1911 |
Directory.CreateDirectory(noticePath); |
1912 |
} |
1913 |
|
1914 |
if (!finfo.Exists) |
1915 |
{ |
1916 |
var arrayBinary = notiFileInfo.FileData.ToArray(); |
1917 |
|
1918 |
using (MemoryStream ms = new MemoryStream(arrayBinary)) |
1919 |
{ |
1920 |
ms.Write(arrayBinary, 0, arrayBinary.Length); |
1921 |
ms.Seek(0, SeekOrigin.Begin); |
1922 |
|
1923 |
using (FileStream fs = finfo.Create()) |
1924 |
{ |
1925 |
ms.CopyTo(fs); |
1926 |
} |
1927 |
} |
1928 |
} |
1929 |
|
1930 |
try |
1931 |
{ |
1932 |
ProcessStartInfo startInfo = new ProcessStartInfo |
1933 |
{ |
1934 |
FileName = finfo.FullName, |
1935 |
UseShellExecute = true, |
1936 |
CreateNoWindow = false, |
1937 |
WindowStyle = ProcessWindowStyle.Normal |
1938 |
}; |
1939 |
|
1940 |
using (Process process = new Process()) |
1941 |
{ |
1942 |
process.StartInfo = startInfo; |
1943 |
process.Start(); |
1944 |
} |
1945 |
//Process.Start(finfo.FullName); |
1946 |
} |
1947 |
catch (Exception ex) |
1948 |
{ |
1949 |
throw ex; |
1950 |
} |
1951 |
|
1952 |
//using (MemoryStream ms = new MemoryStream(arrayBinary)) |
1953 |
//{ |
1954 |
// ProcessStartInfo startInfo = new ProcessStartInfo |
1955 |
// { |
1956 |
// FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName), |
1957 |
// RedirectStandardInput = true, |
1958 |
// UseShellExecute = false, |
1959 |
// CreateNoWindow = true, |
1960 |
// WindowStyle = ProcessWindowStyle.Hidden |
1961 |
// }; |
1962 |
|
1963 |
// using (Process process = new Process()) |
1964 |
// { |
1965 |
// process.StartInfo = startInfo; |
1966 |
// process.Start(); |
1967 |
|
1968 |
// // Write the memory stream contents to the process standard input |
1969 |
// byte[] buffer = ms.ToArray(); |
1970 |
// process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length); |
1971 |
// process.StandardInput.Close(); |
1972 |
|
1973 |
// process.WaitForExit(); |
1974 |
// } |
1975 |
//} |
1976 |
} |
1977 |
} |
1978 |
catch (Exception ex) |
1979 |
{ |
1980 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
1981 |
RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1982 |
} |
1983 |
} |
1984 |
|
1985 |
private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e) |
1986 |
{ |
1987 |
string GetContentType(string filePath) |
1988 |
{ |
1989 |
string extension = Path.GetExtension(filePath).ToLower(); |
1990 |
|
1991 |
switch (extension) |
1992 |
{ |
1993 |
case ".txt": |
1994 |
return "text/plain"; |
1995 |
case ".pdf": |
1996 |
return "application/pdf"; |
1997 |
case ".jpg": |
1998 |
case ".jpeg": |
1999 |
return "image/jpeg"; |
2000 |
case ".png": |
2001 |
return "image/png"; |
2002 |
case ".bmp": |
2003 |
return "image/bmp"; |
2004 |
case ".gif": |
2005 |
return "image/gif"; |
2006 |
default: |
2007 |
return "application/octet-stream"; |
2008 |
} |
2009 |
} |
2010 |
|
2011 |
using (OpenFileDialog ofd = new OpenFileDialog() |
2012 |
{ |
2013 |
//Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*", |
2014 |
Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp)|*.png;*.jpeg;*.gif;*.jpg;*.bmp" |
2015 |
+ "|PNG Portable Network Graphics (*.png)|*.png" |
2016 |
+"|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif" |
2017 |
+ "|BMP Windows Bitmap (*.bmp)|*.bmp" |
2018 |
+ "|GIF Graphics Interchange Format (*.gif)|*.gif", |
2019 |
//Title = "Open an Excel File", |
2020 |
RestoreDirectory = true |
2021 |
}) |
2022 |
{ |
2023 |
try |
2024 |
{ |
2025 |
if (ofd.ShowDialog() == DialogResult.OK) |
2026 |
{ |
2027 |
FileInfo fileInfo = new FileInfo(ofd.FileName); |
2028 |
if (fileInfo.Exists) |
2029 |
{ |
2030 |
AttFileInfo attFile = new AttFileInfo() |
2031 |
{ |
2032 |
RefID = informations.ActiveProject.ProjectID, |
2033 |
Category = "notice", |
2034 |
FileType = GetContentType(fileInfo.FullName), |
2035 |
FileName = fileInfo.Name, |
2036 |
FilePath = fileInfo.DirectoryName, |
2037 |
FileExtension = fileInfo.Extension |
2038 |
}; |
2039 |
|
2040 |
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read)) |
2041 |
{ |
2042 |
using (var reader = new BinaryReader(stream)) |
2043 |
{ |
2044 |
attFile.FileData = reader.ReadBytes((int)stream.Length); |
2045 |
} |
2046 |
} |
2047 |
|
2048 |
bool result = new AttFileController().SetAttFiles(new List<AttFileInfo>() { attFile }, informations.ActiveUser.ID); |
2049 |
|
2050 |
if (result) |
2051 |
{ |
2052 |
RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
2053 |
} |
2054 |
} |
2055 |
} |
2056 |
} |
2057 |
catch (Exception ex) |
2058 |
{ |
2059 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
2060 |
RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
2061 |
} |
2062 |
} |
2063 |
} |
2064 |
|
2065 |
private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e) |
2066 |
{ |
2067 |
bool isReload = false; |
2068 |
|
2069 |
try |
2070 |
{ |
2071 |
if (RadMessageBox.Show($"Do you want to reload the project?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) |
2072 |
{ |
2073 |
if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
2074 |
{ |
2075 |
informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID); |
2076 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
2077 |
|
2078 |
isReload = true; |
2079 |
} |
2080 |
else if (informations.ActiveProject != null) |
2081 |
{ |
2082 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
2083 |
|
2084 |
isReload = true; |
2085 |
} |
2086 |
else |
2087 |
{ |
2088 |
RadMessageBox.Show("Select a project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
2089 |
this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement); |
2090 |
} |
2091 |
} |
2092 |
|
2093 |
if (isReload) |
2094 |
{ |
2095 |
this.LoadProject(); |
2096 |
} |
2097 |
} |
2098 |
catch (Exception ex) |
2099 |
{ |
2100 |
Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex); |
2101 |
RadMessageBox.Show("Failed to reload the project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
2102 |
} |
2103 |
} |
2104 |
#endregion |
2105 |
|
2106 |
#region ColumnGroup |
2107 |
private void InitColumnGroupsViewDefinition(RadGridView gridView) |
2108 |
{ |
2109 |
ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition(); |
2110 |
|
2111 |
List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" }; |
2112 |
List<string> docInfoColNames = new List<string>() { "RefProjectCode", "DocumentNo", "PersonInCharge", "Worker", "JobLevel", "IsTypical", "RevisonNo" }; |
2113 |
List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture", "ToIsMarkup" }; |
2114 |
List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture", "FrIsMarkup" }; |
2115 |
List<string> rvEtcColNames = new List<string>() { "IsID2Work" }; |
2116 |
List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" }; |
2117 |
List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" }; |
2118 |
List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" }; |
2119 |
List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks", "ProdCapture" }; |
2120 |
List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks", "ClientCapture" }; |
2121 |
List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" }; |
2122 |
|
2123 |
//도면 |
2124 |
GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 "); |
2125 |
GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크"); |
2126 |
GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보"); |
2127 |
|
2128 |
GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow(); |
2129 |
docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames); |
2130 |
|
2131 |
GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow(); |
2132 |
docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames); |
2133 |
|
2134 |
docLinkColGrp.Rows.Add(docLinkColGrpRow); |
2135 |
docColGrp.Groups.Add(docLinkColGrp); |
2136 |
docInfoColGrp.Rows.Add(docInfoColGrpRow); |
2137 |
docColGrp.Groups.Add(docInfoColGrp); |
2138 |
|
2139 |
//검토 |
2140 |
GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review"); |
2141 |
GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍"); |
2142 |
GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성"); |
2143 |
GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타"); |
2144 |
|
2145 |
GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow(); |
2146 |
rvToColGrpRow.ColumnNames.AddRange(rvToColNames); |
2147 |
|
2148 |
GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow(); |
2149 |
rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames); |
2150 |
|
2151 |
GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow(); |
2152 |
rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames); |
2153 |
|
2154 |
rvToColGrp.Rows.Add(rvToColGrpRow); |
2155 |
rvFrColGrp.Rows.Add(rvFrColGrpRow); |
2156 |
rvEtcColGrp.Rows.Add(rvEtcColGrpRow); |
2157 |
|
2158 |
|
2159 |
rvColGrp.Groups.Add(rvToColGrp); |
2160 |
rvColGrp.Groups.Add(rvFrColGrp); |
2161 |
rvColGrp.Groups.Add(rvEtcColGrp); |
2162 |
|
2163 |
|
2164 |
//작업 |
2165 |
GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work"); |
2166 |
GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2"); |
2167 |
GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA"); |
2168 |
|
2169 |
GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow(); |
2170 |
wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames); |
2171 |
|
2172 |
GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow(); |
2173 |
wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames); |
2174 |
|
2175 |
wkID2ColGrp.Rows.Add(wkID2ColGrpRow); |
2176 |
wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow); |
2177 |
|
2178 |
wkColGrp.Groups.Add(wkID2ColGrp); |
2179 |
wkColGrp.Groups.Add(wkAVEVAColGrp); |
2180 |
|
2181 |
|
2182 |
//Validation |
2183 |
GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation"); |
2184 |
GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크"); |
2185 |
GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍"); |
2186 |
GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자"); |
2187 |
|
2188 |
GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow(); |
2189 |
valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames); |
2190 |
|
2191 |
GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow(); |
2192 |
valProdColGrpRow.ColumnNames.AddRange(valProdColNames); |
2193 |
|
2194 |
GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow(); |
2195 |
valCntColGrpRow.ColumnNames.AddRange(valCntColNames); |
2196 |
|
2197 |
valLinkColGrp.Rows.Add(valLinkColGrpRow); |
2198 |
valProdColGrp.Rows.Add(valProdColGrpRow); |
2199 |
valCntColGrp.Rows.Add(valCntColGrpRow); |
2200 |
|
2201 |
valColGrp.Groups.Add(valLinkColGrp); |
2202 |
valColGrp.Groups.Add(valProdColGrp); |
2203 |
valColGrp.Groups.Add(valCntColGrp); |
2204 |
|
2205 |
//AVEVA Net |
2206 |
GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet"); |
2207 |
|
2208 |
GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow(); |
2209 |
dtColGrpRow.ColumnNames.AddRange(dtColNames); |
2210 |
|
2211 |
dtColGrp.Rows.Add(dtColGrpRow); |
2212 |
|
2213 |
//Group 추가 |
2214 |
columnGroupsView.ColumnGroups.Add(docColGrp); |
2215 |
columnGroupsView.ColumnGroups.Add(rvColGrp); |
2216 |
columnGroupsView.ColumnGroups.Add(wkColGrp); |
2217 |
columnGroupsView.ColumnGroups.Add(valColGrp); |
2218 |
columnGroupsView.ColumnGroups.Add(dtColGrp); |
2219 |
|
2220 |
gridView.MasterTemplate.ViewDefinition = columnGroupsView; |
2221 |
} |
2222 |
#endregion |
2223 |
|
2224 |
private void txtFullSearch_TextChanged(object sender, EventArgs e) |
2225 |
{ |
2226 |
if(string.IsNullOrWhiteSpace(txtFullSearch.Text)) |
2227 |
radGridViewDocuments.MasterTemplate.Refresh(null); |
2228 |
|
2229 |
txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text); |
2230 |
radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text); |
2231 |
} |
2232 |
|
2233 |
private void btnSearchPrevious_Click(object sender, EventArgs e) |
2234 |
{ |
2235 |
radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult(); |
2236 |
} |
2237 |
|
2238 |
private void btnSearchNext_Click(object sender, EventArgs e) |
2239 |
{ |
2240 |
radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult(); |
2241 |
} |
2242 |
|
2243 |
private void txtFullSearch_KeyDown(object sender, KeyEventArgs e) |
2244 |
{ |
2245 |
if(e.KeyCode == Keys.Enter) |
2246 |
{ |
2247 |
radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult(); |
2248 |
} |
2249 |
} |
2250 |
} |
2251 |
} |
2252 |
|
2253 |
public class FilterColumn |
2254 |
{ |
2255 |
public string Name { get; set; } |
2256 |
public string FieldName { get; set; } |
2257 |
public bool IsSelect { get; set; } |
2258 |
} |