프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ 4f825aa8

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

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

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

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

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

    
25
using GemBox.Spreadsheet;
26

    
27
using Newtonsoft.Json;
28
using System.Diagnostics;
29
using ID2.Manager.Common.Helpers;
30
using Telerik.WinControls.UI.Docking;
31

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

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

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

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

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

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

    
65
        public Main()
66
        {
67
            InitializeComponent();
68
            var verification = new Controls.Verification() { Dock = DockStyle.Fill };
69
            verification.OnDocumentSelected += BindingDocumentToDetailEditor;
70
            this.LayoutValidation.Controls.Add(verification);
71
            this.DockMainTabStrip.Select();
72

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

    
75
            if(!Directory.Exists(appDataPath))
76
            {
77
                Directory.CreateDirectory(appDataPath);
78
            }
79

    
80
            ID2.Manager.Common.Helpers.TableLayoutPanelHelper.SetDoubleBuffered(this);
81

    
82
            this.FormClosing += Main_FormClosing;
83
            this.radButtonElementRefreshCommand.Click += RadButtonElementRefreshCommand_Click;
84
            this.radButtonElementSaveCommand.Click += RadButtonElementSaveCommand_Click;
85
            this.btnDockLayoutReset.Click += BtnDockLayoutReset_Click;
86
            this.radButtonElementSave.Click += RadButtonElementSave_Click;
87
            this.radButtonElementSync.Click += RadButtonElementSync_Click;
88
            this.radButtonElementNotice.Click += RadButtonElementNotice_Click;
89
            this.radButtonElementNoticeUpload.Click += RadButtonElementNoticeUpload_Click;
90
            this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click;
91
            this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click;
92

    
93
            this.radButtonDateClear.Click += RadButtonDateClear_Click;
94
            this.radCheckBox1.CheckStateChanged += RadCheckBox_CheckStateChanged;
95
            this.radCheckBox2.CheckStateChanged += RadCheckBox_CheckStateChanged;
96
            this.radCheckBox3.CheckStateChanged += RadCheckBox_CheckStateChanged;
97
            this.radCheckBox4.CheckStateChanged += RadCheckBox_CheckStateChanged;
98
            this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown;
99
            this.radButtonSearch.Click += RadButtonSearch_Click;
100

    
101
            this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged;
102
            this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting;
103
            this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo;
104
            this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit;
105
            this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick;
106
            this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
107
            this.radGridViewDocuments.FilterChanged += RadGridViewDocuments_FilterChanged;
108

    
109
            this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36;
110
            this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36;
111
            //this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ;
112
            this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false;
113

    
114
            var openProjectView = new OpenProjectView()
115
            {
116
                Dock = DockStyle.Fill
117
            };
118

    
119
            this.backstageViewPageOpenProject.Controls.Add(openProjectView);
120
            openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick;
121
            openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick;
122
            this.backstageButtonItemSelectDB.Click += BackstageButtonItemSelectDB_Click;
123
            this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click;
124
            this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click;
125
            this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened;
126
            this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed;
127

    
128
            this.InitColumnGroupsViewDefinition(this.radGridViewDocuments);
129

    
130
            this.radPageViewPageReview.Controls.Add(briefAndImagesReview);
131
            this.radPageViewPageValidation.Controls.Add(briefAndImagesValidation);
132

    
133
            briefAndImagesReview.RemoveImage += BriefAndImages_RemoveImage;
134
            briefAndImagesValidation.RemoveImage += BriefAndImages_RemoveImage;
135
            this.Initialize();
136
        }
137

    
138
        private void BtnDockLayoutReset_Click(object sender, EventArgs e)
139
        {
140
            this.LoadDockingLayout(true);
141
        }
142

    
143
        private void BriefAndImages_RemoveImage(object sender, AttImageInfo e)
144
        {
145
            try
146
            {
147
                if (e is AttImageInfo)
148
                {
149
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
150
                    {
151
                        var reslut = doc.AttFiles.RemoveAll(x => x.FileID == e.ID);
152

    
153
                        if (reslut > 0)
154
                        {
155

    
156
                        }
157
                        else
158
                        {
159
                            MessageBox.Show("삭제오류");
160
                        }
161
                    }
162
                }
163
            }
164
            catch (Exception ex)
165
            {
166
                Program.logger.Error("BriefAndImages_RemoveImage",ex);
167
            }
168
        }
169

    
170
        private void SaveDockingLayout()
171
        {
172
            try
173
            {
174
                this.DockMain.SaveToXml(dockLayoutPath);
175
            }
176
            catch (Exception ex)
177
            {
178
                System.Diagnostics.Debug.WriteLine("SaveDockingLayout Error.", ex);
179
            }
180
        }
181

    
182
        private void LoadDockingLayout(bool IsDefaultLayoutLoad = false)
183
        {
184
            try
185
            {
186
                bool IsUseLayoutLoad = false;
187

    
188
                try
189
                {
190
                    var dockLayoutFile = new FileInfo(dockLayoutPath);
191

    
192

    
193
                    if (!IsDefaultLayoutLoad && dockLayoutFile.Exists)
194
                    {
195
                        this.DockMain.LoadFromXml(dockLayoutPath);
196
                        IsUseLayoutLoad = true;
197
                    }
198

    
199
                }
200
                catch (Exception ex)
201
                {
202
                    Program.logger.Error($"dock Layout File load Error. File Path : {dockLayoutPath}", ex);
203
                }
204

    
205
                if(!IsUseLayoutLoad)
206
                {
207
                    var layout = Properties.Resources.DefalutDockLayout;
208

    
209
                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(layout)))
210
                    {
211
                        this.DockMain.LoadFromXml(stream);
212
                    }
213
                }
214

    
215
                this.DockMain.DocumentTabsVisible = true;
216

    
217
                this.DockMain.DockWindows.ForAll(x =>
218
                {
219
                    x.DockManager.ShowDocumentPinButton = false;
220
                    x.DockManager.ShowDocumentCloseButton = false;
221
                });
222

    
223
                this.DockMain.AutoHideWindowDisplaying += DockMain_AutoHideWindowDisplaying;
224
                
225
                this.DockMain.DockStateChanged+=(snd,evt)=>
226
                {
227
                    if (evt.DockWindow.Name == DockWindowMain.Name || evt.DockWindow.Name == DockValidation.Name)
228
                    {
229

    
230
                    }
231

    
232
                };
233
                
234
                this.DockMain.DockWindowClosed += (snd, evt) =>
235
                {
236
                     evt.DockWindow.DockState = Telerik.WinControls.UI.Docking.DockState.AutoHide;
237
                     
238
                    //Telerik.WinControls.UI.Docking.AutoHidePosition tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Right;
239

    
240

    
241
                    //List<DockWindow> dockWindows = new List<DockWindow>();
242

    
243
                    //var autoHideWindows = this.DockMain.DockWindows.Where(x => x.DockState == Telerik.WinControls.UI.Docking.DockState.AutoHide).ToList();
244

    
245

    
246
                    //if (evt.DockWindow.AccessibleName == DockWindowMain.AccessibleName || evt.DockWindow.Name == DockValidation.AccessibleName)
247
                    //{
248
                    //    dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName == DockWindowMain.AccessibleName && evt.DockWindow.Name == DockValidation.AccessibleName));
249

    
250
                    //    tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Bottom;
251

    
252
                    //    dockWindows.Add(evt.DockWindow);
253
                    //}
254
                    //else
255
                    //{
256
                    //    dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName != DockWindowMain.AccessibleName || evt.DockWindow.Name != DockValidation.AccessibleName));
257

    
258
                    //    dockWindows.Add(evt.DockWindow);
259
                    //}
260
                    
261

    
262
                    //this.DockMain.AutoHideWindows(dockWindows, tabPosition);
263
                };
264
            }
265
            catch (Exception ex)
266
            {
267
                Program.logger.Error($"dock Layout load Error. File Path : {dockLayoutPath}", ex);
268
            }
269
        }
270

    
271
        private void DockMain_AutoHideWindowDisplaying(object sender, Telerik.WinControls.UI.Docking.AutoHideWindowDisplayingEventArgs e)
272
        {
273

    
274
        }
275

    
276
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
277
        {
278
            SaveDockingLayout();
279
        }
280

    
281
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
282
        {
283
            if (keyData == (Keys.F10 | Keys.Control))
284
            {
285
#if DEBUG
286
                radControlSpyForm.Show();
287
#endif
288
            }
289

    
290
            if (keyData == (Keys.V | Keys.Control))
291
            {
292
                System.Diagnostics.Debug.WriteLine("KeyDown CTRL + V");
293
                
294
                if(Clipboard.ContainsImage())
295
                {
296
                    var IsDoftech = true;
297
                    var selectReview = true;
298
                    string category = "";
299
                    byte[] imageBytes = null;
300

    
301
                    Image clipboardImage = Clipboard.GetImage();
302

    
303
                    using (MemoryStream stream = new MemoryStream())
304
                    {
305
                        clipboardImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
306
                        imageBytes = stream.ToArray();
307
                    }
308

    
309
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
310
                    {
311

    
312
                        /// 도프텍 or 삼성
313
                        if (!string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
314
                        {
315
                            IsDoftech = false;
316
                        }
317

    
318
                        /// 검토 or 검증
319
                        if (radPageViewComment.SelectedPage != radPageViewPageReview)
320
                        {
321
                            selectReview = false;
322
                        }
323

    
324
                        if (IsDoftech && selectReview)
325
                        {
326
                            category = "toreview";
327
                        }
328
                        else if (!IsDoftech && selectReview)
329
                        {
330
                            category = "frreview";
331
                        }
332
                        else if (IsDoftech && !selectReview)
333
                        {
334
                            category = "prodvalidation";
335
                        }
336
                        else 
337
                        {
338
                            category = "clientvalidation";
339
                        }
340

    
341

    
342
                        AttFileInfo newFile = new AttFileInfo
343
                        {
344
                            FileID = Guid.NewGuid().ToString(),
345
                            Category = category,
346
                            FileType = "image/png",
347
                            FileName = "ClipBoard",
348
                            FilePath = "ClipBoard",
349
                            FileExtension = ".png",
350
                            CreatedDate = DateTime.Now,
351
                            Creator = informations.ActiveUser.ID,
352
                            FileData = imageBytes
353

    
354
                        };
355

    
356
                        if (doc.AttFiles == null)
357
                        {
358
                            doc.AttFiles = new List<AttFileInfo>();
359
                        }
360

    
361
                        doc.AttFiles.Add(newFile);
362
                        
363
                        var imageInfo = new AttImageInfo { ID = newFile.FileID, Data = newFile.FileData };
364

    
365
                        switch (category)
366
                        {
367
                            case "toreview":
368
                                briefAndImagesReview.AddToImage(imageInfo, true);
369
                                break;
370
                            case "frreview":
371
                                briefAndImagesReview.AddFrImage(imageInfo, true);
372
                                break;
373
                            case "prodvalidation":
374
                                briefAndImagesValidation.AddToImage(imageInfo, true);
375
                                break;
376
                            case "clientvalidation":
377
                                briefAndImagesValidation.AddFrImage(imageInfo, true);
378
                                break;
379
                        }
380
                    }
381
                }
382
            }
383

    
384
            return base.ProcessCmdKey(ref msg, keyData);
385
        }
386

    
387
        private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
388
        {
389
            if (e.RowInfo is GridViewSearchRowInfo)
390
            {
391
                var row = new SearchRow(e.ViewInfo);
392
                e.RowInfo = row;
393
            }
394

    
395
            //System.Diagnostics.Debug.WriteLine(e.RowInfo.GetType().Name);
396
        }
397

    
398
        private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
399
        {
400
            if (e.SearchFinished)
401
            {
402
                
403
            }
404
        }
405

    
406
        /// <summary>
407
        /// 선택한 Document와 상세 편집 창을 연동시킨다.
408
        /// </summary>
409
        /// <param name="doc"></param>
410
        public void BindingDocumentToDetailEditor(Documents doc)
411
        {
412
            briefAndImagesReview.Clear();
413
            briefAndImagesValidation.Clear();
414

    
415
            //FrRemarks 추가
416

    
417
            briefAndImagesReview.DataBindings.Add(new Binding("BriefDoftech", doc, "ToRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
418
            briefAndImagesReview.DataBindings.Add(new Binding("BriefSec", doc, "FrRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
419

    
420
            briefAndImagesValidation.DataBindings.Add(new Binding("BriefDoftech", doc, "ProdRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
421
            briefAndImagesValidation.DataBindings.Add(new Binding("BriefSec", doc, "ClientRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
422

    
423
            if (doc.AttFiles != null)
424
            {
425
                if (doc.AttFiles.Any(x => x.Category == "toreview"))
426
                {
427
                    var images = doc.AttFiles.Where(x => x.Category == "toreview").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
428
                    briefAndImagesReview.SetToImages(images.ToList());
429
                }
430

    
431
                if (doc.AttFiles.Any(x => x.Category == "frreview"))
432
                {
433
                    var images = doc.AttFiles.Where(x => x.Category == "frreview").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
434
                    briefAndImagesReview.SetFrImages(images.ToList());
435
                }
436

    
437
                if (doc.AttFiles.Any(x => x.Category == "prodvalidation"))
438
                {
439
                    var images = doc.AttFiles.Where(x => x.Category == "prodvalidation").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
440
                    briefAndImagesValidation.SetToImages(images.ToList());
441
                }
442

    
443
                if (doc.AttFiles.Any(x => x.Category == "clientvalidation"))
444
                {
445
                    var images = doc.AttFiles.Where(x => x.Category == "clientvalidation").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
446
                    briefAndImagesValidation.SetFrImages(images.ToList());
447
                }
448
            }
449
        }
450

    
451
        /// <summary>
452
        /// 선택된 행의 AutoCAD와 PDF 파일을 보여준다.
453
        /// </summary>
454
        /// <param name="sender"></param>
455
        /// <param name="e"></param>
456
        private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e)
457
        {
458
            if (this.radGridViewDocuments.SelectedRows.Any() && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
459
            {
460
                //if (informations.ActiveUser.ID != doc.PersonInCharge)
461
                //{
462
                //    var row = this.radGridViewDocuments.SelectedRows.First();
463
                //    foreach(var cell in row.Cells)
464
                //    {
465
                //        cell.ReadOnly = true;
466
                //    }
467
                //}
468
                BindingDocumentToDetailEditor(doc);
469
            }
470
        }
471

    
472
#region Init, Load
473
        private void Initialize()
474
        {
475
            this.Text = Globals.Name;
476

    
477
            this.ID2ManagerRadRibbonBar.Expanded = false;
478

    
479
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
480
        }
481

    
482
        protected override void OnLoad(EventArgs e)
483
        {
484
            try
485
            {
486
                LoadDockingLayout();
487
                InitializeGrid();
488

    
489
                bool isID2DB = this.IsID2Connection();
490
                this.SetMenus(isID2DB);
491

    
492
                if (isID2DB)
493
                {
494
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
495
                    {
496
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
497
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
498

    
499
                        this.LoadProject();
500
                    }
501
                    else
502
                    {
503
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
504

    
505
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
506
                        {
507
                            if (ctrl is OpenProjectView)
508
                            {
509
                                var openProjectView = ctrl as OpenProjectView;
510
                                openProjectView.GetProjectGroups();
511
                                break;
512
                            }
513
                        }
514

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

    
530
            base.OnLoad(e);
531
        }
532

    
533
        private bool IsID2Connection()
534
        {
535
            bool isSuccess = false;
536

    
537
            try
538
            {
539
                isSuccess = Globals.IsProjectDBConnstr();
540

    
541
                if (isSuccess)
542
                {
543
                    var id2Project = new ID2Controller().GetID2ProjectList();
544
                }
545
            }
546
            catch (Exception ex)
547
            {
548
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
549
                isSuccess = false;
550
            }
551

    
552
            return isSuccess;
553
        }
554

    
555
        private void SetMenus(bool isid2)
556
        {
557
            if (isid2)
558
            {
559
                this.IsID2Manager = (new string[] { "Admin", "Manager" }).Contains(informations.ActiveUser.Role) && string.IsNullOrEmpty(informations.ActiveUser.RefProjectID);
560

    
561
                if (this.IsID2Manager)
562
                {
563
                    this.radButtonElementNoticeUpload.Enabled = true;
564

    
565
                    this.backstageViewPageOpenProject.Controls[0].Visible = true;
566
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible;
567
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible;
568
                }
569
                else
570
                {
571
                    this.radButtonElementNoticeUpload.Enabled = false;
572

    
573
                    if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
574
                    {
575
                        this.backstageViewPageOpenProject.Controls[0].Visible = true;
576
                    }
577
                    else
578
                    {
579
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
580
                        {
581
                            ctrl.Visible = false;
582
                        }
583
                    }
584
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
585
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
586
                }
587
            }
588
            else
589
            {
590
                this.radButtonElementNoticeUpload.Enabled = false;
591

    
592
                this.backstageButtonItemSelectDB.Visibility = ElementVisibility.Visible;
593
                foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
594
                {
595
                    ctrl.Visible = false;
596
                }
597
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
598
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
599
            }
600
        }
601

    
602
        public Point GetBackstageLocation()
603
        {
604
            Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
605
            location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
606
            location.Offset(this.ID2ManagerRadRibbonBar.Location);
607

    
608
            return location;
609
        }
610

    
611
        private void InitializeGrid()
612
        {
613
            InitializeColumns();
614
            InitializeSearch();
615
            InitializeGridViewDetail();
616
    
617
            //this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
618
        }
619

    
620
        private void InitializeColumns()
621
        {
622
            bool isClient = !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID);
623
            GridViewColumnCollection cols = this.radGridViewDocuments.Columns;
624

    
625
            cols.ForAll(x =>
626
            {
627
                if (!x.ReadOnly)
628
                {
629
                    switch (x.Name)
630
                    {
631
                        case "FrReviewStatus":
632
                        case "FrRemarks":
633
                        case "FrCreator":
634
                        case "ClientReviewer":
635
                        case "ClientIsResult":
636
                        case "ClientRemarks":
637
                            x.ReadOnly = !isClient;
638
                            break;
639
                        default:
640
                            x.ReadOnly = isClient;
641
                            break;
642
                    }
643
                }
644
            });
645
        }
646

    
647
        private void InitializeSearch()
648
        {
649
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
650

    
651
            lbSearch.Text = "\ue13E";
652
            btnSearchNext.Text = "\ue006";
653
            btnSearchPrevious.Text = "\ue004";
654

    
655
            var chkbox = new RadCheckBoxElement();
656
            chkbox.Text = "Match Case";
657
            chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; };
658

    
659
            btnMatchCase.HostedItem = chkbox;
660

    
661
            var chkbox1 = new RadCheckBoxElement();
662
            chkbox1.Text = "Show All Detail";
663
            chkbox1.CheckStateChanged += (snd, evt) => 
664
            { 
665
                radGridViewDocuments.MasterView.ChildRows.ForAll(x=>x.IsExpanded = chkbox1.Checked); 
666
            };
667

    
668
            btnShowAllDetail.HostedItem = chkbox1;
669

    
670
            var chkbox2 = new RadCheckBoxElement();
671
            chkbox2.Text = "Search from current position";
672
            chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; };
673

    
674
            btnSearchFormCurrent.HostedItem = chkbox2;
675

    
676
            var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x =>
677
                                 new FilterColumn
678
                                 {
679
                                     Name = x.HeaderText,
680
                                     FieldName = x.FieldName,
681
                                     IsSelect = x.AllowSearching
682
                                 }).ToList();
683

    
684
            var panel = new StackLayoutElement();
685
            panel.Orientation = Orientation.Vertical;
686
            
687
            var btnComboColumns = new RadCheckedDropDownListElement();
688
            btnComboColumns.ShowCheckAllItems = true;
689
            btnComboColumns.CheckAllItem.Checked = true;
690
            btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns";
691
            btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true;
692
            btnComboColumns.DropDownMinSize = new Size(200, 200);
693
            btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
694
            btnComboColumns.DisplayMember = "Name";
695
            btnComboColumns.CheckedMember = "IsSelect";
696
            btnComboColumns.ValueMember = "FieldName";
697
            btnComboColumns.TextBox.CustomFont = font1.Name;
698
            btnComboColumns.TextBox.Text = "\ue13A";
699

    
700
            columns.Add(new FilterColumn { FieldName = "CREATE_USER", Name = "Markus User", IsSelect = true });
701
            columns.Add(new FilterColumn { FieldName = "TEXT", Name = "Markus Text", IsSelect = true });
702

    
703
            btnComboColumns.DataSource = columns;
704

    
705
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
706
            {
707
                radGridViewDocuments.MasterTemplate.Refresh(null);
708
            };
709

    
710
            btnComboColumns.PopupOpening += (snd, evt) =>
711
            {
712
                (snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect);
713
            };
714

    
715
            btnComboColumns.PopupClosed += (snd, evt) =>
716
            {
717
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
718
                {
719
                    if (radGridViewDocuments.Columns[item.Value.ToString()] != null)
720
                    {
721
                        radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
722
                    }
723
                }
724
            };
725

    
726
            btnFilters.HostedItem = btnComboColumns;
727
        }
728

    
729
        private void InitializeGridViewDetail()
730
        {
731
            DetailGridViewTemplate markupList = new DetailGridViewTemplate();
732

    
733
            GridViewTextBoxColumn userColumn = new GridViewTextBoxColumn("CREATE_USER");
734
            GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("TEXT");
735

    
736
            userColumn.MinWidth = 110;
737
            userColumn.AutoSizeMode = BestFitColumnMode.AllCells;
738
            userColumn.AllowSearching = false;
739
            textColumn.AutoSizeMode = BestFitColumnMode.AllCells;
740
            textColumn.AllowSearching = false;
741

    
742
            markupList.Columns.AddRange(userColumn, textColumn);
743
            markupList.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
744

    
745
            this.radGridViewDocuments.MasterTemplate.Templates.Add(markupList);
746
            markupList.HierarchyDataProvider = new GridViewEventDataProvider(markupList);
747

    
748
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
749
            this.radGridViewDocuments.RowSourceNeeded += RadGridViewDocuments_RowSourceNeeded;
750
        }
751

    
752
        private void RadGridViewDocuments_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
753
        {
754
            if (e.Template.HierarchyLevel == 1)
755
            {
756
                if (e.ParentRow.DataBoundItem is Documents documents)
757
                {
758
                    if (documents.Markups != null)
759
                    {
760
                        foreach (var makrup in documents.Markups)
761
                        {
762
                            GridViewRowInfo row = e.Template.Rows.NewRow();
763

    
764
                            row.Cells["CREATE_USER"].Value = makrup.CREATE_USER;
765
                            row.Cells["TEXT"].Value = makrup.TEXT;
766
                            e.SourceCollection.Add(row);
767
                        }
768

    
769
                        e.Template.BestFitColumns(BestFitColumnMode.AllCells);
770
                    }
771
                }
772
            }
773
        }
774

    
775
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
776
        {
777
            if (e.IsExpanded)
778
            {
779
            }
780
        }
781

    
782
#endregion
783

    
784
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
785
        {
786
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
787
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
788
        }
789

    
790
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
791
        {
792
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
793

    
794
            foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls)
795
            {
796
                if (ctrl is OpenProjectView)
797
                {
798
                    var openProjectView = ctrl as OpenProjectView;
799
                    openProjectView.GetProjectGroups();
800
                    break;
801
                }
802
            }
803
        }
804

    
805
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
806
        {
807
            try
808
            {
809
                if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
810
                {
811
                    var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
812

    
813
                    informations.ActiveProject = prjArgs.ProjectInfo;
814

    
815
                    this.radRibbonBarBackstageViewID2Manager.Tag = null;
816

    
817
                    this.LoadProject();
818
                }
819
            }
820
            catch (Exception ex)
821
            {
822
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
823
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
824
            }
825
        }
826

    
827
        private void LoadProject()
828
        {
829
            try
830
            {
831
                #region Date
832
                //Date Type
833
                if (this.radCheckedDropDownListDateType.DataSource != null)
834
                    this.radCheckedDropDownListDateType.DataSource = null;
835

    
836
                this.radCheckedDropDownListDateType.DataSource = informations.DateType;
837
                this.radCheckedDropDownListDateType.DisplayMember = "Value";
838
                this.radCheckedDropDownListDateType.ValueMember = "Key";
839

    
840
                //FromDate
841
                this.radDateTimePickerFr.NullableValue = null;
842
                this.radDateTimePickerFr.SetToNullValue();
843

    
844
                //ToDate
845
                this.radDateTimePickerTo.NullableValue = null;
846
                this.radDateTimePickerTo.SetToNullValue();
847
                #endregion
848

    
849
                #region 도면
850
                //Project List
851
                if (this.radDropDownListProject.Items.Count > 0)
852
                    this.radDropDownListProject.Items.Clear();
853
                informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
854
                                        .ForEach(x =>
855
                                        {
856
                                            this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
857
                                        });
858
                var allProject = new RadListDataItem("== 전체 ==", string.Empty);
859
                this.radDropDownListProject.Items.Insert(0, allProject);
860
                allProject.Selected = true;
861

    
862
                //담당자 List
863
                if (this.radDropDownListPersonInCharge.Items.Count > 0)
864
                    this.radDropDownListPersonInCharge.Items.Clear();
865
                informations.UserList.ForEach(x =>
866
                {
867
                    if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
868
                        this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
869
                });
870
                var allUser = new RadListDataItem("== 전체 ==", string.Empty);
871
                this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
872
                allUser.Selected = true;
873

    
874
                //난이도
875
                if (this.radDropDownListJobLevel.Items.Count > 0)
876
                    this.radDropDownListJobLevel.Items.Clear();
877
                informations.JobLevel.ForEach(x =>
878
                {
879
                    this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
880
                });
881
                var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
882
                this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
883
                allJobLevel.Selected = true;
884

    
885
                //도면번호 조회조건
886
                this.radTextBoxDocumentNo.Text = string.Empty;
887
#endregion
888

    
889
#region 검토
890
                //문의(DOF)
891
                if (this.radDropDownListToIsDiscussion.Items.Count > 0)
892
                    this.radDropDownListToIsDiscussion.Items.Clear();
893
                informations.IsYesNo.ForEach(x =>
894
               {
895
                   this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
896
               });
897
                var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
898
                this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
899
                allToIsDiscussion.Selected = true;
900

    
901
                //회신(DS)
902
                if (this.radDropDownListFrReviewStatus.Items.Count > 0)
903
                    this.radDropDownListFrReviewStatus.Items.Clear();
904
                informations.ClientStatus.ForEach(x =>
905
                {
906
                    this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
907
                });
908
                var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
909
                this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
910
                allFrReviewStatus.Selected = true;
911

    
912
                //ID2 작업가능
913
                if (this.radDropDownListIsID2Work.Items.Count > 0)
914
                    this.radDropDownListIsID2Work.Items.Clear();
915
                informations.IsYesNo.ForEach(x =>
916
                {
917
                    var item = new RadListDataItem(x, x);
918
                    if (x.Equals("Yes"))
919
                        item.Selected = true;
920
                    this.radDropDownListIsID2Work.Items.Add(item);
921

    
922
                });
923
                var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty);
924
                this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work);
925
                #endregion
926

    
927
                #region 작업
928
                //ID2 Status
929
                {
930
                    if (this.radDropDownListID2Status.Items.Count > 0)
931
                        this.radDropDownListID2Status.Items.Clear();
932
                    informations.JobStatus.ForEach(x =>
933
                    {
934
                        this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
935
                    });
936
                    var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
937
                    this.radDropDownListID2Status.Items.Insert(0, allID2Status);
938
                    allID2Status.Selected = true;
939
                }
940

    
941
                //ID2 Issues
942
                {
943
                    if (this.radDropDownListID2Issues.Items.Count > 0)
944
                        this.radDropDownListID2Issues.Items.Clear();
945
                    informations.IsYesNo.ForEach(x =>
946
                    {
947
                        this.radDropDownListID2Issues.Items.Add(new RadListDataItem(x, x));
948
                    });
949
                    var allID2Issues = new RadListDataItem("== 전체 ==", string.Empty);
950
                    this.radDropDownListID2Issues.Items.Insert(0, allID2Issues);
951
                    allID2Issues.Selected = true;
952
                }
953

    
954
                //AVEVA Status
955
                {
956
                    if (this.radDropDownListAVEVAStatus.Items.Count > 0)
957
                        this.radDropDownListAVEVAStatus.Items.Clear();
958
                    informations.JobStatus.ForEach(x =>
959
                    {
960
                        this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
961
                    });
962
                    var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
963
                    this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
964
                    allAVEVAStatus.Selected = true;
965
                }
966

    
967
                //AVEVA Issues
968
                {
969
                    if (this.radDropDownListAVEVAIssues.Items.Count > 0)
970
                        this.radDropDownListAVEVAIssues.Items.Clear();
971
                    informations.IsYesNo.ForEach(x =>
972
                    {
973
                        this.radDropDownListAVEVAIssues.Items.Add(new RadListDataItem(x, x));
974
                    });
975
                    var allAVEVAIssues = new RadListDataItem("== 전체 ==", string.Empty);
976
                    this.radDropDownListAVEVAIssues.Items.Insert(0, allAVEVAIssues);
977
                    allAVEVAIssues.Selected = true;
978
                }
979

    
980
                #endregion
981

    
982
                #region 검수
983
                //도프텍 결과
984
                if (this.radDropDownListProdIsResult.Items.Count > 0)
985
                    this.radDropDownListProdIsResult.Items.Clear();
986
                informations.ValidationResult.ForEach(x =>
987
                {
988
                    this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
989
                });
990
                var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
991
                this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
992
                allProdIsResult.Selected = true;
993

    
994
                //삼성 결과
995
                if (this.radDropDownListClientIsResult.Items.Count > 0)
996
                    this.radDropDownListClientIsResult.Items.Clear();
997
                informations.ValidationResult.ForEach(x =>
998
                {
999
                    this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
1000
                });
1001
                var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
1002
                this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
1003
                allClientIsResult.Selected = true;
1004
#endregion
1005

    
1006
#region AVEVA
1007
                //Gateway
1008
                if (this.radDropDownListGateway.Items.Count > 0)
1009
                    this.radDropDownListGateway.Items.Clear();
1010
                informations.IsSuccess.ForEach(x =>
1011
                {
1012
                    this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x));
1013
                });
1014
                var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty);
1015
                this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay);
1016
                allDTIsGateWay.Selected = true;
1017

    
1018
                //Registration
1019
                if (this.radDropDownListRegistration.Items.Count > 0)
1020
                    this.radDropDownListRegistration.Items.Clear();
1021
                informations.IsSuccess.ForEach(x =>
1022
                {
1023
                    this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x));
1024
                });
1025
                var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty);
1026
                this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem);
1027
                allDTIsRegSystem.Selected = true;
1028
#endregion
1029

    
1030
                this.GetDocList();
1031
            }
1032
            catch (Exception ex)
1033
            {
1034
                throw ex;
1035
            }
1036
            finally
1037
            {
1038

    
1039
                this.Cursor = Cursors.Default;
1040

    
1041
            }
1042

    
1043
        }
1044

    
1045
#region Document List 조회
1046
        public void GetDocList()
1047
        {
1048
            try
1049
            {
1050
                if (this.radDropDownListProject.SelectedValue != null)
1051
                {
1052
                    List<string> dateTypes = this.radCheckedDropDownListDateType.CheckedItems.Select(x => x.Value.ToString()).ToList();
1053
                    DateTime? frDate = this.radDateTimePickerFr.Value.Equals(this.radDateTimePickerFr.NullDate) ? (DateTime?)null : this.radDateTimePickerFr.Value;
1054
                    DateTime? toDate = this.radDateTimePickerTo.Value.Equals(this.radDateTimePickerTo.NullDate) ? (DateTime?)null : this.radDateTimePickerTo.Value;
1055

    
1056
                    string projectCode = this.radDropDownListProject.SelectedValue.ToString();
1057
                    string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
1058
                    string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
1059
                    string documentNo = this.radTextBoxDocumentNo.Text.Trim();
1060

    
1061
                    string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
1062
                    string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
1063
                    string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();
1064

    
1065
                    string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
1066
                    string id2Issues = this.radDropDownListID2Issues.SelectedValue.ToString();
1067
                    string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
1068
                    string avevaIssues = this.radDropDownListAVEVAIssues.SelectedValue.ToString();
1069

    
1070
                    string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
1071
                    string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
1072

    
1073
                    string isGateWay = this.radDropDownListGateway.SelectedValue.ToString();
1074
                    string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString();
1075

    
1076
                    var worker = new LoadDocumentsWorker(dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments);
1077
                    worker.OnWorkCompletedHandler += (e) =>
1078
                    {
1079
                        var docData = e.Result as DocumentsResult;
1080

    
1081
                        this.documents = docData.Dwgs;
1082
                        this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
1083
                        this.TotalCount = docData.TotalCount;
1084

    
1085
                        List<string> projectCodes = new List<string>();
1086

    
1087
                        if (!string.IsNullOrWhiteSpace(projectCode))
1088
                        {
1089
                            projectCodes.Add(projectCode);
1090
                        }
1091
                        else
1092
                        {
1093
                            projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
1094
                        }
1095

    
1096
                        this.DocumentListBinding();
1097
                    };
1098

    
1099
                    (btnShowAllDetail.HostedItem as RadCheckBoxElement).Checked = false;
1100
                    worker.StartWork();
1101
                }
1102
            }
1103
            catch (Exception ex)
1104
            {
1105
                throw ex;
1106
            }
1107
        }
1108

    
1109
        public void DocumentListBinding()
1110
        {
1111
            try
1112
            {
1113
                GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
1114
                ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
1115
                ColProjects.DisplayMember = "Name";
1116
                ColProjects.ValueMember = "Code";
1117

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

    
1121
                GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
1122
                ColPersonInCharge.DataSource = workUsers;
1123
                ColPersonInCharge.DisplayMember = "Name";
1124
                ColPersonInCharge.ValueMember = "ID";
1125

    
1126
                GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
1127
                ColWorker.DataSource = workUsers;
1128
                ColWorker.DisplayMember = "Name";
1129
                ColWorker.ValueMember = "ID";
1130

    
1131
                GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
1132
                ColToCreator.DataSource = workUsers;
1133
                ColToCreator.DisplayMember = "Name";
1134
                ColToCreator.ValueMember = "ID";
1135

    
1136
                GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
1137
                ColFrCreator.DataSource = clientUsers;
1138
                ColFrCreator.DisplayMember = "Name";
1139
                ColFrCreator.ValueMember = "ID";
1140

    
1141
                GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
1142
                ColProdReviewer.DataSource = workUsers;
1143
                ColProdReviewer.DisplayMember = "Name";
1144
                ColProdReviewer.ValueMember = "ID";
1145

    
1146
                GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
1147
                ColClientReviewer.DataSource = clientUsers;
1148
                ColClientReviewer.DisplayMember = "Name";
1149
                ColClientReviewer.ValueMember = "ID";
1150

    
1151
                //Data
1152
                if (this.radGridViewDocuments.DataSource != null)
1153
                    this.radGridViewDocuments.DataSource = null;
1154

    
1155
                /*
1156
                var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info;
1157
                var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info);
1158
                var test = from doc in this.documents
1159
                           join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj
1160
                           from docs in gj.DefaultIfEmpty()
1161
                           select new Documents()
1162
                           {
1163
                               DocumentNo = doc.DocumentNo,
1164
                               ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME)
1165
                               //ProdRemarks = docs.DATETIME ?? null
1166
                           };
1167
                */
1168

    
1169
                this.radGridViewDocuments.FilterDescriptors.Clear();
1170
                this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
1171
                this.lbSelectAndTotal.Text = $"{this.documents.Count} / {this.TotalCount} (Selected / Total)";
1172

    
1173
                var verification = this.LayoutValidation.Controls[0] as Verification;
1174
                verification.DocumentListBinding(this.documents);
1175
            }
1176
            catch (Exception ex)
1177
            {
1178
                throw ex;
1179
            }
1180
        }
1181
        #endregion
1182

    
1183
        #region Button, Checkbox event
1184
        private void RadButtonDateClear_Click(object sender, EventArgs e)
1185
        {
1186
            //DateType
1187
            this.radCheckedDropDownListDateType.CheckedItems.Clear();
1188
            //FromDate
1189
            this.radDateTimePickerFr.SetToNullValue();
1190
            //ToDate
1191
            this.radDateTimePickerTo.SetToNullValue();
1192
        }
1193

    
1194
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
1195
        {
1196
            if (sender is RadCheckBox)
1197
            {
1198
                RadCheckBox checkBox = sender as RadCheckBox;
1199

    
1200
                if (checkBox.Tag != null)
1201
                {
1202
                    ColumnGroupsViewDefinition columnGroupsView =  this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1203
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1204
                    if (colGroup != null)
1205
                        colGroup.IsVisible = checkBox.Checked;
1206
                }
1207
            }
1208

    
1209
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
1210
        }
1211

    
1212
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
1213
        {
1214
            if (e.KeyCode == Keys.Enter)
1215
            {
1216
                this.radButtonSearch.Focus();
1217
                this.radButtonSearch.PerformClick();
1218
            }
1219
        }
1220

    
1221
        private void RadButtonSearch_Click(object sender, EventArgs e)
1222
        {
1223
            try
1224
            {
1225
                this.GetDocList();
1226
            }
1227
            catch (Exception ex)
1228
            {
1229
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1230
                RadMessageBox.Show("DWG search failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1231
            }
1232
        }
1233

    
1234
        private void BackstageButtonItemSelectDB_Click(object sender, EventArgs e)
1235
        {
1236
            using (var frm = new SetID2ProjectDB())
1237
            {
1238
                if (frm.ShowDialog(this) == DialogResult.OK)
1239
                {
1240
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
1241
                    {
1242
                        this.radRibbonBarBackstageViewID2Manager.HidePopup();
1243

    
1244
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
1245
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1246

    
1247
                        this.LoadProject();
1248
                    }
1249
                    else
1250
                    {
1251
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1252
                        bool isID2 = this.IsID2Connection();
1253
                        this.SetMenus(isID2);
1254

    
1255
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
1256
                        {
1257
                            if (ctrl is OpenProjectView)
1258
                            {
1259
                                var openProjectView = ctrl as OpenProjectView;
1260
                                openProjectView.GetProjectGroups();
1261
                                break;
1262
                            }
1263
                        }
1264
                    }
1265
                }
1266
            }
1267
        }
1268

    
1269
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
1270
        {
1271
            using (var frm = new SetupUser())
1272
            {
1273
                if (frm.ShowDialog(this) == DialogResult.OK)
1274
                {
1275
                    
1276
                }
1277
            }
1278
        }
1279

    
1280
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
1281
        {
1282
            Application.Exit();
1283
        }
1284
#endregion
1285

    
1286
#region Grid event
1287
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
1288
        {
1289
            if (e.Row is GridViewNewRowInfo)
1290
            {
1291
                
1292
            }
1293
            else
1294
            {
1295
                string extension = string.Empty;
1296

    
1297
                switch (e.Column.Name)
1298
                {
1299
                    case "MarkupLink":
1300
                        {
1301
                            if (e.Row.DataBoundItem is Documents doc)
1302
                            {
1303
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID))
1304
                                {
1305
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID);
1306
                                }
1307
                            }
1308
                        }
1309
                        break;
1310
                    case "AVEVALink":
1311
                    case "AVEVAConnection":
1312
                        MessageBox.Show($"{e.Column.Name} 실행");
1313
                        break;
1314
                    case "ReviewFileName"://일단주석
1315
                        MessageBox.Show($"{e.Column.Name} 실행");
1316
                        break;
1317
                    case "SystemLink":
1318
                        MessageBox.Show($"{e.Column.Name} 실행");
1319
                        break;
1320
                    case "ID2Connection":
1321
                        try
1322
                        {
1323
                            if (e.Row.DataBoundItem is Documents doc)
1324
                            {
1325
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port);
1326

    
1327
                                try
1328
                                {
1329
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
1330
                                    {
1331
                                        DocID = doc.DocID,
1332
                                        ID2StartDate = DateTime.Now,
1333
                                        Worker = informations.ActiveUser.ID
1334
                                    }, informations.ActiveUser.ID);
1335

    
1336
                                    if (returnDoc != null)
1337
                                    {
1338
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
1339
                                        doc.Worker = returnDoc.Worker;
1340
                                        doc.ID2JobTime = returnDoc.ID2JobTime;
1341
                                    }
1342
                                }
1343
                                catch { }
1344
                            }
1345
                        }
1346
                        catch (Exception ex)
1347
                        {
1348
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1349
                        }
1350
                        break;
1351
                }
1352
            }
1353
        }
1354

    
1355
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
1356
        {
1357
            if (e.ActiveEditor is RadDropDownListEditor)
1358
            {
1359
                switch (e.Column.Name)
1360
                {
1361
                    case "JobLevel":
1362
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1363
                        colJobLevel.DataSource = informations.JobLevel;
1364
                        break;
1365
                    case "IsTypical":
1366
                    case "ToIsDiscussion":
1367
                    case "ToIsMarkup":
1368
                    case "FrIsMarkup":
1369
                    case "IsID2Work":
1370
                    case "DTIsImport":
1371
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1372
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
1373
                        break;
1374
                    case "DTIsGateWay":
1375
                    case "DTIsRegSystem":
1376
                        GridViewComboBoxColumn colSuccess = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1377
                        colSuccess.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsSuccess);
1378
                        break;
1379
                    case "ID2Status":
1380
                    case "AVEVAStatus":
1381
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1382
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
1383
                        break;
1384
                    case "FrReviewStatus"://삼성의견status
1385
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1386
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
1387
                        break;
1388
                    case "ProdIsResult":
1389
                    case "ClientIsResult":
1390
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1391
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
1392
                        break;
1393
                }
1394
            }
1395
        }
1396

    
1397
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
1398
        {
1399
            if (e.Row is GridViewDataRowInfo)
1400
            {
1401
                if (e.CellElement is GridRowHeaderCellElement)
1402
                {
1403
                   // if (e.CellElement.RowIndex > -1)
1404
                  //      e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
1405
                }
1406
                else if (e.CellElement is GridGroupExpanderCellElement expanderCellElement)
1407
                {
1408
                    if((e.Row.DataBoundItem as Documents).Markups == null)
1409
                    {
1410
                        expanderCellElement.Enabled = false;
1411
                    }
1412
                }
1413
                else
1414
                {
1415
                    var result = e.Row.DataBoundItem as Documents;
1416
                    if (result != null || e.Row is GridViewNewRowInfo)
1417
                    {
1418
                        switch (e.CellElement.ColumnInfo.Name)
1419
                        {
1420
                            case "AutoCADLink":
1421
                            case "PDFLink":
1422
                            case "MarkupLink":
1423
                            case "AVEVALink":
1424
                            case "AVEVAConnection":
1425
                            case "ReviewFileName"://일단주석
1426
                            case "SystemLink":
1427
                            case "ID2Connection":
1428
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name);
1429
                                break;
1430
                            case "ToCapture":
1431
                                if (result.ToCapture > 0)
1432
                                {
1433
                                    e.CellElement.Image = Properties.Resources.files18;
1434
                                }
1435
                                break;
1436
                            case "FrCapture":
1437
                                if (result.FrCapture > 0)
1438
                                {
1439
                                    e.CellElement.Image = Properties.Resources.files18;
1440
                                }
1441
                                break;
1442
                            case "ProdCapture":
1443
                                if (result.ProdCapture > 0)
1444
                                {
1445
                                    e.CellElement.Image = Properties.Resources.files18;
1446
                                }
1447
                                break;
1448
                            case "ClientCapture":
1449
                                if (result.ClientCapture > 0)
1450
                                {
1451
                                    e.CellElement.Image = Properties.Resources.files18;
1452
                                }
1453
                                break;
1454
                        }
1455
                    }
1456
                    else
1457
                    {
1458

    
1459
                    }
1460
                }
1461
            }
1462
            else if(e.Row is GridViewDetailsRowInfo)
1463
            {
1464
                if (e.CellElement is GridDetailViewCellElement detailViewCellElement)
1465
                {
1466
                    detailViewCellElement.Padding = new Padding(10,2,2,2);
1467
                    detailViewCellElement.BackColor = Color.FromArgb(214, 214, 214);
1468
                    detailViewCellElement.BackColor2 = Color.FromArgb(214, 214, 214);
1469
                }
1470
            }
1471
            //else if (e.Row is GridViewSummaryRowInfo)
1472
            //{
1473
            //    if (e.CellElement is GridRowHeaderCellElement)
1474
            //    {
1475
            //        e.CellElement.Text = "Count";
1476
            //    }
1477
            //    else if (e.CellElement is GridSummaryCellElement)
1478
            //    {
1479
            //        e.CellElement.ForeColor = this._SummaryColor;
1480
            //        e.CellElement.TextAlignment = ContentAlignment.BottomRight;
1481
            //        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
1482
            //    }
1483
            //    else
1484
            //    {
1485

    
1486
            //    }
1487
            //}
1488
            else
1489
            {
1490

    
1491
            }
1492
        }
1493

    
1494
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName)
1495
        {
1496
            RadButtonElement btnElem = null;
1497
            Bitmap bitmap = null; ;
1498

    
1499
            switch (colName)
1500
            {
1501
                case "AutoCADLink":
1502
                    bitmap = new Bitmap(Properties.Resources.cad18);
1503
                    break;
1504
                case "PDFLink":
1505
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1506
                    break;
1507
                case "MarkupLink":
1508
                    bitmap = new Bitmap(Properties.Resources.markus18);
1509
                    break;
1510
                case "AVEVALink":
1511
                case "AVEVAConnection":
1512
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
1513
                    break;
1514
                case "ReviewFileName"://일단주석
1515
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1516
                    break;
1517
                case "SystemLink":
1518
                    bitmap = new Bitmap(Properties.Resources.link18_yellow);
1519
                    break;
1520
                case "ToCapture":
1521
                case "FrCapture":
1522
                    bitmap = new Bitmap(Properties.Resources.files18);
1523
                    break;
1524
                case "ID2Connection":
1525
                    bitmap = new Bitmap(Properties.Resources.id218);
1526
                    break;
1527
            }
1528

    
1529
            switch (colName)
1530
            {
1531
                case "AutoCADLink":
1532
                case "PDFLink":
1533
                case "MarkupLink":
1534
                case "AVEVALink":
1535
                case "AVEVAConnection":
1536
                case "ReviewFileName"://일단주석
1537
                case "SystemLink":
1538
                case "ToCapture":
1539
                case "FrCapture":
1540
                case "ID2Connection":
1541
                    btnElem = (RadButtonElement)elem;
1542
                    btnElem.Margin = new Padding(0);
1543
                    btnElem.Padding = new Padding(0);
1544
                    btnElem.BorderElement.Opacity = 0;
1545
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
1546
                    btnElem.DisplayStyle = DisplayStyle.Image;
1547
                    btnElem.Image = bitmap;
1548
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
1549
                    btnElem.MaxSize = bitmap.Size;
1550
                    break;
1551
            }
1552

    
1553
            return btnElem;
1554
        }
1555

    
1556
        private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
1557
        {
1558
            this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)";
1559
        }
1560
#endregion
1561

    
1562
#region Excel
1563
        private UserInfo GetUser(string user)
1564
        {
1565
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
1566
            if (userInfo != null) return userInfo;
1567

    
1568
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
1569
            if (userInfo != null) return userInfo;
1570

    
1571
            return userInfo ?? new UserInfo();
1572
        }
1573

    
1574
        private ProjectInfo GetProject(string project)
1575
        {
1576
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault();
1577
            if (prjInfo != null) return prjInfo;
1578

    
1579
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
1580
            if (prjInfo != null) return prjInfo;
1581

    
1582
            return prjInfo ?? new ProjectInfo();
1583
        }
1584

    
1585
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
1586
        {
1587
            var form =  new Forms.SelectExcelData();
1588

    
1589
            var dialogResult = form.ShowDialog();
1590

    
1591
            if (dialogResult == DialogResult.OK)
1592
            {
1593
                using (ID2Excel excel = new ID2Excel(informations.UserList.ToList()))
1594
                {
1595
                    var result = excel.ExcelDataImport(form.SelectItems);
1596

    
1597
                    if (result.Error != null)
1598
                    {
1599

    
1600
                        RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1601
                    }
1602
                    else
1603
                    {
1604
                        this.importImages = result.Images;
1605
                        this.documents.AddRange(result.documents);
1606
                        if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1607
                        this.DocumentListBinding();
1608
                        //briefAndImagesReview.SetImages(this.importImages);
1609
                    }
1610

    
1611
                }
1612
            }
1613
        }
1614

    
1615
        private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e)
1616
        {
1617
            using (OpenFileDialog ofd = new OpenFileDialog()
1618
            {
1619
                Filter = "Excel files (*.xlsx)|*.xlsx",
1620
                Title = "Open an Excel File",
1621
                RestoreDirectory = true
1622
            })
1623
            {
1624
                if (ofd.ShowDialog() == DialogResult.OK)
1625
                {
1626
                    //Error Message
1627
                    StringBuilder sbErrMsg = new StringBuilder();
1628

    
1629
                    using(ID2Excel excel = new ID2Excel(informations.UserList.ToList()))
1630
                    {
1631
                       var result = excel.GemboxImport(ofd.FileName);
1632

    
1633
                        if(result.Error != null)
1634
                        {
1635

    
1636
                            RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1637
                        }
1638
                        else
1639
                        {
1640
                            this.documents.AddRange(result.documents);
1641
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1642
                            this.DocumentListBinding();
1643
                        }
1644

    
1645
                    }
1646

    
1647

    
1648
                    //foreach (Documents appDoc in appendDocuments)
1649
                    //{
1650
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1651

    
1652
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1653
                    //    {
1654
                    //        if (fieldInfo.GetValue(appDoc) != null)
1655
                    //        {
1656
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1657

    
1658
                    //            if (cols.Any())
1659
                    //            {
1660
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1661
                    //            }
1662
                    //        }
1663
                    //    }
1664
                    //}
1665
                }
1666
            }
1667
        }
1668

    
1669
        private void RadButtonElementExcelImport_Click_old(object sender, EventArgs e)
1670
        {
1671
            using (OpenFileDialog ofd = new OpenFileDialog()
1672
            {
1673
                Filter = "Excel files (*.xlsx)|*.xlsx",
1674
                Title = "Open an Excel File",
1675
                RestoreDirectory = true
1676
            })
1677
            {
1678
                if (ofd.ShowDialog() == DialogResult.OK)
1679
                {
1680
                    //Error Message
1681
                    StringBuilder sbErrMsg = new StringBuilder();
1682

    
1683
                    var exFile = ExcelFile.Load(ofd.FileName);
1684
                    var ws = exFile.Worksheets[0];
1685

    
1686
                    int rowCount = ws.Rows.Count;
1687
                    int columnCount = ws.CalculateMaxUsedColumns();
1688
                    int exRow = 8;
1689

    
1690
#region Excel 유효성검사
1691

    
1692
                    //Excel 포멧체크
1693
                    if (rowCount < 10 || columnCount != 45)
1694
                    {
1695
                        RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1696
                        return;
1697
                    }
1698

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

    
1705
                    if (sbErrMsg.Length > 0)
1706
                    {
1707
                        string errMsg = sbErrMsg.ToString().Substring(2);
1708
                        if (errMsg.Length > 100)
1709
                        {
1710
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1711
                        }
1712

    
1713
                        RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1714
                        return;
1715
                    }
1716
#endregion
1717

    
1718
#region 엑셀 도명명 중복 값 체크
1719
                    ws.Rows.SelectMany(row => row.AllocatedCells)
1720
                                                 .Where(col => col.Column.Index == 6 && col.Row.Index > exRow)
1721
                                                 .GroupBy(g => g.Row.Index)
1722
                                                 .Select(p => new {
1723
                                                     rowIndex = p.Key,
1724
                                                     docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
1725
                                                 })
1726
                                                 .GroupBy(g => g.docNo)
1727
                                                 .Where(p => p.Count() > 1)
1728
                                                 .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
1729
                                                                                            .Aggregate((x, y) => x.ToString() + "," + y.ToString())
1730
                                                                                            .ToString())
1731
                                                 .ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
1732
                    if (sbErrMsg.Length > 0)
1733
                    {
1734
                        sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
1735
                        string errMsg = sbErrMsg.ToString();
1736
                        if (errMsg.Length > 100)
1737
                        {
1738
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1739
                        }
1740

    
1741
                        RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1742
                        return;
1743
                    }
1744
#endregion
1745

    
1746
#endregion
1747

    
1748
                    List<Documents> appendDocuments = new List<Documents>();
1749

    
1750
                    ws.Rows.Where(row => row.Index > exRow)
1751
                           .ToList()
1752
                           .ForEach(p => appendDocuments.Add(new Documents()
1753
                           {
1754
                               //UID = string.Empty,
1755
                               //Type = this.radTextBoxInsulationType.Text,
1756
                               //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
1757
                               //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
1758
                               //NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
1759
                               //Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value)
1760

    
1761
                               RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1762
                               DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
1763
                               PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
1764
                               JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
1765
                               IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
1766
                               RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
1767
                               ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
1768
                               ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
1769
                               ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
1770
                               //ToCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1771
                               //ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1772
                               FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
1773
                               FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
1774
                               FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
1775
                               //FrCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1776
                               //FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1777
                               IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
1778
                               //ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1779
                               ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
1780
                               ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
1781
                               //ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1782
                               ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
1783
                               ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
1784
                               //AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1785
                               AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
1786
                               AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
1787
                               AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
1788
                               AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
1789
                               ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
1790
                               ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
1791
                               ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
1792
                               ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
1793
                               ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
1794
                               ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
1795
                               DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
1796
                               DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
1797
                               DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
1798
                               DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
1799
                           }));
1800

    
1801
                    this.documents.AddRange(appendDocuments);
1802
                    if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1803
                    this.DocumentListBinding();
1804

    
1805
                    //foreach (Documents appDoc in appendDocuments)
1806
                    //{
1807
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1808

    
1809
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1810
                    //    {
1811
                    //        if (fieldInfo.GetValue(appDoc) != null)
1812
                    //        {
1813
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1814

    
1815
                    //            if (cols.Any())
1816
                    //            {
1817
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1818
                    //            }
1819
                    //        }
1820
                    //    }
1821
                    //}
1822
                }
1823
            }
1824
        }
1825

    
1826
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
1827
        {
1828
            string sPrefixName = "Samsung Elec Task Management";
1829
            string extension = ".xlsx";
1830

    
1831
            using (SaveFileDialog sfd = new SaveFileDialog()
1832
            {
1833
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
1834
                Filter = "Excel|*.xlsx",
1835
                Title = "Save an Excel File",
1836
                CheckFileExists = false,
1837
                CheckPathExists = true,
1838
                OverwritePrompt = true
1839
            })
1840
            {
1841
                if (sfd.ShowDialog() == DialogResult.OK)
1842
                {
1843
                    string fileName = $"{sPrefixName}{extension}";
1844
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
1845
                    string templateFilePath = Path.Combine(templateFolder, fileName);
1846
                    if (!File.Exists(templateFilePath))
1847
                    {
1848
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1849
                        return;
1850
                    }
1851

    
1852
                    var templateExcelFile = ExcelFile.Load(templateFilePath);
1853
                    var templateWorksheets = templateExcelFile.Worksheets;
1854
                    var templateWorksheet = templateWorksheets[0];
1855

    
1856
                    if (this.radGridViewDocuments.Rows.Count > 0)
1857
                    {
1858
                        int rowIndex = 9;
1859
                        //int colIndex = 1;
1860

    
1861
                        foreach (var row in this.radGridViewDocuments.Rows)
1862
                        {
1863
                            var doc = row.DataBoundItem as Documents;
1864

    
1865
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
1866
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
1867
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
1868
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
1869
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
1870
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
1871
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
1872
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
1873
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
1874
                            templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
1875
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
1876
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
1877
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
1878
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
1879
                            templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture;
1880
                            templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
1881
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
1882
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
1883
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
1884
                            templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture;
1885
                            templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
1886
                            templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
1887
                            templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
1888
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
1889
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
1890
                            templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
1891
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
1892
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
1893
                            templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
1894
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
1895
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
1896
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
1897
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
1898
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
1899
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
1900
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
1901
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
1902
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
1903
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
1904
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
1905
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
1906
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
1907
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
1908
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
1909
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
1910
                            rowIndex++;
1911
                        }
1912
                    }
1913
                    templateExcelFile.Save(sfd.FileName);
1914
                    RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1915
                }
1916
            }
1917
        }
1918
#endregion
1919

    
1920
#region Save event
1921

    
1922
        private void SetSaved()
1923
        {
1924
            try
1925
            {
1926
                if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1927
                {
1928
                    #region document no 중복 유효성 체크
1929
                    int dupDwgNoCount = 0;
1930
                    List<string> newDwgNos =  this.documents.Where(x => string.IsNullOrEmpty(x.DocID)).Select(x => x.DocumentNo).ToList();
1931
                    if (newDwgNos.Count > 0)
1932
                    {
1933
                        dupDwgNoCount = new DocumentController().ExistsDocument(informations.ActiveProject.ProjectID, newDwgNos);
1934
                    }
1935

    
1936
                    if (dupDwgNoCount > 0)
1937
                    {
1938
                        RadMessageBox.Show($"Duplicate Dwg No exists.({dupDwgNoCount})", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1939
                        return;
1940
                    }
1941
                    #endregion
1942

    
1943
                    var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments);
1944
                    worker.OnWorkCompletedHandler += (e) =>
1945
                    {
1946
                        bool result = false;
1947
                        bool markusResult = false;
1948
                        bool markusMembersResult = false;
1949

    
1950
                        result = (bool)e.Result;
1951
                        if (result)
1952
                        {
1953
                            markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1954
                            markusMembersResult = new MarkusInfoController().SetMembers(informations.UserList);
1955
                        }
1956

    
1957
                        if (result && markusResult && markusMembersResult)
1958
                        {
1959
                            RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1960

    
1961
                            this.GetDocList();
1962
                        }
1963
                        else if (!result)
1964
                        {
1965
                            RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1966
                        }
1967
                        else if (!markusResult)
1968
                        {
1969
                            RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1970
                        }
1971
                        else if (!markusMembersResult)
1972
                        {
1973
                            RadMessageBox.Show("Markus Members Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1974
                        }
1975
                    };
1976
                    worker.StartWork();
1977
                }
1978
            }
1979
            catch (Exception ex)
1980
            {
1981
                throw ex;
1982
            }
1983
        }
1984

    
1985
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
1986
        {
1987
            try
1988
            {
1989
                this.SetSaved();
1990
            }
1991
            catch (Exception ex)
1992
            {
1993
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1994
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1995
            }
1996
        }
1997

    
1998
        private void RadButtonElementSave_Click(object sender, EventArgs e)
1999
        {
2000
            try
2001
            {
2002
                this.SetSaved();
2003
            }
2004
            catch (Exception ex)
2005
            {
2006
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2007
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2008
            }
2009
        }
2010

    
2011
        private void RadButtonElementSync_Click(object sender, EventArgs e)
2012
        {
2013
            try
2014
            {
2015
                if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2016
                {
2017
                    var worker = new SyncDocumentsWorker(this.radGridViewDocuments);
2018
                    worker.OnWorkCompletedHandler += (arg) =>
2019
                    {
2020
                        if ((bool)arg.Result)
2021
                        {
2022
                            this.GetDocList();
2023

    
2024
                            RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2025
                        }
2026
                    };
2027
                    worker.StartWork();
2028
                }
2029
            }
2030
            catch (Exception ex)
2031
            {
2032
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2033
                RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2034
            }
2035
        }
2036

    
2037
        private void RadButtonElementNotice_Click(object sender, EventArgs e)
2038
        {
2039
            try
2040
            {
2041
                AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProject.ProjectID, "notice");
2042

    
2043
                if (notiFileInfo == null)
2044
                {
2045
                    RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2046
                }
2047
                else
2048
                {
2049
                    string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles");
2050
                    string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}");
2051

    
2052
                    FileInfo finfo = new FileInfo(noticeFileFullName);
2053

    
2054
                    if (!finfo.Directory.Exists)
2055
                    {
2056
                        Directory.CreateDirectory(noticePath);
2057
                    }
2058

    
2059
                    if (!finfo.Exists)
2060
                    {
2061
                        var arrayBinary = notiFileInfo.FileData.ToArray();
2062

    
2063
                        using (MemoryStream ms = new MemoryStream(arrayBinary))
2064
                        {
2065
                            ms.Write(arrayBinary, 0, arrayBinary.Length);
2066
                            ms.Seek(0, SeekOrigin.Begin);
2067

    
2068
                            using (FileStream fs = finfo.Create())
2069
                            {
2070
                                ms.CopyTo(fs);
2071
                            }
2072
                        }
2073
                    }
2074

    
2075
                    try
2076
                    {
2077
                        ProcessStartInfo startInfo = new ProcessStartInfo
2078
                        {
2079
                            FileName = finfo.FullName,
2080
                            UseShellExecute = true,
2081
                            CreateNoWindow = false,
2082
                            WindowStyle = ProcessWindowStyle.Normal
2083
                        };
2084

    
2085
                        using (Process process = new Process())
2086
                        {
2087
                            process.StartInfo = startInfo;
2088
                            process.Start();
2089
                        }
2090
                        //Process.Start(finfo.FullName);
2091
                    }
2092
                    catch (Exception ex)
2093
                    {
2094
                        throw ex;
2095
                    }
2096

    
2097
                    //using (MemoryStream ms = new MemoryStream(arrayBinary))
2098
                    //{
2099
                    //    ProcessStartInfo startInfo = new ProcessStartInfo
2100
                    //    {
2101
                    //        FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName),
2102
                    //        RedirectStandardInput = true,
2103
                    //        UseShellExecute = false,
2104
                    //        CreateNoWindow = true,
2105
                    //        WindowStyle = ProcessWindowStyle.Hidden
2106
                    //    };
2107

    
2108
                    //    using (Process process = new Process())
2109
                    //    {
2110
                    //        process.StartInfo = startInfo;
2111
                    //        process.Start();
2112

    
2113
                    //        // Write the memory stream contents to the process standard input
2114
                    //        byte[] buffer = ms.ToArray();
2115
                    //        process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length);
2116
                    //        process.StandardInput.Close();
2117

    
2118
                    //        process.WaitForExit();
2119
                    //    }
2120
                    //}
2121
                }
2122
            }
2123
            catch (Exception ex)
2124
            {
2125
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2126
                RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2127
            }
2128
        }
2129

    
2130
        private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e)
2131
        {
2132
            string GetContentType(string filePath)
2133
            {
2134
                string extension = Path.GetExtension(filePath).ToLower();
2135

    
2136
                switch (extension)
2137
                {
2138
                    case ".txt":
2139
                        return "text/plain";
2140
                    case ".pdf":
2141
                        return "application/pdf";
2142
                    case ".jpg":
2143
                    case ".jpeg":
2144
                        return "image/jpeg";
2145
                    case ".png":
2146
                        return "image/png";
2147
                    case ".bmp":
2148
                        return "image/bmp";
2149
                    case ".gif":
2150
                        return "image/gif";
2151
                    default:
2152
                        return "application/octet-stream";
2153
                }
2154
            }
2155

    
2156
            using (OpenFileDialog ofd = new OpenFileDialog()
2157
            {
2158
                //Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*",
2159
                Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp)|*.png;*.jpeg;*.gif;*.jpg;*.bmp"
2160
                       + "|PNG Portable Network Graphics (*.png)|*.png"
2161
                       +"|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif"
2162
                       + "|BMP Windows Bitmap (*.bmp)|*.bmp"
2163
                       + "|GIF Graphics Interchange Format (*.gif)|*.gif",
2164
            //Title = "Open an Excel File",
2165
            RestoreDirectory = true
2166
            })
2167
            {
2168
                try
2169
                {
2170
                    if (ofd.ShowDialog() == DialogResult.OK)
2171
                    {
2172
                        FileInfo fileInfo = new FileInfo(ofd.FileName);
2173
                        if (fileInfo.Exists)
2174
                        {
2175
                            AttFileInfo attFile = new AttFileInfo()
2176
                            {
2177
                                RefID = informations.ActiveProject.ProjectID,
2178
                                Category = "notice",
2179
                                FileType = GetContentType(fileInfo.FullName),
2180
                                FileName = fileInfo.Name,
2181
                                FilePath = fileInfo.DirectoryName,
2182
                                FileExtension = fileInfo.Extension
2183
                            };
2184

    
2185
                            using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
2186
                            {
2187
                                using (var reader = new BinaryReader(stream))
2188
                                {
2189
                                    attFile.FileData = reader.ReadBytes((int)stream.Length);
2190
                                }
2191
                            }
2192

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

    
2195
                            if (result)
2196
                            {
2197
                                RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2198
                            }
2199
                        }
2200
                    }
2201
                }
2202
                catch (Exception ex)
2203
                {
2204
                    Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2205
                    RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2206
                }
2207
            }
2208
        }
2209

    
2210
        private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e)
2211
        {
2212
            bool isReload = false;
2213

    
2214
            try
2215
            {
2216
                if (RadMessageBox.Show($"Do you want to reload the project?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2217
                {
2218
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
2219
                    {
2220
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
2221
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2222

    
2223
                        isReload = true;
2224
                    }
2225
                    else if (informations.ActiveProject != null)
2226
                    {
2227
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2228

    
2229
                        isReload = true;
2230
                    }
2231
                    else
2232
                    {
2233
                        RadMessageBox.Show("Select a project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2234
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
2235
                    }
2236
                }
2237

    
2238
                if (isReload)
2239
                {
2240
                    this.LoadProject();
2241
                }
2242
            }
2243
            catch (Exception ex)
2244
            {
2245
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2246
                RadMessageBox.Show("Failed to reload the project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2247
            }
2248
        }
2249
#endregion
2250

    
2251
#region ColumnGroup
2252
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
2253
        {
2254
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
2255

    
2256
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" };
2257
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "DocumentNo", "PersonInCharge", "Worker", "JobLevel", "IsTypical", "RevisonNo" };
2258
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture", "ToIsMarkup" };
2259
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture", "FrIsMarkup" };
2260
            List<string> rvEtcColNames = new List<string>() { "IsID2Work" };
2261
            List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" };
2262
            List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" };
2263
            List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" };
2264
            List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks", "ProdCapture" };
2265
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks", "ClientCapture" };
2266
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
2267

    
2268
            //도면
2269
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 ");
2270
            GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크");
2271
            GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보");
2272

    
2273
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
2274
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
2275

    
2276
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
2277
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
2278

    
2279
            docLinkColGrp.Rows.Add(docLinkColGrpRow);
2280
            docColGrp.Groups.Add(docLinkColGrp);
2281
            docInfoColGrp.Rows.Add(docInfoColGrpRow);
2282
            docColGrp.Groups.Add(docInfoColGrp);
2283

    
2284
            //검토
2285
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
2286
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
2287
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
2288
            GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타");
2289

    
2290
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
2291
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
2292

    
2293
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
2294
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
2295

    
2296
            GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow();
2297
            rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames);
2298

    
2299
            rvToColGrp.Rows.Add(rvToColGrpRow);
2300
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
2301
            rvEtcColGrp.Rows.Add(rvEtcColGrpRow);
2302

    
2303

    
2304
            rvColGrp.Groups.Add(rvToColGrp);
2305
            rvColGrp.Groups.Add(rvFrColGrp);
2306
            rvColGrp.Groups.Add(rvEtcColGrp);
2307

    
2308

    
2309
            //작업
2310
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
2311
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
2312
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
2313

    
2314
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
2315
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
2316

    
2317
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
2318
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
2319

    
2320
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
2321
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
2322

    
2323
            wkColGrp.Groups.Add(wkID2ColGrp);
2324
            wkColGrp.Groups.Add(wkAVEVAColGrp);
2325

    
2326

    
2327
            //Validation
2328
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
2329
            GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크");
2330
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
2331
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
2332

    
2333
            GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow();
2334
            valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames);
2335

    
2336
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
2337
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
2338

    
2339
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
2340
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
2341

    
2342
            valLinkColGrp.Rows.Add(valLinkColGrpRow);
2343
            valProdColGrp.Rows.Add(valProdColGrpRow);
2344
            valCntColGrp.Rows.Add(valCntColGrpRow);
2345

    
2346
            valColGrp.Groups.Add(valLinkColGrp);
2347
            valColGrp.Groups.Add(valProdColGrp);
2348
            valColGrp.Groups.Add(valCntColGrp);
2349

    
2350
            //AVEVA Net
2351
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
2352

    
2353
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
2354
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
2355

    
2356
            dtColGrp.Rows.Add(dtColGrpRow);
2357

    
2358
            //Group 추가
2359
            columnGroupsView.ColumnGroups.Add(docColGrp);
2360
            columnGroupsView.ColumnGroups.Add(rvColGrp);
2361
            columnGroupsView.ColumnGroups.Add(wkColGrp);
2362
            columnGroupsView.ColumnGroups.Add(valColGrp);
2363
            columnGroupsView.ColumnGroups.Add(dtColGrp);
2364

    
2365
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
2366
        }
2367
#endregion
2368

    
2369
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
2370
        {
2371
            if(string.IsNullOrWhiteSpace(txtFullSearch.Text))
2372
                radGridViewDocuments.MasterTemplate.Refresh(null);
2373

    
2374
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
2375
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
2376
        }
2377

    
2378
        private void btnSearchPrevious_Click(object sender, EventArgs e)
2379
        {
2380
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
2381
        }
2382

    
2383
        private void btnSearchNext_Click(object sender, EventArgs e)
2384
        {
2385
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2386
        }
2387

    
2388
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
2389
        {
2390
            if(e.KeyCode == Keys.Enter)
2391
            {
2392
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2393
            }
2394
        }
2395
    }
2396
}
2397

    
2398
public class FilterColumn
2399
{
2400
    public string Name { get; set; }
2401
    public string FieldName { get; set; }
2402
    public bool IsSelect { get; set; }
2403
}
클립보드 이미지 추가 (최대 크기: 500 MB)