프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ 56f7f16e

이력 | 보기 | 이력해설 | 다운로드 (87.4 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

    
31
namespace ID2.Manager
32
{
33
    public partial class Main : RadRibbonForm
34
    {
35
        readonly Informations informations = Informations.Instance;
36
        bool IsID2Manager = false;
37
        List<Documents> documents = new List<Documents>();
38
        List<System.Drawing.Image> importImages = new List<System.Drawing.Image>();
39

    
40
        List<Documents> orgDocuments = null;
41
        int TotalCount = 0;
42

    
43
        BriefAndImages briefAndImagesReview = new BriefAndImages { Dock = DockStyle.Fill };
44
        BriefAndImages briefAndImagesValidation = new BriefAndImages { Dock = DockStyle.Fill };
45

    
46
        private readonly Color _SummaryColor = Color.FromArgb(255, 108, 55);
47

    
48
        public Main()
49
        {
50
            InitializeComponent();
51
            Telerik.WinControls.RadControlSpy.RadControlSpyForm radControlSpyForm = new Telerik.WinControls.RadControlSpy.RadControlSpyForm();
52
            radControlSpyForm.Show();
53

    
54
            this.Load += Main_Load;
55

    
56
            this.radButtonElementRefreshCommand.Click += RadButtonElementRefreshCommand_Click;
57
            this.radButtonElementSaveCommand.Click += RadButtonElementSaveCommand_Click;
58

    
59
            this.radButtonElementSave.Click += RadButtonElementSave_Click;
60
            this.radButtonElementSync.Click += RadButtonElementSync_Click;
61
            this.radButtonElementNotice.Click += RadButtonElementNotice_Click;
62
            this.radButtonElementNoticeUpload.Click += RadButtonElementNoticeUpload_Click;
63
            this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click;
64
            this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click;
65

    
66
            this.radCheckBox1.CheckStateChanged += RadCheckBox_CheckStateChanged;
67
            this.radCheckBox2.CheckStateChanged += RadCheckBox_CheckStateChanged;
68
            this.radCheckBox3.CheckStateChanged += RadCheckBox_CheckStateChanged;
69
            this.radCheckBox4.CheckStateChanged += RadCheckBox_CheckStateChanged;
70
            this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown;
71
            this.radButtonSearch.Click += RadButtonSearch_Click;
72

    
73
            this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged;
74
            this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting;
75
            this.radGridViewDocuments.CreateRow += RadGridViewDocuments_CreateRow;
76
            this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo;
77
            this.radGridViewDocuments.CreateCell += RadGridViewDocuments_CreateCell1;
78
            this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit;
79
            this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick;
80
            this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
81
            this.radGridViewDocuments.FilterChanged += RadGridViewDocuments_FilterChanged;
82

    
83
            this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36;
84
            this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36;
85
            //this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ;
86
            this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false;
87

    
88
            var openProjectView = new OpenProjectView()
89
            {
90
                Dock = DockStyle.Fill
91
            };
92
            this.backstageViewPageOpenProject.Controls.Add(openProjectView);
93
            openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick;
94
            openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick;
95
            this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click;
96
            this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click;
97
            this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened;
98
            this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed;
99

    
100
            this.InitColumnGroupsViewDefinition(this.radGridViewDocuments);
101

    
102
            this.radPageViewPageReview.Controls.Add(briefAndImagesReview);
103
            this.radPageViewPageValidation.Controls.Add(briefAndImagesValidation);
104

    
105
            this.Initialize();
106
        }
107

    
108
        private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
109
        {
110
            if (e.RowInfo is GridViewSearchRowInfo)
111
            {
112
                e.RowInfo = new SearchRow(e.ViewInfo);
113
            }
114
        }
115

    
116
        private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
117
        {
118
            if (e.SearchFinished)
119
            {
120
                
121
            }
122
        }
123

    
124
        /// <summary>
125
        /// 선택된 행의 AutoCAD와 PDF 파일을 보여준다.
126
        /// </summary>
127
        /// <param name="sender"></param>
128
        /// <param name="e"></param>
129
        private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e)
130
        {
131
            void ShowAutoCADFile(string FilePath)
132
            {
133
                Controls.AutoCADViewer viewer = null;
134
                foreach (var control in this.radPageViewPageAutoCAD.Controls)
135
                {
136
                    if (control is Controls.AutoCADViewer _viewer)
137
                    {
138
                        viewer = _viewer;
139
                        break;
140
                    }
141
                }
142

    
143
                if (viewer == null)
144
                {
145
                    viewer = new Controls.AutoCADViewer() { Dock = DockStyle.Fill };
146
                    this.radPageViewPageAutoCAD.Controls.Add(viewer);
147
                }
148
                else
149
                {
150
                    viewer.Visible = true;
151
                }
152

    
153
                if (File.Exists(FilePath) && viewer != null) viewer.ReadDWG(FilePath);
154
            }
155

    
156
            void ShowPDFFile(string FilePath)
157
            {
158
                Controls.PDFViewer viewer = null;
159
                foreach (var control in this.radPageViewPagePDF.Controls)
160
                {
161
                    if (control is Controls.PDFViewer _viewer)
162
                    {
163
                        viewer = _viewer;
164
                        break;
165
                    }
166
                }
167

    
168
                if (viewer == null)
169
                {
170
                    viewer = new Controls.PDFViewer() { Dock = DockStyle.Fill };
171
                    this.radPageViewPagePDF.Controls.Add(viewer);
172
                }
173
                else
174
                {
175
                    viewer.Visible = true;
176
                }
177

    
178
                if (File.Exists(FilePath) && viewer != null) viewer.ReadPDF(FilePath);
179
            }
180

    
181
            if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
182
            {
183
                string dwgExtension = ".dwg";
184
                string dwgFilePath = Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", "Native", $"{doc.DocumentNo}{dwgExtension}");
185
                ShowAutoCADFile(dwgFilePath);
186
      
187
                string pdfExtension = ".pdf";
188
                string pdfFilePath = Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", $"{doc.DocumentNo}{pdfExtension}");
189
                ShowPDFFile(pdfFilePath);
190

    
191
                //if (informations.ActiveUser.ID != doc.PersonInCharge)
192
                //{
193
                //    var row = this.radGridViewDocuments.SelectedRows.First();
194
                //    foreach(var cell in row.Cells)
195
                //    {
196
                //        cell.ReadOnly = true;
197
                //    }
198
                //}
199

    
200
                briefAndImagesReview.Brief = doc.ToRemarks;
201
            }
202
        }
203

    
204
        #region Init, Load
205
        private void Initialize()
206
        {
207
            this.Text = Globals.Name;
208

    
209
            this.ID2ManagerRadRibbonBar.Expanded = false;
210

    
211
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
212

    
213
            this.IsID2Manager = (new string[] { "Admin", "Manager" }).Contains(informations.ActiveUser.Role) && string.IsNullOrEmpty(informations.ActiveUser.RefProjectID);
214

    
215
            if (this.IsID2Manager)
216
            {
217
                this.radButtonElementNoticeUpload.Enabled = true;
218

    
219
                this.backstageViewPageOpenProject.Controls[0].Visible = true;
220
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible;
221
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible;
222
            }
223
            else
224
            {
225
                this.radButtonElementNoticeUpload.Enabled = false;
226

    
227
                if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
228
                {
229
                    this.backstageViewPageOpenProject.Controls[0].Visible = true;
230
                }
231
                else
232
                {
233
                    foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
234
                    {
235
                        ctrl.Visible = false;
236
                    }
237
                }
238
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
239
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
240
            }
241
        }
242

    
243
        protected override void OnLoad(EventArgs e)
244
        {
245
            try
246
            {
247
                if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
248
                {
249
                    informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
250
                    informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
251

    
252
                    this.LoadProject();
253
                }
254
                else
255
                {
256
                    this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
257
                }
258
            }
259
            catch (Exception ex)
260
            {
261
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
262
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
263
            }
264
            base.OnLoad(e);
265
        }
266

    
267
        public Point GetBackstageLocation()
268
        {
269
            Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
270
            location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
271
            location.Offset(this.ID2ManagerRadRibbonBar.Location);
272

    
273
            return location;
274
        }
275

    
276
        private void Main_Load(object sender, EventArgs e)
277
        {
278
            InitializeSearch();
279
            InitializeGridViewDetail();
280
    
281
            this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
282
        }
283

    
284
        private void InitializeSearch()
285
        {
286
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
287

    
288
            lbSearch.Text = "\ue13E";
289
            btnSearchNext.Text = "\ue006";
290
            btnSearchPrevious.Text = "\ue004";
291

    
292
            var chkbox = new RadCheckBoxElement();
293
            chkbox.Text = "Match Case";
294
            chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; };
295

    
296
            btnMatchCase.HostedItem = chkbox;
297

    
298
            var chkbox1 = new RadCheckBoxElement();
299
            chkbox1.Text = "Show All Detail";
300
            chkbox1.CheckStateChanged += (snd, evt) => 
301
            { 
302
                radGridViewDocuments.MasterView.ChildRows.ForAll(x=>x.IsExpanded = chkbox1.Checked); 
303
            };
304

    
305
            btnShowAllDetail.HostedItem = chkbox1;
306

    
307
            var chkbox2 = new RadCheckBoxElement();
308
            chkbox2.Text = "Search from current position";
309
            chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; };
310

    
311
            btnSearchFormCurrent.HostedItem = chkbox2;
312

    
313
            var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x =>
314
                                 new FilterColumn
315
                                 {
316
                                     Name = x.HeaderText,
317
                                     FieldName = x.FieldName,
318
                                     IsSelect = x.AllowSearching
319
                                 });
320

    
321
            var panel = new StackLayoutElement();
322
            panel.Orientation = Orientation.Vertical;
323
            
324
            var btnComboColumns = new RadCheckedDropDownListElement();
325
            btnComboColumns.ShowCheckAllItems = true;
326
            btnComboColumns.CheckAllItem.Checked = true;
327
            btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns";
328
            btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true;
329
            btnComboColumns.DropDownMinSize = new Size(200, 200);
330
            btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
331
            btnComboColumns.DisplayMember = "Name";
332
            btnComboColumns.CheckedMember = "IsSelect";
333
            btnComboColumns.ValueMember = "FieldName";
334
            btnComboColumns.TextBox.CustomFont = font1.Name;
335
            btnComboColumns.TextBox.Text = "\ue13A";
336

    
337
            btnComboColumns.DataSource = columns;
338

    
339
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
340
            {
341
                radGridViewDocuments.MasterTemplate.Refresh(null);
342
            };
343

    
344
            btnComboColumns.PopupOpening += (snd, evt) =>
345
            {
346
                (snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect);
347
            };
348

    
349
            btnComboColumns.PopupClosed += (snd, evt) =>
350
            {
351
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
352
                {
353
                    if (radGridViewDocuments.Columns[item.Value.ToString()] != null)
354
                    {
355
                        radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
356
                    }
357
                }
358
            };
359

    
360
            btnFilters.HostedItem = btnComboColumns;
361
        }
362

    
363
        private void InitializeGridViewDetail()
364
        {
365
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
366
        }
367

    
368
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
369
        {
370
            //e.ChildRow.ChildViewInfos[0].ChildRows[0].Height = 152;
371
            //e.ChildRow.ChildViewInfos[2].ChildRows[0].Height = 152;
372
            e.ChildRow.Height = 224;
373
        }
374

    
375
        #endregion
376

    
377
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
378
        {
379
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
380
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
381
        }
382

    
383
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
384
        {
385
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
386

    
387
            foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls)
388
            {
389
                if (ctrl is OpenProjectView)
390
                {
391
                    var openProjectView = ctrl as OpenProjectView;
392
                    openProjectView.GetProjectGroups();
393
                    break;
394
                }
395
            }
396
        }
397

    
398
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
399
        {
400
            try
401
            {
402
                if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
403
                {
404
                    var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
405

    
406
                    informations.ActiveProject = prjArgs.ProjectInfo;
407

    
408
                    this.radRibbonBarBackstageViewID2Manager.Tag = null;
409

    
410
                    this.LoadProject();
411
                }
412
            }
413
            catch (Exception ex)
414
            {
415
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
416
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
417
            }
418
        }
419

    
420
        private void LoadProject()
421
        {
422
            try
423
            {
424
                #region 도면
425
                //Project List
426
                if (this.radDropDownListProject.Items.Count > 0)
427
                    this.radDropDownListProject.Items.Clear();
428
                informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
429
                                        .ForEach(x =>
430
                                        {
431
                                            this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
432
                                        });
433
                var allProject = new RadListDataItem("== 전체 ==", string.Empty);
434
                this.radDropDownListProject.Items.Insert(0, allProject);
435
                allProject.Selected = true;
436

    
437
                //담당자 List
438
                if (this.radDropDownListPersonInCharge.Items.Count > 0)
439
                    this.radDropDownListPersonInCharge.Items.Clear();
440
                informations.UserList.ForEach(x =>
441
                {
442
                    if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
443
                        this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
444
                });
445
                var allUser = new RadListDataItem("== 전체 ==", string.Empty);
446
                this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
447
                allUser.Selected = true;
448

    
449
                //난이도
450
                if (this.radDropDownListJobLevel.Items.Count > 0)
451
                    this.radDropDownListJobLevel.Items.Clear();
452
                informations.JobLevel.ForEach(x =>
453
                {
454
                    this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
455
                });
456
                var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
457
                this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
458
                allJobLevel.Selected = true;
459

    
460
                //도면번호 조회조건
461
                this.radTextBoxDocumentNo.Text = string.Empty;
462
                #endregion
463

    
464
                #region 검토
465
                //문의(DOF)
466
                if (this.radDropDownListToIsDiscussion.Items.Count > 0)
467
                    this.radDropDownListToIsDiscussion.Items.Clear();
468
                informations.IsYesNo.ForEach(x =>
469
               {
470
                   this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
471
               });
472
                var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
473
                this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
474
                allToIsDiscussion.Selected = true;
475

    
476
                //회신(DS)
477
                if (this.radDropDownListFrReviewStatus.Items.Count > 0)
478
                    this.radDropDownListFrReviewStatus.Items.Clear();
479
                informations.ClientStatus.ForEach(x =>
480
                {
481
                    this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
482
                });
483
                var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
484
                this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
485
                allFrReviewStatus.Selected = true;
486

    
487
                //ID2 작업가능
488
                if (this.radDropDownListIsID2Work.Items.Count > 0)
489
                    this.radDropDownListIsID2Work.Items.Clear();
490
                informations.IsYesNo.ForEach(x =>
491
                {
492
                    var item = new RadListDataItem(x, x);
493
                    if (x.Equals("Yes"))
494
                        item.Selected = true;
495
                    this.radDropDownListIsID2Work.Items.Add(item);
496

    
497
                });
498
                var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty);
499
                this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work);
500
                #endregion
501

    
502
                #region 작업
503
                //ID2 Status
504
                if (this.radDropDownListID2Status.Items.Count > 0)
505
                    this.radDropDownListID2Status.Items.Clear();
506
                informations.JobStatus.ForEach(x =>
507
                {
508
                    this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
509
                });
510
                var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
511
                this.radDropDownListID2Status.Items.Insert(0, allID2Status);
512
                allID2Status.Selected = true;
513

    
514
                //AVEVA Status
515
                if (this.radDropDownListAVEVAStatus.Items.Count > 0)
516
                    this.radDropDownListAVEVAStatus.Items.Clear();
517
                informations.JobStatus.ForEach(x =>
518
                {
519
                    this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
520
                });
521
                var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
522
                this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
523
                allAVEVAStatus.Selected = true;
524
                #endregion
525

    
526
                #region 검수
527
                //도프텍 결과
528
                if (this.radDropDownListProdIsResult.Items.Count > 0)
529
                    this.radDropDownListProdIsResult.Items.Clear();
530
                informations.ValidationResult.ForEach(x =>
531
                {
532
                    this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
533
                });
534
                var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
535
                this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
536
                allProdIsResult.Selected = true;
537

    
538
                //삼성 결과
539
                if (this.radDropDownListClientIsResult.Items.Count > 0)
540
                    this.radDropDownListClientIsResult.Items.Clear();
541
                informations.ValidationResult.ForEach(x =>
542
                {
543
                    this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
544
                });
545
                var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
546
                this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
547
                allClientIsResult.Selected = true;
548
                #endregion
549

    
550
                #region AVEVA
551
                //Gateway
552
                if (this.radDropDownListGateway.Items.Count > 0)
553
                    this.radDropDownListGateway.Items.Clear();
554
                informations.IsSuccess.ForEach(x =>
555
                {
556
                    this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x));
557
                });
558
                var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty);
559
                this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay);
560
                allDTIsGateWay.Selected = true;
561

    
562
                //Registration
563
                if (this.radDropDownListRegistration.Items.Count > 0)
564
                    this.radDropDownListRegistration.Items.Clear();
565
                informations.IsSuccess.ForEach(x =>
566
                {
567
                    this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x));
568
                });
569
                var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty);
570
                this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem);
571
                allDTIsRegSystem.Selected = true;
572
                #endregion
573

    
574
                this.GetDocList();
575
            }
576
            catch (Exception ex)
577
            {
578
                throw ex;
579
            }
580
            finally
581
            {
582

    
583
                this.Cursor = Cursors.Default;
584

    
585
            }
586

    
587
        }
588

    
589
        #region Document List 조회
590
        public void GetDocList()
591
        {
592
            try
593
            {
594
                if (this.radDropDownListProject.SelectedValue != null)
595
                {
596
                    string projectCode = this.radDropDownListProject.SelectedValue.ToString();
597
                    string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
598
                    string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
599
                    string documentNo = this.radTextBoxDocumentNo.Text.Trim();
600

    
601
                    string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
602
                    string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
603
                    string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();
604

    
605
                    string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
606
                    string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
607

    
608
                    string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
609
                    string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
610

    
611
                    string isGateWay = this.radDropDownListGateway.SelectedValue.ToString();
612
                    string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString();
613

    
614
                    var worker = new LoadDocumentsWorker(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments);
615
                    worker.OnWorkCompletedHandler += (e) =>
616
                    {
617
                        var docData = e.Result as DocumentsResult;
618

    
619
                        this.documents = docData.Dwgs;
620
                        this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
621
                        this.TotalCount = docData.TotalCount;
622

    
623
                        List<string> projectCodes = new List<string>();
624

    
625
                        if (!string.IsNullOrWhiteSpace(projectCode))
626
                        {
627
                            projectCodes.Add(projectCode);
628
                        }
629
                        else
630
                        {
631
                            projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
632
                        }
633

    
634
                        this.DocumentListBinding();
635
                    };
636
                    worker.StartWork();
637
                }
638
            }
639
            catch (Exception ex)
640
            {
641
                throw ex;
642
            }
643
        }
644

    
645
        public void DocumentListBinding()
646
        {
647
            try
648
            {
649
                GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
650
                ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
651
                ColProjects.DisplayMember = "Name";
652
                ColProjects.ValueMember = "Code";
653

    
654
                var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID));
655
                var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID));
656

    
657
                GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
658
                ColPersonInCharge.DataSource = workUsers;
659
                ColPersonInCharge.DisplayMember = "Name";
660
                ColPersonInCharge.ValueMember = "ID";
661

    
662
                GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
663
                ColWorker.DataSource = workUsers;
664
                ColWorker.DisplayMember = "Name";
665
                ColWorker.ValueMember = "ID";
666

    
667
                GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
668
                ColToCreator.DataSource = workUsers;
669
                ColToCreator.DisplayMember = "Name";
670
                ColToCreator.ValueMember = "ID";
671

    
672
                GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
673
                ColFrCreator.DataSource = clientUsers;
674
                ColFrCreator.DisplayMember = "Name";
675
                ColFrCreator.ValueMember = "ID";
676

    
677
                GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
678
                ColProdReviewer.DataSource = workUsers;
679
                ColProdReviewer.DisplayMember = "Name";
680
                ColProdReviewer.ValueMember = "ID";
681

    
682
                GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
683
                ColClientReviewer.DataSource = clientUsers;
684
                ColClientReviewer.DisplayMember = "Name";
685
                ColClientReviewer.ValueMember = "ID";
686

    
687
                //Data
688
                if (this.radGridViewDocuments.DataSource != null)
689
                    this.radGridViewDocuments.DataSource = null;
690

    
691
                /*
692
                var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info;
693
                var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info);
694
                var test = from doc in this.documents
695
                           join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj
696
                           from docs in gj.DefaultIfEmpty()
697
                           select new Documents()
698
                           {
699
                               DocumentNo = doc.DocumentNo,
700
                               ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME)
701
                               //ProdRemarks = docs.DATETIME ?? null
702
                           };
703
                */
704

    
705
                this.radGridViewDocuments.FilterDescriptors.Clear();
706
                this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
707
                this.lbSelectAndTotal.Text = $"{this.documents.Count} / {this.TotalCount} (Selected / Total)";
708
            }
709
            catch (Exception ex)
710
            {
711
                throw ex;
712
            }
713
        }
714
        #endregion
715

    
716
        #region Button, Checkbox event
717
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
718
        {
719
            if (sender is RadCheckBox)
720
            {
721
                RadCheckBox checkBox = sender as RadCheckBox;
722

    
723
                if (checkBox.Tag != null)
724
                {
725
                    ColumnGroupsViewDefinition columnGroupsView =  this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
726
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
727
                    if (colGroup != null)
728
                        colGroup.IsVisible = checkBox.Checked;
729
                }
730
            }
731

    
732
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
733
        }
734

    
735
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
736
        {
737
            if (e.KeyCode == Keys.Enter)
738
            {
739
                this.radButtonSearch.Focus();
740
                this.radButtonSearch.PerformClick();
741
            }
742
        }
743

    
744
        private void RadButtonSearch_Click(object sender, EventArgs e)
745
        {
746
            try
747
            {
748
                this.GetDocList();
749
            }
750
            catch (Exception ex)
751
            {
752
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
753
                RadMessageBox.Show("DWG search failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
754
            }
755
        }
756

    
757
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
758
        {
759
            using (var frm = new SetupUser())
760
            {
761
                if (frm.ShowDialog(this) == DialogResult.OK)
762
                {
763
                    
764
                }
765
            }
766
        }
767

    
768
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
769
        {
770
            Application.Exit();
771
        }
772
        #endregion
773

    
774
        #region Grid event
775
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
776
        {
777
            if (e.Row is GridViewNewRowInfo)
778
            {
779
                
780
            }
781
            else
782
            {
783
                string extension = string.Empty;
784

    
785
                switch (e.Column.Name)
786
                {
787
                    case "MarkupLink":
788
                        {
789
                            if (e.Row.DataBoundItem is Documents doc)
790
                            {
791
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID))
792
                                {
793
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID);
794
                                }
795
                            }
796
                        }
797
                        break;
798
                    case "AVEVALink":
799
                    case "AVEVAConnection":
800
                        MessageBox.Show($"{e.Column.Name} 실행");
801
                        break;
802
                    case "ReviewFileName"://일단주석
803
                        MessageBox.Show($"{e.Column.Name} 실행");
804
                        break;
805
                    case "SystemLink":
806
                        MessageBox.Show($"{e.Column.Name} 실행");
807
                        break;
808
                    case "ToCapture":
809
                        {
810
                            if (e.Row.DataBoundItem is Documents dd)
811
                            {
812
                                using (var frm = new ImageView(dd.DocID, "toreview"))
813
                                {
814
                                    frm.ShowDialog(this);
815
                                }
816
                            }
817
                        }
818
                        break;
819
                    case "FrCapture":
820
                        {
821
                            if (e.Row.DataBoundItem is Documents dd)
822
                            {
823
                                using (var frm = new ImageView(dd.DocID, "frreview"))
824
                                {
825
                                    frm.ShowDialog(this);
826
                                }
827
                            }
828
                        }
829
                        break;
830
                    case "ID2Connection":
831
                        try
832
                        {
833
                            if (e.Row.DataBoundItem is Documents doc)
834
                            {
835
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port);
836

    
837
                                try
838
                                {
839
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
840
                                    {
841
                                        DocID = doc.DocID,
842
                                        ID2StartDate = DateTime.Now,
843
                                        Worker = informations.ActiveUser.ID
844
                                    }, informations.ActiveUser.ID);
845

    
846
                                    if (returnDoc != null)
847
                                    {
848
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
849
                                        doc.Worker = returnDoc.Worker;
850
                                        doc.ID2JobTime = returnDoc.ID2JobTime;
851
                                    }
852
                                }
853
                                catch { }
854
                            }
855
                        }
856
                        catch (Exception ex)
857
                        {
858
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
859
                        }
860
                        break;
861
                }
862
            }
863
        }
864

    
865
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
866
        {
867
            if (e.ActiveEditor is RadDropDownListEditor)
868
            {
869
                switch (e.Column.Name)
870
                {
871
                    case "JobLevel":
872
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
873
                        colJobLevel.DataSource = informations.JobLevel;
874
                        break;
875
                    case "IsTypical":
876
                    case "ToIsDiscussion":
877
                    case "ToIsMarkup":
878
                    case "FrIsMarkup":
879
                    case "IsID2Work":
880
                    case "DTIsImport":
881
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
882
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
883
                        break;
884
                    case "DTIsGateWay":
885
                    case "DTIsRegSystem":
886
                        GridViewComboBoxColumn colSuccess = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
887
                        colSuccess.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsSuccess);
888
                        break;
889
                    case "ID2Status":
890
                    case "AVEVAStatus":
891
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
892
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
893
                        break;
894
                    case "FrReviewStatus"://삼성의견status
895
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
896
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
897
                        break;
898
                    case "ProdIsResult":
899
                    case "ClientIsResult":
900
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
901
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
902
                        break;
903
                }
904
            }
905
        }
906

    
907
        private void RadGridViewDocuments_CreateRow(object sender, GridViewCreateRowEventArgs e)
908
        {
909
            if (e.RowType == typeof(GridDetailViewRowElement))
910
            {
911
                //if (e.RowInfo.ChildRows.Count() > 0)
912
                //{
913
                    e.RowElement = new RowDetailViewRowElement();
914
                
915
                //}
916
                //else
917
                //{
918
                //    e.RowElement = null;
919
                //}
920
            }
921
        }
922

    
923

    
924
        private void RadGridViewDocuments_CreateCell1(object sender, GridViewCreateCellEventArgs e)
925
        {
926
            if (e.CellType == typeof(GridDetailViewCellElement))
927
            {
928
                //if (e.Row.RowInfo.ChildRows.Count() > 0)
929
                //{
930
                e.CellElement = new MarkupDetailCellElement(e.Column, e.Row);
931
                //}
932
            }
933
        }
934

    
935

    
936
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
937
        {
938
            if (e.Row is GridViewDataRowInfo)
939
            {
940
                if (e.CellElement is GridRowHeaderCellElement)
941
                {
942
                   // if (e.CellElement.RowIndex > -1)
943
                  //      e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
944
                }
945
                else
946
                {
947
                    var result = e.Row.DataBoundItem as Documents;
948
                    if (result != null || e.Row is GridViewNewRowInfo)
949
                    {
950
                        switch (e.CellElement.ColumnInfo.Name)
951
                        {
952
                            case "AutoCADLink":
953
                            case "PDFLink":
954
                            case "MarkupLink":
955
                            case "AVEVALink":
956
                            case "AVEVAConnection":
957
                            case "ReviewFileName"://일단주석
958
                            case "SystemLink":
959
                            case "ToCapture":
960
                            case "FrCapture":
961
                            case "ID2Connection":
962
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name);
963
                                break;
964
                        }
965
                    }
966
                    else
967
                    {
968

    
969
                    }
970
                }
971
            }
972
            //else if (e.Row is GridViewSummaryRowInfo)
973
            //{
974
            //    if (e.CellElement is GridRowHeaderCellElement)
975
            //    {
976
            //        e.CellElement.Text = "Count";
977
            //    }
978
            //    else if (e.CellElement is GridSummaryCellElement)
979
            //    {
980
            //        e.CellElement.ForeColor = this._SummaryColor;
981
            //        e.CellElement.TextAlignment = ContentAlignment.BottomRight;
982
            //        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
983
            //    }
984
            //    else
985
            //    {
986

    
987
            //    }
988
            //}
989
            else if(e.Row is GridViewDetailsRowInfo)
990
            {
991
                if(e.CellElement is MarkupDetailCellElement element)
992
                {
993
                    //element.UpdateInfo();
994
                }
995
            }
996
            else
997
            {
998

    
999
            }
1000
        }
1001

    
1002
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName)
1003
        {
1004
            RadButtonElement btnElem = null;
1005
            Bitmap bitmap = null; ;
1006

    
1007
            switch (colName)
1008
            {
1009
                case "AutoCADLink":
1010
                    bitmap = new Bitmap(Properties.Resources.cad18);
1011
                    break;
1012
                case "PDFLink":
1013
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1014
                    break;
1015
                case "MarkupLink":
1016
                    bitmap = new Bitmap(Properties.Resources.markus18);
1017
                    break;
1018
                case "AVEVALink":
1019
                case "AVEVAConnection":
1020
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
1021
                    break;
1022
                case "ReviewFileName"://일단주석
1023
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1024
                    break;
1025
                case "SystemLink":
1026
                    bitmap = new Bitmap(Properties.Resources.link18_yellow);
1027
                    break;
1028
                case "ToCapture":
1029
                case "FrCapture":
1030
                    bitmap = new Bitmap(Properties.Resources.files18);
1031
                    break;
1032
                case "ID2Connection":
1033
                    bitmap = new Bitmap(Properties.Resources.id218);
1034
                    break;
1035
            }
1036

    
1037
            switch (colName)
1038
            {
1039
                case "AutoCADLink":
1040
                case "PDFLink":
1041
                case "MarkupLink":
1042
                case "AVEVALink":
1043
                case "AVEVAConnection":
1044
                case "ReviewFileName"://일단주석
1045
                case "SystemLink":
1046
                case "ToCapture":
1047
                case "FrCapture":
1048
                case "ID2Connection":
1049
                    btnElem = (RadButtonElement)elem;
1050
                    btnElem.Margin = new Padding(0);
1051
                    btnElem.Padding = new Padding(0);
1052
                    btnElem.BorderElement.Opacity = 0;
1053
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
1054
                    btnElem.DisplayStyle = DisplayStyle.Image;
1055
                    btnElem.Image = bitmap;
1056
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
1057
                    btnElem.MaxSize = bitmap.Size;
1058
                    break;
1059
            }
1060

    
1061
            return btnElem;
1062
        }
1063

    
1064
        private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
1065
        {
1066
            this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)";
1067
        }
1068
        #endregion
1069

    
1070
        #region Excel
1071
        private UserInfo GetUser(string user)
1072
        {
1073
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
1074
            if (userInfo != null) return userInfo;
1075

    
1076
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
1077
            if (userInfo != null) return userInfo;
1078

    
1079
            return userInfo ?? new UserInfo();
1080
        }
1081

    
1082
        private ProjectInfo GetProject(string project)
1083
        {
1084
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault();
1085
            if (prjInfo != null) return prjInfo;
1086

    
1087
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
1088
            if (prjInfo != null) return prjInfo;
1089

    
1090
            return prjInfo ?? new ProjectInfo();
1091
        }
1092

    
1093
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
1094
        {
1095
            var form =  new Forms.SelectExcelData();
1096

    
1097
            var dialogResult = form.ShowDialog();
1098

    
1099
            if (dialogResult == DialogResult.OK)
1100
            {
1101
                using (ID2Excel excel = new ID2Excel())
1102
                {
1103
                    var result = excel.ExcelDataImport(form.SelectItems);
1104

    
1105
                    if (result.Error != null)
1106
                    {
1107

    
1108
                        RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1109
                    }
1110
                    else
1111
                    {
1112
                        this.importImages = result.Images;
1113
                        this.documents.AddRange(result.documents);
1114
                        if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1115
                        this.DocumentListBinding();
1116
                        briefAndImagesReview.SetImages(this.importImages);
1117
                    }
1118

    
1119
                }
1120
            }
1121
        }
1122

    
1123
        private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e)
1124
        {
1125
            using (OpenFileDialog ofd = new OpenFileDialog()
1126
            {
1127
                Filter = "Excel files (*.xlsx)|*.xlsx",
1128
                Title = "Open an Excel File",
1129
                RestoreDirectory = true
1130
            })
1131
            {
1132
                if (ofd.ShowDialog() == DialogResult.OK)
1133
                {
1134
                    //Error Message
1135
                    StringBuilder sbErrMsg = new StringBuilder();
1136

    
1137
                    using(ID2Excel excel = new ID2Excel())
1138
                    {
1139
                       var result = excel.GemboxImport(ofd.FileName);
1140

    
1141
                        if(result.Error != null)
1142
                        {
1143

    
1144
                            RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1145
                        }
1146
                        else
1147
                        {
1148
                            this.documents.AddRange(result.documents);
1149
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1150
                            this.DocumentListBinding();
1151
                        }
1152

    
1153
                    }
1154

    
1155

    
1156
                    //foreach (Documents appDoc in appendDocuments)
1157
                    //{
1158
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1159

    
1160
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1161
                    //    {
1162
                    //        if (fieldInfo.GetValue(appDoc) != null)
1163
                    //        {
1164
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1165

    
1166
                    //            if (cols.Any())
1167
                    //            {
1168
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1169
                    //            }
1170
                    //        }
1171
                    //    }
1172
                    //}
1173
                }
1174
            }
1175
        }
1176

    
1177
        private void RadButtonElementExcelImport_Click_old(object sender, EventArgs e)
1178
        {
1179
            using (OpenFileDialog ofd = new OpenFileDialog()
1180
            {
1181
                Filter = "Excel files (*.xlsx)|*.xlsx",
1182
                Title = "Open an Excel File",
1183
                RestoreDirectory = true
1184
            })
1185
            {
1186
                if (ofd.ShowDialog() == DialogResult.OK)
1187
                {
1188
                    //Error Message
1189
                    StringBuilder sbErrMsg = new StringBuilder();
1190

    
1191
                    var exFile = ExcelFile.Load(ofd.FileName);
1192
                    var ws = exFile.Worksheets[0];
1193

    
1194
                    int rowCount = ws.Rows.Count;
1195
                    int columnCount = ws.CalculateMaxUsedColumns();
1196
                    int exRow = 8;
1197

    
1198
                    #region Excel 유효성검사
1199

    
1200
                    //Excel 포멧체크
1201
                    if (rowCount < 10 || columnCount != 45)
1202
                    {
1203
                        RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1204
                        return;
1205
                    }
1206

    
1207
                    #region 엑셀 필수값 체크(도면 : 이름,담당자, 난이도, Typical)
1208
                    ws.Rows.SelectMany(row => row.AllocatedCells)
1209
                           .Where(col => col.Column.Index > 5 && col.Column.Index < 10 && col.Row.Index > exRow && col.Value == null)
1210
                           .ToList()
1211
                           .ForEach(p => sbErrMsg.Append(", " + p.Column.Name + p.Row.Name));
1212

    
1213
                    if (sbErrMsg.Length > 0)
1214
                    {
1215
                        string errMsg = sbErrMsg.ToString().Substring(2);
1216
                        if (errMsg.Length > 100)
1217
                        {
1218
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1219
                        }
1220

    
1221
                        RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1222
                        return;
1223
                    }
1224
                    #endregion
1225

    
1226
                    #region 엑셀 도명명 중복 값 체크
1227
                    ws.Rows.SelectMany(row => row.AllocatedCells)
1228
                                                 .Where(col => col.Column.Index == 6 && col.Row.Index > exRow)
1229
                                                 .GroupBy(g => g.Row.Index)
1230
                                                 .Select(p => new {
1231
                                                     rowIndex = p.Key,
1232
                                                     docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
1233
                                                 })
1234
                                                 .GroupBy(g => g.docNo)
1235
                                                 .Where(p => p.Count() > 1)
1236
                                                 .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
1237
                                                                                            .Aggregate((x, y) => x.ToString() + "," + y.ToString())
1238
                                                                                            .ToString())
1239
                                                 .ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
1240
                    if (sbErrMsg.Length > 0)
1241
                    {
1242
                        sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
1243
                        string errMsg = sbErrMsg.ToString();
1244
                        if (errMsg.Length > 100)
1245
                        {
1246
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1247
                        }
1248

    
1249
                        RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1250
                        return;
1251
                    }
1252
                    #endregion
1253

    
1254
                    #endregion
1255

    
1256
                    List<Documents> appendDocuments = new List<Documents>();
1257

    
1258
                    ws.Rows.Where(row => row.Index > exRow)
1259
                           .ToList()
1260
                           .ForEach(p => appendDocuments.Add(new Documents()
1261
                           {
1262
                               //UID = string.Empty,
1263
                               //Type = this.radTextBoxInsulationType.Text,
1264
                               //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
1265
                               //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
1266
                               //NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
1267
                               //Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value)
1268

    
1269
                               RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1270
                               DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
1271
                               PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
1272
                               JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
1273
                               IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
1274
                               RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
1275
                               ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
1276
                               ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
1277
                               ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
1278
                               //ToCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1279
                               //ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1280
                               FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
1281
                               FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
1282
                               FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
1283
                               //FrCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1284
                               //FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1285
                               IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
1286
                               //ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1287
                               ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
1288
                               ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
1289
                               //ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1290
                               ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
1291
                               ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
1292
                               //AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1293
                               AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
1294
                               AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
1295
                               AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
1296
                               AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
1297
                               ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
1298
                               ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
1299
                               ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
1300
                               ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
1301
                               ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
1302
                               ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
1303
                               DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
1304
                               DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
1305
                               DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
1306
                               DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
1307
                           }));
1308

    
1309
                    this.documents.AddRange(appendDocuments);
1310
                    if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1311
                    this.DocumentListBinding();
1312

    
1313
                    //foreach (Documents appDoc in appendDocuments)
1314
                    //{
1315
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1316

    
1317
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1318
                    //    {
1319
                    //        if (fieldInfo.GetValue(appDoc) != null)
1320
                    //        {
1321
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1322

    
1323
                    //            if (cols.Any())
1324
                    //            {
1325
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1326
                    //            }
1327
                    //        }
1328
                    //    }
1329
                    //}
1330
                }
1331
            }
1332
        }
1333

    
1334
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
1335
        {
1336
            string sPrefixName = "Samsung Elec Task Management";
1337
            string extension = ".xlsx";
1338

    
1339
            using (SaveFileDialog sfd = new SaveFileDialog()
1340
            {
1341
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
1342
                Filter = "Excel|*.xlsx",
1343
                Title = "Save an Excel File",
1344
                CheckFileExists = false,
1345
                CheckPathExists = true,
1346
                OverwritePrompt = true
1347
            })
1348
            {
1349
                if (sfd.ShowDialog() == DialogResult.OK)
1350
                {
1351
                    string fileName = $"{sPrefixName}{extension}";
1352
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
1353
                    string templateFilePath = Path.Combine(templateFolder, fileName);
1354
                    if (!File.Exists(templateFilePath))
1355
                    {
1356
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1357
                        return;
1358
                    }
1359

    
1360
                    if (this.radGridViewDocuments.Rows.Count > 0)
1361
                    {
1362
                        var templateExcelFile = ExcelFile.Load(templateFilePath);
1363
                        var templateWorksheets = templateExcelFile.Worksheets;
1364
                        var templateWorksheet = templateWorksheets[0];
1365

    
1366
                        int rowIndex = 9;
1367
                        //int colIndex = 1;
1368

    
1369
                        foreach (var row in this.radGridViewDocuments.Rows)
1370
                        {
1371
                            var doc = row.DataBoundItem as Documents;
1372

    
1373
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
1374
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
1375
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
1376
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
1377
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
1378
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
1379
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
1380
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
1381
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
1382
                            templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
1383
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
1384
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
1385
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
1386
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
1387
                            templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture;
1388
                            templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
1389
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
1390
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
1391
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
1392
                            templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture;
1393
                            templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
1394
                            templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
1395
                            templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
1396
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
1397
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
1398
                            templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
1399
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
1400
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
1401
                            templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
1402
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
1403
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
1404
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
1405
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
1406
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
1407
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
1408
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
1409
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
1410
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
1411
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
1412
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
1413
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
1414
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
1415
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
1416
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
1417
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
1418
                            rowIndex++;
1419
                        }
1420

    
1421
                        templateExcelFile.Save(sfd.FileName);
1422
                        RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1423
                    }
1424
                }
1425
            }
1426
        }
1427
        #endregion
1428

    
1429
        #region Save event
1430

    
1431
        private void SetSaved()
1432
        {
1433
            try
1434
            {
1435
                if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1436
                {
1437
                    var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments);
1438
                    worker.OnWorkCompletedHandler += (e) =>
1439
                    {
1440
                        bool result = (bool)e.Result;
1441

    
1442
                        bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1443

    
1444
                        bool markusMembersResult = new MarkusInfoController().SetMembers(informations.UserList);
1445

    
1446
                        if (result && markusResult && markusMembersResult)
1447
                        {
1448
                            RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1449

    
1450
                            this.GetDocList();
1451
                        }
1452
                        else if (!result)
1453
                        {
1454
                            RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1455
                        }
1456
                        else if (!markusResult)
1457
                        {
1458
                            RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1459
                        }
1460
                        else if (!markusMembersResult)
1461
                        {
1462
                            RadMessageBox.Show("Markus Members Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1463
                        }
1464
                    };
1465
                    worker.StartWork();
1466
                }
1467
            }
1468
            catch (Exception ex)
1469
            {
1470
                throw ex;
1471
            }
1472
        }
1473

    
1474
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
1475
        {
1476
            try
1477
            {
1478
                this.SetSaved();
1479
            }
1480
            catch (Exception ex)
1481
            {
1482
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1483
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1484
            }
1485
        }
1486

    
1487
        private void RadButtonElementSave_Click(object sender, EventArgs e)
1488
        {
1489
            try
1490
            {
1491
                this.SetSaved();
1492
            }
1493
            catch (Exception ex)
1494
            {
1495
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1496
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1497
            }
1498
        }
1499

    
1500
        private void RadButtonElementSync_Click(object sender, EventArgs e)
1501
        {
1502
            try
1503
            {
1504
                if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1505
                {
1506
                    var worker = new SyncDocumentsWorker(this.radGridViewDocuments);
1507
                    worker.OnWorkCompletedHandler += (arg) =>
1508
                    {
1509
                        if ((bool)arg.Result)
1510
                        {
1511
                            this.GetDocList();
1512

    
1513
                            RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1514
                        }
1515
                    };
1516
                    worker.StartWork();
1517
                }
1518
            }
1519
            catch (Exception ex)
1520
            {
1521
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1522
                RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1523
            }
1524
        }
1525

    
1526
        private void RadButtonElementNotice_Click(object sender, EventArgs e)
1527
        {
1528
            try
1529
            {
1530
                AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProject.ProjectID, "notice");
1531

    
1532
                if (notiFileInfo == null)
1533
                {
1534
                    RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1535
                }
1536
                else
1537
                {
1538
                    string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles");
1539
                    string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}");
1540

    
1541
                    System.IO.FileInfo finfo = new System.IO.FileInfo(noticeFileFullName);
1542

    
1543
                    if (!finfo.Directory.Exists)
1544
                    {
1545
                        Directory.CreateDirectory(noticePath);
1546
                    }
1547

    
1548
                    if (!finfo.Exists)
1549
                    {
1550
                        var arrayBinary = notiFileInfo.FileData.ToArray();
1551

    
1552
                        using (MemoryStream ms = new MemoryStream(arrayBinary))
1553
                        {
1554
                            ms.Write(arrayBinary, 0, arrayBinary.Length);
1555
                            ms.Seek(0, SeekOrigin.Begin);
1556

    
1557
                            using (FileStream fs = finfo.Create())
1558
                            {
1559
                                ms.CopyTo(fs);
1560
                            }
1561
                        }
1562
                    }
1563

    
1564
                    try
1565
                    {
1566
                        ProcessStartInfo startInfo = new ProcessStartInfo
1567
                        {
1568
                            FileName = finfo.FullName,
1569
                            UseShellExecute = true,
1570
                            CreateNoWindow = false,
1571
                            WindowStyle = ProcessWindowStyle.Normal
1572
                        };
1573

    
1574
                        using (Process process = new Process())
1575
                        {
1576
                            process.StartInfo = startInfo;
1577
                            process.Start();
1578
                        }
1579
                        //Process.Start(finfo.FullName);
1580
                    }
1581
                    catch (Exception ex)
1582
                    {
1583
                        throw ex;
1584
                    }
1585

    
1586
                    //using (MemoryStream ms = new MemoryStream(arrayBinary))
1587
                    //{
1588
                    //    ProcessStartInfo startInfo = new ProcessStartInfo
1589
                    //    {
1590
                    //        FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName),
1591
                    //        RedirectStandardInput = true,
1592
                    //        UseShellExecute = false,
1593
                    //        CreateNoWindow = true,
1594
                    //        WindowStyle = ProcessWindowStyle.Hidden
1595
                    //    };
1596

    
1597
                    //    using (Process process = new Process())
1598
                    //    {
1599
                    //        process.StartInfo = startInfo;
1600
                    //        process.Start();
1601

    
1602
                    //        // Write the memory stream contents to the process standard input
1603
                    //        byte[] buffer = ms.ToArray();
1604
                    //        process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length);
1605
                    //        process.StandardInput.Close();
1606

    
1607
                    //        process.WaitForExit();
1608
                    //    }
1609
                    //}
1610
                }
1611
            }
1612
            catch (Exception ex)
1613
            {
1614
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1615
                RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1616
            }
1617
        }
1618

    
1619
        private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e)
1620
        {
1621
            string GetContentType(string filePath)
1622
            {
1623
                string extension = Path.GetExtension(filePath).ToLower();
1624

    
1625
                switch (extension)
1626
                {
1627
                    case ".txt":
1628
                        return "text/plain";
1629
                    case ".pdf":
1630
                        return "application/pdf";
1631
                    case ".jpg":
1632
                    case ".jpeg":
1633
                        return "image/jpeg";
1634
                    case ".png":
1635
                        return "image/png";
1636
                    default:
1637
                        return "application/octet-stream";
1638
                }
1639
            }
1640

    
1641
            using (OpenFileDialog ofd = new OpenFileDialog()
1642
            {
1643
                Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*",
1644
                //Title = "Open an Excel File",
1645
                RestoreDirectory = true
1646
            })
1647
            {
1648
                try
1649
                {
1650
                    if (ofd.ShowDialog() == DialogResult.OK)
1651
                    {
1652
                        System.IO.FileInfo fileInfo = new System.IO.FileInfo(ofd.FileName);
1653
                        if (fileInfo.Exists)
1654
                        {
1655
                            AttFileInfo attFile = new AttFileInfo()
1656
                            {
1657
                                RefID = informations.ActiveProject.ProjectID,
1658
                                Category = "notice",
1659
                                FileType = GetContentType(fileInfo.FullName),
1660
                                FileName = fileInfo.Name,
1661
                                FilePath = fileInfo.DirectoryName,
1662
                                FileExtension = fileInfo.Extension
1663
                            };
1664

    
1665
                            using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
1666
                            {
1667
                                using (var reader = new BinaryReader(stream))
1668
                                {
1669
                                    attFile.FileData = reader.ReadBytes((int)stream.Length);
1670
                                }
1671
                            }
1672

    
1673
                            bool result = new AttFileController().SetAttFiles(new List<AttFileInfo>() { attFile }, informations.ActiveUser.ID);
1674

    
1675
                            if (result)
1676
                            {
1677
                                RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1678
                            }
1679
                        }
1680
                    }
1681
                }
1682
                catch (Exception ex)
1683
                {
1684
                    Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1685
                    RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1686
                }
1687
            }
1688
        }
1689

    
1690
        private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e)
1691
        {
1692
            bool isReload = false;
1693

    
1694
            try
1695
            {
1696
                if (RadMessageBox.Show($"Do you want to reload the project?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1697
                {
1698
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
1699
                    {
1700
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
1701
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1702

    
1703
                        isReload = true;
1704
                    }
1705
                    else if (informations.ActiveProject != null)
1706
                    {
1707
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1708

    
1709
                        isReload = true;
1710
                    }
1711
                    else
1712
                    {
1713
                        RadMessageBox.Show("Select a project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1714
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
1715
                    }
1716
                }
1717

    
1718
                if (isReload)
1719
                {
1720
                    this.LoadProject();
1721
                }
1722
            }
1723
            catch (Exception ex)
1724
            {
1725
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1726
                RadMessageBox.Show("Failed to reload the project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1727
            }
1728
        }
1729
        #endregion
1730

    
1731
        #region ColumnGroup
1732
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
1733
        {
1734
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
1735

    
1736
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" };
1737
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "DocumentNo", "PersonInCharge", "Worker", "JobLevel", "IsTypical", "RevisonNo" };
1738
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture", "ToIsMarkup" };
1739
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture", "FrIsMarkup" };
1740
            List<string> rvEtcColNames = new List<string>() { "IsID2Work" };
1741
            List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" };
1742
            List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" };
1743
            List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" };
1744
            List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks" };
1745
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" };
1746
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
1747

    
1748
            //도면
1749
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 ");
1750
            GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크");
1751
            GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보");
1752

    
1753
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
1754
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
1755

    
1756
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
1757
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
1758

    
1759
            docLinkColGrp.Rows.Add(docLinkColGrpRow);
1760
            docColGrp.Groups.Add(docLinkColGrp);
1761
            docInfoColGrp.Rows.Add(docInfoColGrpRow);
1762
            docColGrp.Groups.Add(docInfoColGrp);
1763

    
1764
            //검토
1765
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
1766
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
1767
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
1768
            GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타");
1769

    
1770
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
1771
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
1772

    
1773
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
1774
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
1775

    
1776
            GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow();
1777
            rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames);
1778

    
1779
            rvToColGrp.Rows.Add(rvToColGrpRow);
1780
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
1781
            rvEtcColGrp.Rows.Add(rvEtcColGrpRow);
1782

    
1783

    
1784
            rvColGrp.Groups.Add(rvToColGrp);
1785
            rvColGrp.Groups.Add(rvFrColGrp);
1786
            rvColGrp.Groups.Add(rvEtcColGrp);
1787

    
1788

    
1789
            //작업
1790
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
1791
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
1792
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
1793

    
1794
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
1795
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
1796

    
1797
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
1798
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
1799

    
1800
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
1801
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
1802

    
1803
            wkColGrp.Groups.Add(wkID2ColGrp);
1804
            wkColGrp.Groups.Add(wkAVEVAColGrp);
1805

    
1806

    
1807
            //Validation
1808
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
1809
            GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크");
1810
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
1811
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
1812

    
1813
            GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow();
1814
            valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames);
1815

    
1816
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
1817
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
1818

    
1819
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
1820
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
1821

    
1822
            valLinkColGrp.Rows.Add(valLinkColGrpRow);
1823
            valProdColGrp.Rows.Add(valProdColGrpRow);
1824
            valCntColGrp.Rows.Add(valCntColGrpRow);
1825

    
1826
            valColGrp.Groups.Add(valLinkColGrp);
1827
            valColGrp.Groups.Add(valProdColGrp);
1828
            valColGrp.Groups.Add(valCntColGrp);
1829

    
1830
            //AVEVA Net
1831
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
1832

    
1833
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
1834
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
1835

    
1836
            dtColGrp.Rows.Add(dtColGrpRow);
1837

    
1838
            //Group 추가
1839
            columnGroupsView.ColumnGroups.Add(docColGrp);
1840
            columnGroupsView.ColumnGroups.Add(rvColGrp);
1841
            columnGroupsView.ColumnGroups.Add(wkColGrp);
1842
            columnGroupsView.ColumnGroups.Add(valColGrp);
1843
            columnGroupsView.ColumnGroups.Add(dtColGrp);
1844

    
1845
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
1846
        }
1847
        #endregion
1848

    
1849
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
1850
        {
1851
            if(string.IsNullOrWhiteSpace(txtFullSearch.Text))
1852
                radGridViewDocuments.MasterTemplate.Refresh(null);
1853

    
1854
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
1855
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
1856
        }
1857

    
1858
        private void btnSearchPrevious_Click(object sender, EventArgs e)
1859
        {
1860
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
1861
        }
1862

    
1863
        private void btnSearchNext_Click(object sender, EventArgs e)
1864
        {
1865
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
1866
        }
1867

    
1868
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
1869
        {
1870
            if(e.KeyCode == Keys.Enter)
1871
            {
1872
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
1873
            }
1874
        }
1875
    }
1876
}
1877

    
1878
public class FilterColumn
1879
{
1880
    public string Name { get; set; }
1881
    public string FieldName { get; set; }
1882
    public bool IsSelect { get; set; }
1883
}
클립보드 이미지 추가 (최대 크기: 500 MB)