프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ 40a1e23a

이력 | 보기 | 이력해설 | 다운로드 (137 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
using System.Diagnostics;
14

    
15
using ID2.Manager.Controls;
16
using ID2.Manager.Common;
17
using ID2.Manager.Classes;
18
using ID2.Manager.Data.Models;
19
using ID2.Manager.Forms;
20
using ID2.Manager.Controller.Controllers;
21
using ID2.Manager.Common.Helpers;
22
using static ID2.Manager.Data.Models.Documents;
23

    
24
using Telerik.WinControls;
25
using Telerik.WinControls.UI;
26

    
27
using GemBox.Spreadsheet;
28

    
29
using Newtonsoft.Json;
30

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

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

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

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

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

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

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

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

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

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

    
83
            this.FormClosing += Main_FormClosing;
84
            this.radButtonElementRefreshCommand.Click += RadButtonElementRefreshCommand_Click;
85
            this.radButtonElementSaveCommand.Click += RadButtonElementSaveCommand_Click;
86
            this.btnDockLayoutReset.Click += BtnDockLayoutReset_Click;
87
            this.radButtonElementFilterClear.Click += RadButtonElementFilterClear_Click;
88
            this.radButtonElementSave.Click += RadButtonElementSave_Click;
89
            this.radButtonElementSync.Click += RadButtonElementSync_Click;
90
            this.radButtonElementNotice.Click += RadButtonElementNotice_Click;
91
            this.radButtonElementNoticeUpload.Click += RadButtonElementNoticeUpload_Click;
92
            this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click;
93
            this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click;
94
            this.radButtonElementDelete.Click += RadButtonElementDelete_Click;
95
            this.radButtonElementLevel.Click += RadButtonElementLevel_Click;
96
            this.radButtonElementConvert.Click += RadButtonElementConvert_Click;
97

    
98
            this.radButtonDateClear.Click += RadButtonDateClear_Click;
99

    
100
            this.radDropDownListProject.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
101
            this.radDropDownListPersonInCharge.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
102
            this.radDropDownListJobLevel.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
103
            this.radDropDownListToIsDiscussion.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
104
            this.radDropDownListFrReviewStatus.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
105
            this.radDropDownListID2Status.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
106
            this.radDropDownListID2Issues.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
107
            this.radDropDownListAVEVAStatus.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
108
            this.radDropDownListAVEVAIssues.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
109
            this.radDropDownListProdIsResult.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
110
            this.radDropDownListClientIsResult.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
111
            this.radDropDownListGateway.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
112
            this.radDropDownListRegistration.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
113

    
114
            this.radCollapsiblePanelCondition.Collapsed += RadCollapsiblePanelCondition_Collapsed;
115
            this.radCollapsiblePanelCondition.Expanded += RadCollapsiblePanelCondition_Expanded;
116

    
117
            this.radCheckBoxLink.CheckStateChanged += RadCheckBoxFreezed_CheckStateChanged;
118
            this.radCheckBoxDocInfo.CheckStateChanged += RadCheckBoxFreezed_CheckStateChanged;
119

    
120
            this.radCheckBoxReview.CheckStateChanged += RadCheckBox_CheckStateChanged;
121
            this.radCheckBoxWork.CheckStateChanged += RadCheckBox_CheckStateChanged;
122
            this.radCheckBoxVaildation.CheckStateChanged += RadCheckBox_CheckStateChanged;
123
            this.radCheckBoxAVEVANet.CheckStateChanged += RadCheckBox_CheckStateChanged;
124
            this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown;
125
            this.radTextBoxDocumentNo.KeyUp += RadTextBoxDocumentNo_KeyUp;
126
            this.radButtonSearch.Click += RadButtonSearch_Click;
127
            #region 테마 설정
128
            this.radMenuItemControlDefault.Click += RadMenuItemTheme_Click;
129
            this.radMenuItemOffice2013Dark.Click += RadMenuItemTheme_Click;
130
            this.radMenuItemTelerikMetro.Click += RadMenuItemTheme_Click;
131
            this.radMenuItemVisualStudio2012Dark.Click += RadMenuItemTheme_Click;
132
            this.radMenuItemVisualStudio2012Light.Click += RadMenuItemTheme_Click;
133
            this.radMenuItemWindows8.Click += RadMenuItemTheme_Click;
134
            #endregion
135

    
136
            //this.radGridViewDocuments.DefaultValuesNeeded += RadGridViewDocuments_DefaultValuesNeeded;
137
            this.radGridViewDocuments.UserAddedRow += RadGridViewDocuments_UserAddedRow;
138
            this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged;
139
            this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting;
140
            this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo;
141
            this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit;
142
            this.radGridViewDocuments.CellEndEdit += RadGridViewDocuments_CellEndEdit;
143
            this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick;
144
            this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
145
            //this.radGridViewDocuments.FilterChanging += RadGridViewDocuments_FilterChanging;
146
            this.radGridViewDocuments.FilterChanged += RadGridViewDocuments_FilterChanged;
147
            //this.radGridViewDocuments.CellValidated += RadGridViewDocuments_CellValidated;
148
            this.radGridViewDocuments.ValueChanged += RadGridViewDocuments_ValueChanged;
149
            this.radGridViewDocuments.ValueChanging += RadGridViewDocuments_ValueChanging;
150
            this.radGridViewDocuments.MultiSelect = true;
151
            this.radGridViewDocuments.EnableHotTracking = true;
152
            this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36;
153
            this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36;
154
            //this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ;
155
            this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false;
156

    
157
            var openProjectView = new OpenProjectView()
158
            {
159
                Dock = DockStyle.Fill
160
            };
161

    
162
            this.backstageViewPageOpenProject.Controls.Add(openProjectView);
163
            openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick;
164
            openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick;
165
            this.backstageButtonItemSelectDB.Click += BackstageButtonItemSelectDB_Click;
166
            this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click;
167
            this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click;
168
            this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened;
169
            this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed;
170

    
171
            this.InitColumnGroupsViewDefinition(this.radGridViewDocuments);
172

    
173
            this.radPageViewPageReview.Controls.Add(briefAndImagesReview);
174
            this.radPageViewPageWork.Controls.Add(issueImagesAndAnswerWork);
175

    
176
            briefAndImagesReview.RemoveImage += BriefAndImages_RemoveImage;
177
            issueImagesAndAnswerWork.RemoveImage += IssueImagesAndAnswer_RemoveImage;
178
            this.Initialize();
179
        }
180

    
181
        private void RadGridViewDocuments_ValueChanging(object sender, ValueChangingEventArgs e)
182
        {
183
            if(sender is GridViewCellInfo)
184
            {
185
                if ((sender as GridViewCellInfo).ColumnInfo is GridViewCheckBoxColumn)
186
                {
187
                    if (this.radGridViewDocuments.SelectedRows.Count() > 1)
188
                    {
189
                        if(!this.radGridViewDocuments.SelectedRows.Contains((sender as GridViewCellInfo).RowInfo))
190
                        {
191
                            e.Cancel = true;
192
                        }
193
                    }
194
                }
195
            }
196
        }
197

    
198
        /// <summary>
199
        /// 사용자가 선택한 테마를 적용한다.
200
        /// </summary>
201
        /// <param name="sender"></param>
202
        /// <param name="e"></param>
203
        private void RadMenuItemTheme_Click(object sender, EventArgs e)
204
        {
205
            string theme = (sender as RadMenuItem).Text;
206
            if(theme != this.radDropDownButtonElementTheme.Text)
207
            {
208
                this.radDropDownButtonElementTheme.Text = theme;
209
                Classes.ID2Helper.IniWriteValue(Program.IniFilePath, "App", "Theme", theme);
210
                if (!string.IsNullOrEmpty(theme))
211
                {
212
                    Telerik.WinControls.ThemeResolutionService.ApplicationThemeName = theme;
213
                    Program.ThemeName = theme;
214
                }
215
            }
216
        }
217

    
218
        private void BtnDockLayoutReset_Click(object sender, EventArgs e)
219
        {
220
            this.LoadDockingLayout(true);
221
        }
222

    
223
        private void BriefAndImages_RemoveImage(object sender, AttImageInfo e)
224
        {
225
            try
226
            {
227
                if (e is AttImageInfo)
228
                {
229
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
230
                    {
231
                        var reslut = doc.AttFiles.RemoveAll(x => x.FileID == e.ID);
232

    
233
                        if (reslut > 0)
234
                        {
235
                            switch (e.Category)
236
                            {
237
                                case "toreview":
238
                                    doc.ToCapture -= reslut;
239
                                    break;
240
                                case "frreview":
241
                                    doc.FrCapture -= reslut;
242
                                    break;
243
                            }
244
                        }
245
                        else
246
                        {
247
                            MessageBox.Show("삭제오류");
248
                        }
249
                    }
250
                }
251
            }
252
            catch (Exception ex)
253
            {
254
                Program.logger.Error("BriefAndImages_RemoveImage", ex);
255
            }
256
        }
257

    
258
        private void IssueImagesAndAnswer_RemoveImage(object sender, AttImageInfo e)
259
        {
260
            try
261
            {
262
                if (e is AttImageInfo)
263
                {
264
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
265
                    {
266
                        var reslut = doc.AttFiles.RemoveAll(x => x.FileID == e.ID);
267

    
268
                        if (reslut > 0)
269
                        {
270
                            switch (e.Category)
271
                            {
272
                                case "id2work":
273
                                    doc.ID2Capture -= reslut;
274
                                    break;
275
                            }
276
                        }
277
                        else
278
                        {
279
                            MessageBox.Show("삭제오류");
280
                        }
281
                    }
282
                }
283
            }
284
            catch (Exception ex)
285
            {
286
                Program.logger.Error("IssueImagesAndAnswer_RemoveImage", ex);
287
            }
288
        }
289

    
290
        private void SaveDockingLayout()
291
        {
292
            try
293
            {
294
                this.DockMain.SaveToXml(dockLayoutPath);
295
            }
296
            catch (Exception ex)
297
            {
298
                System.Diagnostics.Debug.WriteLine("SaveDockingLayout Error.", ex);
299
            }
300
        }
301

    
302
        private void LoadDockingLayout(bool IsDefaultLayoutLoad = false)
303
        {
304
            try
305
            {
306
                bool IsUseLayoutLoad = false;
307

    
308
                try
309
                {
310
                    var dockLayoutFile = new FileInfo(dockLayoutPath);
311

    
312

    
313
                    if (!IsDefaultLayoutLoad && dockLayoutFile.Exists)
314
                    {
315
                        this.DockMain.LoadFromXml(dockLayoutPath);
316
                        IsUseLayoutLoad = true;
317
                    }
318

    
319
                }
320
                catch (Exception ex)
321
                {
322
                    Program.logger.Error($"dock Layout File load Error. File Path : {dockLayoutPath}", ex);
323
                }
324

    
325
                if (!IsUseLayoutLoad)
326
                {
327
                    var layout = Properties.Resources.DefalutDockLayout;
328

    
329
                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(layout)))
330
                    {
331
                        this.DockMain.LoadFromXml(stream);
332
                    }
333
                }
334

    
335
                this.DockMain.DocumentTabsVisible = true;
336

    
337
                this.DockMain.DockWindows.ForAll(x =>
338
                {
339
                    x.DockManager.ShowDocumentPinButton = false;
340
                    x.DockManager.ShowDocumentCloseButton = false;
341
                });
342

    
343
                this.DockMain.AutoHideWindowDisplaying += DockMain_AutoHideWindowDisplaying;
344

    
345
                this.DockMain.DockStateChanged += (snd, evt) =>
346
                {
347
                    if (evt.DockWindow.Name == DockWindowMain.Name || evt.DockWindow.Name == DockValidation.Name)
348
                    {
349

    
350
                    }
351

    
352
                };
353

    
354
                this.DockMain.DockWindowClosed += (snd, evt) =>
355
                {
356
                    evt.DockWindow.DockState = Telerik.WinControls.UI.Docking.DockState.AutoHide;
357

    
358
                    //Telerik.WinControls.UI.Docking.AutoHidePosition tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Right;
359

    
360

    
361
                    //List<DockWindow> dockWindows = new List<DockWindow>();
362

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

    
365

    
366
                    //if (evt.DockWindow.AccessibleName == DockWindowMain.AccessibleName || evt.DockWindow.Name == DockValidation.AccessibleName)
367
                    //{
368
                    //    dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName == DockWindowMain.AccessibleName && evt.DockWindow.Name == DockValidation.AccessibleName));
369

    
370
                    //    tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Bottom;
371

    
372
                    //    dockWindows.Add(evt.DockWindow);
373
                    //}
374
                    //else
375
                    //{
376
                    //    dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName != DockWindowMain.AccessibleName || evt.DockWindow.Name != DockValidation.AccessibleName));
377

    
378
                    //    dockWindows.Add(evt.DockWindow);
379
                    //}
380

    
381

    
382
                    //this.DockMain.AutoHideWindows(dockWindows, tabPosition);
383
                };
384
            }
385
            catch (Exception ex)
386
            {
387
                Program.logger.Error($"dock Layout load Error. File Path : {dockLayoutPath}", ex);
388
            }
389
        }
390

    
391
        private void DockMain_AutoHideWindowDisplaying(object sender, Telerik.WinControls.UI.Docking.AutoHideWindowDisplayingEventArgs e)
392
        {
393

    
394
        }
395

    
396
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
397
        {
398
            SaveDockingLayout();
399
        }
400

    
401
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
402
        {
403
            if (keyData == (Keys.F10 | Keys.Control))
404
            {
405
//#if DEBUG
406
//                radControlSpyForm.Show();
407
//#endif
408
            }
409

    
410
            if (keyData == (Keys.V | Keys.Control))
411
            {
412
                System.Diagnostics.Debug.WriteLine("KeyDown CTRL + V");
413

    
414
                if (Clipboard.ContainsImage())
415
                {
416
                    var IsDoftech = true;
417
                    var selectReview = true;
418
                    string category = "";
419
                    byte[] imageBytes = null;
420

    
421
                    Image clipboardImage = Clipboard.GetImage();
422

    
423
                    using (MemoryStream stream = new MemoryStream())
424
                    {
425
                        clipboardImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
426
                        imageBytes = stream.ToArray();
427
                    }
428

    
429
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
430
                    {
431

    
432
                        /// 도프텍 or 삼성
433
                        if (!string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
434
                        {
435
                            IsDoftech = false;
436
                        }
437

    
438
                        /// 검토 or 검증
439
                        if (radPageViewComment.SelectedPage != radPageViewPageReview)
440
                        {
441
                            selectReview = false;
442
                        }
443

    
444
                        if (IsDoftech && selectReview)
445
                        {
446
                            category = "toreview";
447
                        }
448
                        else if (!IsDoftech && selectReview)
449
                        {
450
                            category = "frreview";
451
                        }
452
                        else
453
                        {
454
                            category = "id2work";
455
                        }
456

    
457
                        AttFileInfo newFile = new AttFileInfo
458
                        {
459
                            FileID = Guid.NewGuid().ToString(),
460
                            Category = category,
461
                            FileType = "image/png",
462
                            FileName = "ClipBoard",
463
                            FilePath = "ClipBoard",
464
                            FileExtension = ".png",
465
                            CreatedDate = DateTime.Now,
466
                            Creator = informations.ActiveUser.ID,
467
                            FileData = imageBytes
468

    
469
                        };
470

    
471
                        if (doc.AttFiles == null)
472
                        {
473
                            doc.AttFiles = new List<AttFileInfo>();
474
                        }
475

    
476
                        doc.AttFiles.Add(newFile);
477

    
478
                        var imageInfo = new AttImageInfo { ID = newFile.FileID, Data = newFile.FileData };
479

    
480
                        switch (category)
481
                        {
482
                            case "toreview":
483
                                briefAndImagesReview.AddToImage(imageInfo, true);
484
                                ++doc.ToCapture;
485
                                break;
486
                            case "frreview":
487
                                briefAndImagesReview.AddFrImage(imageInfo, true);
488
                                ++doc.FrCapture;
489
                                break;
490
                            case "id2work":
491
                                issueImagesAndAnswerWork.AddImage(imageInfo, true);
492
                                ++doc.ID2Capture;
493
                                break;
494
                        }
495
                    }
496
                }
497
            }
498

    
499
            return base.ProcessCmdKey(ref msg, keyData);
500
        }
501

    
502
        private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
503
        {
504
            if (e.RowInfo is GridViewSearchRowInfo)
505
            {
506
                var row = new SearchRow(e.ViewInfo);
507
                e.RowInfo = row;
508
            }
509

    
510
            //System.Diagnostics.Debug.WriteLine(e.RowInfo.GetType().Name);
511
        }
512

    
513
        private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
514
        {
515
            if (e.SearchFinished)
516
            {
517

    
518
            }
519
        }
520

    
521
        /// <summary>
522
        /// 선택한 Document와 상세 편집 창을 연동시킨다.
523
        /// </summary>
524
        /// <param name="doc"></param>
525
        public void BindingDocumentToDetailEditor(Documents doc)
526
        {
527
            briefAndImagesReview.Clear();
528
            issueImagesAndAnswerWork.Clear();
529

    
530
            //FrRemarks 추가
531

    
532
            briefAndImagesReview.DataBindings.Add(new Binding("BriefDoftech", doc, "ToRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
533
            briefAndImagesReview.DataBindings.Add(new Binding("BriefSec", doc, "FrRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
534

    
535
            issueImagesAndAnswerWork.DataBindings.Add(new Binding("IssueText", doc, "ID2Issues", false, DataSourceUpdateMode.OnPropertyChanged, null));
536
            issueImagesAndAnswerWork.DataBindings.Add(new Binding("ReplyModificationText", doc, "ReplyModifications", false, DataSourceUpdateMode.OnPropertyChanged, null));
537

    
538
            if (doc.AttFiles != null)
539
            {
540
                if (doc.AttFiles.Any(x => x.Category == "toreview"))
541
                {
542
                    var images = doc.AttFiles.Where(x => x.Category == "toreview").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
543
                    briefAndImagesReview.SetToImages(images.ToList());
544
                }
545

    
546
                if (doc.AttFiles.Any(x => x.Category == "frreview"))
547
                {
548
                    var images = doc.AttFiles.Where(x => x.Category == "frreview").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
549
                    briefAndImagesReview.SetFrImages(images.ToList());
550
                }
551

    
552
                if (doc.AttFiles.Any(x => x.Category == "id2work"))
553
                {
554
                    var images = doc.AttFiles.Where(x => x.Category == "id2work").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
555
                    issueImagesAndAnswerWork.SetImages(images.ToList());
556
                }
557
            }
558
        }
559

    
560
        private void RadGridViewDocuments_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
561
        {
562
            //if (e.Row is GridViewNewRowInfo)
563
            //{
564
            //    e.Row.Cells["RefProjectCode"].ReadOnly = false;
565
            //    e.Row.Cells["DocumentNo"].ReadOnly = false;
566
            //}
567

    
568
            //BindingDocumentToDetailEditor(new Documents());
569
        }
570

    
571
        private void RadGridViewDocuments_UserAddedRow(object sender, GridViewRowEventArgs e)
572
        {
573
            if (e.Row.DataBoundItem is Documents doc)
574
            {
575
                this.lbSelectAndTotal.Text = $"{this.radGridViewDocuments.MasterTemplate.DataView.Count} / {this.SearchCount} / {this.TotalCount} (Filter / Search / Total)";
576
            }
577
        }
578

    
579
        /// <summary>
580
        /// 선택된 행의 AutoCAD와 PDF 파일을 보여준다.
581
        /// </summary>
582
        /// <param name="sender"></param>
583
        /// <param name="e"></param>
584
        private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e)
585
        {
586
            if (this.radGridViewDocuments.SelectedRows.Any() && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
587
            {
588
                //if (informations.ActiveUser.ID != doc.PersonInCharge)
589
                //{
590
                //    var row = this.radGridViewDocuments.SelectedRows.First();
591
                //    foreach(var cell in row.Cells)
592
                //    {
593
                //        cell.ReadOnly = true;
594
                //    }
595
                //}
596
                BindingDocumentToDetailEditor(doc);
597
            }
598
        }
599

    
600
        #region Init, Load
601
        private void Initialize()
602
        {
603
            this.Text = $"{Globals.Name} (Ver : {Application.ProductVersion})";
604

    
605
            this.ID2ManagerRadRibbonBar.Expanded = false;
606

    
607
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
608
        }
609

    
610
        protected override void OnLoad(EventArgs e)
611
        {
612
            try
613
            {
614
                LoadDockingLayout();
615
                this.radDropDownButtonElementTheme.Text = Program.ThemeName;
616

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

    
619
                InitializeGrid();
620

    
621
                bool isID2DB = this.IsID2Connection();
622
                this.SetMenus(isID2DB);
623

    
624
                if (isID2DB)
625
                {
626
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
627
                    {
628
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
629
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
630

    
631
                        this.LoadProject(true);
632
                    }
633
                    else
634
                    {
635
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
636

    
637
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
638
                        {
639
                            if (ctrl is OpenProjectView)
640
                            {
641
                                var openProjectView = ctrl as OpenProjectView;
642
                                openProjectView.GetProjectGroups();
643
                                break;
644
                            }
645
                        }
646

    
647
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
648
                    }
649
                }
650
                else
651
                {
652
                    this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
653
                    RadMessageBox.Show(this, $"Please select db file.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info);
654
                }
655
            }
656
            catch (Exception ex)
657
            {
658
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
659
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
660
            }
661

    
662
            base.OnLoad(e);
663
        }
664

    
665
        private bool IsID2Connection()
666
        {
667
            bool isSuccess = false;
668

    
669
            try
670
            {
671
                isSuccess = Globals.IsProjectDBConnstr();
672

    
673
                if (isSuccess)
674
                {
675
                    var id2Project = new ID2Controller().GetID2ProjectList();
676
                }
677
            }
678
            catch (Exception ex)
679
            {
680
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
681
                isSuccess = false;
682
            }
683

    
684
            return isSuccess;
685
        }
686

    
687
        private void SetMenus(bool isid2)
688
        {
689
            if (isid2)
690
            {
691
                if (this.IsID2Manager)
692
                {
693
                    this.radButtonElementNoticeUpload.Enabled = true;
694

    
695
                    this.backstageViewPageOpenProject.Controls[0].Visible = true;
696
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible;
697
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible;
698

    
699
                    this.ribbonTabProjMgt.Visibility = ElementVisibility.Visible;
700
                }
701
                else
702
                {
703
                    this.radButtonElementNoticeUpload.Enabled = false;
704

    
705
                    if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
706
                    {
707
                        this.backstageViewPageOpenProject.Controls[0].Visible = true;
708
                    }
709
                    else
710
                    {
711
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
712
                        {
713
                            ctrl.Visible = false;
714
                        }
715
                    }
716
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
717
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
718

    
719
                    this.ribbonTabProjMgt.Visibility = ElementVisibility.Collapsed;
720
                }
721
            }
722
            else
723
            {
724
                this.radButtonElementNoticeUpload.Enabled = false;
725

    
726
                this.backstageButtonItemSelectDB.Visibility = ElementVisibility.Visible;
727
                foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
728
                {
729
                    ctrl.Visible = false;
730
                }
731
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
732
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
733

    
734
                this.ribbonTabProjMgt.Visibility = ElementVisibility.Collapsed;
735
            }
736
        }
737

    
738
        public Point GetBackstageLocation()
739
        {
740
            Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
741
            location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
742
            location.Offset(this.ID2ManagerRadRibbonBar.Location);
743

    
744
            return location;
745
        }
746

    
747
        private void InitializeGrid()
748
        {
749
            InitializeColumns();
750
            InitializeSearch();
751
            InitializeGridViewDetail();
752

    
753
            //this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
754
        }
755

    
756
        private void InitializeColumns()
757
        {
758
            bool isClient = !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID);
759
            GridViewColumnCollection cols = this.radGridViewDocuments.Columns;
760

    
761
            cols.ForAll(x =>
762
            {
763
                if (!x.ReadOnly)
764
                {
765
                    switch (x.Name)
766
                    {
767
                        case "FrReviewStatus":
768
                        case "FrRemarks":
769
                        case "FrCreator":
770
                        case "ClientReviewer":
771
                        case "ClientIsResult":
772
                        case "ClientRemarks":
773
                            x.ReadOnly = !isClient;
774
                            break;
775
                        default:
776
                            x.ReadOnly = isClient;
777
                            break;
778
                    }
779
                }
780
            });
781
        }
782

    
783
        private void InitializeSearch()
784
        {
785

    
786
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
787

    
788
            lbSearch.Text = "\ue13E";
789
            btnSearchNext.Text = "\ue006";
790
            btnSearchPrevious.Text = "\ue004";
791

    
792
            var chkbox = new RadCheckBoxElement();
793
            chkbox.Text = "Match Case";
794
            chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; };
795

    
796
            btnMatchCase.HostedItem = chkbox;
797

    
798
            var chkbox1 = new RadCheckBoxElement();
799
            chkbox1.Text = "Show All Detail";
800
            chkbox1.CheckStateChanged += (snd, evt) =>
801
            {
802
                radGridViewDocuments.MasterView.ChildRows.ForAll(x => x.IsExpanded = chkbox1.Checked);
803
            };
804

    
805
            btnShowAllDetail.HostedItem = chkbox1;
806

    
807
            var chkbox2 = new RadCheckBoxElement();
808
            chkbox2.Text = "Search from current position";
809
            chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; };
810

    
811
            btnSearchFormCurrent.HostedItem = chkbox2;
812

    
813
            var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x =>
814
                                 new FilterColumn
815
                                 {
816
                                     Name = x.HeaderText,
817
                                     FieldName = x.FieldName,
818
                                     IsSelect = x.AllowSearching
819
                                 }).ToList();
820

    
821
            var panel = new StackLayoutElement();
822
            panel.Orientation = Orientation.Vertical;
823

    
824
            var btnComboColumns = new RadCheckedDropDownListElement();
825
            btnComboColumns.ShowCheckAllItems = true;
826
            btnComboColumns.CheckAllItem.Checked = true;
827
            btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns";
828
            btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true;
829
            btnComboColumns.DropDownMinSize = new Size(200, 200);
830
            btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
831
            btnComboColumns.DisplayMember = "Name";
832
            btnComboColumns.CheckedMember = "IsSelect";
833
            btnComboColumns.ValueMember = "FieldName";
834
            btnComboColumns.TextBox.CustomFont = font1.Name;
835
            btnComboColumns.TextBox.Text = "\ue13A";
836

    
837
            columns.Add(new FilterColumn { FieldName = "CREATE_USER", Name = "Markus User", IsSelect = true });
838
            columns.Add(new FilterColumn { FieldName = "TEXT", Name = "Markus Text", IsSelect = true });
839

    
840
            btnComboColumns.DataSource = columns;
841

    
842
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
843
            {
844
                radGridViewDocuments.MasterTemplate.Refresh(null);
845
            };
846

    
847
            btnComboColumns.PopupOpening += (snd, evt) =>
848
            {
849
                (snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect);
850
            };
851

    
852
            btnComboColumns.PopupClosed += (snd, evt) =>
853
            {
854
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
855
                {
856
                    if (radGridViewDocuments.Columns[item.Value.ToString()] != null)
857
                    {
858
                        radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
859
                    }
860

    
861
                    foreach (var template in radGridViewDocuments.Templates)
862
                    {
863
                        if (template.Columns[item.Value.ToString()] != null)
864
                        {
865
                            template.Columns[item.Value.ToString()].AllowSearching = item.Checked;
866
                        }
867
                    }
868
                }
869
            };
870

    
871
            btnFilters.HostedItem = btnComboColumns;
872
        }
873

    
874
        private void InitializeGridViewDetail()
875
        {
876
            DetailGridViewTemplate markupList = new DetailGridViewTemplate();
877

    
878
            GridViewTextBoxColumn userColumn = new GridViewTextBoxColumn("CREATE_USER");
879
            GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("TEXT");
880

    
881
            userColumn.MinWidth = 110;
882
            userColumn.AutoSizeMode = BestFitColumnMode.AllCells;
883
            userColumn.AllowSearching = true;
884
            textColumn.AutoSizeMode = BestFitColumnMode.AllCells;
885
            textColumn.AllowSearching = true;
886

    
887
            markupList.Columns.AddRange(userColumn, textColumn);
888
            markupList.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
889

    
890
            this.radGridViewDocuments.MasterTemplate.Templates.Add(markupList);
891
            markupList.HierarchyDataProvider = new GridViewEventDataProvider(markupList);
892

    
893
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
894
            this.radGridViewDocuments.RowSourceNeeded += RadGridViewDocuments_RowSourceNeeded;
895
        }
896

    
897
        private void RadGridViewDocuments_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
898
        {
899
            if (e.Template.HierarchyLevel == 1)
900
            {
901
                if (e.ParentRow.DataBoundItem is Documents documents)
902
                {
903
                    if (documents.Markups != null)
904
                    {
905
                        foreach (var makrup in documents.Markups)
906
                        {
907
                            GridViewRowInfo row = e.Template.Rows.NewRow();
908

    
909
                            row.Cells["CREATE_USER"].Value = makrup.CREATE_USER;
910
                            row.Cells["TEXT"].Value = makrup.TEXT;
911
                            e.SourceCollection.Add(row);
912
                        }
913

    
914
                        e.Template.BestFitColumns(BestFitColumnMode.AllCells);
915
                    }
916
                }
917
            }
918
        }
919

    
920
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
921
        {
922
            if (e.IsExpanded)
923
            {
924
            }
925
        }
926

    
927
        #endregion
928

    
929
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
930
        {
931
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
932
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
933
        }
934

    
935
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
936
        {
937
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
938

    
939
            foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
940
            {
941
                if (ctrl is OpenProjectView)
942
                {
943
                    var openProjectView = ctrl as OpenProjectView;
944
                    openProjectView.GetProjectGroups();
945
                    break;
946
                }
947
            }
948
        }
949

    
950
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
951
        {
952
            try
953
            {
954
                if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
955
                {
956
                    var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
957

    
958
                    informations.ActiveProject = prjArgs.ProjectInfo;
959

    
960
                    this.radRibbonBarBackstageViewID2Manager.Tag = null;
961

    
962
                    this.LoadProject(true);
963
                }
964
            }
965
            catch (Exception ex)
966
            {
967
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
968
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
969
            }
970
        }
971

    
972
        private void LoadProject(bool isFilterClear)
973
        {
974
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
975

    
976
            try
977
            {
978
                #region Date
979
                //Date Type
980
                if (this.radCheckedDropDownListDateType.DataSource != null)
981
                    this.radCheckedDropDownListDateType.DataSource = null;
982

    
983
                this.radCheckedDropDownListDateType.DataSource = informations.DateType;
984
                this.radCheckedDropDownListDateType.DisplayMember = "Value";
985
                this.radCheckedDropDownListDateType.ValueMember = "Key";
986

    
987
                //FromDate
988
                this.radDateTimePickerFr.NullableValue = null;
989
                this.radDateTimePickerFr.SetToNullValue();
990

    
991
                //ToDate
992
                this.radDateTimePickerTo.NullableValue = null;
993
                this.radDateTimePickerTo.SetToNullValue();
994
                #endregion
995

    
996
                #region 도면
997
                //Project List
998
                if (this.radDropDownListProject.Items.Count > 0)
999
                    this.radDropDownListProject.Items.Clear();
1000
                informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
1001
                                        .ForEach(x =>
1002
                                        {
1003
                                            this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
1004
                                        });
1005
                var allProject = new RadListDataItem("== 전체 ==", string.Empty);
1006
                this.radDropDownListProject.Items.Insert(0, allProject);
1007
                allProject.Selected = true;
1008

    
1009
                //담당자 List
1010
                if (this.radDropDownListPersonInCharge.Items.Count > 0)
1011
                    this.radDropDownListPersonInCharge.Items.Clear();
1012
                informations.UserList.ForEach(x =>
1013
                {
1014
                    if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
1015
                        this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
1016
                });
1017
                var allUser = new RadListDataItem("== 전체 ==", string.Empty);
1018
                this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
1019
                allUser.Selected = true;
1020

    
1021
                //난이도
1022
                if (this.radDropDownListJobLevel.Items.Count > 0)
1023
                    this.radDropDownListJobLevel.Items.Clear();
1024
                informations.JobLevel.ForEach(x =>
1025
                {
1026
                    this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
1027
                });
1028
                var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
1029
                this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
1030
                allJobLevel.Selected = true;
1031

    
1032
                //도면번호 조회조건
1033
                this.radTextBoxDocumentNo.Text = string.Empty;
1034
                #endregion
1035

    
1036
                #region 검토
1037
                //문의(DOF)
1038
                if (this.radDropDownListToIsDiscussion.Items.Count > 0)
1039
                    this.radDropDownListToIsDiscussion.Items.Clear();
1040
                informations.IsYesNo.ForEach(x =>
1041
                {
1042
                    this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
1043
                });
1044
                var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
1045
                this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
1046
                allToIsDiscussion.Selected = true;
1047

    
1048
                //회신(DS)
1049
                if (this.radDropDownListFrReviewStatus.Items.Count > 0)
1050
                    this.radDropDownListFrReviewStatus.Items.Clear();
1051
                informations.ClientStatus.ForEach(x =>
1052
                {
1053
                    this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
1054
                });
1055
                var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
1056
                this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
1057
                allFrReviewStatus.Selected = true;
1058
                #endregion
1059

    
1060
                #region 작업
1061
                //ID2 Status
1062
                {
1063
                    if (this.radDropDownListID2Status.Items.Count > 0)
1064
                        this.radDropDownListID2Status.Items.Clear();
1065
                    informations.JobStatus.ForEach(x =>
1066
                    {
1067
                        this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
1068
                    });
1069
                    var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
1070
                    this.radDropDownListID2Status.Items.Insert(0, allID2Status);
1071
                    allID2Status.Selected = true;
1072
                }
1073

    
1074
                //ID2 Issues
1075
                {
1076
                    if (this.radDropDownListID2Issues.Items.Count > 0)
1077
                        this.radDropDownListID2Issues.Items.Clear();
1078
                    informations.IsYesNo.ForEach(x =>
1079
                    {
1080
                        this.radDropDownListID2Issues.Items.Add(new RadListDataItem(x, x));
1081
                    });
1082
                    var allID2Issues = new RadListDataItem("== 전체 ==", string.Empty);
1083
                    this.radDropDownListID2Issues.Items.Insert(0, allID2Issues);
1084
                    allID2Issues.Selected = true;
1085
                }
1086

    
1087
                //AVEVA Status
1088
                {
1089
                    if (this.radDropDownListAVEVAStatus.Items.Count > 0)
1090
                        this.radDropDownListAVEVAStatus.Items.Clear();
1091
                    informations.JobStatus.ForEach(x =>
1092
                    {
1093
                        this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
1094
                    });
1095
                    var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
1096
                    this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
1097
                    allAVEVAStatus.Selected = true;
1098
                }
1099

    
1100
                //AVEVA Issues
1101
                {
1102
                    if (this.radDropDownListAVEVAIssues.Items.Count > 0)
1103
                        this.radDropDownListAVEVAIssues.Items.Clear();
1104
                    informations.IsYesNo.ForEach(x =>
1105
                    {
1106
                        this.radDropDownListAVEVAIssues.Items.Add(new RadListDataItem(x, x));
1107
                    });
1108
                    var allAVEVAIssues = new RadListDataItem("== 전체 ==", string.Empty);
1109
                    this.radDropDownListAVEVAIssues.Items.Insert(0, allAVEVAIssues);
1110
                    allAVEVAIssues.Selected = true;
1111
                }
1112

    
1113
                #endregion
1114

    
1115
                #region 검수
1116
                //도프텍 결과
1117
                if (this.radDropDownListProdIsResult.Items.Count > 0)
1118
                    this.radDropDownListProdIsResult.Items.Clear();
1119
                informations.ValidationResult.ForEach(x =>
1120
                {
1121
                    this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
1122
                });
1123
                var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
1124
                this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
1125
                allProdIsResult.Selected = true;
1126

    
1127
                //삼성 결과
1128
                if (this.radDropDownListClientIsResult.Items.Count > 0)
1129
                    this.radDropDownListClientIsResult.Items.Clear();
1130
                informations.ValidationResult.ForEach(x =>
1131
                {
1132
                    this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
1133
                });
1134
                var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
1135
                this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
1136
                allClientIsResult.Selected = true;
1137
                #endregion
1138

    
1139
                #region AVEVA
1140
                //Gateway
1141
                if (this.radDropDownListGateway.Items.Count > 0)
1142
                    this.radDropDownListGateway.Items.Clear();
1143
                informations.IsYesNo.ForEach(x =>
1144
                {
1145
                    this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x));
1146
                });
1147
                var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty);
1148
                this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay);
1149
                allDTIsGateWay.Selected = true;
1150

    
1151
                //Registration
1152
                if (this.radDropDownListRegistration.Items.Count > 0)
1153
                    this.radDropDownListRegistration.Items.Clear();
1154
                informations.IsYesNo.ForEach(x =>
1155
                {
1156
                    this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x));
1157
                });
1158
                var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty);
1159
                this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem);
1160
                allDTIsRegSystem.Selected = true;
1161
                #endregion
1162

    
1163
                this.GetDocList(isFilterClear);
1164
            }
1165
            catch (Exception ex)
1166
            {
1167
                throw ex;
1168
            }
1169
            finally
1170
            {
1171

    
1172
                this.Cursor = Cursors.Default;
1173

    
1174
            }
1175

    
1176
        }
1177

    
1178
        #region Document List 조회
1179
        public void GetDocList(bool isFilterClear)
1180
        {
1181
            try
1182
            {
1183
                if (this.radDropDownListProject.SelectedValue != null)
1184
                {
1185
                    List<string> dateTypes = this.radCheckedDropDownListDateType.CheckedItems.Select(x => x.Value.ToString()).ToList();
1186
                    DateTime? frDate = this.radDateTimePickerFr.Value.Equals(this.radDateTimePickerFr.NullDate) ? (DateTime?)null : this.radDateTimePickerFr.Value;
1187
                    DateTime? toDate = this.radDateTimePickerTo.Value.Equals(this.radDateTimePickerTo.NullDate) ? (DateTime?)null : this.radDateTimePickerTo.Value;
1188

    
1189
                    string projectCode = this.radDropDownListProject.SelectedValue.ToString();
1190
                    string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
1191
                    string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
1192
                    string documentNo = this.radTextBoxDocumentNo.Text.Trim();
1193

    
1194
                    string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
1195
                    string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
1196

    
1197
                    string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
1198
                    string id2Issues = this.radDropDownListID2Issues.SelectedValue.ToString();
1199
                    string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
1200
                    string avevaIssues = this.radDropDownListAVEVAIssues.SelectedValue.ToString();
1201

    
1202
                    string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
1203
                    string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
1204

    
1205
                    string isGateWay = this.radDropDownListGateway.SelectedValue.ToString();
1206
                    string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString();
1207

    
1208
                    var worker = new LoadDocumentsWorker(dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments);
1209
                    worker.OnWorkCompletedHandler += (e) =>
1210
                    {
1211
                        var docData = e.Result as DocumentsResult;
1212

    
1213
                        this.documents = docData.Dwgs;
1214
                        this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
1215
                        this.TotalCount = docData.TotalCount;
1216
                        this.SearchCount = docData.Dwgs.Count;
1217

    
1218
                        List<string> projectCodes = new List<string>();
1219

    
1220
                        if (!string.IsNullOrWhiteSpace(projectCode))
1221
                        {
1222
                            projectCodes.Add(projectCode);
1223
                        }
1224
                        else
1225
                        {
1226
                            projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
1227
                        }
1228

    
1229
                        this.DocumentListBinding(isFilterClear);
1230
                    };
1231

    
1232
                    (btnShowAllDetail.HostedItem as RadCheckBoxElement).Checked = false;
1233
                    worker.StartWork();
1234
                }
1235
            }
1236
            catch (Exception ex)
1237
            {
1238
                throw ex;
1239
            }
1240
        }
1241

    
1242
        public void DocumentListBinding(bool isFilterClear)
1243
        {
1244
            try
1245
            {
1246
                GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
1247
                ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
1248
                ColProjects.DisplayMember = "Name";
1249
                ColProjects.ValueMember = "Code";
1250

    
1251
                var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID));
1252
                var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID));
1253
                var emptyUser = new UserInfo() { ID = null, Name = null };
1254

    
1255
                GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
1256
                ColPersonInCharge.DataSource = workUsers.Prepend(emptyUser);
1257
                ColPersonInCharge.DisplayMember = "Name";
1258
                ColPersonInCharge.ValueMember = "ID";
1259

    
1260
                GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
1261
                ColWorker.DataSource = workUsers.Prepend(emptyUser);
1262
                ColWorker.DisplayMember = "Name";
1263
                ColWorker.ValueMember = "ID";
1264

    
1265
                GridViewComboBoxColumn ColAVEVAPersonInCharge = this.radGridViewDocuments.Columns["AVEVAPersonInCharge"] as GridViewComboBoxColumn;
1266
                ColAVEVAPersonInCharge.DataSource = workUsers.Prepend(emptyUser);
1267
                ColAVEVAPersonInCharge.DisplayMember = "Name";
1268
                ColAVEVAPersonInCharge.ValueMember = "ID";
1269

    
1270
                GridViewComboBoxColumn ColAVEVAWorker = this.radGridViewDocuments.Columns["AVEVAWorker"] as GridViewComboBoxColumn;
1271
                ColAVEVAWorker.DataSource = workUsers.Prepend(emptyUser);
1272
                ColAVEVAWorker.DisplayMember = "Name";
1273
                ColAVEVAWorker.ValueMember = "ID";
1274

    
1275
                GridViewComboBoxColumn ColReplyRequester = this.radGridViewDocuments.Columns["ReplyRequester"] as GridViewComboBoxColumn;
1276
                ColReplyRequester.DataSource = workUsers;
1277
                ColReplyRequester.DisplayMember = "Name";
1278
                ColReplyRequester.ValueMember = "ID";
1279

    
1280
                GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
1281
                ColToCreator.DataSource = workUsers;
1282
                ColToCreator.DisplayMember = "Name";
1283
                ColToCreator.ValueMember = "ID";
1284

    
1285
                GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
1286
                ColFrCreator.DataSource = clientUsers;
1287
                ColFrCreator.DisplayMember = "Name";
1288
                ColFrCreator.ValueMember = "ID";
1289

    
1290
                GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
1291
                ColProdReviewer.DataSource = workUsers;
1292
                ColProdReviewer.DisplayMember = "Name";
1293
                ColProdReviewer.ValueMember = "ID";
1294

    
1295
                GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
1296
                ColClientReviewer.DataSource = clientUsers;
1297
                ColClientReviewer.DisplayMember = "Name";
1298
                ColClientReviewer.ValueMember = "ID";
1299

    
1300
                //Data
1301
                if (this.radGridViewDocuments.DataSource != null)
1302
                    this.radGridViewDocuments.DataSource = null;
1303

    
1304
                /*
1305
                var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info;
1306
                var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info);
1307
                var test = from doc in this.documents
1308
                           join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj
1309
                           from docs in gj.DefaultIfEmpty()
1310
                           select new Documents()
1311
                           {
1312
                               DocumentNo = doc.DocumentNo,
1313
                               ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME)
1314
                               //ProdRemarks = docs.DATETIME ?? null
1315
                           };
1316
                */
1317

    
1318
                if (isFilterClear)
1319
                    this.radGridViewDocuments.FilterDescriptors.Clear();
1320
                this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
1321
                this.lbSelectAndTotal.Text = $"{this.radGridViewDocuments.MasterTemplate.DataView.Count} / {this.SearchCount} / {this.TotalCount} (Filter / Search / Total)";
1322

    
1323
                var verification = this.LayoutValidation.Controls[0] as Verification;
1324
                verification.DocumentListBinding(this.documents);
1325
            }
1326
            catch (Exception ex)
1327
            {
1328
                throw ex;
1329
            }
1330
        }
1331
        #endregion
1332

    
1333
        #region 조회조건, filter Event
1334
        private void RadButtonDateClear_Click(object sender, EventArgs e)
1335
        {
1336
            //DateType
1337
            this.radCheckedDropDownListDateType.CheckedItems.Clear();
1338
            //FromDate
1339
            this.radDateTimePickerFr.SetToNullValue();
1340
            //ToDate
1341
            this.radDateTimePickerTo.SetToNullValue();
1342
        }
1343

    
1344
        private void RadDropDownList_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
1345
        {
1346
            if (sender is RadDropDownList ddl)
1347
            {
1348
                if (ddl.SelectedValue != null)
1349
                {
1350
                    if (string.IsNullOrEmpty(ddl.SelectedValue.ToString()))
1351
                    {
1352
                        ddl.BackColor = Color.White;
1353
                        ddl.ForeColor = Color.Black;
1354
                        ddl.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular);
1355
                    }
1356
                    else
1357
                    {
1358
                        ddl.BackColor = Color.DarkSlateBlue;
1359
                        ddl.ForeColor = Color.Yellow;
1360
                        ddl.Font = new Font("Segoe UI", 8.25F, FontStyle.Bold);
1361
                    }
1362
                }
1363
            }
1364
        }
1365

    
1366
        private void RadCollapsiblePanelCondition_Collapsed(object sender, EventArgs e)
1367
        {
1368
            this.radCollapsiblePanelCondition.HeaderText = "Show";
1369
            this.LayoutMain.RowStyles[0] = new RowStyle() { SizeType = SizeType.Absolute, Height = 30F };
1370
        }
1371

    
1372
        private void RadCollapsiblePanelCondition_Expanded(object sender, EventArgs e)
1373
        {
1374
            this.radCollapsiblePanelCondition.HeaderText = "Hide";
1375
            this.LayoutMain.RowStyles[0] = new RowStyle() { SizeType = SizeType.Absolute, Height = 210F };
1376
        }
1377

    
1378
        private void RadCheckBoxFreezed_CheckStateChanged(object sender, EventArgs e)
1379
        {
1380
            if (sender is RadCheckBox checkBox)
1381
            {
1382
                if (checkBox.Tag != null)
1383
                {
1384
                    ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1385
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1386
                    if (colGroup != null)
1387
                        colGroup.IsPinned = checkBox.Checked;
1388
                }
1389
            }
1390
        }
1391

    
1392
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
1393
        {
1394
            if (sender is RadCheckBox checkBox)
1395
            {
1396
                if (checkBox.Tag != null)
1397
                {
1398
                    ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1399
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1400
                    if (colGroup != null)
1401
                        colGroup.IsVisible = checkBox.Checked;
1402
                }
1403
            }
1404

    
1405
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
1406
        }
1407

    
1408
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
1409
        {
1410
            if (e.KeyCode == Keys.Enter)
1411
            {
1412
                this.radButtonSearch.Focus();
1413
                this.radButtonSearch.PerformClick();
1414
            }
1415
        }
1416

    
1417
        private void RadTextBoxDocumentNo_KeyUp(object sender, KeyEventArgs e)
1418
        {
1419
            if (sender is RadTextBox txtBox)
1420
            {
1421
                if (txtBox.Text.Length > 0)
1422
                {
1423
                    txtBox.BackColor = Color.DarkSlateBlue;
1424
                    txtBox.ForeColor = Color.Yellow;
1425
                    txtBox.Font = new Font("Segoe UI", 8.25F, FontStyle.Bold);
1426
                }
1427
                else
1428
                {
1429
                    txtBox.BackColor = Color.White;
1430
                    txtBox.ForeColor = Color.Black;
1431
                    txtBox.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular);
1432
                }
1433
            }
1434
        }
1435

    
1436
        private void RadButtonSearch_Click(object sender, EventArgs e)
1437
        {
1438
            try
1439
            {
1440
                BeginInvoke(new Action(() =>
1441
                {
1442
                    this.radCollapsiblePanelCondition.Collapse();
1443
                }));
1444

    
1445
                this.GetDocList(false);
1446
            }
1447
            catch (Exception ex)
1448
            {
1449
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1450
                RadMessageBox.Show("DWG search failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1451
            }
1452
        }
1453
        #endregion
1454

    
1455
        #region Backstage Button Event
1456
        private void BackstageButtonItemSelectDB_Click(object sender, EventArgs e)
1457
        {
1458
            using (var frm = new SetID2ProjectDB())
1459
            {
1460
                if (frm.ShowDialog(this) == DialogResult.OK)
1461
                {
1462
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
1463
                    {
1464
                        this.radRibbonBarBackstageViewID2Manager.HidePopup();
1465

    
1466
                        informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
1467
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1468

    
1469
                        this.LoadProject(true);
1470
                    }
1471
                    else
1472
                    {
1473
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1474
                        bool isID2 = this.IsID2Connection();
1475
                        this.SetMenus(isID2);
1476

    
1477
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
1478
                        {
1479
                            if (ctrl is OpenProjectView)
1480
                            {
1481
                                var openProjectView = ctrl as OpenProjectView;
1482
                                openProjectView.GetProjectGroups();
1483
                                break;
1484
                            }
1485
                        }
1486
                    }
1487
                }
1488
            }
1489
        }
1490

    
1491
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
1492
        {
1493
            using (var frm = new SetupUser())
1494
            {
1495
                if (frm.ShowDialog(this) == DialogResult.OK)
1496
                {
1497

    
1498
                }
1499
            }
1500
        }
1501

    
1502
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
1503
        {
1504
            Application.Exit();
1505
        }
1506
        #endregion
1507

    
1508
        #region Grid event
1509
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
1510
        {
1511
            if (e.Row is GridViewNewRowInfo)
1512
            {
1513

    
1514
            }
1515
            else
1516
            {
1517
                string dwgExtension = ".dwg";
1518
                switch (e.Column.Name)
1519
                {
1520
                    case "AutoCADLink":
1521
                        {
1522
                            if (e.Row.DataBoundItem is Documents doc)
1523
                            {
1524
                                string ID2DrawingFolder = System.IO.Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", "Native");
1525
                                string dwgFilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{doc.DocumentNo}{dwgExtension}");
1526
                                System.Diagnostics.Process.Start(dwgFilePath);
1527
                            }
1528
                        }
1529
                        break;
1530
                    case "MarkupLink":
1531
                        {
1532
                            if (e.Row.DataBoundItem is Documents doc)
1533
                            {
1534
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID))
1535
                                {
1536
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID);
1537
                                }
1538
                            }
1539
                        }
1540
                        break;
1541
                    case "AVEVALink":
1542
                        RadMessageBox.Show($"{e.Column.Name} 실행", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1543
                        break;
1544
                    case "ID2Connection":
1545
                        try
1546
                        {
1547
                            if (e.Row.DataBoundItem is Documents doc)
1548
                            {
1549
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port);
1550

    
1551
                                try
1552
                                {
1553
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
1554
                                    {
1555
                                        DocID = doc.DocID,
1556
                                        ID2StartDate = DateTime.Now,
1557
                                        Worker = informations.ActiveUser.ID
1558
                                    }, informations.ActiveUser.ID);
1559

    
1560
                                    if (returnDoc != null)
1561
                                    {
1562
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
1563
                                        doc.Worker = returnDoc.Worker;
1564
                                    }
1565
                                }
1566
                                catch { }
1567
                            }
1568
                        }
1569
                        catch (Exception ex)
1570
                        {
1571
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1572
                        }
1573
                        break;
1574
                    case "Compare":
1575
                        try
1576
                        {
1577
                            if (e.Row.DataBoundItem is Documents selectedDoc)
1578
                            {
1579
                                if (!string.IsNullOrEmpty(selectedDoc.DocID))
1580
                                {
1581
                                    DockMainTabStrip.SelectedTab = DockValidation;
1582
                                    var verification = this.LayoutValidation.Controls[0] as Verification;
1583
                                    verification.DocumentSelection(selectedDoc);
1584
                                }
1585
                            }
1586
                        }
1587
                        catch (Exception ex)
1588
                        {
1589
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1590
                        }
1591
                        break;
1592
                }
1593
            }
1594
        }
1595

    
1596
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
1597
        {
1598
            if (e.ActiveEditor is RadDropDownListEditor)
1599
            {
1600
                switch (e.Column.Name)
1601
                {
1602
                    //case "RefProjectCode":
1603
                    //    GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1604
                    //    ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
1605
                    //    ColProjects.DisplayMember = "Name";
1606
                    //    ColProjects.ValueMember = "Code";
1607
                    //    break;
1608
                    //case "PersonInCharge":
1609
                    //case "Worker":
1610
                    //case "AVEVAPersonInCharge":
1611
                    //case "AVEVAWorker":
1612
                    //case "ReplyRequester":
1613
                    //case "ToCreator":
1614
                    //case "ProdReviewer":
1615
                    //    var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID));
1616
                    //    GridViewComboBoxColumn ColProdUsers = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1617
                    //    ColProdUsers.DataSource = workUsers;
1618
                    //    ColProdUsers.DisplayMember = "Name";
1619
                    //    ColProdUsers.ValueMember = "ID";
1620
                    //    break;
1621
                    //case "FrCreator":
1622
                    //case "ClientReviewer":
1623
                    //    var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID));
1624
                    //    GridViewComboBoxColumn ColClientUsers = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1625
                    //    ColClientUsers.DataSource = clientUsers;
1626
                    //    ColClientUsers.DisplayMember = "Name";
1627
                    //    ColClientUsers.ValueMember = "ID";
1628
                    //    break;
1629
                    case "JobLevel":
1630
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1631
                        colJobLevel.DataSource = informations.JobLevel;
1632
                        break;
1633
                    case "ToIsDiscussion":
1634
                    case "IsConvert":
1635
                    case "DTIsImport":
1636
                    case "DTIsGateWay":
1637
                    case "DTIsRegSystem":
1638
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1639
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
1640
                        break;
1641
                    case "ID2Status":
1642
                    case "AVEVAStatus":
1643
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1644
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
1645
                        break;
1646
                    case "FrReviewStatus"://삼성의견status
1647
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1648
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
1649
                        break;
1650
                    case "ProdIsResult":
1651
                    case "ClientIsResult":
1652
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1653
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
1654
                        break;
1655
                }
1656
            }
1657
        }
1658

    
1659
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
1660
        {
1661
            if (e.Row is GridViewDataRowInfo)
1662
            {
1663
                if (e.CellElement is GridRowHeaderCellElement)
1664
                {
1665
                    // if (e.CellElement.RowIndex > -1)
1666
                    //      e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
1667
                }
1668
                else if (e.CellElement is GridGroupExpanderCellElement expanderCellElement)
1669
                {
1670
                    if ((e.Row.DataBoundItem as Documents).Markups == null)
1671
                    {
1672
                        expanderCellElement.Enabled = false;
1673
                    }
1674
                    else
1675
                    {
1676
                        expanderCellElement.Enabled = true;
1677
                    }
1678
                }
1679
                else
1680
                {
1681
                    var result = e.Row.DataBoundItem as Documents;
1682
                    if (result != null || e.Row is GridViewNewRowInfo)
1683
                    {
1684
                        switch (e.CellElement.ColumnInfo.Name)
1685
                        {
1686
                            case "AutoCADLink":
1687
                            case "PDFLink":
1688
                            case "AVEVALink":
1689
                            case "ID2Connection":
1690
                            case "Compare":
1691
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name, false);
1692
                                break;
1693
                            case "MarkupLink":
1694
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name, result.Markups == null ? false : true);
1695
                                break;
1696
                            case "ToCapture":
1697
                                if (result.ToCapture > 0)
1698
                                {
1699
                                    e.CellElement.Image = Properties.Resources.files18;
1700
                                }
1701
                                break;
1702
                            case "FrCapture":
1703
                                if (result.FrCapture > 0)
1704
                                {
1705
                                    e.CellElement.Image = Properties.Resources.files18;
1706
                                }
1707
                                break;
1708
                            //case "ProdCapture":
1709
                            //    if (result.ProdCapture > 0)
1710
                            //    {
1711
                            //        e.CellElement.Image = Properties.Resources.files18;
1712
                            //    }
1713
                            //    break;
1714
                            //case "ClientCapture":
1715
                            //    if (result.ClientCapture > 0)
1716
                            //    {
1717
                            //        e.CellElement.Image = Properties.Resources.files18;
1718
                            //    }
1719
                            //    break;
1720
                            case "ID2Capture":
1721
                                if (result.ID2Capture > 0)
1722
                                {
1723
                                    e.CellElement.Image = Properties.Resources.files18;
1724
                                }
1725
                                break;
1726
                        }
1727
                    }
1728
                    else
1729
                    {
1730

    
1731
                    }
1732
                }
1733
            }
1734
            else if (e.Row is GridViewDetailsRowInfo)
1735
            {
1736
                if (e.CellElement is GridDetailViewCellElement detailViewCellElement)
1737
                {
1738
                    detailViewCellElement.Padding = new Padding(10, 2, 2, 2);
1739
                    detailViewCellElement.BackColor = Color.FromArgb(214, 214, 214);
1740
                    detailViewCellElement.BackColor2 = Color.FromArgb(214, 214, 214);
1741
                }
1742
            }
1743
            //else if (e.Row is GridViewNewRowInfo)
1744
            //{
1745
            //    switch (e.CellElement.ColumnInfo.Name)
1746
            //    {
1747
            //        case "RefProjectCode":
1748
            //        case "DocumentNo":
1749
            //            e.CellElement.ColumnInfo.ReadOnly = false;
1750
            //            break;
1751
            //    }
1752
            //}
1753
            //else if (e.Row is GridViewSummaryRowInfo)
1754
            //{
1755
            //    if (e.CellElement is GridRowHeaderCellElement)
1756
            //    {
1757
            //        e.CellElement.Text = "Count";
1758
            //    }
1759
            //    else if (e.CellElement is GridSummaryCellElement)
1760
            //    {
1761
            //        e.CellElement.ForeColor = this._SummaryColor;
1762
            //        e.CellElement.TextAlignment = ContentAlignment.BottomRight;
1763
            //        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
1764
            //    }
1765
            //    else
1766
            //    {
1767

    
1768
            //    }
1769
            //}
1770
            else
1771
            {
1772

    
1773
            }
1774
        }
1775

    
1776
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName, bool isData)
1777
        {
1778
            RadButtonElement btnElem = null;
1779
            Bitmap bitmap = null; ;
1780

    
1781
            switch (colName)
1782
            {
1783
                case "AutoCADLink":
1784
                    bitmap = new Bitmap(Properties.Resources.cad18);
1785
                    break;
1786
                case "PDFLink":
1787
                    bitmap = new Bitmap(Properties.Resources.pdf18);
1788
                    break;
1789
                case "MarkupLink":
1790
                    if (isData)
1791
                    {
1792
                        bitmap = new Bitmap(Properties.Resources.markus18_on);
1793
                    }
1794
                    else
1795
                    {
1796
                        bitmap = new Bitmap(Properties.Resources.markus18);
1797
                    }
1798
                    break;
1799
                case "AVEVALink":
1800
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
1801
                    break;
1802
                case "ID2Connection":
1803
                    bitmap = new Bitmap(Properties.Resources.id218);
1804
                    break;
1805
                case "Compare":
1806
                    bitmap = new Bitmap(Properties.Resources.compare18);
1807
                    break;
1808
            }
1809

    
1810
            switch (colName)
1811
            {
1812
                case "AutoCADLink":
1813
                case "PDFLink":
1814
                case "MarkupLink":
1815
                case "AVEVALink":
1816
                case "ID2Connection":
1817
                case "Compare":
1818
                    btnElem = (RadButtonElement)elem;
1819
                    btnElem.Margin = new Padding(0);
1820
                    btnElem.Padding = new Padding(0);
1821
                    btnElem.BorderElement.Opacity = 0;
1822
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
1823
                    btnElem.DisplayStyle = DisplayStyle.Image;
1824
                    btnElem.Image = bitmap;
1825
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
1826
                    btnElem.MaxSize = bitmap.Size;
1827
                    break;
1828
            }
1829

    
1830
            return btnElem;
1831
        }
1832

    
1833
        private void RadGridViewDocuments_FilterChanging(object sender, GridViewCollectionChangingEventArgs e)
1834
        {
1835

    
1836
        }
1837

    
1838
        private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
1839
        {
1840
            this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.SearchCount} / {this.TotalCount} (Filter / Search / Total)";
1841
        }
1842

    
1843
        private void RadGridViewDocuments_CellValidated(object sender, CellValidatedEventArgs e)
1844
        {
1845
            //if(e.Column is GridViewCheckBoxColumn && radGridViewDocuments.SelectedRows?.Count() > 1)
1846
            //{
1847
            //    radGridViewDocuments.SelectedRows.ForAll(x =>
1848
            //    {
1849
            //        x.Cells[0].Value = e.Value;
1850
            //    });
1851
            //}
1852

    
1853
            //if (e.Column is GridViewComboBoxColumn)
1854
            //{
1855
            //    bool isChecked = e.Row.Cells["Checked"].Value != null && Convert.ToBoolean(e.Row.Cells["Checked"].Value);
1856

    
1857
            //    if (isChecked)
1858
            //    {
1859
            //        //this.GetCheckedDatas(true)
1860
            //        var chkDatas = documents.Where(x=>x.Checked).ToList();
1861
            //        if (chkDatas.Any())
1862
            //        {
1863
            //            string colValue = e.Row.Cells[e.Column.Name].Value == null ? string.Empty : (string)e.Row.Cells[e.Column.Name].Value;
1864
            //            radGridViewDocuments.MasterTemplate.BeginUpdate();
1865
            //            //radGridViewDocuments.SuspendLayout();
1866
            //            //radGridViewDocuments.SuspendUpdate();
1867
            //            switch (e.Column.Name)
1868
            //            {
1869
            //                case "RefProjectCode":
1870
            //                    chkDatas.ParallelForAll(x => x.RefProjectCode = colValue);
1871
            //                    break;
1872
            //                case "PersonInCharge":
1873
            //                    chkDatas.ParallelForAll(x => x.PersonInCharge = colValue);
1874
            //                    break;
1875
            //                case "Worker":
1876
            //                    chkDatas.ParallelForAll(x => x.Worker = colValue);
1877
            //                    break;
1878
            //                case "JobLevel":
1879
            //                    chkDatas.ParallelForAll(x => x.JobLevel = colValue);
1880
            //                    break;
1881
            //                case "ToIsDiscussion":
1882
            //                    chkDatas.ParallelForAll(x => x.ToIsDiscussion = colValue);
1883
            //                    break;
1884
            //                case "ToCreator":
1885
            //                    chkDatas.ParallelForAll(x => x.ToCreator = colValue);
1886
            //                    break;
1887
            //                case "FrReviewStatus":
1888
            //                    chkDatas.ParallelForAll(x => x.FrReviewStatus = colValue);
1889
            //                    break;
1890
            //                case "FrCreator":
1891
            //                    chkDatas.ParallelForAll(x => x.FrCreator = colValue);
1892
            //                    break;
1893
            //                case "ID2Status":
1894
            //                    chkDatas.ParallelForAll(x => x.ID2Status = colValue);
1895
            //                    break;
1896
            //                case "ReplyRequester":
1897
            //                    chkDatas.ParallelForAll(x => x.ReplyRequester = colValue);
1898
            //                    break;
1899
            //                case "IsConvert":
1900
            //                    chkDatas.ParallelForAll(x => x.IsConvert = colValue);
1901
            //                    break;
1902
            //                case "AVEVAPersonInCharge":
1903
            //                    chkDatas.ParallelForAll(x => x.AVEVAPersonInCharge = colValue);
1904
            //                    break;
1905
            //                case "AVEVAWorker":
1906
            //                    chkDatas.ParallelForAll(x => x.AVEVAWorker = colValue);
1907
            //                    break;
1908
            //                case "AVEVAStatus":
1909
            //                    chkDatas.ParallelForAll(x => x.AVEVAStatus = colValue);
1910
            //                    break;
1911
            //                case "ProdReviewer":
1912
            //                    chkDatas.ParallelForAll(x => x.ProdReviewer = colValue);
1913
            //                    break;
1914
            //                case "ProdIsResult":
1915
            //                    chkDatas.ParallelForAll(x => x.ProdIsResult = colValue);
1916
            //                    break;
1917
            //                case "ClientReviewer":
1918
            //                    chkDatas.ParallelForAll(x => x.ClientReviewer = colValue);
1919
            //                    break;
1920
            //                case "ClientIsResult":
1921
            //                    chkDatas.ParallelForAll(x => x.ClientIsResult = colValue);
1922
            //                    break;
1923
            //                case "DTIsGateWay":
1924
            //                    chkDatas.ParallelForAll(x => x.DTIsGateWay = colValue);
1925
            //                    break;
1926
            //                case "DTIsImport":
1927
            //                    chkDatas.ParallelForAll(x => x.DTIsImport = colValue);
1928
            //                    break;
1929
            //                case "DTIsRegSystem":
1930
            //                    chkDatas.ParallelForAll(x => x.DTIsRegSystem = colValue);
1931
            //                    break;
1932
            //            }
1933
            //            //radGridViewDocuments.ResumeLayout();
1934
            //            //radGridViewDocuments.ResumeUpdate();
1935
            //            radGridViewDocuments.MasterTemplate.EndUpdate();
1936

    
1937

    
1938
            //        }
1939
            //    }
1940
            //}
1941
        }
1942

    
1943
        private void RadGridViewDocuments_CellEndEdit(object sender, GridViewCellEventArgs e)
1944
        {
1945
            if (e.Column is GridViewComboBoxColumn)
1946
            {
1947
                var chkDatas = this.GetCheckedDatas(true);
1948

    
1949
                if (chkDatas.Any())
1950
                {
1951
                    RadScrollBarElement vScroll = radGridViewDocuments.TableElement.VScrollBar;
1952
                    int position = vScroll.Value;
1953
                    bool isMaxValue = position == vScroll.Maximum - vScroll.LargeChange + 1;
1954
                    radGridViewDocuments.TableElement.UpdateView();
1955

    
1956
                    object colValue = e.Row.Cells[e.Column.Name].Value;
1957

    
1958
                    radGridViewDocuments.BeginUpdate();
1959
                    radGridViewDocuments.MasterTemplate.BeginUpdate();
1960
   
1961
                    chkDatas.ForAll(x =>
1962
                    {
1963
                        x.SuspendUpdate = true;
1964
                        x.GetType().GetProperty(e.Column.Name).SetValue(x, colValue);
1965
                        x.SuspendUpdate = false;
1966
                    });
1967

    
1968
                    this.ResumeLayout(true);
1969
                    radGridViewDocuments.MasterTemplate.EndUpdate();
1970
                    radGridViewDocuments.EndUpdate();
1971

    
1972
                    if (position > 0)
1973
                    {
1974
                        if (isMaxValue)
1975
                        {
1976
                            position = vScroll.Maximum - vScroll.LargeChange + 1;
1977
                        }
1978
                        radGridViewDocuments.TableElement.VScrollBar.Value = position;
1979
                    }
1980
                }
1981
            }
1982
        }
1983

    
1984
        private void RadGridViewDocuments_ValueChanged(object sender, EventArgs e)
1985
        {
1986
            if (sender is BaseGridEditor baseEditor)
1987
            {
1988
                if (baseEditor.OwnerElement is GridDataCellElement cellElem)
1989
                {
1990
                    if (!(cellElem.RowInfo is GridViewNewRowInfo))
1991
                    {
1992
                        switch (cellElem.ColumnInfo.Name)
1993
                        {
1994
                            case "Checked":
1995
                            case "RefProjectCode":
1996
                            case "PersonInCharge":
1997
                            case "Worker":
1998
                            case "JobLevel":
1999
                            case "ToIsDiscussion":
2000
                            case "ToCreator":
2001
                            case "FrReviewStatus":
2002
                            case "FrCreator":
2003
                            case "ID2Status":
2004
                            case "ReplyRequester":
2005
                            case "IsConvert":
2006
                            case "AVEVAPersonInCharge":
2007
                            case "AVEVAWorker":
2008
                            case "AVEVAStatus":
2009
                            case "ProdReviewer":
2010
                            case "ProdIsResult":
2011
                            case "ClientReviewer":
2012
                            case "ClientIsResult":
2013
                            case "DTIsGateWay":
2014
                            case "DTIsImport":
2015
                            case "DTIsRegSystem":
2016
                                this.radGridViewDocuments.EndEdit();
2017
                                break;
2018
                        }
2019
                    }
2020
                }
2021
            }
2022
        }
2023
        #endregion
2024

    
2025
        /*
2026
        private void GetCheckedList()
2027
        {
2028
            RadGridView grid = this.radGridViewDocuments;
2029

    
2030
            //var checkers = grid.Rows.Where(x =>
2031
            //{
2032
            //    return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2033
            //}).Select(x => x.DataBoundItem as Documents).ToList();
2034

    
2035
            //var viewRows = new Queue<GridViewRowInfo>(this.radGridViewDocuments.MasterTemplate.DataView.Where(x => x.Cells["spq");
2036
            var viewRows = grid.MasterTemplate.DataView;
2037

    
2038
            var checkers = viewRows.Where(x =>
2039
            {
2040
                return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2041
            }).ToList();
2042

    
2043
            var rows = new GridViewDataRowInfo[checkers.Count];
2044
            checkers.CopyTo(rows, 0);
2045

    
2046
            if (rows.Length > 0)
2047
            {
2048
                grid.BeginUpdate();
2049

    
2050
                int nLoop = 0;
2051
                rows.ForAll(x =>
2052
                {
2053
                    grid.Rows.Remove(rows[nLoop]);
2054
                    nLoop++;
2055
                });
2056

    
2057
                grid.EndUpdate();
2058
            }
2059

    
2060

    
2061
            //grid.Rows.re grid.Rows.ToList().Intersect(checkers)
2062

    
2063

    
2064
            //RadMessageBox.Show($"{checkers.Count()}", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2065
            //RadMessageBox.Show($"{this.documents.Count}", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2066
            this.lbSelectAndTotal.Text = $"{grid.MasterTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)";
2067
        }
2068
        */
2069
        private IEnumerable<GridViewRowInfo> GetCheckedRows(bool isView)
2070
        {
2071
            try
2072
            {
2073
                RadGridView grid = this.radGridViewDocuments;
2074
                var viewRows = isView ? grid.MasterTemplate.DataView : grid.Rows.AsEnumerable<GridViewRowInfo>();
2075
                return viewRows.Where(x =>
2076
                {
2077
                    return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2078
                });
2079
            }
2080
            catch (Exception ex)
2081
            {
2082
                throw ex;
2083
            }
2084
        }
2085

    
2086
        private IEnumerable<Documents> GetCheckedDatas(bool isView)
2087
        {
2088
            return this.GetCheckedRows(isView).Where(x => x.DataBoundItem is Documents)
2089
                                              .Select(x => x.DataBoundItem as Documents);
2090
        }
2091

    
2092
        //private IEnumerable<Documents> GetCheckedDatas(bool isView)
2093
        //{
2094
        //    return this.documents.Where(x => x.Checked);
2095
        //}
2096

    
2097
        private void SetSaved()
2098
        {
2099
            this.radGridViewDocuments.EndEdit();
2100

    
2101
            try
2102
            {
2103
                if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2104
                {
2105
                    #region 유효성검사
2106

    
2107
                    #region 필수값 체크(Team, DWG_ID)
2108

    
2109
                    if (this.documents.Any(x => string.IsNullOrEmpty(x.RefProjectCode)))
2110
                    {
2111
                        RadMessageBox.Show($"Please, check the required value (Team).", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2112
                        return;
2113
                    }
2114

    
2115
                    if (this.documents.Any(x => string.IsNullOrEmpty(x.DocumentNo)))
2116
                    {
2117
                        RadMessageBox.Show($"Please, check the required value (DWG_ID).", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2118
                        return;
2119
                    }
2120

    
2121
                    #endregion
2122

    
2123
                    #endregion
2124

    
2125
                    #region document no 중복 유효성 체크
2126
                    int dupDwgNoCount = 0;
2127
                    dupDwgNoCount = this.documents.GroupBy(g => new { g.RefProjectCode, g.DocumentNo })
2128
                                                  .Where(x => x.Count() > 1)
2129
                                                  .Select(x => x.Key).ToList().Count;
2130

    
2131
                    if (dupDwgNoCount > 0)
2132
                    {
2133
                        RadMessageBox.Show($"Duplicate Dwg No exists.({dupDwgNoCount})", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2134
                        return;
2135
                    }
2136
                    #endregion
2137

    
2138
                    var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments);
2139
                    worker.OnWorkCompletedHandler += (e) =>
2140
                    {
2141
                        bool isDwg = false;
2142
                        bool isMarkusPrj = false;
2143
                        bool isMarkusDwg = false;
2144
                        bool isMarkusUser = false;
2145

    
2146
                        (isDwg, isMarkusPrj, isMarkusDwg, isMarkusUser) = ((bool, bool, bool, bool))e.Result;
2147

    
2148
                        if (!isDwg)
2149
                        {
2150
                            RadMessageBox.Show("Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2151
                        }
2152
                        else if (!isMarkusPrj)
2153
                        {
2154
                            RadMessageBox.Show("Markus Projects Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2155
                        }
2156
                        else if (!isMarkusDwg)
2157
                        {
2158
                            RadMessageBox.Show("Markus Data Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2159
                        }
2160
                        else if (!isMarkusUser)
2161
                        {
2162
                            RadMessageBox.Show("Markus Members Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2163
                        }
2164
                        else
2165
                        {
2166
                            RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2167
                            this.GetDocList(false);
2168
                        }
2169
                    };
2170
                    worker.StartWork();
2171
                }
2172
            }
2173
            catch (Exception ex)
2174
            {
2175
                throw ex;
2176
            }
2177
        }
2178

    
2179
        #region Quick Toolbar Button Event
2180
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
2181
        {
2182
            try
2183
            {
2184
                this.SetSaved();
2185
            }
2186
            catch (Exception ex)
2187
            {
2188
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2189
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2190
            }
2191
        }
2192

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

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

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

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

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

    
2234
        #region Home Tab Event
2235

    
2236
        private void RadButtonElementSave_Click(object sender, EventArgs e)
2237
        {
2238
            try
2239
            {
2240
                this.SetSaved();
2241
            }
2242
            catch (Exception ex)
2243
            {
2244
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2245
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2246
            }
2247
        }
2248

    
2249
        private void RadButtonElementSync_Click(object sender, EventArgs e)
2250
        {
2251
            try
2252
            {
2253
                if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2254
                {
2255
                    var worker = new SyncDocumentsWorker(this.radGridViewDocuments);
2256
                    worker.OnWorkCompletedHandler += (arg) =>
2257
                    {
2258
                        if ((bool)arg.Result)
2259
                        {
2260
                            this.GetDocList(false);
2261

    
2262
                            RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2263
                        }
2264
                    };
2265
                    worker.StartWork();
2266
                }
2267
            }
2268
            catch (Exception ex)
2269
            {
2270
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2271
                RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2272
            }
2273
        }
2274

    
2275
        private void RadButtonElementNotice_Click(object sender, EventArgs e)
2276
        {
2277
            try
2278
            {
2279
                AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProject.ProjectID, "notice");
2280

    
2281
                if (notiFileInfo == null)
2282
                {
2283
                    RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2284
                }
2285
                else
2286
                {
2287
                    string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles");
2288
                    string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}");
2289

    
2290
                    FileInfo finfo = new FileInfo(noticeFileFullName);
2291

    
2292
                    if (!finfo.Directory.Exists)
2293
                    {
2294
                        Directory.CreateDirectory(noticePath);
2295
                    }
2296

    
2297
                    if (!finfo.Exists)
2298
                    {
2299
                        var arrayBinary = notiFileInfo.FileData.ToArray();
2300

    
2301
                        using (MemoryStream ms = new MemoryStream(arrayBinary))
2302
                        {
2303
                            ms.Write(arrayBinary, 0, arrayBinary.Length);
2304
                            ms.Seek(0, SeekOrigin.Begin);
2305

    
2306
                            using (FileStream fs = finfo.Create())
2307
                            {
2308
                                ms.CopyTo(fs);
2309
                            }
2310
                        }
2311
                    }
2312

    
2313
                    try
2314
                    {
2315
                        ProcessStartInfo startInfo = new ProcessStartInfo
2316
                        {
2317
                            FileName = finfo.FullName,
2318
                            UseShellExecute = true,
2319
                            CreateNoWindow = false,
2320
                            WindowStyle = ProcessWindowStyle.Normal
2321
                        };
2322

    
2323
                        using (Process process = new Process())
2324
                        {
2325
                            process.StartInfo = startInfo;
2326
                            process.Start();
2327
                        }
2328
                        //Process.Start(finfo.FullName);
2329
                    }
2330
                    catch (Exception ex)
2331
                    {
2332
                        throw ex;
2333
                    }
2334

    
2335
                    //using (MemoryStream ms = new MemoryStream(arrayBinary))
2336
                    //{
2337
                    //    ProcessStartInfo startInfo = new ProcessStartInfo
2338
                    //    {
2339
                    //        FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName),
2340
                    //        RedirectStandardInput = true,
2341
                    //        UseShellExecute = false,
2342
                    //        CreateNoWindow = true,
2343
                    //        WindowStyle = ProcessWindowStyle.Hidden
2344
                    //    };
2345

    
2346
                    //    using (Process process = new Process())
2347
                    //    {
2348
                    //        process.StartInfo = startInfo;
2349
                    //        process.Start();
2350

    
2351
                    //        // Write the memory stream contents to the process standard input
2352
                    //        byte[] buffer = ms.ToArray();
2353
                    //        process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length);
2354
                    //        process.StandardInput.Close();
2355

    
2356
                    //        process.WaitForExit();
2357
                    //    }
2358
                    //}
2359
                }
2360
            }
2361
            catch (Exception ex)
2362
            {
2363
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2364
                RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2365
            }
2366
        }
2367

    
2368
        private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e)
2369
        {
2370
            string GetContentType(string filePath)
2371
            {
2372
                string extension = Path.GetExtension(filePath).ToLower();
2373

    
2374
                switch (extension)
2375
                {
2376
                    case ".txt":
2377
                        return "text/plain";
2378
                    case ".pdf":
2379
                        return "application/pdf";
2380
                    case ".jpg":
2381
                    case ".jpeg":
2382
                        return "image/jpeg";
2383
                    case ".png":
2384
                        return "image/png";
2385
                    case ".bmp":
2386
                        return "image/bmp";
2387
                    case ".gif":
2388
                        return "image/gif";
2389
                    default:
2390
                        return "application/octet-stream";
2391
                }
2392
            }
2393

    
2394
            using (OpenFileDialog ofd = new OpenFileDialog()
2395
            {
2396
                //Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*",
2397
                Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp)|*.png;*.jpeg;*.gif;*.jpg;*.bmp"
2398
                       + "|PNG Portable Network Graphics (*.png)|*.png"
2399
                       + "|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif"
2400
                       + "|BMP Windows Bitmap (*.bmp)|*.bmp"
2401
                       + "|GIF Graphics Interchange Format (*.gif)|*.gif",
2402
                //Title = "Open an Excel File",
2403
                RestoreDirectory = true
2404
            })
2405
            {
2406
                try
2407
                {
2408
                    if (ofd.ShowDialog() == DialogResult.OK)
2409
                    {
2410
                        FileInfo fileInfo = new FileInfo(ofd.FileName);
2411
                        if (fileInfo.Exists)
2412
                        {
2413
                            AttFileInfo attFile = new AttFileInfo()
2414
                            {
2415
                                RefID = informations.ActiveProject.ProjectID,
2416
                                Category = "notice",
2417
                                FileType = GetContentType(fileInfo.FullName),
2418
                                FileName = fileInfo.Name,
2419
                                FilePath = fileInfo.DirectoryName,
2420
                                FileExtension = fileInfo.Extension
2421
                            };
2422

    
2423
                            using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
2424
                            {
2425
                                using (var reader = new BinaryReader(stream))
2426
                                {
2427
                                    attFile.FileData = reader.ReadBytes((int)stream.Length);
2428
                                }
2429
                            }
2430

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

    
2433
                            if (result)
2434
                            {
2435
                                RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2436
                            }
2437
                        }
2438
                    }
2439
                }
2440
                catch (Exception ex)
2441
                {
2442
                    Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2443
                    RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2444
                }
2445
            }
2446
        }
2447

    
2448
        private void RadButtonElementFilterClear_Click(object sender, EventArgs e)
2449
        {
2450
            if (RadMessageBox.Show("Are you sure you want to clear the filter?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2451
            {
2452
                this.radGridViewDocuments.FilterDescriptors.Clear();
2453
            }
2454
        }
2455
        #endregion
2456

    
2457
        #region Project Manager Tab Event
2458

    
2459
        #region Excel
2460
        private UserInfo GetUser(string user)
2461
        {
2462
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
2463
            if (userInfo != null) return userInfo;
2464

    
2465
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
2466
            if (userInfo != null) return userInfo;
2467

    
2468
            return userInfo ?? new UserInfo();
2469
        }
2470

    
2471
        private ProjectInfo GetProject(string project)
2472
        {
2473
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.Code.Equals(project)).FirstOrDefault();
2474
            if (prjInfo != null) return prjInfo;
2475

    
2476
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
2477
            if (prjInfo != null) return prjInfo;
2478

    
2479
            return prjInfo ?? new ProjectInfo();
2480
        }
2481

    
2482
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
2483
        {
2484
            var form = new Forms.SelectExcelData();
2485

    
2486
            var dialogResult = form.ShowDialog();
2487

    
2488
            if (dialogResult == DialogResult.OK)
2489
            {
2490
                using (ID2Excel excel = new ID2Excel())
2491
                {
2492
                    var result = excel.ExcelDataImport(form.SelectItems);
2493

    
2494
                    if (result.Error != null)
2495
                    {
2496
                        RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
2497
                    }
2498
                    else
2499
                    {
2500
                        this.importImages = result.Images;//???
2501

    
2502
                        var intersections = this.documents.Intersect(result.documents, new DocumentsUniqueCompare());
2503
                        var subtractions = result.documents.Except(this.documents, new DocumentsUniqueCompare());
2504

    
2505
                        if (intersections.Any())
2506
                        {
2507
                            var intersectionImports = result.documents.Intersect(this.documents, new DocumentsUniqueCompare());
2508

    
2509
                            intersections.ForAll(x =>
2510
                            {
2511
                                var intersectionImport = intersectionImports.FirstOrDefault(o => o.RefProjectCode == x.RefProjectCode && o.DocumentNo == x.DocumentNo);
2512
                                if (intersectionImport != null)
2513
                                {
2514
                                    x.DataCopy(intersectionImport);
2515
                                }
2516
                            });
2517
                        }
2518

    
2519
                        this.documents.AddRange(subtractions);
2520
                        if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
2521
                        this.DocumentListBinding(false);
2522
                        //briefAndImagesReview.SetImages(this.importImages);
2523

    
2524
                        RadMessageBox.Show("Import is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2525
                    }
2526

    
2527
                }
2528
            }
2529
        }
2530

    
2531
        private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e)
2532
        {
2533
            using (OpenFileDialog ofd = new OpenFileDialog()
2534
            {
2535
                Filter = "Excel files (*.xlsx)|*.xlsx",
2536
                Title = "Open an Excel File",
2537
                RestoreDirectory = true
2538
            })
2539
            {
2540
                if (ofd.ShowDialog() == DialogResult.OK)
2541
                {
2542
                    //Error Message
2543
                    StringBuilder sbErrMsg = new StringBuilder();
2544

    
2545
                    using (ID2Excel excel = new ID2Excel())
2546
                    {
2547
                        var result = excel.GemboxImport(ofd.FileName);
2548

    
2549
                        if (result.Error != null)
2550
                        {
2551

    
2552
                            RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
2553
                        }
2554
                        else
2555
                        {
2556
                            this.documents.AddRange(result.documents);
2557
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
2558
                            this.DocumentListBinding(false);
2559
                        }
2560

    
2561
                    }
2562

    
2563

    
2564
                    //foreach (Documents appDoc in appendDocuments)
2565
                    //{
2566
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
2567

    
2568
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
2569
                    //    {
2570
                    //        if (fieldInfo.GetValue(appDoc) != null)
2571
                    //        {
2572
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
2573

    
2574
                    //            if (cols.Any())
2575
                    //            {
2576
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
2577
                    //            }
2578
                    //        }
2579
                    //    }
2580
                    //}
2581
                }
2582
            }
2583
        }
2584

    
2585
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
2586
        {
2587
            string sPrefixName = "Samsung Elec Task Management";
2588
            string extension = ".xlsx";
2589

    
2590
            using (SaveFileDialog sfd = new SaveFileDialog()
2591
            {
2592
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
2593
                Filter = "Excel|*.xlsx",
2594
                Title = "Save an Excel File",
2595
                CheckFileExists = false,
2596
                CheckPathExists = true,
2597
                OverwritePrompt = true
2598
            })
2599
            {
2600
                if (sfd.ShowDialog() == DialogResult.OK)
2601
                {
2602
                    string fileName = $"{sPrefixName}{extension}";
2603
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
2604
                    string templateFilePath = Path.Combine(templateFolder, fileName);
2605
                    if (!File.Exists(templateFilePath))
2606
                    {
2607
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
2608
                        return;
2609
                    }
2610

    
2611
                    var templateExcelFile = ExcelFile.Load(templateFilePath);
2612
                    var templateWorksheets = templateExcelFile.Worksheets;
2613
                    var templateWorksheet = templateWorksheets[0];
2614

    
2615
                    if (this.radGridViewDocuments.Rows.Count > 0)
2616
                    {
2617
                        int rowIndex = 9;
2618
                        //int colIndex = 1;
2619
                        int rowNo = 1;
2620

    
2621
                        foreach (var row in this.radGridViewDocuments.MasterTemplate.DataView)
2622
                        {
2623
                            var doc = row.DataBoundItem as Documents;
2624

    
2625
                            templateWorksheet.Cells[rowIndex, 0].Value = rowNo++;
2626

    
2627
                            templateWorksheet.Cells[rowIndex, 7].Value = doc.RefProjectCode;
2628
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.System;
2629
                            templateWorksheet.Cells[rowIndex, 9].Value = doc.SubSystemCode;
2630
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.DocumentNo;
2631
                            templateWorksheet.Cells[rowIndex, 11].Value = this.GetUser(doc.PersonInCharge).Name;
2632
                            templateWorksheet.Cells[rowIndex, 12].Value = this.GetUser(doc.Worker).Name;
2633
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.AVEVAPersonInCharge).Name;
2634
                            templateWorksheet.Cells[rowIndex, 14].Value = this.GetUser(doc.AVEVAWorker).Name;
2635
                            templateWorksheet.Cells[rowIndex, 15].Value = doc.JobLevel;
2636
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.RevisonNo;
2637
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.ToIsDiscussion;
2638
                            templateWorksheet.Cells[rowIndex, 18].Value = doc.ToRemarks;
2639
                            templateWorksheet.Cells[rowIndex, 19].Value = this.GetUser(doc.ToCreator).Name;
2640
                            //toreview-20
2641
                            templateWorksheet.Cells[rowIndex, 21].Value = doc.FrReviewStatus;
2642
                            templateWorksheet.Cells[rowIndex, 22].Value = doc.FrRemarks;
2643
                            templateWorksheet.Cells[rowIndex, 23].Value = this.GetUser(doc.FrCreator).Name;
2644
                            //frreview-24
2645
                            templateWorksheet.Cells[rowIndex, 25].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
2646
                            templateWorksheet.Cells[rowIndex, 26].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
2647
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Status;
2648
                            templateWorksheet.Cells[rowIndex, 28].Value = doc.ID2Issues;
2649
                            //id2work-29
2650
                            templateWorksheet.Cells[rowIndex, 30].Value = doc.ReplyModifications;
2651
                            templateWorksheet.Cells[rowIndex, 31].Value = this.GetUser(doc.ReplyRequester).Name;
2652
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.IsConvert;
2653
                            templateWorksheet.Cells[rowIndex, 33].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
2654
                            templateWorksheet.Cells[rowIndex, 34].Value = $"{doc.AVEVAWorkDate:yyyy/MM/dd}";
2655
                            templateWorksheet.Cells[rowIndex, 35].Value = doc.AVEVAStatus;
2656
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.AVEVAIssues;
2657
                            templateWorksheet.Cells[rowIndex, 37].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
2658
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ProdReviewer).Name;
2659
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ProdIsResult;
2660
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ProdRemarks;
2661
                            templateWorksheet.Cells[rowIndex, 41].Value = this.GetUser(doc.ClientReviewer).Name;
2662
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.ClientIsResult;
2663
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.ClientRemarks;
2664
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTIsGateWay;
2665
                            templateWorksheet.Cells[rowIndex, 45].Value = doc.DTIsImport;
2666
                            templateWorksheet.Cells[rowIndex, 46].Value = doc.DTIsRegSystem;
2667
                            templateWorksheet.Cells[rowIndex, 47].Value = doc.DTRemarks;
2668

    
2669
                            /*
2670
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
2671
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
2672
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
2673
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
2674
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
2675
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
2676
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
2677
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
2678
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
2679
                            //templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
2680
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
2681
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
2682
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
2683
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
2684
                            //templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture;
2685
                            //templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
2686
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
2687
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
2688
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
2689
                            //templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture;
2690
                            //templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
2691
                            //templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
2692
                            //templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
2693
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
2694
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
2695
                            //templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
2696
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
2697
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
2698
                            //templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
2699
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
2700
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
2701
                            //추가필요templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAWorkDate:yyyy/MM/dd}";
2702
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
2703
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
2704
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
2705
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
2706
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
2707
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
2708
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
2709
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
2710
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
2711
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
2712
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
2713
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
2714
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
2715
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
2716
                            */
2717
                            rowIndex++;
2718
                        }
2719
                    }
2720
                    templateExcelFile.Save(sfd.FileName);
2721
                    RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2722
                }
2723
            }
2724
        }
2725
        #endregion
2726

    
2727
        #region DWG
2728
        private void RadButtonElementDelete_Click(object sender, EventArgs e)
2729
        {
2730
            IEnumerable<Documents> chkDatas = null;
2731

    
2732
            try
2733
            {
2734
                chkDatas = this.GetCheckedDatas(true);
2735

    
2736
                if (chkDatas.Any())
2737
                {
2738
                    if (RadMessageBox.Show("Do you want to Delete?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2739
                    {
2740
                        Queue<Documents> qChkData = new Queue<Documents>(chkDatas);
2741
                        while (qChkData.Any())
2742
                        {
2743
                            this.documents.Remove(qChkData.Dequeue());
2744
                        }
2745
                        this.DocumentListBinding(false);
2746
                        RadMessageBox.Show("Delete is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2747
                    }
2748
                }
2749
                else
2750
                {
2751
                    RadMessageBox.Show("Please check the DWG.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2752
                }
2753
            }
2754
            catch (Exception ex)
2755
            {
2756
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2757
                RadMessageBox.Show("DWG delete failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2758
            }
2759
        }
2760

    
2761
        private void RadButtonElementLevel_Click(object sender, EventArgs e)
2762
        {
2763
            RadMessageBox.Show("도면 Level 자동 조정.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2764
        }
2765
        #endregion
2766

    
2767
        #region Markup
2768
        private void RadButtonElementConvert_Click(object sender, EventArgs e)
2769
        {
2770
            if (radGridViewDocuments.SelectedRows?.Count() > 0)
2771
            {
2772
                List<Documents> checkedDocList = this.GetCheckedDatas(true).ToList();
2773

    
2774
                if (checkedDocList.Count > 1)
2775
                {
2776
                    MarkusConvertWorker convertWorker = new MarkusConvertWorker(checkedDocList.ToList(), radGridViewDocuments);
2777

    
2778
                    convertWorker.OnWorkCompletedHandler += (args) =>
2779
                    {
2780
                        if (convertWorker.ErrorDocList.Count() > 0)
2781
                        {
2782
                            var ids = string.Join("\n", convertWorker.ErrorDocList.Select(x => x.DocumentNo));
2783
                            string message = $"Convert Error.\nPlease check the DWG.\n\n{ids}";
2784

    
2785
                            RadMessageBox.Show(message, Globals.Name, MessageBoxButtons.OK);
2786
                        }
2787
                        else
2788
                        {
2789
                            RadMessageBox.Show("Conversion successfully.", Globals.Name, MessageBoxButtons.OK);
2790
                        }
2791
                    };
2792

    
2793
                    convertWorker.StartWork();
2794
                }
2795
                else
2796
                {
2797
                    var item = radGridViewDocuments.SelectedRows.First().DataBoundItem as Documents;
2798
                    MarkusConvert.Call(Properties.Settings.Default.MarkusService, item.RefProjectCode, item.DocumentNo);
2799
                }
2800
            }
2801
        }
2802
        #endregion
2803

    
2804
        #endregion
2805

    
2806
        #region ColumnGroup
2807
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
2808
        {
2809
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
2810

    
2811
            List<string> chkColNames = new List<string>() { "Checked" };
2812

    
2813
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "ID2Connection", "PDFLink", "MarkupLink", "AVEVALink", "Compare" };
2814
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "System", "DocumentNo", "PersonInCharge" };
2815
            List<string> docOtherInfoColNames = new List<string>() { "SubSystemCode", "Worker", "AVEVAPersonInCharge", "AVEVAWorker", "JobLevel", "RevisonNo" };
2816
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture" };
2817
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" };
2818
            List<string> wkID2ColNames = new List<string>() { "ID2StartDate", "ID2EndDate", "ID2Status", "ID2Issues", "ID2Capture", "ReplyModifications", "ReplyRequester" };
2819
            List<string> wkAVEVAColNames = new List<string>() { "IsConvert", "AVEVAConvertDate", "AVEVAWorkDate", "AVEVAStatus", "AVEVAIssues" };
2820
            List<string> valProdColNames = new List<string>() { "AVEVAReviewDate", "ProdReviewer", "ProdIsResult", "ProdRemarks" };
2821
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" };
2822
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
2823

    
2824
            //체크
2825
            GridViewColumnGroup chkColGrp = new GridViewColumnGroup("√") { IsPinned = true };
2826
            GridViewColumnGroupRow chkColGrpRow = new GridViewColumnGroupRow();
2827
            chkColGrpRow.ColumnNames.AddRange(chkColNames);
2828
            chkColGrp.Rows.Add(chkColGrpRow);
2829

    
2830
            //링크
2831
            GridViewColumnGroup docLinkGrp = new GridViewColumnGroup("프로그램 연동", "link") { IsPinned = true };
2832

    
2833
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
2834
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
2835

    
2836
            docLinkGrp.Rows.Add(docLinkColGrpRow);
2837

    
2838
            //도면
2839
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면정보", "docinfo") { IsPinned = true };
2840

    
2841
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
2842
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
2843

    
2844
            docColGrp.Rows.Add(docInfoColGrpRow);
2845

    
2846
            //도면상세
2847
            GridViewColumnGroup docOtherColGrp = new GridViewColumnGroup("도면상세 ");
2848

    
2849
            GridViewColumnGroupRow docOtherInfoColGrpRow = new GridViewColumnGroupRow();
2850
            docOtherInfoColGrpRow.ColumnNames.AddRange(docOtherInfoColNames);
2851

    
2852
            docOtherColGrp.Rows.Add(docOtherInfoColGrpRow);
2853

    
2854
            //검토
2855
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
2856
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
2857
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
2858

    
2859
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
2860
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
2861

    
2862
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
2863
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
2864

    
2865
            rvToColGrp.Rows.Add(rvToColGrpRow);
2866
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
2867

    
2868
            rvColGrp.Groups.Add(rvToColGrp);
2869
            rvColGrp.Groups.Add(rvFrColGrp);
2870

    
2871
            //작업
2872
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
2873
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
2874
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
2875

    
2876
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
2877
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
2878

    
2879
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
2880
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
2881

    
2882
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
2883
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
2884

    
2885
            wkColGrp.Groups.Add(wkID2ColGrp);
2886
            wkColGrp.Groups.Add(wkAVEVAColGrp);
2887

    
2888
            //Validation
2889
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
2890
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
2891
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
2892

    
2893
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
2894
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
2895

    
2896
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
2897
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
2898

    
2899
            valProdColGrp.Rows.Add(valProdColGrpRow);
2900
            valCntColGrp.Rows.Add(valCntColGrpRow);
2901

    
2902
            valColGrp.Groups.Add(valProdColGrp);
2903
            valColGrp.Groups.Add(valCntColGrp);
2904

    
2905
            //AVEVA Net
2906
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
2907

    
2908
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
2909
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
2910

    
2911
            dtColGrp.Rows.Add(dtColGrpRow);
2912

    
2913
            //Group 추가
2914
            columnGroupsView.ColumnGroups.Add(chkColGrp);
2915
            columnGroupsView.ColumnGroups.Add(docLinkGrp);
2916
            columnGroupsView.ColumnGroups.Add(docColGrp);
2917
            columnGroupsView.ColumnGroups.Add(docOtherColGrp);
2918
            columnGroupsView.ColumnGroups.Add(wkColGrp);
2919
            columnGroupsView.ColumnGroups.Add(rvColGrp);
2920
            columnGroupsView.ColumnGroups.Add(valColGrp);
2921
            columnGroupsView.ColumnGroups.Add(dtColGrp);
2922

    
2923
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
2924
        }
2925

    
2926
        #region grid view group
2927
        /*
2928
        private void InitGridViewDefinition(RadGridView gridView)
2929
        {
2930
            ColumnGroupsViewDefinition colGrpViewDef = new ColumnGroupsViewDefinition();
2931
            colGrpViewDef.ColumnGroups.AddRange(new[]
2932
            {
2933
                this.SetGridColumnGroup("√", "√", true, true, Enumerable.Empty<GridViewColumnGroup>(),this.SetGridColumnGroupRow(new[] { "Checked" })),
2934
                this.SetGridColumnGroup("프로그램 연동", "link", true, true, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "AutoCADLink", "ID2Connection", "PDFLink", "MarkupLink", "AVEVALink", "Compare" })),
2935
                this.SetGridColumnGroup("도면정보", "docinfo", true, true, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "RefProjectCode", "System", "DocumentNo", "PersonInCharge" })),
2936
                this.SetGridColumnGroup("도면상세", "도면상세", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "SubSystemCode", "Worker", "AVEVAPersonInCharge", "AVEVAWorker", "JobLevel", "RevisonNo" })),
2937
                this.SetGridColumnGroup("작업", "work", true, false, new[]
2938
                {
2939
                    this.SetGridColumnGroup("ID2","ID2", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "ID2StartDate", "ID2EndDate", "ID2Status", "ID2Issues", "ID2Capture", "ReplyModifications", "ReplyRequester" })),
2940
                    this.SetGridColumnGroup("AVEVA","AVEVA", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" }))
2941
                }, null),
2942
                this.SetGridColumnGroup("검토", "review", true, false, new[]
2943
                {
2944
                    this.SetGridColumnGroup("도프텍","도프텍", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture" })),
2945
                    this.SetGridColumnGroup("삼성","삼성", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" }))
2946
                }, null),
2947
                this.SetGridColumnGroup("Validation", "validation", true, false, new[]
2948
                {
2949
                    this.SetGridColumnGroup("도프텍","도프텍", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "AVEVAReviewDate", "ProdReviewer", "ProdIsResult", "ProdRemarks" })),
2950
                    this.SetGridColumnGroup("삼성전자","삼성전자", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "ClientReviewer", "ClientIsResult", "ClientRemarks" }))
2951
                }, null),
2952
                this.SetGridColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" }))
2953
            });
2954
            gridView.MasterTemplate.ViewDefinition = colGrpViewDef;
2955
        }
2956

    
2957
        private GridViewColumnGroup SetGridColumnGroup(string groupText, string groupName, bool groupShowHeader, bool groupFreezed, IEnumerable<GridViewColumnGroup> groups, GridViewColumnGroupRow columnGroupRow)
2958
        {
2959
            GridViewColumnGroup colGrp = new GridViewColumnGroup()
2960
            {
2961
                Text = groupText,
2962
                Name = groupName,
2963
                ShowHeader = groupShowHeader,
2964
                IsPinned = groupFreezed
2965
            };
2966
            groups.ForAll(x => colGrp.Groups.Add(x));
2967
            colGrp.Rows.Add(columnGroupRow);
2968
            return colGrp;
2969
        }
2970

    
2971
        private GridViewColumnGroupRow SetGridColumnGroupRow(IEnumerable<string> columnList)
2972
        {
2973
            GridViewColumnGroupRow colGrpRow = new GridViewColumnGroupRow();
2974
            colGrpRow.ColumnNames.AddRange(columnList);
2975
            return colGrpRow;
2976
        }
2977
        */
2978
        #endregion
2979

    
2980
        #endregion
2981

    
2982
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
2983
        {
2984
            if (string.IsNullOrWhiteSpace(txtFullSearch.Text))
2985
                radGridViewDocuments.MasterTemplate.Refresh(null);
2986

    
2987
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
2988
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
2989
        }
2990

    
2991
        private void btnSearchPrevious_Click(object sender, EventArgs e)
2992
        {
2993
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
2994
        }
2995

    
2996
        private void btnSearchNext_Click(object sender, EventArgs e)
2997
        {
2998
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
2999
        }
3000

    
3001
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
3002
        {
3003
            if (e.KeyCode == Keys.Enter)
3004
            {
3005
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
3006
            }
3007
        }
3008

    
3009
        private void commandBarSearch_ItemOverflowed(object sender, EventArgs e)
3010
        {
3011
            commandBarSearch.OverflowButton.AddRemoveButtonsMenuItem.Visibility = ElementVisibility.Collapsed;
3012
            commandBarSearch.OverflowButton.CustomizeButtonMenuItem.Visibility = ElementVisibility.Collapsed;
3013
        }
3014

    
3015
        private void commandBarSearch_ItemOutOfOverflow(object sender, EventArgs e)
3016
        {
3017
            commandBarSearch.OverflowButton.AddRemoveButtonsMenuItem.Visibility = ElementVisibility.Collapsed;
3018
            commandBarSearch.OverflowButton.CustomizeButtonMenuItem.Visibility = ElementVisibility.Collapsed;
3019
        }
3020
    }
3021
}
3022

    
3023
public class FilterColumn
3024
{
3025
    public string Name { get; set; }
3026
    public string FieldName { get; set; }
3027
    public bool IsSelect { get; set; }
3028
}