프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ 0fedddc3

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

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows.Forms;
10

    
11
using System.IO;
12
using System.Reflection;
13

    
14
using ID2.Manager.Controls;
15
using ID2.Manager.Common;
16
using ID2.Manager.Classes;
17
using ID2.Manager.Data.Models;
18
using ID2.Manager.Forms;
19
using ID2.Manager.Controller.Controllers;
20

    
21
using Telerik.WinControls;
22
using Telerik.WinControls.UI;
23
using Telerik.WinControls.Data;
24

    
25
using GemBox.Spreadsheet;
26

    
27
using Newtonsoft.Json;
28
using System.Diagnostics;
29
using ID2.Manager.Common.Helpers;
30

    
31
namespace ID2.Manager
32
{
33
    public partial class Main : RadRibbonForm
34
    {
35
        protected override CreateParams CreateParams
36
        {
37
            get
38
            {
39
                CreateParams cp = base.CreateParams;
40
                cp.ExStyle |= 0x02000000;
41
                return cp;
42
            }
43
        }
44

    
45
        private string dockLayoutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName,
46
         "dock.xml");
47

    
48
        readonly Informations informations = Informations.Instance;
49
        bool IsID2Manager = false;
50
        List<Documents> documents = new List<Documents>();
51
        List<System.Drawing.Image> importImages = new List<System.Drawing.Image>();
52

    
53
        List<Documents> orgDocuments = null;
54
        int TotalCount = 0;
55

    
56
        BriefAndImages briefAndImagesReview = new BriefAndImages { Dock = DockStyle.Fill };
57
        BriefAndImages briefAndImagesValidation = new BriefAndImages { Dock = DockStyle.Fill };
58

    
59
#if DEBUG
60
        Telerik.WinControls.RadControlSpy.RadControlSpyForm radControlSpyForm = new Telerik.WinControls.RadControlSpy.RadControlSpyForm();
61
#endif
62
        private readonly Color _SummaryColor = Color.FromArgb(255, 108, 55);
63

    
64
        public Main()
65
        {
66
            InitializeComponent();
67

    
68
            var appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName);
69

    
70
            if(!Directory.Exists(appDataPath))
71
            {
72
                Directory.CreateDirectory(appDataPath);
73
            }
74

    
75
            ID2.Manager.Common.Helpers.TableLayoutPanelHelper.SetDoubleBuffered(this);
76

    
77
            this.FormClosing += Main_FormClosing;
78
            this.radButtonElementRefreshCommand.Click += RadButtonElementRefreshCommand_Click;
79
            this.radButtonElementSaveCommand.Click += RadButtonElementSaveCommand_Click;
80
            this.btnDockLayoutReset.Click += BtnDockLayoutReset_Click;
81
            this.radButtonElementSave.Click += RadButtonElementSave_Click;
82
            this.radButtonElementSync.Click += RadButtonElementSync_Click;
83
            this.radButtonElementNotice.Click += RadButtonElementNotice_Click;
84
            this.radButtonElementNoticeUpload.Click += RadButtonElementNoticeUpload_Click;
85
            this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click;
86
            this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click;
87

    
88
            this.radCheckBox1.CheckStateChanged += RadCheckBox_CheckStateChanged;
89
            this.radCheckBox2.CheckStateChanged += RadCheckBox_CheckStateChanged;
90
            this.radCheckBox3.CheckStateChanged += RadCheckBox_CheckStateChanged;
91
            this.radCheckBox4.CheckStateChanged += RadCheckBox_CheckStateChanged;
92
            this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown;
93
            this.radButtonSearch.Click += RadButtonSearch_Click;
94

    
95
            this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged;
96
            this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting;
97
            this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo;
98
            this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit;
99
            this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick;
100
            this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
101
            this.radGridViewDocuments.FilterChanged += RadGridViewDocuments_FilterChanged;
102

    
103
            this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36;
104
            this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36;
105
            //this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ;
106
            this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false;
107

    
108
            var openProjectView = new OpenProjectView()
109
            {
110
                Dock = DockStyle.Fill
111
            };
112

    
113
            this.backstageViewPageOpenProject.Controls.Add(openProjectView);
114
            openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick;
115
            openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick;
116
            this.backstageButtonItemSelectDB.Click += BackstageButtonItemSelectDB_Click;
117
            this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click;
118
            this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click;
119
            this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened;
120
            this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed;
121

    
122
            this.InitColumnGroupsViewDefinition(this.radGridViewDocuments);
123

    
124
            this.radPageViewPageReview.Controls.Add(briefAndImagesReview);
125
            this.radPageViewPageValidation.Controls.Add(briefAndImagesValidation);
126

    
127
            briefAndImagesReview.RemoveImage += BriefAndImages_RemoveImage;
128
            briefAndImagesValidation.RemoveImage += BriefAndImages_RemoveImage;
129
            this.Initialize();
130
        }
131

    
132
        private void BtnDockLayoutReset_Click(object sender, EventArgs e)
133
        {
134
            this.LoadDockingLayout(true);
135
        }
136

    
137
        private void BriefAndImages_RemoveImage(object sender, AttImageInfo e)
138
        {
139
            try
140
            {
141

    
142
                if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
143
                {
144
                    var reslut = doc.AttFiles.RemoveAll(x => x.FileID == e.ID);
145

    
146
                    if (reslut > 0)
147
                    {
148

    
149
                    }
150
                    else
151
                    {
152
                        MessageBox.Show("삭제오류");
153
                    }
154
                }
155
            }
156
            catch (Exception ex)
157
            {
158
                Program.logger.Error("BriefAndImages_RemoveImage",ex);
159
            }
160
        }
161

    
162
        private void SaveDockingLayout()
163
        {
164
            try
165
            {
166
                this.DockMain.SaveToXml(dockLayoutPath);
167
            }
168
            catch (Exception ex)
169
            {
170
                System.Diagnostics.Debug.WriteLine("SaveDockingLayout Error.", ex);
171
            }
172
        }
173

    
174
        private void LoadDockingLayout(bool IsDefaultLayoutLoad = false)
175
        {
176
            try
177
            {
178
                bool IsUseLayoutLoad = false;
179

    
180
                try
181
                {
182
                    var dockLayoutFile = new FileInfo(dockLayoutPath);
183

    
184

    
185
                    if (!IsDefaultLayoutLoad && dockLayoutFile.Exists)
186
                    {
187
                        this.DockMain.LoadFromXml(dockLayoutPath);
188
                        IsUseLayoutLoad = true;
189
                    }
190

    
191
                }
192
                catch (Exception ex)
193
                {
194
                    Program.logger.Error($"dock Layout File load Error. File Path : {dockLayoutPath}", ex);
195
                }
196

    
197
                if(!IsUseLayoutLoad)
198
                {
199
                    var layout = Properties.Resources.DefalutDockLayout;
200

    
201
                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(layout)))
202
                    {
203
                        this.DockMain.LoadFromXml(stream);
204
                    }
205
                }
206

    
207
                this.DockMain.DocumentTabsVisible = true;
208

    
209
                this.DockMain.DockWindows.ForAll(x =>
210
                {
211
                    x.DockManager.ShowDocumentPinButton = false;
212
                    x.DockManager.ShowDocumentCloseButton = false;
213
                });
214

    
215
                this.DockMain.AutoHideWindowDisplaying += DockMain_AutoHideWindowDisplaying;
216
                
217
                this.DockMain.DockStateChanged+=(snd,evt)=>
218
                {
219
                    if (evt.DockWindow.Name == DockWindowMain.Name || evt.DockWindow.Name == DockValidation.Name)
220
                    {
221

    
222
                    }
223

    
224
                };
225

    
226
                this.DockMain.DockWindowClosed += (snd, evt) =>
227
                {
228
                    evt.DockWindow.DockState = Telerik.WinControls.UI.Docking.DockState.AutoHide;
229

    
230

    
231
                    Telerik.WinControls.UI.Docking.AutoHidePosition tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Right;
232

    
233
                    if (evt.DockWindow.Name == DockWindowMain.Name || evt.DockWindow.Name == DockValidation.Name)
234
                    {
235
                        tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Bottom;
236
                    }
237

    
238
                    this.DockMain.AutoHideWindows(new Telerik.WinControls.UI.Docking.DockWindow[] { evt.DockWindow }, tabPosition);
239
                };
240
            }
241
            catch (Exception ex)
242
            {
243
                Program.logger.Error($"dock Layout load Error. File Path : {dockLayoutPath}", ex);
244
            }
245
        }
246

    
247
        private void DockMain_AutoHideWindowDisplaying(object sender, Telerik.WinControls.UI.Docking.AutoHideWindowDisplayingEventArgs e)
248
        {
249

    
250
        }
251

    
252
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
253
        {
254
            SaveDockingLayout();
255
        }
256

    
257
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
258
        {
259
            if (keyData == (Keys.F10 | Keys.Control))
260
            {
261
#if DEBUG
262
                radControlSpyForm.Show();
263
#endif
264
            }
265

    
266
            if (keyData == (Keys.V | Keys.Control))
267
            {
268
                System.Diagnostics.Debug.WriteLine("KeyDown CTRL + V");
269
                
270
                if(Clipboard.ContainsImage())
271
                {
272
                    var IsDoftech = true;
273
                    var selectReview = true;
274
                    string category = "";
275
                    byte[] imageBytes = null;
276

    
277
                    Image clipboardImage = Clipboard.GetImage();
278

    
279
                    using (MemoryStream stream = new MemoryStream())
280
                    {
281
                        clipboardImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
282
                        imageBytes = stream.ToArray();
283
                    }
284

    
285
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
286
                    {
287

    
288
                        /// 도프텍 or 삼성
289
                        if (!string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
290
                        {
291
                            IsDoftech = false;
292
                        }
293

    
294
                        /// 검토 or 검증
295
                        if (radPageViewComment.SelectedPage != radPageViewPageReview)
296
                        {
297
                            selectReview = false;
298
                        }
299

    
300
                        if (IsDoftech && selectReview)
301
                        {
302
                            category = "toreview";
303
                        }
304
                        else if (!IsDoftech && selectReview)
305
                        {
306
                            category = "frreview";
307
                        }
308
                        else if (IsDoftech && !selectReview)
309
                        {
310
                            category = "prodvalidation";
311
                        }
312
                        else 
313
                        {
314
                            category = "clientvalidation";
315
                        }
316

    
317

    
318
                        AttFileInfo newFile = new AttFileInfo
319
                        {
320
                            FileID = Guid.NewGuid().ToString(),
321
                            Category = category,
322
                            FileType = "image/png",
323
                            FileName = "ClipBoard",
324
                            FilePath = "ClipBoard",
325
                            FileExtension = ".png",
326
                            CreatedDate = DateTime.Now,
327
                            Creator = informations.ActiveUser.ID,
328
                            FileData = imageBytes
329

    
330
                        };
331

    
332
                        if (doc.AttFiles == null)
333
                        {
334
                            doc.AttFiles = new List<AttFileInfo>();
335
                        }
336

    
337
                        doc.AttFiles.Add(newFile);
338
                        
339
                        var imageInfo = new AttImageInfo { ID = newFile.FileID, Data = newFile.FileData };
340

    
341
                        switch (category)
342
                        {
343
                            case "toreview":
344
                                briefAndImagesReview.AddToImage(imageInfo, true);
345
                                break;
346
                            case "frreview":
347
                                briefAndImagesReview.AddFrImage(imageInfo, true);
348
                                break;
349
                            case "prodvalidation":
350
                                briefAndImagesValidation.AddToImage(imageInfo, true);
351
                                break;
352
                            case "clientvalidation":
353
                                briefAndImagesValidation.AddFrImage(imageInfo, true);
354
                                break;
355
                        }
356
                    }
357
                }
358
            }
359

    
360
            return base.ProcessCmdKey(ref msg, keyData);
361
        }
362

    
363
        private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
364
        {
365
            if (e.RowInfo is GridViewSearchRowInfo)
366
            {
367
                e.RowInfo = new SearchRow(e.ViewInfo);
368
            }
369

    
370
            System.Diagnostics.Debug.WriteLine(e.RowInfo.GetType().Name);
371
        }
372

    
373
        private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
374
        {
375
            if (e.SearchFinished)
376
            {
377
                
378
            }
379
        }
380

    
381
        /// <summary>
382
        /// 선택된 행의 AutoCAD와 PDF 파일을 보여준다.
383
        /// </summary>
384
        /// <param name="sender"></param>
385
        /// <param name="e"></param>
386
        private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e)
387
        {
388
            void ShowAutoCADFile(string FilePath)
389
            {
390
                Controls.AutoCADViewer viewer = null;
391
                foreach (var control in this.radPageViewPageAutoCAD.Controls)
392
                {
393
                    if (control is Controls.AutoCADViewer _viewer)
394
                    {
395
                        viewer = _viewer;
396
                        break;
397
                    }
398
                }
399

    
400
                if (viewer == null)
401
                {
402
                    viewer = new Controls.AutoCADViewer() { Dock = DockStyle.Fill };
403
                    this.radPageViewPageAutoCAD.Controls.Add(viewer);
404
                }
405
                else
406
                {
407
                    viewer.Visible = true;
408
                }
409

    
410
                if (File.Exists(FilePath) && viewer != null) viewer.ReadDWG(FilePath);
411
            }
412

    
413
            if (this.radGridViewDocuments.SelectedRows.Any() && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
414
            {
415
                string dwgExtension = ".dwg";
416
                string dwgFilePath = Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", "Native", $"{doc.DocumentNo}{dwgExtension}");
417
                ShowAutoCADFile(dwgFilePath);
418
      
419
                //if (informations.ActiveUser.ID != doc.PersonInCharge)
420
                //{
421
                //    var row = this.radGridViewDocuments.SelectedRows.First();
422
                //    foreach(var cell in row.Cells)
423
                //    {
424
                //        cell.ReadOnly = true;
425
                //    }
426
                //}
427

    
428
                briefAndImagesReview.Clear();
429
                briefAndImagesValidation.Clear();
430

    
431
                //FrRemarks 추가
432

    
433
                briefAndImagesReview.DataBindings.Add(new Binding("BriefDoftech", doc, "ToRemarks", false, DataSourceUpdateMode.OnValidation, null));
434
                ///briefAndImagesReview.DataBindings.Add(new Binding("BriefSec", doc, "ToRemarks", false, DataSourceUpdateMode.OnValidation, null));
435

    
436
                briefAndImagesValidation.DataBindings.Add(new Binding("BriefDoftech", doc, "ClientRemarks", false,DataSourceUpdateMode.OnValidation,null));
437

    
438
                if (doc.AttFiles != null)
439
                {
440
                    if (doc.AttFiles.Count(x => x.Category == "toreview") > 0)
441
                    {
442
                        var images = doc.AttFiles.Where(x => x.Category == "toreview").Select(x =>new AttImageInfo { ID = x.FileID, Data = x.FileData });
443
                        briefAndImagesReview.SetToImages(images.ToList());
444
                    }
445

    
446
                    if (doc.AttFiles.Count(x => x.Category == "frreview") > 0)
447
                    {
448
                        var images = doc.AttFiles.Where(x => x.Category == "frreview").Select(x => new AttImageInfo { ID = x.FileID, Data = x.FileData });
449
                        briefAndImagesReview.SetFrImages(images.ToList());
450
                    }
451

    
452
                    if (doc.AttFiles.Count(x => x.Category == "prodvalidation") > 0)
453
                    {
454
                        var images = doc.AttFiles.Where(x => x.Category == "prodvalidation").Select(x => new AttImageInfo { ID = x.FileID, Data = x.FileData });
455
                        briefAndImagesValidation.SetToImages(images.ToList());
456
                    }
457

    
458
                    if (doc.AttFiles.Count(x => x.Category == "clientvalidation") > 0)
459
                    {
460
                        var images = doc.AttFiles.Where(x => x.Category == "clientvalidation").Select(x => new AttImageInfo { ID = x.FileID, Data = x.FileData });
461
                        briefAndImagesValidation.SetFrImages(images.ToList());
462
                    }
463
                }
464
            }
465
        }
466

    
467
#region Init, Load
468
        private void Initialize()
469
        {
470
            this.Text = Globals.Name;
471

    
472
            this.ID2ManagerRadRibbonBar.Expanded = false;
473

    
474
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
475
        }
476

    
477
        protected override void OnLoad(EventArgs e)
478
        {
479
            try
480
            {
481
                LoadDockingLayout();
482
                InitializeGrid();
483

    
484
                bool isID2 = this.IsID2Connection();
485
                this.SetMenus(isID2);
486

    
487
                if (isID2)
488
                {
489
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
490
                    {
491
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
492
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
493

    
494
                        this.LoadProject();
495
                    }
496
                    else
497
                    {
498
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
499

    
500
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
501
                        {
502
                            if (ctrl is OpenProjectView)
503
                            {
504
                                var openProjectView = ctrl as OpenProjectView;
505
                                openProjectView.GetProjectGroups();
506
                                break;
507
                            }
508
                        }
509

    
510
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
511
                    }
512
                }
513
                else
514
                {
515
                    this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
516
                    RadMessageBox.Show(this, $"Please select db file.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info);
517
                }
518
            }
519
            catch (Exception ex)
520
            {
521
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
522
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
523
            }
524

    
525
            base.OnLoad(e);
526
        }
527

    
528
        private bool IsID2Connection()
529
        {
530
            bool isSuccess = false;
531

    
532
            isSuccess = Globals.IsProjectDBConnstr();
533
            try
534
            {
535
                var id2Project = new ID2Controller().GetID2ProjectList();
536
            }
537
            catch
538
            {
539
                isSuccess = false;
540
            }
541

    
542
            return isSuccess;
543
        }
544

    
545
        private void SetMenus(bool isid2)
546
        {
547
            if (isid2)
548
            {
549
                this.IsID2Manager = (new string[] { "Admin", "Manager" }).Contains(informations.ActiveUser.Role) && string.IsNullOrEmpty(informations.ActiveUser.RefProjectID);
550

    
551
                if (this.IsID2Manager)
552
                {
553
                    this.radButtonElementNoticeUpload.Enabled = true;
554

    
555
                    this.backstageViewPageOpenProject.Controls[0].Visible = true;
556
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible;
557
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible;
558
                }
559
                else
560
                {
561
                    this.radButtonElementNoticeUpload.Enabled = false;
562

    
563
                    if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
564
                    {
565
                        this.backstageViewPageOpenProject.Controls[0].Visible = true;
566
                    }
567
                    else
568
                    {
569
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
570
                        {
571
                            ctrl.Visible = false;
572
                        }
573
                    }
574
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
575
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
576
                }
577
            }
578
            else
579
            {
580
                this.radButtonElementNoticeUpload.Enabled = false;
581

    
582
                this.backstageButtonItemSelectDB.Visibility = ElementVisibility.Visible;
583
                foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
584
                {
585
                    ctrl.Visible = false;
586
                }
587
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
588
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
589
            }
590
        }
591

    
592
        public Point GetBackstageLocation()
593
        {
594
            Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
595
            location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
596
            location.Offset(this.ID2ManagerRadRibbonBar.Location);
597

    
598
            return location;
599
        }
600

    
601
        private void InitializeGrid()
602
        {
603
            InitializeSearch();
604
            InitializeGridViewDetail();
605
    
606
            //this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
607
        }
608

    
609
        private void InitializeSearch()
610
        {
611
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
612

    
613
            lbSearch.Text = "\ue13E";
614
            btnSearchNext.Text = "\ue006";
615
            btnSearchPrevious.Text = "\ue004";
616

    
617
            var chkbox = new RadCheckBoxElement();
618
            chkbox.Text = "Match Case";
619
            chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; };
620

    
621
            btnMatchCase.HostedItem = chkbox;
622

    
623
            var chkbox1 = new RadCheckBoxElement();
624
            chkbox1.Text = "Show All Detail";
625
            chkbox1.CheckStateChanged += (snd, evt) => 
626
            { 
627
                radGridViewDocuments.MasterView.ChildRows.ForAll(x=>x.IsExpanded = chkbox1.Checked); 
628
            };
629

    
630
            btnShowAllDetail.HostedItem = chkbox1;
631

    
632
            var chkbox2 = new RadCheckBoxElement();
633
            chkbox2.Text = "Search from current position";
634
            chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; };
635

    
636
            btnSearchFormCurrent.HostedItem = chkbox2;
637

    
638
            var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x =>
639
                                 new FilterColumn
640
                                 {
641
                                     Name = x.HeaderText,
642
                                     FieldName = x.FieldName,
643
                                     IsSelect = x.AllowSearching
644
                                 });
645

    
646
            var panel = new StackLayoutElement();
647
            panel.Orientation = Orientation.Vertical;
648
            
649
            var btnComboColumns = new RadCheckedDropDownListElement();
650
            btnComboColumns.ShowCheckAllItems = true;
651
            btnComboColumns.CheckAllItem.Checked = true;
652
            btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns";
653
            btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true;
654
            btnComboColumns.DropDownMinSize = new Size(200, 200);
655
            btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
656
            btnComboColumns.DisplayMember = "Name";
657
            btnComboColumns.CheckedMember = "IsSelect";
658
            btnComboColumns.ValueMember = "FieldName";
659
            btnComboColumns.TextBox.CustomFont = font1.Name;
660
            btnComboColumns.TextBox.Text = "\ue13A";
661
            
662
            btnComboColumns.DataSource = columns;
663

    
664
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
665
            {
666
                radGridViewDocuments.MasterTemplate.Refresh(null);
667
            };
668

    
669
            btnComboColumns.PopupOpening += (snd, evt) =>
670
            {
671
                (snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect);
672
            };
673

    
674
            btnComboColumns.PopupClosed += (snd, evt) =>
675
            {
676
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
677
                {
678
                    if (radGridViewDocuments.Columns[item.Value.ToString()] != null)
679
                    {
680
                        radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
681
                    }
682
                }
683
            };
684

    
685
            btnFilters.HostedItem = btnComboColumns;
686
        }
687

    
688
        private void InitializeGridViewDetail()
689
        {
690
            DetailGridViewTemplate markupList = new DetailGridViewTemplate();
691

    
692
            markupList.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
693
           
694
            GridViewTextBoxColumn userColumn = new GridViewTextBoxColumn("CREATE_USER");
695
            GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("TEXT");
696

    
697
            userColumn.AutoSizeMode = BestFitColumnMode.AllCells;
698
            textColumn.AutoSizeMode = BestFitColumnMode.AllCells;
699

    
700
            markupList.Columns.AddRange(userColumn, textColumn);
701
            this.radGridViewDocuments.MasterTemplate.Templates.Add(markupList);
702
            markupList.HierarchyDataProvider = new GridViewEventDataProvider(markupList);
703

    
704
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
705
            this.radGridViewDocuments.RowSourceNeeded += RadGridViewDocuments_RowSourceNeeded;
706
        }
707

    
708
        private void RadGridViewDocuments_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
709
        {
710
            if (e.Template.HierarchyLevel == 1)
711
            {
712
                if (e.ParentRow.DataBoundItem is Documents documents)
713
                {
714
                    if (documents.Markups != null)
715
                    {
716
                        foreach (var makrup in documents.Markups)
717
                        {
718
                            GridViewRowInfo row = e.Template.Rows.NewRow();
719

    
720
                            row.Cells["CREATE_USER"].Value = makrup.CREATE_USER;
721
                            row.Cells["TEXT"].Value = makrup.TEXT;
722
                            e.SourceCollection.Add(row);
723
                        }
724

    
725
                        e.Template.BestFitColumns();
726
                    }
727
                }
728
            }
729
        }
730

    
731
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
732
        {
733
        }
734

    
735
#endregion
736

    
737
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
738
        {
739
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
740
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
741
        }
742

    
743
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
744
        {
745
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
746

    
747
            foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls)
748
            {
749
                if (ctrl is OpenProjectView)
750
                {
751
                    var openProjectView = ctrl as OpenProjectView;
752
                    openProjectView.GetProjectGroups();
753
                    break;
754
                }
755
            }
756
        }
757

    
758
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
759
        {
760
            try
761
            {
762
                if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
763
                {
764
                    var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
765

    
766
                    informations.ActiveProject = prjArgs.ProjectInfo;
767

    
768
                    this.radRibbonBarBackstageViewID2Manager.Tag = null;
769

    
770
                    this.LoadProject();
771
                }
772
            }
773
            catch (Exception ex)
774
            {
775
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
776
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
777
            }
778
        }
779

    
780
        private void LoadProject()
781
        {
782
            try
783
            {
784
#region 도면
785
                //Project List
786
                if (this.radDropDownListProject.Items.Count > 0)
787
                    this.radDropDownListProject.Items.Clear();
788
                informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
789
                                        .ForEach(x =>
790
                                        {
791
                                            this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
792
                                        });
793
                var allProject = new RadListDataItem("== 전체 ==", string.Empty);
794
                this.radDropDownListProject.Items.Insert(0, allProject);
795
                allProject.Selected = true;
796

    
797
                //담당자 List
798
                if (this.radDropDownListPersonInCharge.Items.Count > 0)
799
                    this.radDropDownListPersonInCharge.Items.Clear();
800
                informations.UserList.ForEach(x =>
801
                {
802
                    if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
803
                        this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
804
                });
805
                var allUser = new RadListDataItem("== 전체 ==", string.Empty);
806
                this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
807
                allUser.Selected = true;
808

    
809
                //난이도
810
                if (this.radDropDownListJobLevel.Items.Count > 0)
811
                    this.radDropDownListJobLevel.Items.Clear();
812
                informations.JobLevel.ForEach(x =>
813
                {
814
                    this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
815
                });
816
                var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
817
                this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
818
                allJobLevel.Selected = true;
819

    
820
                //도면번호 조회조건
821
                this.radTextBoxDocumentNo.Text = string.Empty;
822
#endregion
823

    
824
#region 검토
825
                //문의(DOF)
826
                if (this.radDropDownListToIsDiscussion.Items.Count > 0)
827
                    this.radDropDownListToIsDiscussion.Items.Clear();
828
                informations.IsYesNo.ForEach(x =>
829
               {
830
                   this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
831
               });
832
                var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
833
                this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
834
                allToIsDiscussion.Selected = true;
835

    
836
                //회신(DS)
837
                if (this.radDropDownListFrReviewStatus.Items.Count > 0)
838
                    this.radDropDownListFrReviewStatus.Items.Clear();
839
                informations.ClientStatus.ForEach(x =>
840
                {
841
                    this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
842
                });
843
                var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
844
                this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
845
                allFrReviewStatus.Selected = true;
846

    
847
                //ID2 작업가능
848
                if (this.radDropDownListIsID2Work.Items.Count > 0)
849
                    this.radDropDownListIsID2Work.Items.Clear();
850
                informations.IsYesNo.ForEach(x =>
851
                {
852
                    var item = new RadListDataItem(x, x);
853
                    if (x.Equals("Yes"))
854
                        item.Selected = true;
855
                    this.radDropDownListIsID2Work.Items.Add(item);
856

    
857
                });
858
                var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty);
859
                this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work);
860
#endregion
861

    
862
#region 작업
863
                //ID2 Status
864
                if (this.radDropDownListID2Status.Items.Count > 0)
865
                    this.radDropDownListID2Status.Items.Clear();
866
                informations.JobStatus.ForEach(x =>
867
                {
868
                    this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
869
                });
870
                var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
871
                this.radDropDownListID2Status.Items.Insert(0, allID2Status);
872
                allID2Status.Selected = true;
873

    
874
                //AVEVA Status
875
                if (this.radDropDownListAVEVAStatus.Items.Count > 0)
876
                    this.radDropDownListAVEVAStatus.Items.Clear();
877
                informations.JobStatus.ForEach(x =>
878
                {
879
                    this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
880
                });
881
                var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
882
                this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
883
                allAVEVAStatus.Selected = true;
884
#endregion
885

    
886
#region 검수
887
                //도프텍 결과
888
                if (this.radDropDownListProdIsResult.Items.Count > 0)
889
                    this.radDropDownListProdIsResult.Items.Clear();
890
                informations.ValidationResult.ForEach(x =>
891
                {
892
                    this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
893
                });
894
                var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
895
                this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
896
                allProdIsResult.Selected = true;
897

    
898
                //삼성 결과
899
                if (this.radDropDownListClientIsResult.Items.Count > 0)
900
                    this.radDropDownListClientIsResult.Items.Clear();
901
                informations.ValidationResult.ForEach(x =>
902
                {
903
                    this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
904
                });
905
                var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
906
                this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
907
                allClientIsResult.Selected = true;
908
#endregion
909

    
910
#region AVEVA
911
                //Gateway
912
                if (this.radDropDownListGateway.Items.Count > 0)
913
                    this.radDropDownListGateway.Items.Clear();
914
                informations.IsSuccess.ForEach(x =>
915
                {
916
                    this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x));
917
                });
918
                var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty);
919
                this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay);
920
                allDTIsGateWay.Selected = true;
921

    
922
                //Registration
923
                if (this.radDropDownListRegistration.Items.Count > 0)
924
                    this.radDropDownListRegistration.Items.Clear();
925
                informations.IsSuccess.ForEach(x =>
926
                {
927
                    this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x));
928
                });
929
                var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty);
930
                this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem);
931
                allDTIsRegSystem.Selected = true;
932
#endregion
933

    
934
                this.GetDocList();
935
            }
936
            catch (Exception ex)
937
            {
938
                throw ex;
939
            }
940
            finally
941
            {
942

    
943
                this.Cursor = Cursors.Default;
944

    
945
            }
946

    
947
        }
948

    
949
#region Document List 조회
950
        public void GetDocList()
951
        {
952
            try
953
            {
954
                if (this.radDropDownListProject.SelectedValue != null)
955
                {
956
                    string projectCode = this.radDropDownListProject.SelectedValue.ToString();
957
                    string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
958
                    string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
959
                    string documentNo = this.radTextBoxDocumentNo.Text.Trim();
960

    
961
                    string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
962
                    string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
963
                    string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();
964

    
965
                    string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
966
                    string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
967

    
968
                    string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
969
                    string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
970

    
971
                    string isGateWay = this.radDropDownListGateway.SelectedValue.ToString();
972
                    string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString();
973

    
974
                    var worker = new LoadDocumentsWorker(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments);
975
                    worker.OnWorkCompletedHandler += (e) =>
976
                    {
977
                        var docData = e.Result as DocumentsResult;
978

    
979
                        this.documents = docData.Dwgs;
980
                        this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
981
                        this.TotalCount = docData.TotalCount;
982

    
983
                        List<string> projectCodes = new List<string>();
984

    
985
                        if (!string.IsNullOrWhiteSpace(projectCode))
986
                        {
987
                            projectCodes.Add(projectCode);
988
                        }
989
                        else
990
                        {
991
                            projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
992
                        }
993

    
994
                        this.DocumentListBinding();
995
                    };
996
                    worker.StartWork();
997
                }
998
            }
999
            catch (Exception ex)
1000
            {
1001
                throw ex;
1002
            }
1003
        }
1004

    
1005
        public void DocumentListBinding()
1006
        {
1007
            try
1008
            {
1009
                GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
1010
                ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
1011
                ColProjects.DisplayMember = "Name";
1012
                ColProjects.ValueMember = "Code";
1013

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

    
1017
                GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
1018
                ColPersonInCharge.DataSource = workUsers;
1019
                ColPersonInCharge.DisplayMember = "Name";
1020
                ColPersonInCharge.ValueMember = "ID";
1021

    
1022
                GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
1023
                ColWorker.DataSource = workUsers;
1024
                ColWorker.DisplayMember = "Name";
1025
                ColWorker.ValueMember = "ID";
1026

    
1027
                GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
1028
                ColToCreator.DataSource = workUsers;
1029
                ColToCreator.DisplayMember = "Name";
1030
                ColToCreator.ValueMember = "ID";
1031

    
1032
                GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
1033
                ColFrCreator.DataSource = clientUsers;
1034
                ColFrCreator.DisplayMember = "Name";
1035
                ColFrCreator.ValueMember = "ID";
1036

    
1037
                GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
1038
                ColProdReviewer.DataSource = workUsers;
1039
                ColProdReviewer.DisplayMember = "Name";
1040
                ColProdReviewer.ValueMember = "ID";
1041

    
1042
                GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
1043
                ColClientReviewer.DataSource = clientUsers;
1044
                ColClientReviewer.DisplayMember = "Name";
1045
                ColClientReviewer.ValueMember = "ID";
1046

    
1047
                //Data
1048
                if (this.radGridViewDocuments.DataSource != null)
1049
                    this.radGridViewDocuments.DataSource = null;
1050

    
1051
                /*
1052
                var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info;
1053
                var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info);
1054
                var test = from doc in this.documents
1055
                           join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj
1056
                           from docs in gj.DefaultIfEmpty()
1057
                           select new Documents()
1058
                           {
1059
                               DocumentNo = doc.DocumentNo,
1060
                               ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME)
1061
                               //ProdRemarks = docs.DATETIME ?? null
1062
                           };
1063
                */
1064

    
1065
                this.radGridViewDocuments.FilterDescriptors.Clear();
1066
                this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
1067
                this.lbSelectAndTotal.Text = $"{this.documents.Count} / {this.TotalCount} (Selected / Total)";
1068
            }
1069
            catch (Exception ex)
1070
            {
1071
                throw ex;
1072
            }
1073
        }
1074
#endregion
1075

    
1076
#region Button, Checkbox event
1077
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
1078
        {
1079
            if (sender is RadCheckBox)
1080
            {
1081
                RadCheckBox checkBox = sender as RadCheckBox;
1082

    
1083
                if (checkBox.Tag != null)
1084
                {
1085
                    ColumnGroupsViewDefinition columnGroupsView =  this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1086
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1087
                    if (colGroup != null)
1088
                        colGroup.IsVisible = checkBox.Checked;
1089
                }
1090
            }
1091

    
1092
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
1093
        }
1094

    
1095
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
1096
        {
1097
            if (e.KeyCode == Keys.Enter)
1098
            {
1099
                this.radButtonSearch.Focus();
1100
                this.radButtonSearch.PerformClick();
1101
            }
1102
        }
1103

    
1104
        private void RadButtonSearch_Click(object sender, EventArgs e)
1105
        {
1106
            try
1107
            {
1108
                this.GetDocList();
1109
            }
1110
            catch (Exception ex)
1111
            {
1112
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1113
                RadMessageBox.Show("DWG search failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1114
            }
1115
        }
1116

    
1117
        private void BackstageButtonItemSelectDB_Click(object sender, EventArgs e)
1118
        {
1119
            using (var frm = new SetID2ProjectDB())
1120
            {
1121
                if (frm.ShowDialog(this) == DialogResult.OK)
1122
                {
1123
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
1124
                    {
1125
                        this.radRibbonBarBackstageViewID2Manager.HidePopup();
1126

    
1127
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
1128
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1129

    
1130
                        this.LoadProject();
1131
                    }
1132
                    else
1133
                    {
1134
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1135
                        bool isID2 = this.IsID2Connection();
1136
                        this.SetMenus(isID2);
1137

    
1138
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
1139
                        {
1140
                            if (ctrl is OpenProjectView)
1141
                            {
1142
                                var openProjectView = ctrl as OpenProjectView;
1143
                                openProjectView.GetProjectGroups();
1144
                                break;
1145
                            }
1146
                        }
1147
                    }
1148
                }
1149
            }
1150
        }
1151

    
1152
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
1153
        {
1154
            using (var frm = new SetupUser())
1155
            {
1156
                if (frm.ShowDialog(this) == DialogResult.OK)
1157
                {
1158
                    
1159
                }
1160
            }
1161
        }
1162

    
1163
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
1164
        {
1165
            Application.Exit();
1166
        }
1167
#endregion
1168

    
1169
#region Grid event
1170
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
1171
        {
1172
            if (e.Row is GridViewNewRowInfo)
1173
            {
1174
                
1175
            }
1176
            else
1177
            {
1178
                string extension = string.Empty;
1179

    
1180
                switch (e.Column.Name)
1181
                {
1182
                    case "MarkupLink":
1183
                        {
1184
                            if (e.Row.DataBoundItem is Documents doc)
1185
                            {
1186
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID))
1187
                                {
1188
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID);
1189
                                }
1190
                            }
1191
                        }
1192
                        break;
1193
                    case "AVEVALink":
1194
                    case "AVEVAConnection":
1195
                        MessageBox.Show($"{e.Column.Name} 실행");
1196
                        break;
1197
                    case "ReviewFileName"://일단주석
1198
                        MessageBox.Show($"{e.Column.Name} 실행");
1199
                        break;
1200
                    case "SystemLink":
1201
                        MessageBox.Show($"{e.Column.Name} 실행");
1202
                        break;
1203
                    case "ToCapture":
1204
                        {
1205
                            if (e.Row.DataBoundItem is Documents dd)
1206
                            {
1207
                                using (var frm = new ImageView(dd.DocID, "toreview"))
1208
                                {
1209
                                    frm.ShowDialog(this);
1210
                                }
1211
                            }
1212
                        }
1213
                        break;
1214
                    case "FrCapture":
1215
                        {
1216
                            if (e.Row.DataBoundItem is Documents dd)
1217
                            {
1218
                                using (var frm = new ImageView(dd.DocID, "frreview"))
1219
                                {
1220
                                    frm.ShowDialog(this);
1221
                                }
1222
                            }
1223
                        }
1224
                        break;
1225
                    case "ID2Connection":
1226
                        try
1227
                        {
1228
                            if (e.Row.DataBoundItem is Documents doc)
1229
                            {
1230
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port);
1231

    
1232
                                try
1233
                                {
1234
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
1235
                                    {
1236
                                        DocID = doc.DocID,
1237
                                        ID2StartDate = DateTime.Now,
1238
                                        Worker = informations.ActiveUser.ID
1239
                                    }, informations.ActiveUser.ID);
1240

    
1241
                                    if (returnDoc != null)
1242
                                    {
1243
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
1244
                                        doc.Worker = returnDoc.Worker;
1245
                                        doc.ID2JobTime = returnDoc.ID2JobTime;
1246
                                    }
1247
                                }
1248
                                catch { }
1249
                            }
1250
                        }
1251
                        catch (Exception ex)
1252
                        {
1253
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1254
                        }
1255
                        break;
1256
                }
1257
            }
1258
        }
1259

    
1260
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
1261
        {
1262
            if (e.ActiveEditor is RadDropDownListEditor)
1263
            {
1264
                switch (e.Column.Name)
1265
                {
1266
                    case "JobLevel":
1267
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1268
                        colJobLevel.DataSource = informations.JobLevel;
1269
                        break;
1270
                    case "IsTypical":
1271
                    case "ToIsDiscussion":
1272
                    case "ToIsMarkup":
1273
                    case "FrIsMarkup":
1274
                    case "IsID2Work":
1275
                    case "DTIsImport":
1276
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1277
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
1278
                        break;
1279
                    case "DTIsGateWay":
1280
                    case "DTIsRegSystem":
1281
                        GridViewComboBoxColumn colSuccess = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1282
                        colSuccess.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsSuccess);
1283
                        break;
1284
                    case "ID2Status":
1285
                    case "AVEVAStatus":
1286
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1287
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
1288
                        break;
1289
                    case "FrReviewStatus"://삼성의견status
1290
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1291
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
1292
                        break;
1293
                    case "ProdIsResult":
1294
                    case "ClientIsResult":
1295
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1296
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
1297
                        break;
1298
                }
1299
            }
1300
        }
1301

    
1302
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
1303
        {
1304
            if (e.Row is GridViewDataRowInfo)
1305
            {
1306
                System.Diagnostics.Debug.WriteLine(e.CellElement.GetType().Name);
1307
                
1308
                if (e.CellElement is GridRowHeaderCellElement)
1309
                {
1310
                   // if (e.CellElement.RowIndex > -1)
1311
                  //      e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
1312
                }
1313
                else if (e.CellElement is GridGroupExpanderCellElement expanderCellElement)
1314
                {
1315
                    if((e.Row.DataBoundItem as Documents).Markups == null)
1316
                    {
1317
                        expanderCellElement.Enabled = false;
1318
                    }
1319
                }
1320
                else
1321
                {
1322
                    var result = e.Row.DataBoundItem as Documents;
1323
                    if (result != null || e.Row is GridViewNewRowInfo)
1324
                    {
1325
                        switch (e.CellElement.ColumnInfo.Name)
1326
                        {
1327
                            case "AutoCADLink":
1328
                            case "PDFLink":
1329
                            case "MarkupLink":
1330
                            case "AVEVALink":
1331
                            case "AVEVAConnection":
1332
                            case "ReviewFileName"://일단주석
1333
                            case "SystemLink":
1334
                            case "ToCapture":
1335
                            case "FrCapture":
1336
                            case "ID2Connection":
1337
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name);
1338
                                break;
1339
                        }
1340
                    }
1341
                    else
1342
                    {
1343

    
1344
                    }
1345
                }
1346
            }
1347
            else if(e.Row is GridViewDetailsRowInfo)
1348
            {
1349
                if (e.CellElement is GridDetailViewCellElement detailViewCellElement)
1350
                {
1351
                    detailViewCellElement.Padding = new Padding(2);
1352
                }
1353
            }
1354
            //else if (e.Row is GridViewSummaryRowInfo)
1355
            //{
1356
            //    if (e.CellElement is GridRowHeaderCellElement)
1357
            //    {
1358
            //        e.CellElement.Text = "Count";
1359
            //    }
1360
            //    else if (e.CellElement is GridSummaryCellElement)
1361
            //    {
1362
            //        e.CellElement.ForeColor = this._SummaryColor;
1363
            //        e.CellElement.TextAlignment = ContentAlignment.BottomRight;
1364
            //        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
1365
            //    }
1366
            //    else
1367
            //    {
1368

    
1369
            //    }
1370
            //}
1371
            else
1372
            {
1373

    
1374
            }
1375
        }
1376

    
1377
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName)
1378
        {
1379
            RadButtonElement btnElem = null;
1380
            Bitmap bitmap = null; ;
1381

    
1382
            switch (colName)
1383
            {
1384
                case "AutoCADLink":
1385
                    bitmap = new Bitmap(Properties.Resources.cad18);
1386
                    break;
1387
                case "PDFLink":
1388
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1389
                    break;
1390
                case "MarkupLink":
1391
                    bitmap = new Bitmap(Properties.Resources.markus18);
1392
                    break;
1393
                case "AVEVALink":
1394
                case "AVEVAConnection":
1395
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
1396
                    break;
1397
                case "ReviewFileName"://일단주석
1398
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1399
                    break;
1400
                case "SystemLink":
1401
                    bitmap = new Bitmap(Properties.Resources.link18_yellow);
1402
                    break;
1403
                case "ToCapture":
1404
                case "FrCapture":
1405
                    bitmap = new Bitmap(Properties.Resources.files18);
1406
                    break;
1407
                case "ID2Connection":
1408
                    bitmap = new Bitmap(Properties.Resources.id218);
1409
                    break;
1410
            }
1411

    
1412
            switch (colName)
1413
            {
1414
                case "AutoCADLink":
1415
                case "PDFLink":
1416
                case "MarkupLink":
1417
                case "AVEVALink":
1418
                case "AVEVAConnection":
1419
                case "ReviewFileName"://일단주석
1420
                case "SystemLink":
1421
                case "ToCapture":
1422
                case "FrCapture":
1423
                case "ID2Connection":
1424
                    btnElem = (RadButtonElement)elem;
1425
                    btnElem.Margin = new Padding(0);
1426
                    btnElem.Padding = new Padding(0);
1427
                    btnElem.BorderElement.Opacity = 0;
1428
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
1429
                    btnElem.DisplayStyle = DisplayStyle.Image;
1430
                    btnElem.Image = bitmap;
1431
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
1432
                    btnElem.MaxSize = bitmap.Size;
1433
                    break;
1434
            }
1435

    
1436
            return btnElem;
1437
        }
1438

    
1439
        private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
1440
        {
1441
            this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)";
1442
        }
1443
#endregion
1444

    
1445
#region Excel
1446
        private UserInfo GetUser(string user)
1447
        {
1448
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
1449
            if (userInfo != null) return userInfo;
1450

    
1451
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
1452
            if (userInfo != null) return userInfo;
1453

    
1454
            return userInfo ?? new UserInfo();
1455
        }
1456

    
1457
        private ProjectInfo GetProject(string project)
1458
        {
1459
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault();
1460
            if (prjInfo != null) return prjInfo;
1461

    
1462
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
1463
            if (prjInfo != null) return prjInfo;
1464

    
1465
            return prjInfo ?? new ProjectInfo();
1466
        }
1467

    
1468
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
1469
        {
1470
            var form =  new Forms.SelectExcelData();
1471

    
1472
            var dialogResult = form.ShowDialog();
1473

    
1474
            if (dialogResult == DialogResult.OK)
1475
            {
1476
                using (ID2Excel excel = new ID2Excel(informations.UserList.ToList()))
1477
                {
1478
                    var result = excel.ExcelDataImport(form.SelectItems);
1479

    
1480
                    if (result.Error != null)
1481
                    {
1482

    
1483
                        RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1484
                    }
1485
                    else
1486
                    {
1487
                        this.importImages = result.Images;
1488
                        this.documents.AddRange(result.documents);
1489
                        if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1490
                        this.DocumentListBinding();
1491
                        //briefAndImagesReview.SetImages(this.importImages);
1492
                    }
1493

    
1494
                }
1495
            }
1496
        }
1497

    
1498
        private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e)
1499
        {
1500
            using (OpenFileDialog ofd = new OpenFileDialog()
1501
            {
1502
                Filter = "Excel files (*.xlsx)|*.xlsx",
1503
                Title = "Open an Excel File",
1504
                RestoreDirectory = true
1505
            })
1506
            {
1507
                if (ofd.ShowDialog() == DialogResult.OK)
1508
                {
1509
                    //Error Message
1510
                    StringBuilder sbErrMsg = new StringBuilder();
1511

    
1512
                    using(ID2Excel excel = new ID2Excel(informations.UserList.ToList()))
1513
                    {
1514
                       var result = excel.GemboxImport(ofd.FileName);
1515

    
1516
                        if(result.Error != null)
1517
                        {
1518

    
1519
                            RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1520
                        }
1521
                        else
1522
                        {
1523
                            this.documents.AddRange(result.documents);
1524
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1525
                            this.DocumentListBinding();
1526
                        }
1527

    
1528
                    }
1529

    
1530

    
1531
                    //foreach (Documents appDoc in appendDocuments)
1532
                    //{
1533
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1534

    
1535
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1536
                    //    {
1537
                    //        if (fieldInfo.GetValue(appDoc) != null)
1538
                    //        {
1539
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1540

    
1541
                    //            if (cols.Any())
1542
                    //            {
1543
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1544
                    //            }
1545
                    //        }
1546
                    //    }
1547
                    //}
1548
                }
1549
            }
1550
        }
1551

    
1552
        private void RadButtonElementExcelImport_Click_old(object sender, EventArgs e)
1553
        {
1554
            using (OpenFileDialog ofd = new OpenFileDialog()
1555
            {
1556
                Filter = "Excel files (*.xlsx)|*.xlsx",
1557
                Title = "Open an Excel File",
1558
                RestoreDirectory = true
1559
            })
1560
            {
1561
                if (ofd.ShowDialog() == DialogResult.OK)
1562
                {
1563
                    //Error Message
1564
                    StringBuilder sbErrMsg = new StringBuilder();
1565

    
1566
                    var exFile = ExcelFile.Load(ofd.FileName);
1567
                    var ws = exFile.Worksheets[0];
1568

    
1569
                    int rowCount = ws.Rows.Count;
1570
                    int columnCount = ws.CalculateMaxUsedColumns();
1571
                    int exRow = 8;
1572

    
1573
#region Excel 유효성검사
1574

    
1575
                    //Excel 포멧체크
1576
                    if (rowCount < 10 || columnCount != 45)
1577
                    {
1578
                        RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1579
                        return;
1580
                    }
1581

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

    
1588
                    if (sbErrMsg.Length > 0)
1589
                    {
1590
                        string errMsg = sbErrMsg.ToString().Substring(2);
1591
                        if (errMsg.Length > 100)
1592
                        {
1593
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1594
                        }
1595

    
1596
                        RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1597
                        return;
1598
                    }
1599
#endregion
1600

    
1601
#region 엑셀 도명명 중복 값 체크
1602
                    ws.Rows.SelectMany(row => row.AllocatedCells)
1603
                                                 .Where(col => col.Column.Index == 6 && col.Row.Index > exRow)
1604
                                                 .GroupBy(g => g.Row.Index)
1605
                                                 .Select(p => new {
1606
                                                     rowIndex = p.Key,
1607
                                                     docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
1608
                                                 })
1609
                                                 .GroupBy(g => g.docNo)
1610
                                                 .Where(p => p.Count() > 1)
1611
                                                 .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
1612
                                                                                            .Aggregate((x, y) => x.ToString() + "," + y.ToString())
1613
                                                                                            .ToString())
1614
                                                 .ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
1615
                    if (sbErrMsg.Length > 0)
1616
                    {
1617
                        sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
1618
                        string errMsg = sbErrMsg.ToString();
1619
                        if (errMsg.Length > 100)
1620
                        {
1621
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1622
                        }
1623

    
1624
                        RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1625
                        return;
1626
                    }
1627
#endregion
1628

    
1629
#endregion
1630

    
1631
                    List<Documents> appendDocuments = new List<Documents>();
1632

    
1633
                    ws.Rows.Where(row => row.Index > exRow)
1634
                           .ToList()
1635
                           .ForEach(p => appendDocuments.Add(new Documents()
1636
                           {
1637
                               //UID = string.Empty,
1638
                               //Type = this.radTextBoxInsulationType.Text,
1639
                               //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
1640
                               //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
1641
                               //NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
1642
                               //Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value)
1643

    
1644
                               RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1645
                               DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
1646
                               PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
1647
                               JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
1648
                               IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
1649
                               RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
1650
                               ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
1651
                               ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
1652
                               ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
1653
                               //ToCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1654
                               //ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1655
                               FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
1656
                               FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
1657
                               FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
1658
                               //FrCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1659
                               //FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1660
                               IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
1661
                               //ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1662
                               ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
1663
                               ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
1664
                               //ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1665
                               ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
1666
                               ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
1667
                               //AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1668
                               AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
1669
                               AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
1670
                               AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
1671
                               AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
1672
                               ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
1673
                               ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
1674
                               ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
1675
                               ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
1676
                               ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
1677
                               ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
1678
                               DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
1679
                               DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
1680
                               DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
1681
                               DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
1682
                           }));
1683

    
1684
                    this.documents.AddRange(appendDocuments);
1685
                    if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1686
                    this.DocumentListBinding();
1687

    
1688
                    //foreach (Documents appDoc in appendDocuments)
1689
                    //{
1690
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1691

    
1692
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1693
                    //    {
1694
                    //        if (fieldInfo.GetValue(appDoc) != null)
1695
                    //        {
1696
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1697

    
1698
                    //            if (cols.Any())
1699
                    //            {
1700
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1701
                    //            }
1702
                    //        }
1703
                    //    }
1704
                    //}
1705
                }
1706
            }
1707
        }
1708

    
1709
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
1710
        {
1711
            string sPrefixName = "Samsung Elec Task Management";
1712
            string extension = ".xlsx";
1713

    
1714
            using (SaveFileDialog sfd = new SaveFileDialog()
1715
            {
1716
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
1717
                Filter = "Excel|*.xlsx",
1718
                Title = "Save an Excel File",
1719
                CheckFileExists = false,
1720
                CheckPathExists = true,
1721
                OverwritePrompt = true
1722
            })
1723
            {
1724
                if (sfd.ShowDialog() == DialogResult.OK)
1725
                {
1726
                    string fileName = $"{sPrefixName}{extension}";
1727
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
1728
                    string templateFilePath = Path.Combine(templateFolder, fileName);
1729
                    if (!File.Exists(templateFilePath))
1730
                    {
1731
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1732
                        return;
1733
                    }
1734

    
1735
                    if (this.radGridViewDocuments.Rows.Count > 0)
1736
                    {
1737
                        var templateExcelFile = ExcelFile.Load(templateFilePath);
1738
                        var templateWorksheets = templateExcelFile.Worksheets;
1739
                        var templateWorksheet = templateWorksheets[0];
1740

    
1741
                        int rowIndex = 9;
1742
                        //int colIndex = 1;
1743

    
1744
                        foreach (var row in this.radGridViewDocuments.Rows)
1745
                        {
1746
                            var doc = row.DataBoundItem as Documents;
1747

    
1748
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
1749
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
1750
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
1751
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
1752
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
1753
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
1754
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
1755
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
1756
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
1757
                            templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
1758
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
1759
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
1760
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
1761
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
1762
                            templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture;
1763
                            templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
1764
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
1765
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
1766
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
1767
                            templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture;
1768
                            templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
1769
                            templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
1770
                            templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
1771
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
1772
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
1773
                            templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
1774
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
1775
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
1776
                            templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
1777
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
1778
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
1779
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
1780
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
1781
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
1782
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
1783
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
1784
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
1785
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
1786
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
1787
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
1788
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
1789
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
1790
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
1791
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
1792
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
1793
                            rowIndex++;
1794
                        }
1795

    
1796
                        templateExcelFile.Save(sfd.FileName);
1797
                        RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1798
                    }
1799
                }
1800
            }
1801
        }
1802
#endregion
1803

    
1804
#region Save event
1805

    
1806
        private void SetSaved()
1807
        {
1808
            try
1809
            {
1810
                if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1811
                {
1812
                    var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments);
1813
                    worker.OnWorkCompletedHandler += (e) =>
1814
                    {
1815
                        bool result = (bool)e.Result;
1816

    
1817
                        bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1818

    
1819
                        bool markusMembersResult = new MarkusInfoController().SetMembers(informations.UserList);
1820

    
1821
                        if (result && markusResult && markusMembersResult)
1822
                        {
1823
                            RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1824

    
1825
                            this.GetDocList();
1826
                        }
1827
                        else if (!result)
1828
                        {
1829
                            RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1830
                        }
1831
                        else if (!markusResult)
1832
                        {
1833
                            RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1834
                        }
1835
                        else if (!markusMembersResult)
1836
                        {
1837
                            RadMessageBox.Show("Markus Members Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1838
                        }
1839
                    };
1840
                    worker.StartWork();
1841
                }
1842
            }
1843
            catch (Exception ex)
1844
            {
1845
                throw ex;
1846
            }
1847
        }
1848

    
1849
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
1850
        {
1851
            try
1852
            {
1853
                this.SetSaved();
1854
            }
1855
            catch (Exception ex)
1856
            {
1857
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1858
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1859
            }
1860
        }
1861

    
1862
        private void RadButtonElementSave_Click(object sender, EventArgs e)
1863
        {
1864
            try
1865
            {
1866
                this.SetSaved();
1867
            }
1868
            catch (Exception ex)
1869
            {
1870
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1871
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1872
            }
1873
        }
1874

    
1875
        private void RadButtonElementSync_Click(object sender, EventArgs e)
1876
        {
1877
            try
1878
            {
1879
                if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1880
                {
1881
                    var worker = new SyncDocumentsWorker(this.radGridViewDocuments);
1882
                    worker.OnWorkCompletedHandler += (arg) =>
1883
                    {
1884
                        if ((bool)arg.Result)
1885
                        {
1886
                            this.GetDocList();
1887

    
1888
                            RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1889
                        }
1890
                    };
1891
                    worker.StartWork();
1892
                }
1893
            }
1894
            catch (Exception ex)
1895
            {
1896
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1897
                RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1898
            }
1899
        }
1900

    
1901
        private void RadButtonElementNotice_Click(object sender, EventArgs e)
1902
        {
1903
            try
1904
            {
1905
                AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProject.ProjectID, "notice");
1906

    
1907
                if (notiFileInfo == null)
1908
                {
1909
                    RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1910
                }
1911
                else
1912
                {
1913
                    string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles");
1914
                    string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}");
1915

    
1916
                    FileInfo finfo = new FileInfo(noticeFileFullName);
1917

    
1918
                    if (!finfo.Directory.Exists)
1919
                    {
1920
                        Directory.CreateDirectory(noticePath);
1921
                    }
1922

    
1923
                    if (!finfo.Exists)
1924
                    {
1925
                        var arrayBinary = notiFileInfo.FileData.ToArray();
1926

    
1927
                        using (MemoryStream ms = new MemoryStream(arrayBinary))
1928
                        {
1929
                            ms.Write(arrayBinary, 0, arrayBinary.Length);
1930
                            ms.Seek(0, SeekOrigin.Begin);
1931

    
1932
                            using (FileStream fs = finfo.Create())
1933
                            {
1934
                                ms.CopyTo(fs);
1935
                            }
1936
                        }
1937
                    }
1938

    
1939
                    try
1940
                    {
1941
                        ProcessStartInfo startInfo = new ProcessStartInfo
1942
                        {
1943
                            FileName = finfo.FullName,
1944
                            UseShellExecute = true,
1945
                            CreateNoWindow = false,
1946
                            WindowStyle = ProcessWindowStyle.Normal
1947
                        };
1948

    
1949
                        using (Process process = new Process())
1950
                        {
1951
                            process.StartInfo = startInfo;
1952
                            process.Start();
1953
                        }
1954
                        //Process.Start(finfo.FullName);
1955
                    }
1956
                    catch (Exception ex)
1957
                    {
1958
                        throw ex;
1959
                    }
1960

    
1961
                    //using (MemoryStream ms = new MemoryStream(arrayBinary))
1962
                    //{
1963
                    //    ProcessStartInfo startInfo = new ProcessStartInfo
1964
                    //    {
1965
                    //        FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName),
1966
                    //        RedirectStandardInput = true,
1967
                    //        UseShellExecute = false,
1968
                    //        CreateNoWindow = true,
1969
                    //        WindowStyle = ProcessWindowStyle.Hidden
1970
                    //    };
1971

    
1972
                    //    using (Process process = new Process())
1973
                    //    {
1974
                    //        process.StartInfo = startInfo;
1975
                    //        process.Start();
1976

    
1977
                    //        // Write the memory stream contents to the process standard input
1978
                    //        byte[] buffer = ms.ToArray();
1979
                    //        process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length);
1980
                    //        process.StandardInput.Close();
1981

    
1982
                    //        process.WaitForExit();
1983
                    //    }
1984
                    //}
1985
                }
1986
            }
1987
            catch (Exception ex)
1988
            {
1989
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1990
                RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1991
            }
1992
        }
1993

    
1994
        private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e)
1995
        {
1996
            string GetContentType(string filePath)
1997
            {
1998
                string extension = Path.GetExtension(filePath).ToLower();
1999

    
2000
                switch (extension)
2001
                {
2002
                    case ".txt":
2003
                        return "text/plain";
2004
                    case ".pdf":
2005
                        return "application/pdf";
2006
                    case ".jpg":
2007
                    case ".jpeg":
2008
                        return "image/jpeg";
2009
                    case ".png":
2010
                        return "image/png";
2011
                    case ".bmp":
2012
                        return "image/bmp";
2013
                    case ".gif":
2014
                        return "image/gif";
2015
                    default:
2016
                        return "application/octet-stream";
2017
                }
2018
            }
2019

    
2020
            using (OpenFileDialog ofd = new OpenFileDialog()
2021
            {
2022
                //Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*",
2023
                Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp)|*.png;*.jpeg;*.gif;*.jpg;*.bmp"
2024
                       + "|PNG Portable Network Graphics (*.png)|*.png"
2025
                       +"|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif"
2026
                       + "|BMP Windows Bitmap (*.bmp)|*.bmp"
2027
                       + "|GIF Graphics Interchange Format (*.gif)|*.gif",
2028
            //Title = "Open an Excel File",
2029
            RestoreDirectory = true
2030
            })
2031
            {
2032
                try
2033
                {
2034
                    if (ofd.ShowDialog() == DialogResult.OK)
2035
                    {
2036
                        FileInfo fileInfo = new FileInfo(ofd.FileName);
2037
                        if (fileInfo.Exists)
2038
                        {
2039
                            AttFileInfo attFile = new AttFileInfo()
2040
                            {
2041
                                RefID = informations.ActiveProject.ProjectID,
2042
                                Category = "notice",
2043
                                FileType = GetContentType(fileInfo.FullName),
2044
                                FileName = fileInfo.Name,
2045
                                FilePath = fileInfo.DirectoryName,
2046
                                FileExtension = fileInfo.Extension
2047
                            };
2048

    
2049
                            using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
2050
                            {
2051
                                using (var reader = new BinaryReader(stream))
2052
                                {
2053
                                    attFile.FileData = reader.ReadBytes((int)stream.Length);
2054
                                }
2055
                            }
2056

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

    
2059
                            if (result)
2060
                            {
2061
                                RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2062
                            }
2063
                        }
2064
                    }
2065
                }
2066
                catch (Exception ex)
2067
                {
2068
                    Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2069
                    RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2070
                }
2071
            }
2072
        }
2073

    
2074
        private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e)
2075
        {
2076
            bool isReload = false;
2077

    
2078
            try
2079
            {
2080
                if (RadMessageBox.Show($"Do you want to reload the project?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2081
                {
2082
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
2083
                    {
2084
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
2085
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2086

    
2087
                        isReload = true;
2088
                    }
2089
                    else if (informations.ActiveProject != null)
2090
                    {
2091
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2092

    
2093
                        isReload = true;
2094
                    }
2095
                    else
2096
                    {
2097
                        RadMessageBox.Show("Select a project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2098
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
2099
                    }
2100
                }
2101

    
2102
                if (isReload)
2103
                {
2104
                    this.LoadProject();
2105
                }
2106
            }
2107
            catch (Exception ex)
2108
            {
2109
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2110
                RadMessageBox.Show("Failed to reload the project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2111
            }
2112
        }
2113
#endregion
2114

    
2115
#region ColumnGroup
2116
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
2117
        {
2118
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
2119

    
2120
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" };
2121
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "DocumentNo", "PersonInCharge", "Worker", "JobLevel", "IsTypical", "RevisonNo" };
2122
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture", "ToIsMarkup" };
2123
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture", "FrIsMarkup" };
2124
            List<string> rvEtcColNames = new List<string>() { "IsID2Work" };
2125
            List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" };
2126
            List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" };
2127
            List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" };
2128
            List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks" };
2129
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" };
2130
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
2131

    
2132
            //도면
2133
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 ");
2134
            GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크");
2135
            GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보");
2136

    
2137
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
2138
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
2139

    
2140
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
2141
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
2142

    
2143
            docLinkColGrp.Rows.Add(docLinkColGrpRow);
2144
            docColGrp.Groups.Add(docLinkColGrp);
2145
            docInfoColGrp.Rows.Add(docInfoColGrpRow);
2146
            docColGrp.Groups.Add(docInfoColGrp);
2147

    
2148
            //검토
2149
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
2150
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
2151
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
2152
            GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타");
2153

    
2154
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
2155
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
2156

    
2157
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
2158
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
2159

    
2160
            GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow();
2161
            rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames);
2162

    
2163
            rvToColGrp.Rows.Add(rvToColGrpRow);
2164
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
2165
            rvEtcColGrp.Rows.Add(rvEtcColGrpRow);
2166

    
2167

    
2168
            rvColGrp.Groups.Add(rvToColGrp);
2169
            rvColGrp.Groups.Add(rvFrColGrp);
2170
            rvColGrp.Groups.Add(rvEtcColGrp);
2171

    
2172

    
2173
            //작업
2174
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
2175
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
2176
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
2177

    
2178
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
2179
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
2180

    
2181
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
2182
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
2183

    
2184
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
2185
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
2186

    
2187
            wkColGrp.Groups.Add(wkID2ColGrp);
2188
            wkColGrp.Groups.Add(wkAVEVAColGrp);
2189

    
2190

    
2191
            //Validation
2192
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
2193
            GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크");
2194
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
2195
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
2196

    
2197
            GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow();
2198
            valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames);
2199

    
2200
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
2201
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
2202

    
2203
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
2204
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
2205

    
2206
            valLinkColGrp.Rows.Add(valLinkColGrpRow);
2207
            valProdColGrp.Rows.Add(valProdColGrpRow);
2208
            valCntColGrp.Rows.Add(valCntColGrpRow);
2209

    
2210
            valColGrp.Groups.Add(valLinkColGrp);
2211
            valColGrp.Groups.Add(valProdColGrp);
2212
            valColGrp.Groups.Add(valCntColGrp);
2213

    
2214
            //AVEVA Net
2215
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
2216

    
2217
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
2218
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
2219

    
2220
            dtColGrp.Rows.Add(dtColGrpRow);
2221

    
2222
            //Group 추가
2223
            columnGroupsView.ColumnGroups.Add(docColGrp);
2224
            columnGroupsView.ColumnGroups.Add(rvColGrp);
2225
            columnGroupsView.ColumnGroups.Add(wkColGrp);
2226
            columnGroupsView.ColumnGroups.Add(valColGrp);
2227
            columnGroupsView.ColumnGroups.Add(dtColGrp);
2228

    
2229
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
2230
        }
2231
#endregion
2232

    
2233
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
2234
        {
2235
            if(string.IsNullOrWhiteSpace(txtFullSearch.Text))
2236
                radGridViewDocuments.MasterTemplate.Refresh(null);
2237

    
2238
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
2239
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
2240
        }
2241

    
2242
        private void btnSearchPrevious_Click(object sender, EventArgs e)
2243
        {
2244
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
2245
        }
2246

    
2247
        private void btnSearchNext_Click(object sender, EventArgs e)
2248
        {
2249
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2250
        }
2251

    
2252
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
2253
        {
2254
            if(e.KeyCode == Keys.Enter)
2255
            {
2256
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2257
            }
2258
        }
2259
    }
2260
}
2261

    
2262
public class FilterColumn
2263
{
2264
    public string Name { get; set; }
2265
    public string FieldName { get; set; }
2266
    public bool IsSelect { get; set; }
2267
}
클립보드 이미지 추가 (최대 크기: 500 MB)