프로젝트

일반

사용자정보

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

hytos / ID2.Manager / ID2.Manager / Main.cs @ 2aa2a446

이력 | 보기 | 이력해설 | 다운로드 (108 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
            
650
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
651

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

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

    
660
            btnMatchCase.HostedItem = chkbox;
661

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

    
669
            btnShowAllDetail.HostedItem = chkbox1;
670

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

    
675
            btnSearchFormCurrent.HostedItem = chkbox2;
676

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

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

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

    
704
            btnComboColumns.DataSource = columns;
705

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

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

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

    
725
                    foreach (var template in radGridViewDocuments.Templates)
726
                    {
727
                        if (template.Columns[item.Value.ToString()] != null)
728
                        {
729
                            template.Columns[item.Value.ToString()].AllowSearching = item.Checked;
730
                        }
731
                    }
732
                }
733
            };
734

    
735
            btnFilters.HostedItem = btnComboColumns;
736
        }
737

    
738
        private void InitializeGridViewDetail()
739
        {
740
            DetailGridViewTemplate markupList = new DetailGridViewTemplate();
741

    
742
            GridViewTextBoxColumn userColumn = new GridViewTextBoxColumn("CREATE_USER");
743
            GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("TEXT");
744

    
745
            userColumn.MinWidth = 110;
746
            userColumn.AutoSizeMode = BestFitColumnMode.AllCells;
747
            userColumn.AllowSearching = true;
748
            textColumn.AutoSizeMode = BestFitColumnMode.AllCells;
749
            textColumn.AllowSearching = true;
750

    
751
            markupList.Columns.AddRange(userColumn, textColumn);
752
            markupList.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
753

    
754
            this.radGridViewDocuments.MasterTemplate.Templates.Add(markupList);
755
            markupList.HierarchyDataProvider = new GridViewEventDataProvider(markupList);
756

    
757
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
758
            this.radGridViewDocuments.RowSourceNeeded += RadGridViewDocuments_RowSourceNeeded;
759
        }
760

    
761
        private void RadGridViewDocuments_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
762
        {
763
            if (e.Template.HierarchyLevel == 1)
764
            {
765
                if (e.ParentRow.DataBoundItem is Documents documents)
766
                {
767
                    if (documents.Markups != null)
768
                    {
769
                        foreach (var makrup in documents.Markups)
770
                        {
771
                            GridViewRowInfo row = e.Template.Rows.NewRow();
772

    
773
                            row.Cells["CREATE_USER"].Value = makrup.CREATE_USER;
774
                            row.Cells["TEXT"].Value = makrup.TEXT;
775
                            e.SourceCollection.Add(row);
776
                        }
777
                        
778
                        e.Template.BestFitColumns(BestFitColumnMode.AllCells);
779
                    }
780
                }
781
            }
782
        }
783

    
784
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
785
        {
786
            if (e.IsExpanded)
787
            {
788
            }
789
        }
790

    
791
#endregion
792

    
793
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
794
        {
795
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
796
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
797
        }
798

    
799
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
800
        {
801
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
802

    
803
            foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls)
804
            {
805
                if (ctrl is OpenProjectView)
806
                {
807
                    var openProjectView = ctrl as OpenProjectView;
808
                    openProjectView.GetProjectGroups();
809
                    break;
810
                }
811
            }
812
        }
813

    
814
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
815
        {
816
            try
817
            {
818
                if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
819
                {
820
                    var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
821

    
822
                    informations.ActiveProject = prjArgs.ProjectInfo;
823

    
824
                    this.radRibbonBarBackstageViewID2Manager.Tag = null;
825

    
826
                    this.LoadProject();
827
                }
828
            }
829
            catch (Exception ex)
830
            {
831
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
832
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
833
            }
834
        }
835

    
836
        private void LoadProject()
837
        {
838
            try
839
            {
840
                #region Date
841
                //Date Type
842
                if (this.radCheckedDropDownListDateType.DataSource != null)
843
                    this.radCheckedDropDownListDateType.DataSource = null;
844

    
845
                this.radCheckedDropDownListDateType.DataSource = informations.DateType;
846
                this.radCheckedDropDownListDateType.DisplayMember = "Value";
847
                this.radCheckedDropDownListDateType.ValueMember = "Key";
848

    
849
                //FromDate
850
                this.radDateTimePickerFr.NullableValue = null;
851
                this.radDateTimePickerFr.SetToNullValue();
852

    
853
                //ToDate
854
                this.radDateTimePickerTo.NullableValue = null;
855
                this.radDateTimePickerTo.SetToNullValue();
856
                #endregion
857

    
858
                #region 도면
859
                //Project List
860
                if (this.radDropDownListProject.Items.Count > 0)
861
                    this.radDropDownListProject.Items.Clear();
862
                informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
863
                                        .ForEach(x =>
864
                                        {
865
                                            this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
866
                                        });
867
                var allProject = new RadListDataItem("== 전체 ==", string.Empty);
868
                this.radDropDownListProject.Items.Insert(0, allProject);
869
                allProject.Selected = true;
870

    
871
                //담당자 List
872
                if (this.radDropDownListPersonInCharge.Items.Count > 0)
873
                    this.radDropDownListPersonInCharge.Items.Clear();
874
                informations.UserList.ForEach(x =>
875
                {
876
                    if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
877
                        this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
878
                });
879
                var allUser = new RadListDataItem("== 전체 ==", string.Empty);
880
                this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
881
                allUser.Selected = true;
882

    
883
                //난이도
884
                if (this.radDropDownListJobLevel.Items.Count > 0)
885
                    this.radDropDownListJobLevel.Items.Clear();
886
                informations.JobLevel.ForEach(x =>
887
                {
888
                    this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
889
                });
890
                var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
891
                this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
892
                allJobLevel.Selected = true;
893

    
894
                //도면번호 조회조건
895
                this.radTextBoxDocumentNo.Text = string.Empty;
896
#endregion
897

    
898
#region 검토
899
                //문의(DOF)
900
                if (this.radDropDownListToIsDiscussion.Items.Count > 0)
901
                    this.radDropDownListToIsDiscussion.Items.Clear();
902
                informations.IsYesNo.ForEach(x =>
903
               {
904
                   this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
905
               });
906
                var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
907
                this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
908
                allToIsDiscussion.Selected = true;
909

    
910
                //회신(DS)
911
                if (this.radDropDownListFrReviewStatus.Items.Count > 0)
912
                    this.radDropDownListFrReviewStatus.Items.Clear();
913
                informations.ClientStatus.ForEach(x =>
914
                {
915
                    this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
916
                });
917
                var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
918
                this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
919
                allFrReviewStatus.Selected = true;
920
                #endregion
921

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

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

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

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

    
975
                #endregion
976

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

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

    
1001
#region AVEVA
1002
                //Gateway
1003
                if (this.radDropDownListGateway.Items.Count > 0)
1004
                    this.radDropDownListGateway.Items.Clear();
1005
                informations.IsYesNo.ForEach(x =>
1006
                {
1007
                    this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x));
1008
                });
1009
                var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty);
1010
                this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay);
1011
                allDTIsGateWay.Selected = true;
1012

    
1013
                //Registration
1014
                if (this.radDropDownListRegistration.Items.Count > 0)
1015
                    this.radDropDownListRegistration.Items.Clear();
1016
                informations.IsYesNo.ForEach(x =>
1017
                {
1018
                    this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x));
1019
                });
1020
                var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty);
1021
                this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem);
1022
                allDTIsRegSystem.Selected = true;
1023
#endregion
1024

    
1025
                this.GetDocList();
1026
            }
1027
            catch (Exception ex)
1028
            {
1029
                throw ex;
1030
            }
1031
            finally
1032
            {
1033

    
1034
                this.Cursor = Cursors.Default;
1035

    
1036
            }
1037

    
1038
        }
1039

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

    
1051
                    string projectCode = this.radDropDownListProject.SelectedValue.ToString();
1052
                    string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
1053
                    string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
1054
                    string documentNo = this.radTextBoxDocumentNo.Text.Trim();
1055

    
1056
                    string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
1057
                    string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
1058

    
1059
                    string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
1060
                    string id2Issues = this.radDropDownListID2Issues.SelectedValue.ToString();
1061
                    string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
1062
                    string avevaIssues = this.radDropDownListAVEVAIssues.SelectedValue.ToString();
1063

    
1064
                    string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
1065
                    string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
1066

    
1067
                    string isGateWay = this.radDropDownListGateway.SelectedValue.ToString();
1068
                    string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString();
1069

    
1070
                    var worker = new LoadDocumentsWorker(dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments);
1071
                    worker.OnWorkCompletedHandler += (e) =>
1072
                    {
1073
                        var docData = e.Result as DocumentsResult;
1074

    
1075
                        this.documents = docData.Dwgs;
1076
                        this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
1077
                        this.TotalCount = docData.TotalCount;
1078

    
1079
                        List<string> projectCodes = new List<string>();
1080

    
1081
                        if (!string.IsNullOrWhiteSpace(projectCode))
1082
                        {
1083
                            projectCodes.Add(projectCode);
1084
                        }
1085
                        else
1086
                        {
1087
                            projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
1088
                        }
1089

    
1090
                        this.DocumentListBinding();
1091
                    };
1092

    
1093
                    (btnShowAllDetail.HostedItem as RadCheckBoxElement).Checked = false;
1094
                    worker.StartWork();
1095
                }
1096
            }
1097
            catch (Exception ex)
1098
            {
1099
                throw ex;
1100
            }
1101
        }
1102

    
1103
        public void DocumentListBinding()
1104
        {
1105
            try
1106
            {
1107
                GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
1108
                ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
1109
                ColProjects.DisplayMember = "Name";
1110
                ColProjects.ValueMember = "Code";
1111

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

    
1115
                GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
1116
                ColPersonInCharge.DataSource = workUsers;
1117
                ColPersonInCharge.DisplayMember = "Name";
1118
                ColPersonInCharge.ValueMember = "ID";
1119

    
1120
                GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
1121
                ColWorker.DataSource = workUsers;
1122
                ColWorker.DisplayMember = "Name";
1123
                ColWorker.ValueMember = "ID";
1124

    
1125
                GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
1126
                ColToCreator.DataSource = workUsers;
1127
                ColToCreator.DisplayMember = "Name";
1128
                ColToCreator.ValueMember = "ID";
1129

    
1130
                GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
1131
                ColFrCreator.DataSource = clientUsers;
1132
                ColFrCreator.DisplayMember = "Name";
1133
                ColFrCreator.ValueMember = "ID";
1134

    
1135
                GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
1136
                ColProdReviewer.DataSource = workUsers;
1137
                ColProdReviewer.DisplayMember = "Name";
1138
                ColProdReviewer.ValueMember = "ID";
1139

    
1140
                GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
1141
                ColClientReviewer.DataSource = clientUsers;
1142
                ColClientReviewer.DisplayMember = "Name";
1143
                ColClientReviewer.ValueMember = "ID";
1144

    
1145
                //Data
1146
                if (this.radGridViewDocuments.DataSource != null)
1147
                    this.radGridViewDocuments.DataSource = null;
1148

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

    
1163
                this.radGridViewDocuments.FilterDescriptors.Clear();
1164
                this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
1165
                this.lbSelectAndTotal.Text = $"{this.documents.Count} / {this.TotalCount} (Selected / Total)";
1166

    
1167
                var verification = this.LayoutValidation.Controls[0] as Verification;
1168
                verification.DocumentListBinding(this.documents);
1169
            }
1170
            catch (Exception ex)
1171
            {
1172
                throw ex;
1173
            }
1174
        }
1175
        #endregion
1176

    
1177
        #region Button, Checkbox event
1178
        private void RadButtonDateClear_Click(object sender, EventArgs e)
1179
        {
1180
            //DateType
1181
            this.radCheckedDropDownListDateType.CheckedItems.Clear();
1182
            //FromDate
1183
            this.radDateTimePickerFr.SetToNullValue();
1184
            //ToDate
1185
            this.radDateTimePickerTo.SetToNullValue();
1186
        }
1187

    
1188
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
1189
        {
1190
            if (sender is RadCheckBox)
1191
            {
1192
                RadCheckBox checkBox = sender as RadCheckBox;
1193

    
1194
                if (checkBox.Tag != null)
1195
                {
1196
                    ColumnGroupsViewDefinition columnGroupsView =  this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1197
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1198
                    if (colGroup != null)
1199
                        colGroup.IsVisible = checkBox.Checked;
1200
                }
1201
            }
1202

    
1203
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
1204
        }
1205

    
1206
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
1207
        {
1208
            if (e.KeyCode == Keys.Enter)
1209
            {
1210
                this.radButtonSearch.Focus();
1211
                this.radButtonSearch.PerformClick();
1212
            }
1213
        }
1214

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

    
1228
        private void BackstageButtonItemSelectDB_Click(object sender, EventArgs e)
1229
        {
1230
            using (var frm = new SetID2ProjectDB())
1231
            {
1232
                if (frm.ShowDialog(this) == DialogResult.OK)
1233
                {
1234
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
1235
                    {
1236
                        this.radRibbonBarBackstageViewID2Manager.HidePopup();
1237

    
1238
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
1239
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1240

    
1241
                        this.LoadProject();
1242
                    }
1243
                    else
1244
                    {
1245
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1246
                        bool isID2 = this.IsID2Connection();
1247
                        this.SetMenus(isID2);
1248

    
1249
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
1250
                        {
1251
                            if (ctrl is OpenProjectView)
1252
                            {
1253
                                var openProjectView = ctrl as OpenProjectView;
1254
                                openProjectView.GetProjectGroups();
1255
                                break;
1256
                            }
1257
                        }
1258
                    }
1259
                }
1260
            }
1261
        }
1262

    
1263
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
1264
        {
1265
            using (var frm = new SetupUser())
1266
            {
1267
                if (frm.ShowDialog(this) == DialogResult.OK)
1268
                {
1269
                    
1270
                }
1271
            }
1272
        }
1273

    
1274
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
1275
        {
1276
            Application.Exit();
1277
        }
1278
#endregion
1279

    
1280
#region Grid event
1281
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
1282
        {
1283
            if (e.Row is GridViewNewRowInfo)
1284
            {
1285
                
1286
            }
1287
            else
1288
            {
1289
                string extension = string.Empty;
1290

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

    
1321
                                try
1322
                                {
1323
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
1324
                                    {
1325
                                        DocID = doc.DocID,
1326
                                        ID2StartDate = DateTime.Now,
1327
                                        Worker = informations.ActiveUser.ID
1328
                                    }, informations.ActiveUser.ID);
1329

    
1330
                                    if (returnDoc != null)
1331
                                    {
1332
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
1333
                                        doc.Worker = returnDoc.Worker;
1334
                                    }
1335
                                }
1336
                                catch { }
1337
                            }
1338
                        }
1339
                        catch (Exception ex)
1340
                        {
1341
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1342
                        }
1343
                        break;
1344
                }
1345
            }
1346
        }
1347

    
1348
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
1349
        {
1350
            if (e.ActiveEditor is RadDropDownListEditor)
1351
            {
1352
                switch (e.Column.Name)
1353
                {
1354
                    case "JobLevel":
1355
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1356
                        colJobLevel.DataSource = informations.JobLevel;
1357
                        break;
1358
                    case "IsTypical":
1359
                    case "ToIsDiscussion":
1360
                    case "DTIsImport":
1361
                    case "DTIsGateWay":
1362
                    case "DTIsRegSystem":
1363
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1364
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
1365
                        break;
1366
                    case "ID2Status":
1367
                    case "AVEVAStatus":
1368
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1369
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
1370
                        break;
1371
                    case "FrReviewStatus"://삼성의견status
1372
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1373
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
1374
                        break;
1375
                    case "ProdIsResult":
1376
                    case "ClientIsResult":
1377
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1378
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
1379
                        break;
1380
                }
1381
            }
1382
        }
1383

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

    
1446
                    }
1447
                }
1448
            }
1449
            else if(e.Row is GridViewDetailsRowInfo)
1450
            {
1451
                if (e.CellElement is GridDetailViewCellElement detailViewCellElement)
1452
                {
1453
                    detailViewCellElement.Padding = new Padding(10,2,2,2);
1454
                    detailViewCellElement.BackColor = Color.FromArgb(214, 214, 214);
1455
                    detailViewCellElement.BackColor2 = Color.FromArgb(214, 214, 214);
1456
                }
1457
            }
1458
            //else if (e.Row is GridViewSummaryRowInfo)
1459
            //{
1460
            //    if (e.CellElement is GridRowHeaderCellElement)
1461
            //    {
1462
            //        e.CellElement.Text = "Count";
1463
            //    }
1464
            //    else if (e.CellElement is GridSummaryCellElement)
1465
            //    {
1466
            //        e.CellElement.ForeColor = this._SummaryColor;
1467
            //        e.CellElement.TextAlignment = ContentAlignment.BottomRight;
1468
            //        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
1469
            //    }
1470
            //    else
1471
            //    {
1472

    
1473
            //    }
1474
            //}
1475
            else
1476
            {
1477

    
1478
            }
1479
        }
1480

    
1481
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName)
1482
        {
1483
            RadButtonElement btnElem = null;
1484
            Bitmap bitmap = null; ;
1485

    
1486
            switch (colName)
1487
            {
1488
                case "AutoCADLink":
1489
                    bitmap = new Bitmap(Properties.Resources.cad18);
1490
                    break;
1491
                case "PDFLink":
1492
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1493
                    break;
1494
                case "MarkupLink":
1495
                    bitmap = new Bitmap(Properties.Resources.markus18);
1496
                    break;
1497
                case "AVEVALink":
1498
                case "AVEVAConnection":
1499
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
1500
                    break;
1501
                case "ReviewFileName"://일단주석
1502
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1503
                    break;
1504
                case "SystemLink":
1505
                    bitmap = new Bitmap(Properties.Resources.link18_yellow);
1506
                    break;
1507
                case "ID2Connection":
1508
                    bitmap = new Bitmap(Properties.Resources.id218);
1509
                    break;
1510
            }
1511

    
1512
            switch (colName)
1513
            {
1514
                case "AutoCADLink":
1515
                case "PDFLink":
1516
                case "MarkupLink":
1517
                case "AVEVALink":
1518
                case "AVEVAConnection":
1519
                case "ReviewFileName"://일단주석
1520
                case "SystemLink":
1521
                case "ID2Connection":
1522
                    btnElem = (RadButtonElement)elem;
1523
                    btnElem.Margin = new Padding(0);
1524
                    btnElem.Padding = new Padding(0);
1525
                    btnElem.BorderElement.Opacity = 0;
1526
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
1527
                    btnElem.DisplayStyle = DisplayStyle.Image;
1528
                    btnElem.Image = bitmap;
1529
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
1530
                    btnElem.MaxSize = bitmap.Size;
1531
                    break;
1532
            }
1533

    
1534
            return btnElem;
1535
        }
1536

    
1537
        private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
1538
        {
1539
            this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)";
1540
        }
1541
#endregion
1542

    
1543
#region Excel
1544
        private UserInfo GetUser(string user)
1545
        {
1546
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
1547
            if (userInfo != null) return userInfo;
1548

    
1549
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
1550
            if (userInfo != null) return userInfo;
1551

    
1552
            return userInfo ?? new UserInfo();
1553
        }
1554

    
1555
        private ProjectInfo GetProject(string project)
1556
        {
1557
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault();
1558
            if (prjInfo != null) return prjInfo;
1559

    
1560
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
1561
            if (prjInfo != null) return prjInfo;
1562

    
1563
            return prjInfo ?? new ProjectInfo();
1564
        }
1565

    
1566
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
1567
        {
1568
            var form =  new Forms.SelectExcelData();
1569

    
1570
            var dialogResult = form.ShowDialog();
1571

    
1572
            if (dialogResult == DialogResult.OK)
1573
            {
1574
                using (ID2Excel excel = new ID2Excel(informations.UserList.ToList()))
1575
                {
1576
                    var result = excel.ExcelDataImport(form.SelectItems);
1577

    
1578
                    if (result.Error != null)
1579
                    {
1580

    
1581
                        RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1582
                    }
1583
                    else
1584
                    {
1585
                        this.importImages = result.Images;
1586
                        this.documents.AddRange(result.documents);
1587
                        if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1588
                        this.DocumentListBinding();
1589
                        //briefAndImagesReview.SetImages(this.importImages);
1590
                    }
1591

    
1592
                }
1593
            }
1594
        }
1595

    
1596
        private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e)
1597
        {
1598
            using (OpenFileDialog ofd = new OpenFileDialog()
1599
            {
1600
                Filter = "Excel files (*.xlsx)|*.xlsx",
1601
                Title = "Open an Excel File",
1602
                RestoreDirectory = true
1603
            })
1604
            {
1605
                if (ofd.ShowDialog() == DialogResult.OK)
1606
                {
1607
                    //Error Message
1608
                    StringBuilder sbErrMsg = new StringBuilder();
1609

    
1610
                    using(ID2Excel excel = new ID2Excel(informations.UserList.ToList()))
1611
                    {
1612
                       var result = excel.GemboxImport(ofd.FileName);
1613

    
1614
                        if(result.Error != null)
1615
                        {
1616

    
1617
                            RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1618
                        }
1619
                        else
1620
                        {
1621
                            this.documents.AddRange(result.documents);
1622
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1623
                            this.DocumentListBinding();
1624
                        }
1625

    
1626
                    }
1627

    
1628

    
1629
                    //foreach (Documents appDoc in appendDocuments)
1630
                    //{
1631
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1632

    
1633
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1634
                    //    {
1635
                    //        if (fieldInfo.GetValue(appDoc) != null)
1636
                    //        {
1637
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1638

    
1639
                    //            if (cols.Any())
1640
                    //            {
1641
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1642
                    //            }
1643
                    //        }
1644
                    //    }
1645
                    //}
1646
                }
1647
            }
1648
        }
1649

    
1650
        private void RadButtonElementExcelImport_Click_old(object sender, EventArgs e)
1651
        {
1652
            using (OpenFileDialog ofd = new OpenFileDialog()
1653
            {
1654
                Filter = "Excel files (*.xlsx)|*.xlsx",
1655
                Title = "Open an Excel File",
1656
                RestoreDirectory = true
1657
            })
1658
            {
1659
                if (ofd.ShowDialog() == DialogResult.OK)
1660
                {
1661
                    //Error Message
1662
                    StringBuilder sbErrMsg = new StringBuilder();
1663

    
1664
                    var exFile = ExcelFile.Load(ofd.FileName);
1665
                    var ws = exFile.Worksheets[0];
1666

    
1667
                    int rowCount = ws.Rows.Count;
1668
                    int columnCount = ws.CalculateMaxUsedColumns();
1669
                    int exRow = 8;
1670

    
1671
#region Excel 유효성검사
1672

    
1673
                    //Excel 포멧체크
1674
                    if (rowCount < 10 || columnCount != 45)
1675
                    {
1676
                        RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1677
                        return;
1678
                    }
1679

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

    
1686
                    if (sbErrMsg.Length > 0)
1687
                    {
1688
                        string errMsg = sbErrMsg.ToString().Substring(2);
1689
                        if (errMsg.Length > 100)
1690
                        {
1691
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1692
                        }
1693

    
1694
                        RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1695
                        return;
1696
                    }
1697
#endregion
1698

    
1699
#region 엑셀 도명명 중복 값 체크
1700
                    ws.Rows.SelectMany(row => row.AllocatedCells)
1701
                                                 .Where(col => col.Column.Index == 6 && col.Row.Index > exRow)
1702
                                                 .GroupBy(g => g.Row.Index)
1703
                                                 .Select(p => new {
1704
                                                     rowIndex = p.Key,
1705
                                                     docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
1706
                                                 })
1707
                                                 .GroupBy(g => g.docNo)
1708
                                                 .Where(p => p.Count() > 1)
1709
                                                 .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
1710
                                                                                            .Aggregate((x, y) => x.ToString() + "," + y.ToString())
1711
                                                                                            .ToString())
1712
                                                 .ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
1713
                    if (sbErrMsg.Length > 0)
1714
                    {
1715
                        sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
1716
                        string errMsg = sbErrMsg.ToString();
1717
                        if (errMsg.Length > 100)
1718
                        {
1719
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1720
                        }
1721

    
1722
                        RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1723
                        return;
1724
                    }
1725
#endregion
1726

    
1727
#endregion
1728

    
1729
                    List<Documents> appendDocuments = new List<Documents>();
1730

    
1731
                    ws.Rows.Where(row => row.Index > exRow)
1732
                           .ToList()
1733
                           .ForEach(p => appendDocuments.Add(new Documents()
1734
                           {
1735
                               //UID = string.Empty,
1736
                               //Type = this.radTextBoxInsulationType.Text,
1737
                               //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
1738
                               //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
1739
                               //NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
1740
                               //Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value)
1741

    
1742
                               RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1743
                               DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
1744
                               PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
1745
                               JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
1746
                               IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
1747
                               RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
1748
                               ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
1749
                               ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
1750
                               ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
1751
                               //ToCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1752
                               //ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1753
                               FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
1754
                               FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
1755
                               FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
1756
                               //FrCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1757
                               //FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1758
                               //IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
1759
                               //ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1760
                               ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
1761
                               ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
1762
                               //ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1763
                               ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
1764
                               ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
1765
                               //AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1766
                               AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
1767
                               AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
1768
                               AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
1769
                               AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
1770
                               ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
1771
                               ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
1772
                               ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
1773
                               ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
1774
                               ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
1775
                               ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
1776
                               DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
1777
                               DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
1778
                               DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
1779
                               DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
1780
                           }));
1781

    
1782
                    this.documents.AddRange(appendDocuments);
1783
                    if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1784
                    this.DocumentListBinding();
1785

    
1786
                    //foreach (Documents appDoc in appendDocuments)
1787
                    //{
1788
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1789

    
1790
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1791
                    //    {
1792
                    //        if (fieldInfo.GetValue(appDoc) != null)
1793
                    //        {
1794
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1795

    
1796
                    //            if (cols.Any())
1797
                    //            {
1798
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1799
                    //            }
1800
                    //        }
1801
                    //    }
1802
                    //}
1803
                }
1804
            }
1805
        }
1806

    
1807
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
1808
        {
1809
            string sPrefixName = "Samsung Elec Task Management";
1810
            string extension = ".xlsx";
1811

    
1812
            using (SaveFileDialog sfd = new SaveFileDialog()
1813
            {
1814
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
1815
                Filter = "Excel|*.xlsx",
1816
                Title = "Save an Excel File",
1817
                CheckFileExists = false,
1818
                CheckPathExists = true,
1819
                OverwritePrompt = true
1820
            })
1821
            {
1822
                if (sfd.ShowDialog() == DialogResult.OK)
1823
                {
1824
                    string fileName = $"{sPrefixName}{extension}";
1825
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
1826
                    string templateFilePath = Path.Combine(templateFolder, fileName);
1827
                    if (!File.Exists(templateFilePath))
1828
                    {
1829
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1830
                        return;
1831
                    }
1832

    
1833
                    var templateExcelFile = ExcelFile.Load(templateFilePath);
1834
                    var templateWorksheets = templateExcelFile.Worksheets;
1835
                    var templateWorksheet = templateWorksheets[0];
1836

    
1837
                    if (this.radGridViewDocuments.Rows.Count > 0)
1838
                    {
1839
                        int rowIndex = 9;
1840
                        //int colIndex = 1;
1841

    
1842
                        foreach (var row in this.radGridViewDocuments.Rows)
1843
                        {
1844
                            var doc = row.DataBoundItem as Documents;
1845

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

    
1901
#region Save event
1902

    
1903
        private void SetSaved()
1904
        {
1905
            try
1906
            {
1907
                if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1908
                {
1909
                    #region document no 중복 유효성 체크
1910
                    int dupDwgNoCount = 0;
1911
                    List<string> newDwgNos =  this.documents.Where(x => string.IsNullOrEmpty(x.DocID)).Select(x => x.DocumentNo).ToList();
1912
                    if (newDwgNos.Count > 0)
1913
                    {
1914
                        dupDwgNoCount = new DocumentController().ExistsDocument(informations.ActiveProject.ProjectID, newDwgNos);
1915
                    }
1916

    
1917
                    if (dupDwgNoCount > 0)
1918
                    {
1919
                        RadMessageBox.Show($"Duplicate Dwg No exists.({dupDwgNoCount})", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1920
                        return;
1921
                    }
1922
                    #endregion
1923

    
1924
                    var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments);
1925
                    worker.OnWorkCompletedHandler += (e) =>
1926
                    {
1927
                        bool result = false;
1928
                        bool markusResult = false;
1929
                        bool markusMembersResult = false;
1930

    
1931
                        result = (bool)e.Result;
1932
                        if (result)
1933
                        {
1934
                            markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1935
                            markusMembersResult = new MarkusInfoController().SetMembers(informations.UserList);
1936
                        }
1937

    
1938
                        if (result && markusResult && markusMembersResult)
1939
                        {
1940
                            RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1941

    
1942
                            this.GetDocList();
1943
                        }
1944
                        else if (!result)
1945
                        {
1946
                            RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1947
                        }
1948
                        else if (!markusResult)
1949
                        {
1950
                            RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1951
                        }
1952
                        else if (!markusMembersResult)
1953
                        {
1954
                            RadMessageBox.Show("Markus Members Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1955
                        }
1956
                    };
1957
                    worker.StartWork();
1958
                }
1959
            }
1960
            catch (Exception ex)
1961
            {
1962
                throw ex;
1963
            }
1964
        }
1965

    
1966
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
1967
        {
1968
            try
1969
            {
1970
                this.SetSaved();
1971
            }
1972
            catch (Exception ex)
1973
            {
1974
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1975
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1976
            }
1977
        }
1978

    
1979
        private void RadButtonElementSave_Click(object sender, EventArgs e)
1980
        {
1981
            try
1982
            {
1983
                this.SetSaved();
1984
            }
1985
            catch (Exception ex)
1986
            {
1987
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1988
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1989
            }
1990
        }
1991

    
1992
        private void RadButtonElementSync_Click(object sender, EventArgs e)
1993
        {
1994
            try
1995
            {
1996
                if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1997
                {
1998
                    var worker = new SyncDocumentsWorker(this.radGridViewDocuments);
1999
                    worker.OnWorkCompletedHandler += (arg) =>
2000
                    {
2001
                        if ((bool)arg.Result)
2002
                        {
2003
                            this.GetDocList();
2004

    
2005
                            RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2006
                        }
2007
                    };
2008
                    worker.StartWork();
2009
                }
2010
            }
2011
            catch (Exception ex)
2012
            {
2013
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2014
                RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2015
            }
2016
        }
2017

    
2018
        private void RadButtonElementNotice_Click(object sender, EventArgs e)
2019
        {
2020
            try
2021
            {
2022
                AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProject.ProjectID, "notice");
2023

    
2024
                if (notiFileInfo == null)
2025
                {
2026
                    RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2027
                }
2028
                else
2029
                {
2030
                    string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles");
2031
                    string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}");
2032

    
2033
                    FileInfo finfo = new FileInfo(noticeFileFullName);
2034

    
2035
                    if (!finfo.Directory.Exists)
2036
                    {
2037
                        Directory.CreateDirectory(noticePath);
2038
                    }
2039

    
2040
                    if (!finfo.Exists)
2041
                    {
2042
                        var arrayBinary = notiFileInfo.FileData.ToArray();
2043

    
2044
                        using (MemoryStream ms = new MemoryStream(arrayBinary))
2045
                        {
2046
                            ms.Write(arrayBinary, 0, arrayBinary.Length);
2047
                            ms.Seek(0, SeekOrigin.Begin);
2048

    
2049
                            using (FileStream fs = finfo.Create())
2050
                            {
2051
                                ms.CopyTo(fs);
2052
                            }
2053
                        }
2054
                    }
2055

    
2056
                    try
2057
                    {
2058
                        ProcessStartInfo startInfo = new ProcessStartInfo
2059
                        {
2060
                            FileName = finfo.FullName,
2061
                            UseShellExecute = true,
2062
                            CreateNoWindow = false,
2063
                            WindowStyle = ProcessWindowStyle.Normal
2064
                        };
2065

    
2066
                        using (Process process = new Process())
2067
                        {
2068
                            process.StartInfo = startInfo;
2069
                            process.Start();
2070
                        }
2071
                        //Process.Start(finfo.FullName);
2072
                    }
2073
                    catch (Exception ex)
2074
                    {
2075
                        throw ex;
2076
                    }
2077

    
2078
                    //using (MemoryStream ms = new MemoryStream(arrayBinary))
2079
                    //{
2080
                    //    ProcessStartInfo startInfo = new ProcessStartInfo
2081
                    //    {
2082
                    //        FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName),
2083
                    //        RedirectStandardInput = true,
2084
                    //        UseShellExecute = false,
2085
                    //        CreateNoWindow = true,
2086
                    //        WindowStyle = ProcessWindowStyle.Hidden
2087
                    //    };
2088

    
2089
                    //    using (Process process = new Process())
2090
                    //    {
2091
                    //        process.StartInfo = startInfo;
2092
                    //        process.Start();
2093

    
2094
                    //        // Write the memory stream contents to the process standard input
2095
                    //        byte[] buffer = ms.ToArray();
2096
                    //        process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length);
2097
                    //        process.StandardInput.Close();
2098

    
2099
                    //        process.WaitForExit();
2100
                    //    }
2101
                    //}
2102
                }
2103
            }
2104
            catch (Exception ex)
2105
            {
2106
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2107
                RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2108
            }
2109
        }
2110

    
2111
        private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e)
2112
        {
2113
            string GetContentType(string filePath)
2114
            {
2115
                string extension = Path.GetExtension(filePath).ToLower();
2116

    
2117
                switch (extension)
2118
                {
2119
                    case ".txt":
2120
                        return "text/plain";
2121
                    case ".pdf":
2122
                        return "application/pdf";
2123
                    case ".jpg":
2124
                    case ".jpeg":
2125
                        return "image/jpeg";
2126
                    case ".png":
2127
                        return "image/png";
2128
                    case ".bmp":
2129
                        return "image/bmp";
2130
                    case ".gif":
2131
                        return "image/gif";
2132
                    default:
2133
                        return "application/octet-stream";
2134
                }
2135
            }
2136

    
2137
            using (OpenFileDialog ofd = new OpenFileDialog()
2138
            {
2139
                //Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*",
2140
                Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp)|*.png;*.jpeg;*.gif;*.jpg;*.bmp"
2141
                       + "|PNG Portable Network Graphics (*.png)|*.png"
2142
                       +"|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif"
2143
                       + "|BMP Windows Bitmap (*.bmp)|*.bmp"
2144
                       + "|GIF Graphics Interchange Format (*.gif)|*.gif",
2145
            //Title = "Open an Excel File",
2146
            RestoreDirectory = true
2147
            })
2148
            {
2149
                try
2150
                {
2151
                    if (ofd.ShowDialog() == DialogResult.OK)
2152
                    {
2153
                        FileInfo fileInfo = new FileInfo(ofd.FileName);
2154
                        if (fileInfo.Exists)
2155
                        {
2156
                            AttFileInfo attFile = new AttFileInfo()
2157
                            {
2158
                                RefID = informations.ActiveProject.ProjectID,
2159
                                Category = "notice",
2160
                                FileType = GetContentType(fileInfo.FullName),
2161
                                FileName = fileInfo.Name,
2162
                                FilePath = fileInfo.DirectoryName,
2163
                                FileExtension = fileInfo.Extension
2164
                            };
2165

    
2166
                            using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
2167
                            {
2168
                                using (var reader = new BinaryReader(stream))
2169
                                {
2170
                                    attFile.FileData = reader.ReadBytes((int)stream.Length);
2171
                                }
2172
                            }
2173

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

    
2176
                            if (result)
2177
                            {
2178
                                RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2179
                            }
2180
                        }
2181
                    }
2182
                }
2183
                catch (Exception ex)
2184
                {
2185
                    Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2186
                    RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2187
                }
2188
            }
2189
        }
2190

    
2191
        private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e)
2192
        {
2193
            bool isReload = false;
2194

    
2195
            try
2196
            {
2197
                if (RadMessageBox.Show($"Do you want to reload the project?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2198
                {
2199
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
2200
                    {
2201
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
2202
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2203

    
2204
                        isReload = true;
2205
                    }
2206
                    else if (informations.ActiveProject != null)
2207
                    {
2208
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2209

    
2210
                        isReload = true;
2211
                    }
2212
                    else
2213
                    {
2214
                        RadMessageBox.Show("Select a project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2215
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
2216
                    }
2217
                }
2218

    
2219
                if (isReload)
2220
                {
2221
                    this.LoadProject();
2222
                }
2223
            }
2224
            catch (Exception ex)
2225
            {
2226
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2227
                RadMessageBox.Show("Failed to reload the project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2228
            }
2229
        }
2230
#endregion
2231

    
2232
#region ColumnGroup
2233
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
2234
        {
2235
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
2236

    
2237
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" };
2238
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "System", "SubSystemCode", "DocumentNo", "PersonInCharge", "Worker", "JobLevel", "IsTypical", "RevisonNo" };
2239
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture" };
2240
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" };
2241
            List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2Status", "ID2Issues" };
2242
            List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" };
2243
            List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" };
2244
            List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks", "ProdCapture" };
2245
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks", "ClientCapture" };
2246
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
2247

    
2248
            //도면
2249
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 ");
2250
            GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("프로그램 연동");
2251
            GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보");
2252

    
2253
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
2254
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
2255

    
2256
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
2257
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
2258

    
2259
            docLinkColGrp.Rows.Add(docLinkColGrpRow);
2260
            docColGrp.Groups.Add(docLinkColGrp);
2261
            docInfoColGrp.Rows.Add(docInfoColGrpRow);
2262
            docColGrp.Groups.Add(docInfoColGrp);
2263

    
2264
            //검토
2265
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
2266
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
2267
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
2268

    
2269
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
2270
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
2271

    
2272
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
2273
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
2274

    
2275
            rvToColGrp.Rows.Add(rvToColGrpRow);
2276
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
2277

    
2278
            rvColGrp.Groups.Add(rvToColGrp);
2279
            rvColGrp.Groups.Add(rvFrColGrp);
2280

    
2281
            //작업
2282
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
2283
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
2284
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
2285

    
2286
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
2287
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
2288

    
2289
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
2290
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
2291

    
2292
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
2293
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
2294

    
2295
            wkColGrp.Groups.Add(wkID2ColGrp);
2296
            wkColGrp.Groups.Add(wkAVEVAColGrp);
2297

    
2298

    
2299
            //Validation
2300
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
2301
            GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크");
2302
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
2303
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
2304

    
2305
            GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow();
2306
            valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames);
2307

    
2308
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
2309
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
2310

    
2311
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
2312
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
2313

    
2314
            valLinkColGrp.Rows.Add(valLinkColGrpRow);
2315
            valProdColGrp.Rows.Add(valProdColGrpRow);
2316
            valCntColGrp.Rows.Add(valCntColGrpRow);
2317

    
2318
            valColGrp.Groups.Add(valLinkColGrp);
2319
            valColGrp.Groups.Add(valProdColGrp);
2320
            valColGrp.Groups.Add(valCntColGrp);
2321

    
2322
            //AVEVA Net
2323
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
2324

    
2325
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
2326
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
2327

    
2328
            dtColGrp.Rows.Add(dtColGrpRow);
2329

    
2330
            //Group 추가
2331
            columnGroupsView.ColumnGroups.Add(docColGrp);
2332
            columnGroupsView.ColumnGroups.Add(rvColGrp);
2333
            columnGroupsView.ColumnGroups.Add(wkColGrp);
2334
            columnGroupsView.ColumnGroups.Add(valColGrp);
2335
            columnGroupsView.ColumnGroups.Add(dtColGrp);
2336

    
2337
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
2338
        }
2339
#endregion
2340

    
2341
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
2342
        {
2343
            if(string.IsNullOrWhiteSpace(txtFullSearch.Text))
2344
                radGridViewDocuments.MasterTemplate.Refresh(null);
2345

    
2346
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
2347
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
2348
        }
2349

    
2350
        private void btnSearchPrevious_Click(object sender, EventArgs e)
2351
        {
2352
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
2353
        }
2354

    
2355
        private void btnSearchNext_Click(object sender, EventArgs e)
2356
        {
2357
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2358
        }
2359

    
2360
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
2361
        {
2362
            if(e.KeyCode == Keys.Enter)
2363
            {
2364
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2365
            }
2366
        }
2367

    
2368
        private void commandBarSearch_ItemOverflowed(object sender, EventArgs e)
2369
        {
2370
            commandBarSearch.OverflowButton.AddRemoveButtonsMenuItem.Visibility = ElementVisibility.Collapsed;
2371
            commandBarSearch.OverflowButton.CustomizeButtonMenuItem.Visibility = ElementVisibility.Collapsed;
2372
        }
2373

    
2374
        private void commandBarSearch_ItemOutOfOverflow(object sender, EventArgs e)
2375
        {
2376
            commandBarSearch.OverflowButton.AddRemoveButtonsMenuItem.Visibility = ElementVisibility.Collapsed;
2377
            commandBarSearch.OverflowButton.CustomizeButtonMenuItem.Visibility = ElementVisibility.Collapsed;
2378
        }
2379
    }
2380
}
2381

    
2382
public class FilterColumn
2383
{
2384
    public string Name { get; set; }
2385
    public string FieldName { get; set; }
2386
    public bool IsSelect { get; set; }
2387
}
클립보드 이미지 추가 (최대 크기: 500 MB)