프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ 67cfe4dc

이력 | 보기 | 이력해설 | 다운로드 (159 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
using Telerik.WinControls.Enumerations;
27

    
28
using GemBox.Spreadsheet;
29

    
30
using Newtonsoft.Json;
31

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

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

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

    
54
        List<Documents> orgDocuments = null;
55
        int TotalCount = 0;
56
        int SearchCount = 0;
57
        int ROW_HEADER_COLUMN_WIDTH { get; } = 48;
58

    
59
        BriefAndImages briefAndImagesReview = new BriefAndImages { Dock = DockStyle.Fill };
60
        IssueImagesAndAnswer issueImagesAndAnswerWork = new IssueImagesAndAnswer { Dock = DockStyle.Fill };
61

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

    
68
        public Main()
69
        {
70
            InitializeComponent();
71
            var classify = new Controls.Classify(this.radProgressBarElement) { Dock = DockStyle.Fill };
72
            classify.UpdateDocumentsEvent += Classify_UpdateDocumentsEvent;
73
            classify.OnClassifyCompleted += Classify_OnClassifyCompleted;
74
            this.LayoutValidation.Controls.Add(classify);
75
            this.DockMainTabStrip.Select();
76

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

    
79
            if (!Directory.Exists(appDataPath))
80
            {
81
                Directory.CreateDirectory(appDataPath);
82
            }
83

    
84
            ID2.Manager.Common.Helpers.TableLayoutPanelHelper.SetDoubleBuffered(this);
85

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

    
101
            this.radButtonDateClear.Click += RadButtonDateClear_Click;
102

    
103
            this.radDropDownListTeam.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
104
            this.radDropDownListProject.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
105
            this.radDropDownListPersonInCharge.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
106
            this.radDropDownListJobLevel.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
107
            this.radDropDownListToIsDiscussion.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
108
            this.radDropDownListFrReviewStatus.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
109
            this.radDropDownListID2Status.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
110
            this.radDropDownListID2Issues.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
111
            this.radDropDownListAVEVAStatus.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
112
            this.radDropDownListAVEVAIssues.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
113
            this.radDropDownListProdIsResult.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
114
            this.radDropDownListClientIsResult.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
115
            this.radDropDownListGateway.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
116
            this.radDropDownListRegistration.SelectedIndexChanged += RadDropDownList_SelectedIndexChanged;
117

    
118
            this.radCollapsiblePanelCondition.Collapsed += RadCollapsiblePanelCondition_Collapsed;
119
            this.radCollapsiblePanelCondition.Expanded += RadCollapsiblePanelCondition_Expanded;
120

    
121
            this.radCheckBoxLink.CheckStateChanged += RadCheckBoxFreezed_CheckStateChanged;
122
            this.radCheckBoxDocInfo.CheckStateChanged += RadCheckBoxFreezed_CheckStateChanged;
123

    
124
            this.radCheckBoxReview.CheckStateChanged += RadCheckBox_CheckStateChanged;
125
            this.radCheckBoxWork.CheckStateChanged += RadCheckBox_CheckStateChanged;
126
            this.radCheckBoxVaildation.CheckStateChanged += RadCheckBox_CheckStateChanged;
127
            this.radCheckBoxAVEVANet.CheckStateChanged += RadCheckBox_CheckStateChanged;
128
            this.radTextBoxDocumentNo.TextChanged += RadTextBoxDocumentNo_TextChanged;
129
            this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown;
130
            //this.radTextBoxDocumentNo.KeyUp += RadTextBoxDocumentNo_KeyUp;
131
            this.radButtonSearch.Click += RadButtonSearch_Click;
132
            #region 테마 설정
133
            this.radMenuItemControlDefault.Click += RadMenuItemTheme_Click;
134
            this.radMenuItemOffice2013Dark.Click += RadMenuItemTheme_Click;
135
            this.radMenuItemTelerikMetro.Click += RadMenuItemTheme_Click;
136
            this.radMenuItemVisualStudio2012Dark.Click += RadMenuItemTheme_Click;
137
            this.radMenuItemVisualStudio2012Light.Click += RadMenuItemTheme_Click;
138
            this.radMenuItemWindows8.Click += RadMenuItemTheme_Click;
139
            #endregion
140

    
141
            //this.radGridViewDocuments.DefaultValuesNeeded += RadGridViewDocuments_DefaultValuesNeeded;
142
            this.radGridViewDocuments.UserAddedRow += RadGridViewDocuments_UserAddedRow;
143
            this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged;
144
            this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting;
145
            this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo;
146
            this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit;
147
            this.radGridViewDocuments.CellEndEdit += RadGridViewDocuments_CellEndEdit;
148
            this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick;
149
            this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
150
            //this.radGridViewDocuments.FilterChanging += RadGridViewDocuments_FilterChanging;
151
            this.radGridViewDocuments.FilterChanged += RadGridViewDocuments_FilterChanged;
152
            //this.radGridViewDocuments.CellValidated += RadGridViewDocuments_CellValidated;
153
            this.radGridViewDocuments.HeaderCellToggleStateChanged += RadGridViewDocuments_HeaderCellToggleStateChanged;
154
            this.radGridViewDocuments.ValueChanging += RadGridViewDocuments_ValueChanging;
155
            this.radGridViewDocuments.ValueChanged += RadGridViewDocuments_ValueChanged;
156
            this.radGridViewDocuments.MultiSelect = true;
157
            this.radGridViewDocuments.EnableHotTracking = true;
158
            //this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ;
159
            this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false;
160
            this.radGridViewDocuments.GroupSummaryEvaluate += RadGridViewDocuments_GroupSummaryEvaluate;
161

    
162
            this.radGridViewID2Symbols.GroupSummaryEvaluate += RadGridViewDocuments_GroupSummaryEvaluate;
163

    
164
            var openProjectView = new OpenProjectView()
165
            {
166
                Dock = DockStyle.Fill
167
            };
168

    
169
            this.backstageViewPageOpenProject.Controls.Add(openProjectView);
170
            openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick;
171
            openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick;
172
            this.backstageButtonItemSelectDB.Click += BackstageButtonItemSelectDB_Click;
173
            this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click;
174
            this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click;
175
            this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened;
176
            this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed;
177

    
178
            this.InitColumnGroupsViewDefinition(this.radGridViewDocuments);
179

    
180
            this.radPageViewPageReview.Controls.Add(briefAndImagesReview);
181
            this.radPageViewPageWork.Controls.Add(issueImagesAndAnswerWork);
182

    
183
            briefAndImagesReview.RemoveImage += BriefAndImages_RemoveImage;
184
            issueImagesAndAnswerWork.RemoveImage += IssueImagesAndAnswer_RemoveImage;
185
            
186
            this.radButtonSearchSymbol.ButtonElement.CustomFont = "TelerikWebUI";
187
            this.radButtonSearchSymbol.ButtonElement.Text = "\ue13E";
188
            this.designSymbol.ActiveViewport.CoordinateSystemIcon.Visible = false;
189

    
190
            this.radCheckBoxElementID2SymbolSearch.CheckStateChanged += RadCheckBoxElementID2SymbolSearch_CheckStateChanged;
191

    
192
            this.Initialize();
193
        }
194

    
195
        private void RadCheckBoxElementID2SymbolSearch_CheckStateChanged(object sender, EventArgs e)
196
        {
197
            this.toolWindowSymbol.DockState = (sender as Telerik.WinControls.UI.RadCheckBoxElement).IsChecked ? 
198
                Telerik.WinControls.UI.Docking.DockState.Docked : Telerik.WinControls.UI.Docking.DockState.Hidden;
199
        }
200

    
201
        /// <summary>
202
        /// 그룹에 속한 항목의 개수를 표시한다.
203
        /// </summary>
204
        /// <param name="sender"></param>
205
        /// <param name="e"></param>
206
        private void RadGridViewDocuments_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
207
        {
208
            if (e.Parent != this.radGridViewDocuments.MasterTemplate)
209
            {
210
                e.FormatString = $"{e.Value} - ({e.Group.ItemCount})";
211
            }
212
        }
213

    
214
        /// <summary>
215
        /// 유사도 분류 작업이 완료되면 유사도 수행 버튼을 활성화 시킨다.
216
        /// </summary>
217
        private void Classify_OnClassifyCompleted()
218
        {
219
            this.radButtonElementClassify.Visibility = ElementVisibility.Visible;
220
            this.radButtonElementStopWorking.Visibility = ElementVisibility.Collapsed;
221
        }
222

    
223
        /// <summary>
224
        /// 현재 보이는 Document를 Classify 화면에 표시한다.
225
        /// </summary>
226
        private void Classify_UpdateDocumentsEvent()
227
        {
228
            var docs = ((GridDataView)radGridViewDocuments.MasterTemplate.DataView).Indexer.Items.Select(x => x.DataBoundItem as Documents).ToList();
229
            var classify = this.LayoutValidation.Controls[0] as Classify;
230
            classify.DocumentListBinding(docs);
231
        }
232

    
233
        /// <summary>
234
        /// 사용자가 선택한 테마를 적용한다.
235
        /// </summary>
236
        /// <param name="sender"></param>
237
        /// <param name="e"></param>
238
        private void RadMenuItemTheme_Click(object sender, EventArgs e)
239
        {
240
            string theme = (sender as RadMenuItem).Text;
241
            if(theme != this.radDropDownButtonElementTheme.Text)
242
            {
243
                this.radDropDownButtonElementTheme.Text = theme;
244
                Classes.ID2Helper.IniWriteValue(Program.IniFilePath, "App", "Theme", theme);
245
                if (!string.IsNullOrEmpty(theme))
246
                {
247
                    Telerik.WinControls.ThemeResolutionService.ApplicationThemeName = theme;
248
                    Program.ThemeName = theme;
249
                }
250
            }
251
        }
252

    
253
        private void BtnDockLayoutReset_Click(object sender, EventArgs e)
254
        {
255
            this.LoadDockingLayout(true);
256
        }
257

    
258
        private void BriefAndImages_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 "toreview":
273
                                    doc.ToCapture -= reslut;
274
                                    break;
275
                                case "frreview":
276
                                    doc.FrCapture -= reslut;
277
                                    break;
278
                            }
279
                        }
280
                        else
281
                        {
282
                            MessageBox.Show("삭제오류");
283
                        }
284
                    }
285
                }
286
            }
287
            catch (Exception ex)
288
            {
289
                Program.logger.Error("BriefAndImages_RemoveImage", ex);
290
            }
291
        }
292

    
293
        private void IssueImagesAndAnswer_RemoveImage(object sender, AttImageInfo e)
294
        {
295
            try
296
            {
297
                if (e is AttImageInfo)
298
                {
299
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
300
                    {
301
                        var reslut = doc.AttFiles.RemoveAll(x => x.FileID == e.ID);
302

    
303
                        if (reslut > 0)
304
                        {
305
                            switch (e.Category)
306
                            {
307
                                case "id2work":
308
                                    doc.ID2Capture -= reslut;
309
                                    break;
310
                            }
311
                        }
312
                        else
313
                        {
314
                            MessageBox.Show("삭제오류");
315
                        }
316
                    }
317
                }
318
            }
319
            catch (Exception ex)
320
            {
321
                Program.logger.Error("IssueImagesAndAnswer_RemoveImage", ex);
322
            }
323
        }
324

    
325
        private void SaveDockingLayout()
326
        {
327
            try
328
            {
329
                this.DockMain.SaveToXml(dockLayoutPath);
330
            }
331
            catch (Exception ex)
332
            {
333
                System.Diagnostics.Debug.WriteLine("SaveDockingLayout Error.", ex);
334
            }
335
        }
336

    
337
        private void LoadDockingLayout(bool IsDefaultLayoutLoad = false)
338
        {
339
            try
340
            {
341
                bool IsUseLayoutLoad = false;
342

    
343
                try
344
                {
345
                    var dockLayoutFile = new FileInfo(dockLayoutPath);
346

    
347

    
348
                    if (!IsDefaultLayoutLoad && dockLayoutFile.Exists)
349
                    {
350
                        this.DockMain.LoadFromXml(dockLayoutPath);
351
                        IsUseLayoutLoad = true;
352
                    }
353

    
354
                }
355
                catch (Exception ex)
356
                {
357
                    Program.logger.Error($"dock Layout File load Error. File Path : {dockLayoutPath}", ex);
358
                }
359

    
360
                if (!IsUseLayoutLoad)
361
                {
362
                    var layout = Properties.Resources.DefalutDockLayout;
363

    
364
                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(layout)))
365
                    {
366
                        this.DockMain.LoadFromXml(stream);
367
                    }
368
                }
369

    
370
                this.DockMain.DocumentTabsVisible = true;
371

    
372
                this.DockMain.DockWindows.ForAll(x =>
373
                {
374
                    x.DockManager.ShowDocumentPinButton = false;
375
                    x.DockManager.ShowDocumentCloseButton = false;
376
                });
377

    
378
                this.DockMain.AutoHideWindowDisplaying += DockMain_AutoHideWindowDisplaying;
379

    
380
                this.DockMain.DockStateChanged += (snd, evt) =>
381
                {
382
                    if (evt.DockWindow.Name == DockWindowMain.Name || evt.DockWindow.Name == DockClassify.Name)
383
                    {
384

    
385
                    }
386

    
387
                };
388

    
389
                this.DockMain.DockWindowClosed += (snd, evt) =>
390
                {
391
                    evt.DockWindow.DockState = Telerik.WinControls.UI.Docking.DockState.AutoHide;
392

    
393
                    //Telerik.WinControls.UI.Docking.AutoHidePosition tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Right;
394

    
395

    
396
                    //List<DockWindow> dockWindows = new List<DockWindow>();
397

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

    
400

    
401
                    //if (evt.DockWindow.AccessibleName == DockWindowMain.AccessibleName || evt.DockWindow.Name == DockValidation.AccessibleName)
402
                    //{
403
                    //    dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName == DockWindowMain.AccessibleName && evt.DockWindow.Name == DockValidation.AccessibleName));
404

    
405
                    //    tabPosition = Telerik.WinControls.UI.Docking.AutoHidePosition.Bottom;
406

    
407
                    //    dockWindows.Add(evt.DockWindow);
408
                    //}
409
                    //else
410
                    //{
411
                    //    dockWindows.AddRange(autoHideWindows.Where(x => x.AccessibleName != DockWindowMain.AccessibleName || evt.DockWindow.Name != DockValidation.AccessibleName));
412

    
413
                    //    dockWindows.Add(evt.DockWindow);
414
                    //}
415

    
416

    
417
                    //this.DockMain.AutoHideWindows(dockWindows, tabPosition);
418
                };
419
            }
420
            catch (Exception ex)
421
            {
422
                Program.logger.Error($"dock Layout load Error. File Path : {dockLayoutPath}", ex);
423
            }
424
        }
425

    
426
        private void DockMain_AutoHideWindowDisplaying(object sender, Telerik.WinControls.UI.Docking.AutoHideWindowDisplayingEventArgs e)
427
        {
428

    
429
        }
430

    
431
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
432
        {
433
            SaveDockingLayout();
434
        }
435

    
436
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
437
        {
438
            if (keyData == (Keys.F10 | Keys.Control))
439
            {
440
//#if DEBUG
441
//                radControlSpyForm.Show();
442
//#endif
443
            }
444

    
445
            if (keyData == (Keys.V | Keys.Control))
446
            {
447
                System.Diagnostics.Debug.WriteLine("KeyDown CTRL + V");
448

    
449
                if (Clipboard.ContainsImage())
450
                {
451
                    var IsDoftech = true;
452
                    var selectReview = true;
453
                    string category = "";
454
                    byte[] imageBytes = null;
455

    
456
                    Image clipboardImage = Clipboard.GetImage();
457

    
458
                    using (MemoryStream stream = new MemoryStream())
459
                    {
460
                        clipboardImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
461
                        imageBytes = stream.ToArray();
462
                    }
463

    
464
                    if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
465
                    {
466

    
467
                        /// 도프텍 or 삼성
468
                        if (!string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
469
                        {
470
                            IsDoftech = false;
471
                        }
472

    
473
                        /// 검토 or 검증
474
                        if (radPageViewComment.SelectedPage != radPageViewPageReview)
475
                        {
476
                            selectReview = false;
477
                        }
478

    
479
                        if (IsDoftech && selectReview)
480
                        {
481
                            category = "toreview";
482
                        }
483
                        else if (!IsDoftech && selectReview)
484
                        {
485
                            category = "frreview";
486
                        }
487
                        else
488
                        {
489
                            category = "id2work";
490
                        }
491

    
492
                        AttFileInfo newFile = new AttFileInfo
493
                        {
494
                            FileID = Guid.NewGuid().ToString(),
495
                            Category = category,
496
                            FileType = "image/png",
497
                            FileName = "ClipBoard",
498
                            FilePath = "ClipBoard",
499
                            FileExtension = ".png",
500
                            CreatedDate = DateTime.Now,
501
                            Creator = informations.ActiveUser.ID,
502
                            FileData = imageBytes
503

    
504
                        };
505

    
506
                        if (doc.AttFiles == null)
507
                        {
508
                            doc.AttFiles = new List<AttFileInfo>();
509
                        }
510

    
511
                        doc.AttFiles.Add(newFile);
512

    
513
                        var imageInfo = new AttImageInfo { ID = newFile.FileID, Data = newFile.FileData };
514

    
515
                        switch (category)
516
                        {
517
                            case "toreview":
518
                                briefAndImagesReview.AddToImage(imageInfo, true);
519
                                ++doc.ToCapture;
520
                                break;
521
                            case "frreview":
522
                                briefAndImagesReview.AddFrImage(imageInfo, true);
523
                                ++doc.FrCapture;
524
                                break;
525
                            case "id2work":
526
                                issueImagesAndAnswerWork.AddImage(imageInfo, true);
527
                                ++doc.ID2Capture;
528
                                break;
529
                        }
530
                    }
531
                }
532
            }
533

    
534
            return base.ProcessCmdKey(ref msg, keyData);
535
        }
536

    
537
        private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
538
        {
539
            if (e.RowInfo is GridViewSearchRowInfo)
540
            {
541
                var row = new SearchRow(e.ViewInfo);
542
                e.RowInfo = row;
543
            }
544

    
545
            //System.Diagnostics.Debug.WriteLine(e.RowInfo.GetType().Name);
546
        }
547

    
548
        private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
549
        {
550
            if (e.SearchFinished)
551
            {
552

    
553
            }
554
        }
555

    
556
        /// <summary>
557
        /// 선택한 Document와 상세 편집 창을 연동시킨다.
558
        /// </summary>
559
        /// <param name="doc"></param>
560
        public void BindingDocumentToDetailEditor(Documents doc)
561
        {
562
            briefAndImagesReview.Clear();
563
            issueImagesAndAnswerWork.Clear();
564

    
565
            //FrRemarks 추가
566

    
567
            briefAndImagesReview.DataBindings.Add(new Binding("BriefDoftech", doc, "ToRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
568
            briefAndImagesReview.DataBindings.Add(new Binding("BriefSec", doc, "FrRemarks", false, DataSourceUpdateMode.OnPropertyChanged, null));
569

    
570
            issueImagesAndAnswerWork.DataBindings.Add(new Binding("IssueText", doc, "ID2Issues", false, DataSourceUpdateMode.OnPropertyChanged, null));
571
            issueImagesAndAnswerWork.DataBindings.Add(new Binding("ReplyModificationText", doc, "ReplyModifications", false, DataSourceUpdateMode.OnPropertyChanged, null));
572

    
573
            if (doc.AttFiles != null)
574
            {
575
                if (doc.AttFiles.Any(x => x.Category == "toreview"))
576
                {
577
                    var images = doc.AttFiles.Where(x => x.Category == "toreview").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
578
                    briefAndImagesReview.SetToImages(images.ToList());
579
                }
580

    
581
                if (doc.AttFiles.Any(x => x.Category == "frreview"))
582
                {
583
                    var images = doc.AttFiles.Where(x => x.Category == "frreview").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
584
                    briefAndImagesReview.SetFrImages(images.ToList());
585
                }
586

    
587
                if (doc.AttFiles.Any(x => x.Category == "id2work"))
588
                {
589
                    var images = doc.AttFiles.Where(x => x.Category == "id2work").Select(x => new AttImageInfo { ID = x.FileID, Category = x.Category, Data = x.FileData });
590
                    issueImagesAndAnswerWork.SetImages(images.ToList());
591
                }
592
            }
593
        }
594

    
595
        private void RadGridViewDocuments_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
596
        {
597
            //if (e.Row is GridViewNewRowInfo)
598
            //{
599
            //    e.Row.Cells["RefProjectCode"].ReadOnly = false;
600
            //    e.Row.Cells["DocumentNo"].ReadOnly = false;
601
            //}
602

    
603
            //BindingDocumentToDetailEditor(new Documents());
604
        }
605

    
606
        private void RadGridViewDocuments_UserAddedRow(object sender, GridViewRowEventArgs e)
607
        {
608
            if (e.Row.DataBoundItem is Documents doc)
609
            {
610
                this.lbSelectAndTotal.Text = $"{this.radGridViewDocuments.MasterTemplate.DataView.Count} / {this.SearchCount} / {this.TotalCount} (Filter / Search / Total)";
611
            }
612
        }
613

    
614
        /// <summary>
615
        /// 선택된 행의 AutoCAD와 PDF 파일을 보여준다.
616
        /// </summary>
617
        /// <param name="sender"></param>
618
        /// <param name="e"></param>
619
        private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e)
620
        {
621
            if (this.radGridViewDocuments.SelectedRows.Any() && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
622
            {
623
                //if (informations.ActiveUser.ID != doc.PersonInCharge)
624
                //{
625
                //    var row = this.radGridViewDocuments.SelectedRows.First();
626
                //    foreach(var cell in row.Cells)
627
                //    {
628
                //        cell.ReadOnly = true;
629
                //    }
630
                //}
631
                BindingDocumentToDetailEditor(doc);
632
            }
633
        }
634

    
635
        #region Init, Load
636
        private void Initialize()
637
        {
638
            this.Text = $"{Globals.Name} (Ver : {Application.ProductVersion})";
639

    
640
            this.ID2ManagerRadRibbonBar.Expanded = false;
641

    
642
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
643
        }
644

    
645
        protected override void OnLoad(EventArgs e)
646
        {
647
            try
648
            {
649
                LoadDockingLayout();
650
                this.radDropDownButtonElementTheme.Text = Program.ThemeName;
651

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

    
654
                InitializeGrid();
655

    
656
                bool isID2DB = this.IsID2Connection();
657
                this.SetMenus(isID2DB);
658

    
659
                if (isID2DB)
660
                {
661
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
662
                    {
663
                        informations.ActiveProjects = new List<ProjectInfo>() { new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID) };
664
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
665

    
666
                        this.LoadProject(true);
667
                    }
668
                    else
669
                    {
670
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
671
                        /*
672
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
673
                        {
674
                            if (ctrl is OpenProjectView)
675
                            {
676
                                var openProjectView = ctrl as OpenProjectView;
677
                                openProjectView.GetProjectGroups();
678
                                break;
679
                            }
680
                        }
681
                        */
682
                    };
683
                }
684
                else
685
                {
686
                    this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
687
                    RadMessageBox.Show(this, $"Please select db file.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info);
688
                }
689

    
690
                this.radButtonSearchSymbol.Click += RadButtonSearchSymbol_Click;
691
                this.radTextBoxSymbolName.KeyDown += RadTextBoxSymbolName_KeyDown;
692
                this.radGridViewID2Symbols.DataBindingComplete += RadGridViewID2Symbols_DataBindingComplete;
693
                this.radGridViewID2Symbols.SelectionChanged += RadGridViewID2Symbols_SelectionChanged;
694

    
695
                this.radButtonElementStopWorking.Visibility = ElementVisibility.Collapsed;
696
                this.radButtonElementClassify.Click += RadButtonElementClassify_Click;
697
                this.radButtonElementStopWorking.Click += RadButtonElementStopWorking_Click;
698
                this.radButtonElementExtractText.Click += RadButtonElementExtractText_Click;
699

    
700
                this.radCheckBoxElementID2SymbolSearch.Checked = this.toolWindowSymbol.DockState != Telerik.WinControls.UI.Docking.DockState.Hidden;
701
            }
702
            catch (Exception ex)
703
            {
704
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
705
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
706
            }
707

    
708
            base.OnLoad(e);
709
        }
710

    
711
        /// <summary>
712
        /// 도면에서 텍스트를 추출한다.
713
        /// </summary>
714
        /// <param name="sender"></param>
715
        /// <param name="e"></param>
716
        private void RadButtonElementExtractText_Click(object sender, EventArgs e)
717
        {
718
            var classify = this.LayoutValidation.Controls[0] as Classify;
719
            classify.ExtractText();
720
        }
721

    
722
        private void RadButtonElementStopWorking_Click(object sender, EventArgs e)
723
        {
724
            this.radButtonElementClassify.Visibility = ElementVisibility.Visible;
725
            this.radButtonElementStopWorking.Visibility = ElementVisibility.Collapsed;
726

    
727
            var classify = this.LayoutValidation.Controls[0] as Classify;
728
            classify.StopWorking();
729
        }
730

    
731
        private void RadButtonElementClassify_Click(object sender, EventArgs e)
732
        {
733
            this.radButtonElementClassify.Visibility = ElementVisibility.Collapsed;
734
            this.radButtonElementStopWorking.Visibility = ElementVisibility.Visible;
735

    
736
            var classify = this.LayoutValidation.Controls[0] as Classify;
737
            classify.DoClassifyDrawing();
738
        }
739

    
740
        /// <summary>
741
        /// 주어진 SymbolName을 포함하는 심볼들(실제로 프로젝트에 사용된)을 찾는다.
742
        /// </summary>
743
        /// <param name="SymbolName"></param>
744
        private void SearchSymbols(string SymbolName)
745
        {
746
            var AllSymbols = new List<ID2Symbol>();
747
            List<string> actPrjIDs = informations.ActiveProjects.Select(x => x.ProjectID).ToList();
748
            var id2prjs = informations.FindID2ProjectList(actPrjIDs).Where(x =>
749
            !string.IsNullOrEmpty(x.Host) && !string.IsNullOrEmpty(x.User) && !string.IsNullOrEmpty(x.Password)).ToList();
750
            foreach (var id2prj in id2prjs)
751
            {
752
                try
753
                {
754
                    var controller = new DocumentController(id2prj);
755
                    var configs = controller.GetID2Configurations();
756
                    var config = configs.FirstOrDefault(x => x.Section.Equals("Data Save") && x.Key.Equals("Drawing Xml Only"));
757
                    id2prj.XmlOnly = config != null && config.Value.Equals("1");
758
                    var symbols = controller.FindID2Symbols(SymbolName, id2prj.XmlOnly);
759
                    symbols.ForAll(x =>
760
                    {
761
                        x.PrjName = id2prj.Name;
762
                        x.PrjPath = id2prj.Path;
763
                    });
764
                    AllSymbols.AddRange(symbols);
765

    
766
                }
767
                catch (Exception ex)
768
                {
769
                    RadMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
770
                }
771
            }
772

    
773
            var worker = new ID2SymbolWorker(id2prjs, AllSymbols, this.radGridViewID2Symbols);
774
            worker.OnWorkCompletedHandler += (_e) =>
775
            {
776
                this.radGridViewID2Symbols.DataSource = worker.Used;
777
            };
778
            worker.StartWork();
779
        }
780

    
781
        private void RadButtonSearchSymbol_Click(object sender, EventArgs e)
782
        {
783
            string SymbolName = this.radTextBoxSymbolName.Text;
784
            SearchSymbols(SymbolName);
785
        }
786

    
787
        /// <summary>
788
        /// 선택 항목의 심볼을 화면에 표시한다.
789
        /// </summary>
790
        /// <param name="sender"></param>
791
        /// <param name="e"></param>
792
        private void RadGridViewID2Symbols_SelectionChanged(object sender, EventArgs e)
793
        {
794
            if (this.radGridViewID2Symbols.SelectedRows.Any() && !this.designSymbol.IsBusy)
795
            {
796
                var symbol = this.radGridViewID2Symbols.SelectedRows.First().DataBoundItem as ID2Symbol;
797
                string DxfFilePath = Path.Combine(symbol.PrjPath, "image", symbol.Type, symbol.Name + ".dxf");
798
                
799
                devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(DxfFilePath);
800
                this.designSymbol.WorkCompleted += (_sender, _e) =>
801
                {
802
                    if (_e.WorkUnit is devDept.Eyeshot.Translators.ReadAutodesk dxf)
803
                    {
804
                        this.designSymbol.Clear();
805
                        dxf.AddToScene(this.designSymbol);
806

    
807
                        #region 원점과 연결점들을 표시한다.
808
                        var tokens = symbol.OriginalPoint.Split(',');
809
                        if (tokens.Length == 2)
810
                        {
811
                            double x = Convert.ToDouble(tokens[0]);
812
                            double y = symbol.Height - Convert.ToDouble(tokens[1]);
813
                            var pt = new devDept.Eyeshot.Entities.Point(new devDept.Geometry.Point2D(x, y), 6)
814
                            {
815
                                Color = Color.Red,
816
                                ColorMethod = devDept.Eyeshot.Entities.colorMethodType.byEntity
817
                            };
818
                            this.designSymbol.Entities.Add(pt);
819
                        }
820

    
821
                        int index = 1;
822
                        tokens = symbol.ConnectionPoint.Split('/');
823
                        foreach(var token in tokens)
824
                        {
825
                            var _tokens = token.Split(',');
826
                            double x = Convert.ToDouble(_tokens[1]);
827
                            double y = symbol.Height - Convert.ToDouble(_tokens[2]);
828
                            var pt = new devDept.Eyeshot.Entities.Point(new devDept.Geometry.Point2D(x, y), 6)
829
                            {
830
                                Color = Color.Blue,
831
                                ColorMethod = devDept.Eyeshot.Entities.colorMethodType.byEntity
832
                            };
833
                            this.designSymbol.Entities.Add(pt);
834
                            #region 연결점 번호 표시
835
                            var text = new devDept.Eyeshot.Entities.Text(new devDept.Geometry.Point3D(x, y), index.ToString(), 6)
836
                            {
837
                                Color = Color.Blue,
838
                                ColorMethod = devDept.Eyeshot.Entities.colorMethodType.byEntity
839
                            };
840
                            this.designSymbol.Entities.Add(text);
841
                            index++;
842
                            #endregion
843
                        }
844
                        #endregion
845

    
846
                        this.designSymbol.ZoomFit();
847
                    }
848
                };
849
                this.designSymbol.StartWork(ra);
850
            }
851
        }
852

    
853
        private void RadGridViewID2Symbols_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
854
        {
855
            this.radGridViewID2Symbols.BestFitColumns();
856
        }
857

    
858
        /// <summary>
859
        /// 입력한 이름을 가진 ID2 심볼을 조회합니다.
860
        /// </summary>
861
        /// <param name="sender"></param>
862
        /// <param name="e"></param>
863
        private void RadTextBoxSymbolName_KeyDown(object sender, KeyEventArgs e)
864
        {
865
            var informations = Informations.Instance;
866
            if(e.KeyCode == Keys.Enter)
867
            {
868
                string SymbolName = this.radTextBoxSymbolName.Text;
869
                SearchSymbols(SymbolName);
870
            }
871
        }
872

    
873
        private bool IsID2Connection()
874
        {
875
            bool isSuccess = false;
876

    
877
            try
878
            {
879
                isSuccess = Globals.IsProjectDBConnstr();
880

    
881
                if (isSuccess)
882
                {
883
                    var id2Project = new ID2Controller().GetID2ProjectList();
884
                }
885
            }
886
            catch (Exception ex)
887
            {
888
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
889
                isSuccess = false;
890
            }
891

    
892
            return isSuccess;
893
        }
894

    
895
        private void SetMenus(bool isid2)
896
        {
897
            if (isid2)
898
            {
899
                if (this.IsID2Manager)
900
                {
901
                    this.radButtonElementNoticeUpload.Enabled = true;
902

    
903
                    this.backstageViewPageOpenProject.Controls[0].Visible = true;
904
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible;
905
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible;
906

    
907
                    this.ribbonTabProjMgt.Visibility = ElementVisibility.Visible;
908
                }
909
                else
910
                {
911
                    this.radButtonElementNoticeUpload.Enabled = false;
912

    
913
                    if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
914
                    {
915
                        this.backstageViewPageOpenProject.Controls[0].Visible = true;
916
                    }
917
                    else
918
                    {
919
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
920
                        {
921
                            ctrl.Visible = false;
922
                        }
923
                    }
924
                    this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
925
                    this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
926

    
927
                    this.ribbonTabProjMgt.Visibility = ElementVisibility.Collapsed;
928
                }
929
            }
930
            else
931
            {
932
                this.radButtonElementNoticeUpload.Enabled = false;
933

    
934
                this.backstageButtonItemSelectDB.Visibility = ElementVisibility.Visible;
935
                foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
936
                {
937
                    ctrl.Visible = false;
938
                }
939
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
940
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
941

    
942
                this.ribbonTabProjMgt.Visibility = ElementVisibility.Collapsed;
943
            }
944
        }
945

    
946
        public Point GetBackstageLocation()
947
        {
948
            Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
949
            location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
950
            location.Offset(this.ID2ManagerRadRibbonBar.Location);
951

    
952
            return location;
953
        }
954

    
955
        private void InitializeGrid()
956
        {
957
            InitializeProp();
958
            InitializeColumns();
959
            InitializeSearch();
960
            InitializeGridViewDetail();
961

    
962
            //this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
963
        }
964

    
965
        private void InitializeProp()
966
        {
967
            this.radGridViewDocuments.AllowAddNewRow = this.IsID2Manager;
968
        }
969

    
970
        private void InitializeColumns()
971
        {
972
            bool isClient = !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID);
973
            GridViewColumnCollection cols = this.radGridViewDocuments.Columns;
974

    
975
            cols.ForAll(x =>
976
            {
977
                if (!x.ReadOnly)
978
                {
979
                    switch (x.Name)
980
                    {
981
                        case "PersonInCharge":
982
                        case "AVEVAPersonInCharge":
983
                            x.ReadOnly = !this.IsID2Manager;
984
                            break;
985
                        case "FrReviewStatus":
986
                        case "FrRemarks":
987
                        case "FrCreator":
988
                        case "ClientReviewer":
989
                        case "ClientIsResult":
990
                        case "ClientRemarks":
991
                            x.ReadOnly = !isClient;
992
                            break;
993
                        default:
994
                            x.ReadOnly = isClient;
995
                            break;
996
                    }
997
                }
998
            });
999
        }
1000

    
1001
        private void InitializeSearch()
1002
        {
1003

    
1004
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
1005

    
1006
            lbSearch.Text = "\ue13E";
1007
            btnSearchNext.Text = "\ue006";
1008
            btnSearchPrevious.Text = "\ue004";
1009

    
1010
            var chkbox = new RadCheckBoxElement();
1011
            chkbox.Text = "Match Case";
1012
            chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; };
1013

    
1014
            btnMatchCase.HostedItem = chkbox;
1015

    
1016
            var chkbox1 = new RadCheckBoxElement();
1017
            chkbox1.Text = "Show All Detail";
1018
            chkbox1.CheckStateChanged += (snd, evt) =>
1019
            {
1020
                radGridViewDocuments.MasterView.ChildRows.ForAll(x => x.IsExpanded = chkbox1.Checked);
1021
            };
1022

    
1023
            btnShowAllDetail.HostedItem = chkbox1;
1024

    
1025
            var chkbox2 = new RadCheckBoxElement();
1026
            chkbox2.Text = "Search from current position";
1027
            chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; };
1028

    
1029
            btnSearchFormCurrent.HostedItem = chkbox2;
1030

    
1031
            var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x =>
1032
                                 new FilterColumn
1033
                                 {
1034
                                     Name = x.HeaderText,
1035
                                     FieldName = x.FieldName,
1036
                                     IsSelect = x.AllowSearching
1037
                                 }).ToList();
1038

    
1039
            var panel = new StackLayoutElement();
1040
            panel.Orientation = Orientation.Vertical;
1041

    
1042
            var btnComboColumns = new RadCheckedDropDownListElement();
1043
            btnComboColumns.ShowCheckAllItems = true;
1044
            btnComboColumns.CheckAllItem.Checked = true;
1045
            btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns";
1046
            btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true;
1047
            btnComboColumns.DropDownMinSize = new Size(200, 200);
1048
            btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
1049
            btnComboColumns.DisplayMember = "Name";
1050
            btnComboColumns.CheckedMember = "IsSelect";
1051
            btnComboColumns.ValueMember = "FieldName";
1052
            btnComboColumns.TextBox.CustomFont = font1.Name;
1053
            btnComboColumns.TextBox.Text = "\ue13A";
1054

    
1055
            columns.Add(new FilterColumn { FieldName = "CREATE_USER", Name = "Markus User", IsSelect = true });
1056
            columns.Add(new FilterColumn { FieldName = "TEXT", Name = "Markus Text", IsSelect = true });
1057

    
1058
            btnComboColumns.DataSource = columns;
1059

    
1060
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
1061
            {
1062
                radGridViewDocuments.MasterTemplate.Refresh(null);
1063
            };
1064

    
1065
            btnComboColumns.PopupOpening += (snd, evt) =>
1066
            {
1067
                (snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect);
1068
            };
1069

    
1070
            btnComboColumns.PopupClosed += (snd, evt) =>
1071
            {
1072
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
1073
                {
1074
                    if (radGridViewDocuments.Columns[item.Value.ToString()] != null)
1075
                    {
1076
                        radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
1077
                    }
1078

    
1079
                    foreach (var template in radGridViewDocuments.Templates)
1080
                    {
1081
                        if (template.Columns[item.Value.ToString()] != null)
1082
                        {
1083
                            template.Columns[item.Value.ToString()].AllowSearching = item.Checked;
1084
                        }
1085
                    }
1086
                }
1087
            };
1088

    
1089
            btnFilters.HostedItem = btnComboColumns;
1090
        }
1091

    
1092
        private void InitializeGridViewDetail()
1093
        {
1094
            DetailGridViewTemplate markupList = new DetailGridViewTemplate();
1095

    
1096
            GridViewTextBoxColumn userColumn = new GridViewTextBoxColumn("CREATE_USER");
1097
            GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("TEXT");
1098

    
1099
            userColumn.MinWidth = 110;
1100
            userColumn.AutoSizeMode = BestFitColumnMode.AllCells;
1101
            userColumn.AllowSearching = true;
1102
            textColumn.AutoSizeMode = BestFitColumnMode.AllCells;
1103
            textColumn.AllowSearching = true;
1104

    
1105
            markupList.Columns.AddRange(userColumn, textColumn);
1106
            markupList.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
1107

    
1108
            this.radGridViewDocuments.MasterTemplate.Templates.Add(markupList);
1109
            markupList.HierarchyDataProvider = new GridViewEventDataProvider(markupList);
1110

    
1111
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
1112
            this.radGridViewDocuments.RowSourceNeeded += RadGridViewDocuments_RowSourceNeeded;
1113
        }
1114

    
1115
        private void RadGridViewDocuments_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
1116
        {
1117
            if (e.Template.HierarchyLevel == 1)
1118
            {
1119
                if (e.ParentRow.DataBoundItem is Documents documents)
1120
                {
1121
                    if (documents.Markups != null)
1122
                    {
1123
                        foreach (var makrup in documents.Markups)
1124
                        {
1125
                            GridViewRowInfo row = e.Template.Rows.NewRow();
1126

    
1127
                            row.Cells["CREATE_USER"].Value = makrup.CREATE_USER;
1128
                            row.Cells["TEXT"].Value = makrup.TEXT;
1129
                            e.SourceCollection.Add(row);
1130
                        }
1131

    
1132
                        e.Template.BestFitColumns(BestFitColumnMode.AllCells);
1133
                    }
1134
                }
1135
            }
1136
        }
1137

    
1138
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
1139
        {
1140
            if (e.IsExpanded)
1141
            {
1142
            }
1143
        }
1144

    
1145
        #endregion
1146

    
1147
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
1148
        {
1149
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
1150
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
1151
        }
1152

    
1153
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
1154
        {
1155
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
1156

    
1157
            foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
1158
            {
1159
                if (ctrl is OpenProjectView)
1160
                {
1161
                    var openProjectView = ctrl as OpenProjectView;
1162
                    openProjectView.GetProjectGroups();
1163
                    break;
1164
                }
1165
            }
1166
        }
1167

    
1168

    
1169
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
1170
        {
1171
            try
1172
            {
1173
                if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
1174
                {
1175
                    var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
1176

    
1177
                    informations.ActiveProjects = prjArgs.ProjectInfos;
1178

    
1179
                    this.radRibbonBarBackstageViewID2Manager.Tag = null;
1180

    
1181
                    this.LoadProject(true);
1182
                }
1183
            }
1184
            catch (Exception ex)
1185
            {
1186
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1187
                RadMessageBox.Show("Failed to load project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1188
            }
1189
        }
1190

    
1191
        private void LoadProject(bool isFilterClear)
1192
        {
1193
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
1194

    
1195
            try
1196
            {
1197
                //Project Group Name
1198
                //this.radLabelProjectGroupNm.Text = informations.ActiveProject.Name;
1199
                this.radLabelProjectGroupNm.Text = string.Join(", ", informations.ActiveProjects.Select(x => x.Name));
1200

    
1201
                #region Date
1202
                //Date Type
1203
                if (this.radCheckedDropDownListDateType.DataSource != null)
1204
                    this.radCheckedDropDownListDateType.DataSource = null;
1205

    
1206
                this.radCheckedDropDownListDateType.DataSource = informations.DateType;
1207
                this.radCheckedDropDownListDateType.DisplayMember = "Value";
1208
                this.radCheckedDropDownListDateType.ValueMember = "Key";
1209

    
1210
                //FromDate
1211
                this.radDateTimePickerFr.NullableValue = null;
1212
                this.radDateTimePickerFr.SetToNullValue();
1213

    
1214
                //ToDate
1215
                this.radDateTimePickerTo.NullableValue = null;
1216
                this.radDateTimePickerTo.SetToNullValue();
1217
                #endregion
1218

    
1219
                #region 도면
1220
                //Team List
1221
                if (this.radDropDownListTeam.Items.Count > 0)
1222
                    this.radDropDownListTeam.Items.Clear();
1223
                //informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID) && !string.IsNullOrEmpty(x.Team))
1224
                //                        .GroupBy(g => g.Team)
1225
                //                        .OrderBy(o => o.Key)
1226
                //                        .Select(x => x.Key)
1227
                //                        .ForAll(x =>
1228
                //                        {
1229
                //                            this.radDropDownListTeam.Items.Add(new RadListDataItem(x, x));
1230
                //                        });
1231
                (from allPrj in informations.ProjectList
1232
                 join actPrj in informations.ActiveProjects on allPrj.GroupID equals actPrj.ProjectID
1233
                 where !string.IsNullOrEmpty(allPrj.Team)
1234
                 select allPrj).GroupBy(g => g.Team)
1235
                               .OrderBy(o => o.Key)
1236
                               .Select(x => x.Key)
1237
                               .ForAll(x =>
1238
                               {
1239
                                   this.radDropDownListTeam.Items.Add(new RadListDataItem(x, x));
1240
                               });
1241

    
1242

    
1243
                var allTeam = new RadListDataItem("== 전체 ==", string.Empty);
1244
                this.radDropDownListTeam.Items.Insert(0, allTeam);
1245
                allTeam.Selected = true;
1246

    
1247
                //Project List
1248
                if (this.radDropDownListProject.Items.Count > 0)
1249
                    this.radDropDownListProject.Items.Clear();
1250
                //informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
1251
                //                        .ForEach(x =>
1252
                //                        {
1253
                //                            this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
1254
                //                        });
1255
                (from allPrj in informations.ProjectList
1256
                 join actPrj in informations.ActiveProjects on allPrj.GroupID equals actPrj.ProjectID
1257
                 select allPrj).ForAll(x =>
1258
                 {
1259
                     this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
1260
                 });
1261

    
1262
                this.radDropDownListProject.Items.Add(new RadListDataItem("== ID2 Project 미등록 ==", null));//ID2 Project 미등록
1263

    
1264
                var allProject = new RadListDataItem("== 전체 ==", string.Empty);
1265
                this.radDropDownListProject.Items.Insert(0, allProject);
1266
                allProject.Selected = true;
1267

    
1268
                //담당자 List
1269
                if (this.radDropDownListPersonInCharge.Items.Count > 0)
1270
                    this.radDropDownListPersonInCharge.Items.Clear();
1271
                informations.UserList.ForEach(x =>
1272
                {
1273
                    if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
1274
                    {
1275
                        var userItem = new RadListDataItem(x.Name, x.ID);
1276
                        this.radDropDownListPersonInCharge.Items.Add(userItem);
1277

    
1278
                        if (!this.IsID2Manager)
1279
                            if (x.ID.Equals(informations.ActiveUser.ID))
1280
                                userItem.Selected = true;
1281
                    }
1282
                        
1283
                });
1284
                var allUser = new RadListDataItem("== 전체 ==", string.Empty);
1285
                this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
1286
                if (this.IsID2Manager)
1287
                    allUser.Selected = true;
1288
                else
1289
                    this.radDropDownListPersonInCharge.Enabled = false;
1290

    
1291
                //난이도
1292
                if (this.radDropDownListJobLevel.Items.Count > 0)
1293
                    this.radDropDownListJobLevel.Items.Clear();
1294
                informations.JobLevel.ForEach(x =>
1295
                {
1296
                    this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
1297
                });
1298
                var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
1299
                this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
1300
                allJobLevel.Selected = true;
1301

    
1302
                //도면번호 조회조건
1303
                this.radTextBoxDocumentNo.Text = string.Empty;
1304
                #endregion
1305

    
1306
                #region 검토
1307
                //문의(DOF)
1308
                if (this.radDropDownListToIsDiscussion.Items.Count > 0)
1309
                    this.radDropDownListToIsDiscussion.Items.Clear();
1310
                informations.IsYesNo.ForEach(x =>
1311
                {
1312
                    this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
1313
                });
1314
                var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
1315
                this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
1316
                allToIsDiscussion.Selected = true;
1317

    
1318
                //회신(DS)
1319
                if (this.radDropDownListFrReviewStatus.Items.Count > 0)
1320
                    this.radDropDownListFrReviewStatus.Items.Clear();
1321
                informations.ClientStatus.ForEach(x =>
1322
                {
1323
                    this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
1324
                });
1325
                var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
1326
                this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
1327
                allFrReviewStatus.Selected = true;
1328
                #endregion
1329

    
1330
                #region 작업
1331
                //ID2 Status
1332
                {
1333
                    if (this.radDropDownListID2Status.Items.Count > 0)
1334
                        this.radDropDownListID2Status.Items.Clear();
1335
                    informations.JobStatus.ForEach(x =>
1336
                    {
1337
                        this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
1338
                    });
1339
                    var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
1340
                    this.radDropDownListID2Status.Items.Insert(0, allID2Status);
1341
                    allID2Status.Selected = true;
1342
                }
1343

    
1344
                //ID2 Issues
1345
                {
1346
                    if (this.radDropDownListID2Issues.Items.Count > 0)
1347
                        this.radDropDownListID2Issues.Items.Clear();
1348
                    informations.IsYesNo.ForEach(x =>
1349
                    {
1350
                        this.radDropDownListID2Issues.Items.Add(new RadListDataItem(x, x));
1351
                    });
1352
                    var allID2Issues = new RadListDataItem("== 전체 ==", string.Empty);
1353
                    this.radDropDownListID2Issues.Items.Insert(0, allID2Issues);
1354
                    allID2Issues.Selected = true;
1355
                }
1356

    
1357
                //AVEVA Status
1358
                {
1359
                    if (this.radDropDownListAVEVAStatus.Items.Count > 0)
1360
                        this.radDropDownListAVEVAStatus.Items.Clear();
1361
                    informations.JobStatus.ForEach(x =>
1362
                    {
1363
                        this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
1364
                    });
1365
                    var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
1366
                    this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
1367
                    allAVEVAStatus.Selected = true;
1368
                }
1369

    
1370
                //AVEVA Issues
1371
                {
1372
                    if (this.radDropDownListAVEVAIssues.Items.Count > 0)
1373
                        this.radDropDownListAVEVAIssues.Items.Clear();
1374
                    informations.IsYesNo.ForEach(x =>
1375
                    {
1376
                        this.radDropDownListAVEVAIssues.Items.Add(new RadListDataItem(x, x));
1377
                    });
1378
                    var allAVEVAIssues = new RadListDataItem("== 전체 ==", string.Empty);
1379
                    this.radDropDownListAVEVAIssues.Items.Insert(0, allAVEVAIssues);
1380
                    allAVEVAIssues.Selected = true;
1381
                }
1382

    
1383
                #endregion
1384

    
1385
                #region 검수
1386
                //도프텍 결과
1387
                if (this.radDropDownListProdIsResult.Items.Count > 0)
1388
                    this.radDropDownListProdIsResult.Items.Clear();
1389
                informations.ValidationResult.ForEach(x =>
1390
                {
1391
                    this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
1392
                });
1393
                var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
1394
                this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
1395
                allProdIsResult.Selected = true;
1396

    
1397
                //삼성 결과
1398
                if (this.radDropDownListClientIsResult.Items.Count > 0)
1399
                    this.radDropDownListClientIsResult.Items.Clear();
1400
                informations.ValidationResult.ForEach(x =>
1401
                {
1402
                    this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
1403
                });
1404
                var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
1405
                this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
1406
                allClientIsResult.Selected = true;
1407
                #endregion
1408

    
1409
                #region AVEVA
1410
                //Gateway
1411
                if (this.radDropDownListGateway.Items.Count > 0)
1412
                    this.radDropDownListGateway.Items.Clear();
1413
                informations.IsYesNo.ForEach(x =>
1414
                {
1415
                    this.radDropDownListGateway.Items.Add(new RadListDataItem(x, x));
1416
                });
1417
                var allDTIsGateWay = new RadListDataItem("== 전체 ==", string.Empty);
1418
                this.radDropDownListGateway.Items.Insert(0, allDTIsGateWay);
1419
                allDTIsGateWay.Selected = true;
1420

    
1421
                //Registration
1422
                if (this.radDropDownListRegistration.Items.Count > 0)
1423
                    this.radDropDownListRegistration.Items.Clear();
1424
                informations.IsYesNo.ForEach(x =>
1425
                {
1426
                    this.radDropDownListRegistration.Items.Add(new RadListDataItem(x, x));
1427
                });
1428
                var allDTIsRegSystem = new RadListDataItem("== 전체 ==", string.Empty);
1429
                this.radDropDownListRegistration.Items.Insert(0, allDTIsRegSystem);
1430
                allDTIsRegSystem.Selected = true;
1431
                #endregion
1432

    
1433
                this.GetDocList(isFilterClear);
1434
            }
1435
            catch (Exception ex)
1436
            {
1437
                throw ex;
1438
            }
1439
            finally
1440
            {
1441

    
1442
                this.Cursor = Cursors.Default;
1443

    
1444
            }
1445

    
1446
        }
1447

    
1448
        #region Document List 조회
1449
        public void GetDocList(bool isFilterClear)
1450
        {
1451
            try
1452
            {
1453
                string team = this.radDropDownListTeam.SelectedValue.ToString();
1454

    
1455
                List<string> dateTypes = this.radCheckedDropDownListDateType.CheckedItems.Select(x => x.Value.ToString()).ToList();
1456
                DateTime? frDate = this.radDateTimePickerFr.Value.Equals(this.radDateTimePickerFr.NullDate) ? (DateTime?)null : this.radDateTimePickerFr.Value;
1457
                DateTime? toDate = this.radDateTimePickerTo.Value.Equals(this.radDateTimePickerTo.NullDate) ? (DateTime?)null : this.radDateTimePickerTo.Value;
1458

    
1459
                string projectCode = this.radDropDownListProject.SelectedValue?.ToString();
1460
                string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
1461
                string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
1462
                string documentNo = this.radTextBoxDocumentNo.Text.Trim();
1463

    
1464
                string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
1465
                string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
1466

    
1467
                string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
1468
                string id2Issues = this.radDropDownListID2Issues.SelectedValue.ToString();
1469
                string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
1470
                string avevaIssues = this.radDropDownListAVEVAIssues.SelectedValue.ToString();
1471

    
1472
                string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
1473
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
1474

    
1475
                string isGateWay = this.radDropDownListGateway.SelectedValue.ToString();
1476
                string isRegSystem = this.radDropDownListRegistration.SelectedValue.ToString();
1477

    
1478
                var worker = new LoadDocumentsWorker(dateTypes, frDate, toDate, team, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem, this.radGridViewDocuments);
1479
                worker.OnWorkCompletedHandler += (e) =>
1480
                {
1481
                    var docData = e.Result as DocumentsResult;
1482

    
1483
                    this.documents = docData.Dwgs;
1484
                    this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(docData.Dwgs));
1485
                    this.TotalCount = docData.TotalCount;
1486
                    this.SearchCount = docData.Dwgs.Count;
1487

    
1488
                    List<string> projectCodes = new List<string>();
1489

    
1490
                    if (!string.IsNullOrWhiteSpace(projectCode))
1491
                    {
1492
                        projectCodes.Add(projectCode);
1493
                    }
1494
                    else
1495
                    {
1496
                        projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
1497
                    }
1498

    
1499
                    this.DocumentListBinding(isFilterClear);
1500
                };
1501

    
1502
                (btnShowAllDetail.HostedItem as RadCheckBoxElement).Checked = false;
1503
                worker.StartWork();
1504
            }
1505
            catch (Exception ex)
1506
            {
1507
                throw ex;
1508
            }
1509
        }
1510

    
1511
        public void DocumentListBinding(bool isFilterClear)
1512
        {
1513
            try
1514
            {
1515
                GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
1516
                //ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).Select(x => x.Code).ToList();
1517
                ColProjects.DataSource = (from allPrj in informations.ProjectList
1518
                                         join actPrj in informations.ActiveProjects on allPrj.GroupID equals actPrj.ProjectID
1519
                                         select allPrj).Select(x => x.Code).ToList();
1520
                //ColProjects.DisplayMember = "Name";
1521
                //ColProjects.ValueMember = "Code";
1522

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

    
1527
                GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
1528
                ColPersonInCharge.DataSource = workUsers.Prepend(emptyUser);
1529
                ColPersonInCharge.DisplayMember = "Name";
1530
                ColPersonInCharge.ValueMember = "ID";
1531

    
1532
                GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
1533
                ColWorker.DataSource = workUsers.Prepend(emptyUser);
1534
                ColWorker.DisplayMember = "Name";
1535
                ColWorker.ValueMember = "ID";
1536

    
1537
                GridViewComboBoxColumn ColAVEVAPersonInCharge = this.radGridViewDocuments.Columns["AVEVAPersonInCharge"] as GridViewComboBoxColumn;
1538
                ColAVEVAPersonInCharge.DataSource = workUsers.Prepend(emptyUser);
1539
                ColAVEVAPersonInCharge.DisplayMember = "Name";
1540
                ColAVEVAPersonInCharge.ValueMember = "ID";
1541

    
1542
                GridViewComboBoxColumn ColAVEVAWorker = this.radGridViewDocuments.Columns["AVEVAWorker"] as GridViewComboBoxColumn;
1543
                ColAVEVAWorker.DataSource = workUsers.Prepend(emptyUser);
1544
                ColAVEVAWorker.DisplayMember = "Name";
1545
                ColAVEVAWorker.ValueMember = "ID";
1546

    
1547
                GridViewComboBoxColumn ColReplyRequester = this.radGridViewDocuments.Columns["ReplyRequester"] as GridViewComboBoxColumn;
1548
                ColReplyRequester.DataSource = workUsers;
1549
                ColReplyRequester.DisplayMember = "Name";
1550
                ColReplyRequester.ValueMember = "ID";
1551

    
1552
                GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
1553
                ColToCreator.DataSource = workUsers;
1554
                ColToCreator.DisplayMember = "Name";
1555
                ColToCreator.ValueMember = "ID";
1556

    
1557
                GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
1558
                ColFrCreator.DataSource = clientUsers;
1559
                ColFrCreator.DisplayMember = "Name";
1560
                ColFrCreator.ValueMember = "ID";
1561

    
1562
                GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
1563
                ColProdReviewer.DataSource = workUsers.Prepend(emptyUser);
1564
                ColProdReviewer.DisplayMember = "Name";
1565
                ColProdReviewer.ValueMember = "ID";
1566

    
1567
                GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
1568
                ColClientReviewer.DataSource = clientUsers;
1569
                ColClientReviewer.DisplayMember = "Name";
1570
                ColClientReviewer.ValueMember = "ID";
1571

    
1572
                //Data
1573
                if (this.radGridViewDocuments.DataSource != null)
1574
                    this.radGridViewDocuments.DataSource = null;
1575

    
1576
                /*
1577
                var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info;
1578
                var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info);
1579
                var test = from doc in this.documents
1580
                           join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj
1581
                           from docs in gj.DefaultIfEmpty()
1582
                           select new Documents()
1583
                           {
1584
                               DocumentNo = doc.DocumentNo,
1585
                               ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME)
1586
                               //ProdRemarks = docs.DATETIME ?? null
1587
                           };
1588
                */
1589

    
1590
                if (isFilterClear)
1591
                    this.radGridViewDocuments.FilterDescriptors.Clear();
1592
                this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
1593
                this.lbSelectAndTotal.Text = $"{this.radGridViewDocuments.MasterTemplate.DataView.Count} / {this.SearchCount} / {this.TotalCount} (Filter / Search / Total)";
1594
                this.lbChecked.Text = $"Checked : {this.GetCheckedRows(true).Count()}";
1595

    
1596
                var classify = this.LayoutValidation.Controls[0] as Classify;
1597
                classify.DocumentListBinding(this.documents);
1598
            }
1599
            catch (Exception ex)
1600
            {
1601
                throw ex;
1602
            }
1603
        }
1604
        #endregion
1605

    
1606
        #region 조회조건, filter Event
1607
        private void RadButtonDateClear_Click(object sender, EventArgs e)
1608
        {
1609
            //DateType
1610
            this.radCheckedDropDownListDateType.CheckedItems.Clear();
1611
            //FromDate
1612
            this.radDateTimePickerFr.SetToNullValue();
1613
            //ToDate
1614
            this.radDateTimePickerTo.SetToNullValue();
1615
        }
1616

    
1617
        private void RadDropDownList_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
1618
        {
1619
            if (sender is RadDropDownList ddl)
1620
            {
1621
                string ddlSelectedValue = ddl.SelectedValue?.ToString();
1622
                if (ddlSelectedValue == null)
1623
                {
1624
                    ddl.BackColor = Color.DarkSlateBlue;
1625
                    ddl.ForeColor = Color.Yellow;
1626
                    ddl.Font = new Font("Segoe UI", 8.25F, FontStyle.Bold);
1627
                }
1628
                else if (ddlSelectedValue.Equals(string.Empty))
1629
                {
1630
                    ddl.BackColor = Color.White;
1631
                    ddl.ForeColor = Color.Black;
1632
                    ddl.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular);
1633
                }
1634
                else
1635
                {
1636
                    ddl.BackColor = Color.DarkSlateBlue;
1637
                    ddl.ForeColor = Color.Yellow;
1638
                    ddl.Font = new Font("Segoe UI", 8.25F, FontStyle.Bold);
1639
                }
1640
            }
1641
        }
1642

    
1643
        private void RadCollapsiblePanelCondition_Collapsed(object sender, EventArgs e)
1644
        {
1645
            this.radCollapsiblePanelCondition.HeaderText = "Show";
1646
            this.LayoutMain.RowStyles[1] = new RowStyle() { SizeType = SizeType.Absolute, Height = 30F };
1647
        }
1648

    
1649
        private void RadCollapsiblePanelCondition_Expanded(object sender, EventArgs e)
1650
        {
1651
            this.radCollapsiblePanelCondition.HeaderText = "Hide";
1652
            this.LayoutMain.RowStyles[1] = new RowStyle() { SizeType = SizeType.Absolute, Height = 210F };
1653
        }
1654

    
1655
        private void RadCheckBoxFreezed_CheckStateChanged(object sender, EventArgs e)
1656
        {
1657
            if (sender is RadCheckBox checkBox)
1658
            {
1659
                if (checkBox.Tag != null)
1660
                {
1661
                    ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1662
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1663
                    if (colGroup != null)
1664
                        colGroup.IsPinned = checkBox.Checked;
1665
                }
1666
            }
1667
        }
1668

    
1669
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
1670
        {
1671
            if (sender is RadCheckBox checkBox)
1672
            {
1673
                if (checkBox.Tag != null)
1674
                {
1675
                    ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
1676
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
1677
                    if (colGroup != null)
1678
                        colGroup.IsVisible = checkBox.Checked;
1679
                }
1680
            }
1681

    
1682
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
1683
        }
1684

    
1685
        private void RadTextBoxDocumentNo_TextChanged(object sender, EventArgs e)
1686
        {
1687
            if (sender is RadTextBox txtBox)
1688
            {
1689
                if (txtBox.Text.Length > 0)
1690
                {
1691
                    txtBox.BackColor = Color.DarkSlateBlue;
1692
                    txtBox.ForeColor = Color.Yellow;
1693
                    txtBox.Font = new Font("Segoe UI", 8.25F, FontStyle.Bold);
1694
                }
1695
                else
1696
                {
1697
                    txtBox.BackColor = Color.White;
1698
                    txtBox.ForeColor = Color.Black;
1699
                    txtBox.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular);
1700
                }
1701
            }
1702
        }
1703

    
1704
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
1705
        {
1706
            if (e.KeyCode == Keys.Enter)
1707
            {
1708
                this.radButtonSearch.Focus();
1709
                this.radButtonSearch.PerformClick();
1710
            }
1711
        }
1712

    
1713
        //private void RadTextBoxDocumentNo_KeyUp(object sender, KeyEventArgs e)
1714
        //{
1715
        //    if (sender is RadTextBox txtBox)
1716
        //    {
1717
        //        if (txtBox.Text.Length > 0)
1718
        //        {
1719
        //            txtBox.BackColor = Color.DarkSlateBlue;
1720
        //            txtBox.ForeColor = Color.Yellow;
1721
        //            txtBox.Font = new Font("Segoe UI", 8.25F, FontStyle.Bold);
1722
        //        }
1723
        //        else
1724
        //        {
1725
        //            txtBox.BackColor = Color.White;
1726
        //            txtBox.ForeColor = Color.Black;
1727
        //            txtBox.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular);
1728
        //        }
1729
        //    }
1730
        //}
1731

    
1732
        private void RadButtonSearch_Click(object sender, EventArgs e)
1733
        {
1734
            try
1735
            {
1736
                BeginInvoke(new Action(() =>
1737
                {
1738
                    this.radCollapsiblePanelCondition.Collapse();
1739
                }));
1740

    
1741
                this.GetDocList(false);
1742
            }
1743
            catch (Exception ex)
1744
            {
1745
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
1746
                RadMessageBox.Show("DWG search failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1747
            }
1748
        }
1749
        #endregion
1750

    
1751
        #region Backstage Button Event
1752
        private void BackstageButtonItemSelectDB_Click(object sender, EventArgs e)
1753
        {
1754
            using (var frm = new SetID2ProjectDB())
1755
            {
1756
                if (frm.ShowDialog(this) == DialogResult.OK)
1757
                {
1758
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
1759
                    {
1760
                        this.radRibbonBarBackstageViewID2Manager.HidePopup();
1761

    
1762
                        informations.ActiveProjects = new List<ProjectInfo>() { new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID) };
1763
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1764

    
1765
                        this.LoadProject(true);
1766
                    }
1767
                    else
1768
                    {
1769
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
1770
                        bool isID2 = this.IsID2Connection();
1771
                        this.SetMenus(isID2);
1772

    
1773
                        foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
1774
                        {
1775
                            if (ctrl is OpenProjectView)
1776
                            {
1777
                                var openProjectView = ctrl as OpenProjectView;
1778
                                openProjectView.GetProjectGroups();
1779
                                break;
1780
                            }
1781
                        }
1782
                    }
1783
                }
1784
            }
1785
        }
1786

    
1787
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
1788
        {
1789
            using (var frm = new SetupUser())
1790
            {
1791
                if (frm.ShowDialog(this) == DialogResult.OK)
1792
                {
1793

    
1794
                }
1795
            }
1796
        }
1797

    
1798
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
1799
        {
1800
            Application.Exit();
1801
        }
1802
        #endregion
1803

    
1804
        #region Grid event
1805
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
1806
        {
1807
            if (e.Row is GridViewNewRowInfo)
1808
            {
1809

    
1810
            }
1811
            else
1812
            {
1813
                string dwgExtension = ".dwg";
1814
                switch (e.Column.Name)
1815
                {
1816
                    case "AutoCADLink":
1817
                        {
1818
                            if (e.Row.DataBoundItem is Documents doc)
1819
                            {
1820
                                string ID2DrawingFolder = System.IO.Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", "Native");
1821
                                string dwgFilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{doc.DocumentNo}{dwgExtension}");
1822
                                if (File.Exists(dwgFilePath))
1823
                                {
1824
                                    System.Diagnostics.Process.Start(dwgFilePath);
1825
                                }
1826
                                else
1827
                                {
1828
                                    RadMessageBox.Show($"Can't find file({dwgFilePath})");
1829
                                }
1830
                            }
1831
                        }
1832
                        break;
1833
                    case "MarkupLink":
1834
                        {
1835
                            if (e.Row.DataBoundItem is Documents doc)
1836
                            {
1837
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID))
1838
                                {
1839
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID);
1840
                                }
1841
                            }
1842
                        }
1843
                        break;
1844
                    case "AVEVALink":
1845
                        {
1846
                            if (e.Row.DataBoundItem is Documents doc)
1847
                            {
1848
                                ProjectInfo docProjectGroup = informations.FindDocProjectGroup(doc.RefProjectCode);
1849
                            }
1850
                        }
1851

    
1852
                        RadMessageBox.Show($"{e.Column.Name} 실행", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1853
                        break;
1854
                    case "ID2Connection":
1855
                        try
1856
                        {
1857
                            if (e.Row.DataBoundItem is Documents doc)
1858
                            {
1859
                                var id2Prj = informations.FindID2Project(doc.RefProjectCode);
1860
                                string ID2Port = new ProjectController(id2Prj).GetID2PortByProject();
1861
                                if (!int.TryParse(ID2Port, out int id2Port))
1862
                                    id2Port = Properties.Settings.Default.ID2Port;
1863

    
1864
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, id2Port);
1865

    
1866
                                try
1867
                                {
1868
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
1869
                                    {
1870
                                        DocID = doc.DocID,
1871
                                        ID2StartDate = DateTime.Now,
1872
                                        Worker = informations.ActiveUser.ID
1873
                                    }, informations.ActiveUser.ID);
1874

    
1875
                                    if (returnDoc != null)
1876
                                    {
1877
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
1878
                                        doc.Worker = returnDoc.Worker;
1879
                                    }
1880
                                }
1881
                                catch { }
1882
                            }
1883
                        }
1884
                        catch (Exception ex)
1885
                        {
1886
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1887
                        }
1888
                        break;
1889
                }
1890
            }
1891
        }
1892

    
1893
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
1894
        {
1895
            if (e.ActiveEditor is RadDropDownListEditor)
1896
            {
1897
                switch (e.Column.Name)
1898
                {
1899
                    //case "RefProjectCode":
1900
                    //    GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1901
                    //    ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
1902
                    //    ColProjects.DisplayMember = "Name";
1903
                    //    ColProjects.ValueMember = "Code";
1904
                    //    break;
1905
                    //case "PersonInCharge":
1906
                    //case "Worker":
1907
                    //case "AVEVAPersonInCharge":
1908
                    //case "AVEVAWorker":
1909
                    //case "ReplyRequester":
1910
                    //case "ToCreator":
1911
                    //case "ProdReviewer":
1912
                    //    var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID));
1913
                    //    GridViewComboBoxColumn ColProdUsers = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1914
                    //    ColProdUsers.DataSource = workUsers;
1915
                    //    ColProdUsers.DisplayMember = "Name";
1916
                    //    ColProdUsers.ValueMember = "ID";
1917
                    //    break;
1918
                    //case "FrCreator":
1919
                    //case "ClientReviewer":
1920
                    //    var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID));
1921
                    //    GridViewComboBoxColumn ColClientUsers = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1922
                    //    ColClientUsers.DataSource = clientUsers;
1923
                    //    ColClientUsers.DisplayMember = "Name";
1924
                    //    ColClientUsers.ValueMember = "ID";
1925
                    //    break;
1926
                    case "JobLevel":
1927
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1928
                        colJobLevel.DataSource = informations.JobLevel;
1929
                        break;
1930
                    case "ToIsDiscussion":
1931
                    case "IsConvert":
1932
                    case "DTIsImport":
1933
                    case "DTIsGateWay":
1934
                    case "DTIsRegSystem":
1935
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1936
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
1937
                        break;
1938
                    case "ID2Status":
1939
                    case "AVEVAStatus":
1940
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1941
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
1942
                        break;
1943
                    case "FrReviewStatus"://삼성의견status
1944
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1945
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
1946
                        break;
1947
                    case "ProdIsResult":
1948
                    case "ClientIsResult":
1949
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
1950
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
1951
                        break;
1952
                }
1953
            }
1954
        }
1955

    
1956
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
1957
        {
1958
            if (e.Row is GridViewNewRowInfo)
1959
            {
1960
                switch (e.CellElement.ColumnInfo.Name)
1961
                {
1962
                    case "DocumentNo":
1963
                        e.Row.Cells[e.CellElement.ColumnInfo.Name].ReadOnly = false;
1964
                        break;
1965
                }
1966
            }
1967
            else if (e.Row is GridViewDataRowInfo)
1968
            {
1969
                if (e.CellElement is GridRowHeaderCellElement)
1970
                {
1971
                    if (e.CellElement.RowIndex > -1) e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
1972
                }
1973
                else if (e.CellElement is GridGroupExpanderCellElement expanderCellElement)
1974
                {
1975
                    if ((e.Row.DataBoundItem as Documents).Markups == null)
1976
                    {
1977
                        expanderCellElement.Enabled = false;
1978
                    }
1979
                    else
1980
                    {
1981
                        expanderCellElement.Enabled = true;
1982
                    }
1983
                }
1984
                else
1985
                {
1986
                    var result = e.Row.DataBoundItem as Documents;
1987
                    if (result != null || e.Row is GridViewNewRowInfo)
1988
                    {
1989
                        switch (e.CellElement.ColumnInfo.Name)
1990
                        {
1991
                            case "AutoCADLink":
1992
                            case "PDFLink":
1993
                            case "AVEVALink":
1994
                            case "ID2Connection":
1995
                            case "Compare":
1996
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name, false);
1997
                                break;
1998
                            case "MarkupLink":
1999
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name, result.IsMarkup);
2000
                                break;
2001
                            case "ToCapture":
2002
                                if (result.ToCapture > 0)
2003
                                {
2004
                                    e.CellElement.Image = Properties.Resources.files18;
2005
                                }
2006
                                break;
2007
                            case "FrCapture":
2008
                                if (result.FrCapture > 0)
2009
                                {
2010
                                    e.CellElement.Image = Properties.Resources.files18;
2011
                                }
2012
                                break;
2013
                            case "ID2Capture":
2014
                                if (result.ID2Capture > 0)
2015
                                {
2016
                                    e.CellElement.Image = Properties.Resources.files18;
2017
                                }
2018
                                break;
2019
                            case "DocumentNo":
2020
                                if (result.DocID == null)
2021
                                {
2022
                                    e.Row.Cells[e.CellElement.ColumnInfo.Name].ReadOnly = false;
2023
                                }
2024
                                else
2025
                                {
2026
                                    e.Row.Cells[e.CellElement.ColumnInfo.Name].ReadOnly = true;
2027
                                }
2028
                                break;
2029
                        }
2030
                    }
2031
                    else
2032
                    {
2033

    
2034
                    }
2035
                }
2036
            }
2037
            else if (e.Row is GridViewDetailsRowInfo)
2038
            {
2039
                if (e.CellElement is GridDetailViewCellElement detailViewCellElement)
2040
                {
2041
                    detailViewCellElement.Padding = new Padding(10, 2, 2, 2);
2042
                    detailViewCellElement.BackColor = Color.FromArgb(214, 214, 214);
2043
                    detailViewCellElement.BackColor2 = Color.FromArgb(214, 214, 214);
2044
                }
2045
            }
2046
            else if (e.CellElement is GridRowHeaderCellElement && e.Row is GridViewGroupRowInfo)
2047
            {
2048
                e.CellElement.ResetValue(LightVisualElement.TextImageRelationProperty, ValueResetFlags.Local);
2049

    
2050
                e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
2051
                e.CellElement.TextAlignment = ContentAlignment.TopRight;
2052
                e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText;
2053
            }
2054
            //else if (e.Row is GridViewNewRowInfo)
2055
            //{
2056
            //    switch (e.CellElement.ColumnInfo.Name)
2057
            //    {
2058
            //        case "RefProjectCode":
2059
            //        case "DocumentNo":
2060
            //            e.CellElement.ColumnInfo.ReadOnly = false;
2061
            //            break;
2062
            //    }
2063
            //}
2064
            //else if (e.Row is GridViewSummaryRowInfo)
2065
            //{
2066
            //    if (e.CellElement is GridRowHeaderCellElement)
2067
            //    {
2068
            //        e.CellElement.Text = "Count";
2069
            //    }
2070
            //    else if (e.CellElement is GridSummaryCellElement)
2071
            //    {
2072
            //        e.CellElement.ForeColor = this._SummaryColor;
2073
            //        e.CellElement.TextAlignment = ContentAlignment.BottomRight;
2074
            //        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
2075
            //    }
2076
            //    else
2077
            //    {
2078

    
2079
            //    }
2080
            //}
2081
            else
2082
            {
2083

    
2084
            }
2085
        }
2086

    
2087
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName, bool isData)
2088
        {
2089
            RadButtonElement btnElem = null;
2090
            Bitmap bitmap = null; ;
2091

    
2092
            switch (colName)
2093
            {
2094
                case "AutoCADLink":
2095
                    bitmap = new Bitmap(Properties.Resources.cad18);
2096
                    break;
2097
                case "PDFLink":
2098
                    bitmap = new Bitmap(Properties.Resources.pdf18);
2099
                    break;
2100
                case "MarkupLink":
2101
                    if (isData)
2102
                    {
2103
                        bitmap = new Bitmap(Properties.Resources.markus18_on);
2104
                    }
2105
                    else
2106
                    {
2107
                        bitmap = new Bitmap(Properties.Resources.markus18);
2108
                    }
2109
                    break;
2110
                case "AVEVALink":
2111
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
2112
                    break;
2113
                case "ID2Connection":
2114
                    bitmap = new Bitmap(Properties.Resources.id218);
2115
                    break;
2116
                case "Compare":
2117
                    bitmap = new Bitmap(Properties.Resources.compare18);
2118
                    break;
2119
            }
2120

    
2121
            switch (colName)
2122
            {
2123
                case "AutoCADLink":
2124
                case "PDFLink":
2125
                case "MarkupLink":
2126
                case "AVEVALink":
2127
                case "ID2Connection":
2128
                case "Compare":
2129
                    btnElem = (RadButtonElement)elem;
2130
                    btnElem.Margin = new Padding(0);
2131
                    btnElem.Padding = new Padding(0);
2132
                    btnElem.BorderElement.Opacity = 0;
2133
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
2134
                    btnElem.DisplayStyle = DisplayStyle.Image;
2135
                    btnElem.Image = bitmap;
2136
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
2137
                    btnElem.MaxSize = bitmap.Size;
2138
                    break;
2139
            }
2140

    
2141
            return btnElem;
2142
        }
2143

    
2144
        private void RadGridViewDocuments_FilterChanging(object sender, GridViewCollectionChangingEventArgs e)
2145
        {
2146

    
2147
        }
2148

    
2149
        private void RadGridViewDocuments_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
2150
        {
2151
            this.radGridViewDocuments.ClearSelection();
2152
            if (e.GridViewTemplate.DataView.Count > 0)
2153
            {
2154
                e.GridViewTemplate.DataView[0].IsSelected = true;
2155
            }
2156

    
2157
            #region 현재 화면에 보이는 Document만 Classify 화면에 표시
2158
            /*
2159
            var docs = ((GridDataView)radGridViewDocuments.MasterTemplate.DataView).Indexer.Items.Select(x => x.DataBoundItem as Documents).ToList();
2160
            var classify = this.LayoutValidation.Controls[0] as Classify;
2161
            classify.DocumentListBinding(docs);
2162
            */
2163
            #endregion
2164

    
2165
            this.lbSelectAndTotal.Text = $"{e.GridViewTemplate.DataView.Count} / {this.SearchCount} / {this.TotalCount} (Filter / Search / Total)";
2166
            this.lbChecked.Text = $"Checked : {this.GetCheckedRows(true).Count()}";
2167
        }
2168

    
2169
        private void RadGridViewDocuments_CellValidated(object sender, CellValidatedEventArgs e)
2170
        {
2171
            //if(e.Column is GridViewCheckBoxColumn && radGridViewDocuments.SelectedRows?.Count() > 1)
2172
            //{
2173
            //    radGridViewDocuments.SelectedRows.ForAll(x =>
2174
            //    {
2175
            //        x.Cells[0].Value = e.Value;
2176
            //    });
2177
            //}
2178

    
2179
            //if (e.Column is GridViewComboBoxColumn)
2180
            //{
2181
            //    bool isChecked = e.Row.Cells["Checked"].Value != null && Convert.ToBoolean(e.Row.Cells["Checked"].Value);
2182

    
2183
            //    if (isChecked)
2184
            //    {
2185
            //        //this.GetCheckedDatas(true)
2186
            //        var chkDatas = documents.Where(x=>x.Checked).ToList();
2187
            //        if (chkDatas.Any())
2188
            //        {
2189
            //            string colValue = e.Row.Cells[e.Column.Name].Value == null ? string.Empty : (string)e.Row.Cells[e.Column.Name].Value;
2190
            //            radGridViewDocuments.MasterTemplate.BeginUpdate();
2191
            //            //radGridViewDocuments.SuspendLayout();
2192
            //            //radGridViewDocuments.SuspendUpdate();
2193
            //            switch (e.Column.Name)
2194
            //            {
2195
            //                case "RefProjectCode":
2196
            //                    chkDatas.ParallelForAll(x => x.RefProjectCode = colValue);
2197
            //                    break;
2198
            //                case "PersonInCharge":
2199
            //                    chkDatas.ParallelForAll(x => x.PersonInCharge = colValue);
2200
            //                    break;
2201
            //                case "Worker":
2202
            //                    chkDatas.ParallelForAll(x => x.Worker = colValue);
2203
            //                    break;
2204
            //                case "JobLevel":
2205
            //                    chkDatas.ParallelForAll(x => x.JobLevel = colValue);
2206
            //                    break;
2207
            //                case "ToIsDiscussion":
2208
            //                    chkDatas.ParallelForAll(x => x.ToIsDiscussion = colValue);
2209
            //                    break;
2210
            //                case "ToCreator":
2211
            //                    chkDatas.ParallelForAll(x => x.ToCreator = colValue);
2212
            //                    break;
2213
            //                case "FrReviewStatus":
2214
            //                    chkDatas.ParallelForAll(x => x.FrReviewStatus = colValue);
2215
            //                    break;
2216
            //                case "FrCreator":
2217
            //                    chkDatas.ParallelForAll(x => x.FrCreator = colValue);
2218
            //                    break;
2219
            //                case "ID2Status":
2220
            //                    chkDatas.ParallelForAll(x => x.ID2Status = colValue);
2221
            //                    break;
2222
            //                case "ReplyRequester":
2223
            //                    chkDatas.ParallelForAll(x => x.ReplyRequester = colValue);
2224
            //                    break;
2225
            //                case "IsConvert":
2226
            //                    chkDatas.ParallelForAll(x => x.IsConvert = colValue);
2227
            //                    break;
2228
            //                case "AVEVAPersonInCharge":
2229
            //                    chkDatas.ParallelForAll(x => x.AVEVAPersonInCharge = colValue);
2230
            //                    break;
2231
            //                case "AVEVAWorker":
2232
            //                    chkDatas.ParallelForAll(x => x.AVEVAWorker = colValue);
2233
            //                    break;
2234
            //                case "AVEVAStatus":
2235
            //                    chkDatas.ParallelForAll(x => x.AVEVAStatus = colValue);
2236
            //                    break;
2237
            //                case "ProdReviewer":
2238
            //                    chkDatas.ParallelForAll(x => x.ProdReviewer = colValue);
2239
            //                    break;
2240
            //                case "ProdIsResult":
2241
            //                    chkDatas.ParallelForAll(x => x.ProdIsResult = colValue);
2242
            //                    break;
2243
            //                case "ClientReviewer":
2244
            //                    chkDatas.ParallelForAll(x => x.ClientReviewer = colValue);
2245
            //                    break;
2246
            //                case "ClientIsResult":
2247
            //                    chkDatas.ParallelForAll(x => x.ClientIsResult = colValue);
2248
            //                    break;
2249
            //                case "DTIsGateWay":
2250
            //                    chkDatas.ParallelForAll(x => x.DTIsGateWay = colValue);
2251
            //                    break;
2252
            //                case "DTIsImport":
2253
            //                    chkDatas.ParallelForAll(x => x.DTIsImport = colValue);
2254
            //                    break;
2255
            //                case "DTIsRegSystem":
2256
            //                    chkDatas.ParallelForAll(x => x.DTIsRegSystem = colValue);
2257
            //                    break;
2258
            //            }
2259
            //            //radGridViewDocuments.ResumeLayout();
2260
            //            //radGridViewDocuments.ResumeUpdate();
2261
            //            radGridViewDocuments.MasterTemplate.EndUpdate();
2262

    
2263

    
2264
            //        }
2265
            //    }
2266
            //}
2267
        }
2268

    
2269
        private void RadGridViewDocuments_CellEndEdit(object sender, GridViewCellEventArgs e)
2270
        {
2271
            if (e.Column is GridViewComboBoxColumn || e.Column is GridViewDateTimeColumn)
2272
            {
2273
                var chkDatas = this.GetCheckedDatas(true);
2274
                var rowData = e.Row.DataBoundItem as Documents;
2275

    
2276
                if (chkDatas.Any() && chkDatas.Contains(rowData))
2277
                {
2278
                    RadScrollBarElement vScroll = radGridViewDocuments.TableElement.VScrollBar;
2279
                    int vPosition = vScroll.Value;
2280
                    bool isvMaxValue = vPosition == vScroll.Maximum - vScroll.LargeChange + 1;
2281

    
2282
                    RadScrollBarElement hScroll = radGridViewDocuments.TableElement.HScrollBar;
2283
                    int hPosition = hScroll.Value;
2284
                    bool ishMaxValue = hPosition == hScroll.Maximum - hScroll.LargeChange + 1;
2285

    
2286
                    radGridViewDocuments.TableElement.UpdateView();
2287

    
2288
                    object colValue = e.Row.Cells[e.Column.Name].Value;
2289

    
2290
                    radGridViewDocuments.BeginUpdate();
2291
                    radGridViewDocuments.MasterTemplate.BeginUpdate();
2292
   
2293
                    chkDatas.ForAll(x =>
2294
                    {
2295
                        x.SuspendUpdate = true;
2296
                        x.GetType().GetProperty(e.Column.Name).SetValue(x, colValue);
2297
                        switch (e.Column.Name)
2298
                        {
2299
                            case "RefProjectCode":
2300
                                x.Team = informations.FindID2PrjTeam(colValue?.ToString());
2301
                                break;
2302
                        }
2303
                        x.SuspendUpdate = false;
2304
                    });
2305

    
2306
                    this.ResumeLayout(true);
2307
                    radGridViewDocuments.MasterTemplate.EndUpdate();
2308
                    radGridViewDocuments.EndUpdate();
2309

    
2310
                    if (vPosition > 0)
2311
                    {
2312
                        if (isvMaxValue)
2313
                        {
2314
                            vPosition = vScroll.Maximum - vScroll.LargeChange + 1;
2315
                        }
2316
                        radGridViewDocuments.TableElement.VScrollBar.Value = vPosition;
2317
                    }
2318

    
2319
                    if (hPosition > 0)
2320
                    {
2321
                        if (ishMaxValue)
2322
                        {
2323
                            hPosition = hScroll.Maximum - hScroll.LargeChange + 1;
2324
                        }
2325
                        radGridViewDocuments.TableElement.HScrollBar.Value = hPosition;
2326
                    }
2327
                }
2328
            }
2329
        }
2330

    
2331
        private void RadGridViewDocuments_HeaderCellToggleStateChanged(object sender, GridViewHeaderCellEventArgs e)
2332
        {
2333
            if (sender is RadElement elem)
2334
            {
2335
                if (elem.IsMouseOverElement)//header를 직접 눌렀을 경우 - 미리 예상해야함
2336
                {
2337
                    //on, off 에 따라서 보여지는 거 다 체크이거나 다 언체크
2338

    
2339
                    //this.radGridViewDocuments.FilterDescriptors
2340
                    var selectedRows = this.radGridViewDocuments.SelectedRows;
2341

    
2342
                    if (selectedRows.Count > 1)
2343
                    {
2344
                        var chkRows = this.GetCheckedRows(true);
2345
                        var selectedCheckedRows = selectedRows.AsEnumerable<GridViewRowInfo>()
2346
                                                              .Where(x =>
2347
                                                              {
2348
                                                                  return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2349
                                                              });
2350
                        var selectedUncheckedRows = selectedRows.Except(selectedCheckedRows);
2351

    
2352
                        int checkedCount = 0;
2353

    
2354
                        if (e.State == ToggleState.On)
2355
                        {
2356
                            checkedCount = chkRows.Count() + selectedUncheckedRows.Count();
2357
                        }
2358
                        else
2359
                        {
2360
                            checkedCount = chkRows.Count() - selectedCheckedRows.Count();
2361
                        }
2362

    
2363
                        this.lbChecked.Text = $"Checked : {checkedCount}";
2364
                    }
2365
                    else
2366
                    {
2367
                        if (e.State == ToggleState.On)
2368
                        {
2369
                            this.lbChecked.Text = $"Checked : {this.radGridViewDocuments.MasterTemplate.DataView.Count}";
2370
                        }
2371
                        else
2372
                        {
2373
                            this.lbChecked.Text = $"Checked : {0}";
2374
                        }
2375
                    }
2376
                }
2377
                else//filter 나 item check box 체크 등 다른 이유로 헤더에 체크가 됐을 경우는 get... 이거로 해도 됨
2378
                {
2379
                    this.lbChecked.Text = $"Checked : {this.GetCheckedRows(true).Count()}";
2380
                }
2381
            }
2382
        }
2383

    
2384
        private void RadGridViewDocuments_ValueChanging(object sender, ValueChangingEventArgs e)
2385
        {
2386
            if (sender is GridViewCellInfo)
2387
            {
2388
                if ((sender as GridViewCellInfo).ColumnInfo is GridViewCheckBoxColumn)
2389
                {
2390
                    if (this.radGridViewDocuments.SelectedRows.Count() > 1)
2391
                    {
2392
                        if (!this.radGridViewDocuments.SelectedRows.Contains((sender as GridViewCellInfo).RowInfo))
2393
                        {
2394
                            e.Cancel = true;
2395
                        }
2396
                    }
2397
                }
2398
            }
2399
        }
2400

    
2401
        private void RadGridViewDocuments_ValueChanged(object sender, EventArgs e)
2402
        {
2403
            if (sender is BaseGridEditor baseEditor)
2404
            {
2405
                if (baseEditor.OwnerElement is GridDataCellElement cellElem)
2406
                {
2407
                    if (!(cellElem.RowInfo is GridViewNewRowInfo))
2408
                    {
2409
                        switch (cellElem.ColumnInfo.Name)
2410
                        {
2411
                            case "Checked":
2412
                                this.radGridViewDocuments.EndEdit();
2413
                                this.lbChecked.Text = $"Checked : {this.GetCheckedRows(true).Count()}";
2414
                                break;
2415
                            case "RefProjectCode":
2416
                                this.radGridViewDocuments.EndEdit();
2417
                                Documents result = cellElem.RowInfo.DataBoundItem as Documents;
2418
                                if (result != null)
2419
                                {
2420
                                    result.Team = informations.FindID2PrjTeam(cellElem.Value?.ToString());
2421
                                }
2422
                                break;
2423
                            case "PersonInCharge":
2424
                            case "Worker":
2425
                            case "JobLevel":
2426
                            case "ToIsDiscussion":
2427
                            case "ToCreator":
2428
                            case "FrReviewStatus":
2429
                            case "FrCreator":
2430
                            case "ID2Status":
2431
                            case "ReplyRequester":
2432
                            case "IsConvert":
2433
                            case "AVEVAPersonInCharge":
2434
                            case "AVEVAWorker":
2435
                            case "AVEVAStatus":
2436
                            case "ProdReviewer":
2437
                            case "ProdIsResult":
2438
                            case "ClientReviewer":
2439
                            case "ClientIsResult":
2440
                            case "DTIsGateWay":
2441
                            case "DTIsImport":
2442
                            case "DTIsRegSystem":
2443
                            //날짜
2444
                            case "AVEVAConvertDate":
2445
                            case "AVEVAReviewDate":
2446
                            case "AVEVAWorkDate":
2447
                                this.radGridViewDocuments.EndEdit();
2448
                                break;
2449
                        }
2450
                    }
2451
                }
2452
            }
2453
        }
2454
        #endregion
2455

    
2456
        /*
2457
        private void GetCheckedList()
2458
        {
2459
            RadGridView grid = this.radGridViewDocuments;
2460

    
2461
            //var checkers = grid.Rows.Where(x =>
2462
            //{
2463
            //    return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2464
            //}).Select(x => x.DataBoundItem as Documents).ToList();
2465

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

    
2469
            var checkers = viewRows.Where(x =>
2470
            {
2471
                return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2472
            }).ToList();
2473

    
2474
            var rows = new GridViewDataRowInfo[checkers.Count];
2475
            checkers.CopyTo(rows, 0);
2476

    
2477
            if (rows.Length > 0)
2478
            {
2479
                grid.BeginUpdate();
2480

    
2481
                int nLoop = 0;
2482
                rows.ForAll(x =>
2483
                {
2484
                    grid.Rows.Remove(rows[nLoop]);
2485
                    nLoop++;
2486
                });
2487

    
2488
                grid.EndUpdate();
2489
            }
2490

    
2491

    
2492
            //grid.Rows.re grid.Rows.ToList().Intersect(checkers)
2493

    
2494

    
2495
            //RadMessageBox.Show($"{checkers.Count()}", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2496
            //RadMessageBox.Show($"{this.documents.Count}", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2497
            this.lbSelectAndTotal.Text = $"{grid.MasterTemplate.DataView.Count} / {this.TotalCount} (Selected / Total)";
2498
        }
2499
        */
2500
        private IEnumerable<GridViewRowInfo> GetCheckedRows(bool isView)
2501
        {
2502
            try
2503
            {
2504
                RadGridView grid = this.radGridViewDocuments;
2505
                var viewRows = isView ? grid.MasterTemplate.DataView : grid.Rows.AsEnumerable<GridViewRowInfo>();
2506
                return viewRows.Where(x =>
2507
                {
2508
                    return x.Cells["Checked"].Value != null && Convert.ToBoolean(x.Cells["Checked"].Value);
2509
                });
2510
            }
2511
            catch (Exception ex)
2512
            {
2513
                throw ex;
2514
            }
2515
        }
2516

    
2517
        private IEnumerable<Documents> GetCheckedDatas(bool isView)
2518
        {
2519
            return this.GetCheckedRows(isView).Where(x => x.DataBoundItem is Documents)
2520
                                              .Select(x => x.DataBoundItem as Documents);
2521
        }
2522

    
2523
        //private IEnumerable<Documents> GetCheckedDatas(bool isView)
2524
        //{
2525
        //    return this.documents.Where(x => x.Checked);
2526
        //}
2527

    
2528
        private void SetSaved()
2529
        {
2530
            this.radGridViewDocuments.EndEdit();
2531

    
2532
            try
2533
            {
2534
                if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2535
                {
2536
                    #region 유효성검사
2537

    
2538
                    #region 필수값 체크(ID2 Project, DWG_ID)
2539

    
2540
                    if (this.documents.Any(x => string.IsNullOrEmpty(x.RefProjectCode)))
2541
                    {
2542
                        RadMessageBox.Show($"Please, check the required value (ID2 Project).", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2543
                        return;
2544
                    }
2545

    
2546
                    if (this.documents.Any(x => string.IsNullOrEmpty(x.DocumentNo)))
2547
                    {
2548
                        RadMessageBox.Show($"Please, check the required value (DWG_ID).", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2549
                        return;
2550
                    }
2551

    
2552
                    #endregion
2553

    
2554
                    #endregion
2555

    
2556
                    #region document no 중복 유효성 체크
2557
                    int dupDwgNoCount = 0;
2558
                    dupDwgNoCount = this.documents.GroupBy(g => new { g.RefProjectCode, g.DocumentNo })
2559
                                                  .Where(x => x.Count() > 1)
2560
                                                  .Select(x => x.Key).ToList().Count;
2561

    
2562
                    if (dupDwgNoCount > 0)
2563
                    {
2564
                        RadMessageBox.Show($"Duplicate Dwg No exists.({dupDwgNoCount})", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2565
                        return;
2566
                    }
2567
                    #endregion
2568

    
2569
                    var worker = new SetDocumentsWorker(this.documents, this.orgDocuments, this.radGridViewDocuments);
2570
                    worker.OnWorkCompletedHandler += (e) =>
2571
                    {
2572
                        bool isDwg = false;
2573
                        bool isMarkusPrj = false;
2574
                        bool isMarkusDwg = false;
2575
                        bool isMarkusUser = false;
2576

    
2577
                        (isDwg, isMarkusPrj, isMarkusDwg, isMarkusUser) = ((bool, bool, bool, bool))e.Result;
2578

    
2579
                        if (!isDwg)
2580
                        {
2581
                            RadMessageBox.Show("Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2582
                        }
2583
                        else if (!isMarkusPrj)
2584
                        {
2585
                            RadMessageBox.Show("Markus Projects Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2586
                        }
2587
                        else if (!isMarkusDwg)
2588
                        {
2589
                            RadMessageBox.Show("Markus Data Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2590
                        }
2591
                        else if (!isMarkusUser)
2592
                        {
2593
                            RadMessageBox.Show("Markus Members Save is not complete.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2594
                        }
2595
                        else
2596
                        {
2597
                            RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2598
                            this.GetDocList(false);
2599
                        }
2600
                    };
2601
                    worker.StartWork();
2602
                }
2603
            }
2604
            catch (Exception ex)
2605
            {
2606
                throw ex;
2607
            }
2608
        }
2609

    
2610
        #region Quick Toolbar Button Event
2611
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
2612
        {
2613
            try
2614
            {
2615
                this.SetSaved();
2616
            }
2617
            catch (Exception ex)
2618
            {
2619
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2620
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2621
            }
2622
        }
2623

    
2624
        private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e)
2625
        {
2626
            bool isReload = false;
2627

    
2628
            try
2629
            {
2630
                if (RadMessageBox.Show($"Do you want to reload the project?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2631
                {
2632
                    if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
2633
                    {
2634
                        //informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
2635
                        informations.ActiveProjects = new List<ProjectInfo>() { new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID) };
2636
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2637

    
2638
                        isReload = true;
2639
                    }
2640
                    else if (informations.ActiveProjects.Count > 0)
2641
                    {
2642
                        informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
2643

    
2644
                        isReload = true;
2645
                    }
2646
                    else
2647
                    {
2648
                        RadMessageBox.Show("Select a project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2649
                        this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
2650
                    }
2651
                }
2652

    
2653
                if (isReload)
2654
                {
2655
                    this.LoadProject(false);
2656
                }
2657
            }
2658
            catch (Exception ex)
2659
            {
2660
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2661
                RadMessageBox.Show("Failed to reload the project.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2662
            }
2663
        }
2664
        #endregion
2665

    
2666
        #region Home Tab Event
2667

    
2668
        private void RadButtonElementSave_Click(object sender, EventArgs e)
2669
        {
2670
            try
2671
            {
2672
                this.SetSaved();
2673
            }
2674
            catch (Exception ex)
2675
            {
2676
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2677
                RadMessageBox.Show("DWG save failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2678
            }
2679
        }
2680

    
2681
        private void RadButtonElementSync_Click(object sender, EventArgs e)
2682
        {
2683
            try
2684
            {
2685
                if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2686
                {
2687
                    var worker = new SyncDocumentsWorker(this.radGridViewDocuments);
2688
                    worker.OnWorkCompletedHandler += (arg) =>
2689
                    {
2690
                        if ((bool)arg.Result)
2691
                        {
2692
                            this.GetDocList(false);
2693

    
2694
                            RadMessageBox.Show("Sync with ID2 completed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2695
                        }
2696
                    };
2697
                    worker.StartWork();
2698
                }
2699
            }
2700
            catch (Exception ex)
2701
            {
2702
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2703
                RadMessageBox.Show("Failed to sync with id2.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2704
            }
2705
        }
2706

    
2707
        private void RadButtonElementNotice_Click(object sender, EventArgs e)
2708
        {
2709
            try
2710
            {
2711
                AttFileInfo notiFileInfo = new AttFileController().GetAttFileInfo(informations.ActiveProjects[0].ProjectID, "notice");
2712

    
2713
                if (notiFileInfo == null)
2714
                {
2715
                    RadMessageBox.Show("No notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2716
                }
2717
                else
2718
                {
2719
                    string noticePath = Path.Combine(Globals.ProgramDataFolder, "NoticeFiles");
2720
                    string noticeFileFullName = Path.Combine(noticePath, $"{notiFileInfo.FileID}{notiFileInfo.FileExtension}");
2721

    
2722
                    FileInfo finfo = new FileInfo(noticeFileFullName);
2723

    
2724
                    if (!finfo.Directory.Exists)
2725
                    {
2726
                        Directory.CreateDirectory(noticePath);
2727
                    }
2728

    
2729
                    if (!finfo.Exists)
2730
                    {
2731
                        var arrayBinary = notiFileInfo.FileData.ToArray();
2732

    
2733
                        using (MemoryStream ms = new MemoryStream(arrayBinary))
2734
                        {
2735
                            ms.Write(arrayBinary, 0, arrayBinary.Length);
2736
                            ms.Seek(0, SeekOrigin.Begin);
2737

    
2738
                            using (FileStream fs = finfo.Create())
2739
                            {
2740
                                ms.CopyTo(fs);
2741
                            }
2742
                        }
2743
                    }
2744

    
2745
                    try
2746
                    {
2747
                        ProcessStartInfo startInfo = new ProcessStartInfo
2748
                        {
2749
                            FileName = finfo.FullName,
2750
                            UseShellExecute = true,
2751
                            CreateNoWindow = false,
2752
                            WindowStyle = ProcessWindowStyle.Normal
2753
                        };
2754

    
2755
                        using (Process process = new Process())
2756
                        {
2757
                            process.StartInfo = startInfo;
2758
                            process.Start();
2759
                        }
2760
                        //Process.Start(finfo.FullName);
2761
                    }
2762
                    catch (Exception ex)
2763
                    {
2764
                        throw ex;
2765
                    }
2766

    
2767
                    //using (MemoryStream ms = new MemoryStream(arrayBinary))
2768
                    //{
2769
                    //    ProcessStartInfo startInfo = new ProcessStartInfo
2770
                    //    {
2771
                    //        FileName = Path.Combine(attFileInfo.FilePath, attFileInfo.FileName),
2772
                    //        RedirectStandardInput = true,
2773
                    //        UseShellExecute = false,
2774
                    //        CreateNoWindow = true,
2775
                    //        WindowStyle = ProcessWindowStyle.Hidden
2776
                    //    };
2777

    
2778
                    //    using (Process process = new Process())
2779
                    //    {
2780
                    //        process.StartInfo = startInfo;
2781
                    //        process.Start();
2782

    
2783
                    //        // Write the memory stream contents to the process standard input
2784
                    //        byte[] buffer = ms.ToArray();
2785
                    //        process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length);
2786
                    //        process.StandardInput.Close();
2787

    
2788
                    //        process.WaitForExit();
2789
                    //    }
2790
                    //}
2791
                }
2792
            }
2793
            catch (Exception ex)
2794
            {
2795
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2796
                RadMessageBox.Show("Notification lookup failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2797
            }
2798
        }
2799

    
2800
        private void RadButtonElementNoticeUpload_Click(object sender, EventArgs e)
2801
        {
2802
            string GetContentType(string filePath)
2803
            {
2804
                string extension = Path.GetExtension(filePath).ToLower();
2805

    
2806
                switch (extension)
2807
                {
2808
                    case ".txt":
2809
                        return "text/plain";
2810
                    case ".pdf":
2811
                        return "application/pdf";
2812
                    case ".jpg":
2813
                    case ".jpeg":
2814
                        return "image/jpeg";
2815
                    case ".png":
2816
                        return "image/png";
2817
                    case ".bmp":
2818
                        return "image/bmp";
2819
                    case ".gif":
2820
                        return "image/gif";
2821
                    default:
2822
                        return "application/octet-stream";
2823
                }
2824
            }
2825

    
2826
            if (informations.ActiveProjects.Count == 1)
2827
            {
2828
                using (OpenFileDialog ofd = new OpenFileDialog()
2829
                {
2830
                    //Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*",
2831
                    Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp)|*.png;*.jpeg;*.gif;*.jpg;*.bmp"
2832
                           + "|PNG Portable Network Graphics (*.png)|*.png"
2833
                           + "|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif"
2834
                           + "|BMP Windows Bitmap (*.bmp)|*.bmp"
2835
                           + "|GIF Graphics Interchange Format (*.gif)|*.gif",
2836
                    //Title = "Open an Excel File",
2837
                    RestoreDirectory = true
2838
                })
2839
                {
2840
                    try
2841
                    {
2842
                        if (ofd.ShowDialog() == DialogResult.OK)
2843
                        {
2844
                            FileInfo fileInfo = new FileInfo(ofd.FileName);
2845
                            if (fileInfo.Exists)
2846
                            {
2847
                                AttFileInfo attFile = new AttFileInfo()
2848
                                {
2849
                                    RefID = informations.ActiveProjects[0].ProjectID,
2850
                                    Category = "notice",
2851
                                    FileType = GetContentType(fileInfo.FullName),
2852
                                    FileName = fileInfo.Name,
2853
                                    FilePath = fileInfo.DirectoryName,
2854
                                    FileExtension = fileInfo.Extension
2855
                                };
2856

    
2857
                                using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
2858
                                {
2859
                                    using (var reader = new BinaryReader(stream))
2860
                                    {
2861
                                        attFile.FileData = reader.ReadBytes((int)stream.Length);
2862
                                    }
2863
                                }
2864

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

    
2867
                                if (result)
2868
                                {
2869
                                    RadMessageBox.Show("An Notice has been posted.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2870
                                }
2871
                            }
2872
                        }
2873
                    }
2874
                    catch (Exception ex)
2875
                    {
2876
                        Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2877
                        RadMessageBox.Show("Failed to register the Notice.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2878
                    }
2879
                }
2880
            }
2881
            else
2882
            {
2883
                RadMessageBox.Show("Please select a project.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info);
2884
                return;
2885
            }
2886
        }
2887

    
2888
        private void RadButtonElementFilterClear_Click(object sender, EventArgs e)
2889
        {
2890
            if (RadMessageBox.Show("Are you sure you want to clear the filter?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
2891
            {
2892
                this.radGridViewDocuments.FilterDescriptors.Clear();
2893
            }
2894
        }
2895
        #endregion
2896

    
2897
        #region Project Manager Tab Event
2898

    
2899
        #region Excel
2900
        private UserInfo GetUser(string user)
2901
        {
2902
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
2903
            if (userInfo != null) return userInfo;
2904

    
2905
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
2906
            if (userInfo != null) return userInfo;
2907

    
2908
            return userInfo ?? new UserInfo();
2909
        }
2910

    
2911
        private ProjectInfo GetProject(string project)
2912
        {
2913
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.Code.Equals(project)).FirstOrDefault();
2914
            if (prjInfo != null) return prjInfo;
2915

    
2916
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
2917
            if (prjInfo != null) return prjInfo;
2918

    
2919
            return prjInfo ?? new ProjectInfo();
2920
        }
2921

    
2922
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
2923
        {
2924
            try
2925
            {
2926
                var form = new Forms.SelectExcelData();
2927

    
2928
                var dialogResult = form.ShowDialog();
2929

    
2930
                if (dialogResult == DialogResult.OK)
2931
                {
2932
                    using (ID2Excel excel = new ID2Excel())
2933
                    {
2934
                        var result = excel.ExcelDataImport(form.SelectItems);
2935

    
2936
                        if (result.Error != null)
2937
                        {
2938
                            RadMessageBox.Show(result.Error, Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2939
                        }
2940
                        else
2941
                        {
2942
                            this.importImages = result.Images;//???
2943

    
2944
                            var intersections = this.documents.Intersect(result.documents, new DocumentsUniqueCompare());
2945
                            var subtractions = result.documents.Except(this.documents, new DocumentsUniqueCompare());
2946

    
2947
                            if (intersections.Any())
2948
                            {
2949
                                var intersectionImports = result.documents.Intersect(this.documents, new DocumentsUniqueCompare());
2950

    
2951
                                intersections.ForAll(x =>
2952
                                {
2953
                                    var intersectionImport = intersectionImports.FirstOrDefault(o => o.RefProjectCode == x.RefProjectCode && o.DocumentNo == x.DocumentNo);
2954
                                    if (intersectionImport != null)
2955
                                    {
2956
                                        x.DataCopy(intersectionImport);
2957
                                    }
2958
                                });
2959
                            }
2960

    
2961
                            this.documents.AddRange(subtractions);
2962
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
2963
                            this.DocumentListBinding(false);
2964
                            //briefAndImagesReview.SetImages(this.importImages);
2965

    
2966
                            RadMessageBox.Show("Import is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
2967
                        }
2968

    
2969
                    }
2970
                }
2971
            }
2972
            catch (Exception ex)
2973
            {
2974
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
2975
                RadMessageBox.Show("DWG excel import failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
2976
            }
2977
        }
2978

    
2979
        private void RadButtonElementExcelImport_Click_gembox(object sender, EventArgs e)
2980
        {
2981
            using (OpenFileDialog ofd = new OpenFileDialog()
2982
            {
2983
                Filter = "Excel files (*.xlsx)|*.xlsx",
2984
                Title = "Open an Excel File",
2985
                RestoreDirectory = true
2986
            })
2987
            {
2988
                if (ofd.ShowDialog() == DialogResult.OK)
2989
                {
2990
                    //Error Message
2991
                    StringBuilder sbErrMsg = new StringBuilder();
2992

    
2993
                    using (ID2Excel excel = new ID2Excel())
2994
                    {
2995
                        var result = excel.GemboxImport(ofd.FileName);
2996

    
2997
                        if (result.Error != null)
2998
                        {
2999

    
3000
                            RadMessageBox.Show(result.Error, "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
3001
                        }
3002
                        else
3003
                        {
3004
                            this.documents.AddRange(result.documents);
3005
                            if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
3006
                            this.DocumentListBinding(false);
3007
                        }
3008

    
3009
                    }
3010

    
3011

    
3012
                    //foreach (Documents appDoc in appendDocuments)
3013
                    //{
3014
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
3015

    
3016
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
3017
                    //    {
3018
                    //        if (fieldInfo.GetValue(appDoc) != null)
3019
                    //        {
3020
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
3021

    
3022
                    //            if (cols.Any())
3023
                    //            {
3024
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
3025
                    //            }
3026
                    //        }
3027
                    //    }
3028
                    //}
3029
                }
3030
            }
3031
        }
3032

    
3033
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
3034
        {
3035
            string sPrefixName = "Samsung Elec Task Management";
3036
            string extension = ".xlsx";
3037

    
3038
            using (SaveFileDialog sfd = new SaveFileDialog()
3039
            {
3040
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
3041
                Filter = "Excel|*.xlsx",
3042
                Title = "Save an Excel File",
3043
                CheckFileExists = false,
3044
                CheckPathExists = true,
3045
                OverwritePrompt = true
3046
            })
3047
            {
3048
                if (sfd.ShowDialog() == DialogResult.OK)
3049
                {
3050
                    string fileName = $"{sPrefixName}{extension}";
3051
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
3052
                    string templateFilePath = Path.Combine(templateFolder, fileName);
3053
                    if (!File.Exists(templateFilePath))
3054
                    {
3055
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
3056
                        return;
3057
                    }
3058

    
3059
                    var templateExcelFile = ExcelFile.Load(templateFilePath);
3060
                    var templateWorksheets = templateExcelFile.Worksheets;
3061
                    var templateWorksheet = templateWorksheets[0];
3062

    
3063
                    if (this.radGridViewDocuments.Rows.Count > 0)
3064
                    {
3065
                        int rowIndex = 9;
3066
                        //int colIndex = 1;
3067
                        int rowNo = 1;
3068

    
3069
                        foreach (var row in this.radGridViewDocuments.MasterTemplate.DataView)
3070
                        {
3071
                            var doc = row.DataBoundItem as Documents;
3072
                            int colIndex = 0;
3073
                            templateWorksheet.Cells[rowIndex, colIndex].Value = rowNo++;
3074
                            colIndex = 6;//1~6연동필드
3075
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.Team;
3076
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.RefProjectCode;
3077
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.System;
3078
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.SubSystemCode;
3079
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.DocumentNo;
3080
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.PersonInCharge).Name;
3081
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.Worker).Name;
3082
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.AVEVAPersonInCharge).Name;
3083
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.AVEVAWorker).Name;
3084
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.Simularity;
3085
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.Simularity2;
3086
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.JobLevel;
3087
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.RevisonNo;
3088
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ToIsDiscussion;
3089
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ToRemarks;
3090
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.ToCreator).Name;
3091
                            ++colIndex;//toreview-23
3092
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.FrReviewStatus;
3093
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.FrRemarks;
3094
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.FrCreator).Name;
3095
                            ++colIndex;//frreview-27
3096
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = $"{doc.ID2StartDate:yyyy/MM/dd HH:mm:ss}";
3097
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = $"{doc.ID2EndDate:yyyy/MM/dd HH:mm:ss}";
3098
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ID2Status;
3099
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ID2Issues;
3100
                            ++colIndex;//id2work-32
3101
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ReplyModifications;
3102
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.ReplyRequester).Name;
3103
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.IsConvert;
3104
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
3105
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = $"{doc.AVEVAWorkDate:yyyy/MM/dd}";
3106
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.AVEVAStatus;
3107
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.AVEVAIssues;
3108
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
3109
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.ProdReviewer).Name;
3110
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ProdIsResult;
3111
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ProdRemarks;
3112
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = this.GetUser(doc.ClientReviewer).Name;
3113
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ClientIsResult;
3114
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.ClientRemarks;
3115
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.DTIsGateWay;
3116
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.DTIsImport;
3117
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.DTIsRegSystem;
3118
                            templateWorksheet.Cells[rowIndex, ++colIndex].Value = doc.DTRemarks;
3119

    
3120
                            /*
3121
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
3122
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
3123
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
3124
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
3125
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
3126
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
3127
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
3128
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
3129
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
3130
                            //templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
3131
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
3132
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
3133
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
3134
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
3135
                            //templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture;
3136
                            //templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
3137
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
3138
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
3139
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
3140
                            //templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture;
3141
                            //templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
3142
                            //templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
3143
                            //templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
3144
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
3145
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
3146
                            //templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
3147
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
3148
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
3149
                            //templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
3150
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
3151
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
3152
                            //추가필요templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAWorkDate:yyyy/MM/dd}";
3153
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
3154
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
3155
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
3156
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
3157
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
3158
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
3159
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
3160
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
3161
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
3162
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
3163
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
3164
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
3165
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
3166
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
3167
                            */
3168
                            rowIndex++;
3169
                        }
3170
                    }
3171
                    templateExcelFile.Save(sfd.FileName);
3172
                    RadMessageBox.Show("Exporting 'Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
3173
                }
3174
            }
3175
        }
3176
        #endregion
3177

    
3178
        #region DWG
3179
        private void RadButtonElementDelete_Click(object sender, EventArgs e)
3180
        {
3181
            IEnumerable<Documents> chkDatas = null;
3182

    
3183
            try
3184
            {
3185
                chkDatas = this.GetCheckedDatas(true);
3186

    
3187
                if (chkDatas.Any())
3188
                {
3189
                    if (RadMessageBox.Show("Do you want to Delete?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
3190
                    {
3191
                        Queue<Documents> qChkData = new Queue<Documents>(chkDatas);
3192
                        while (qChkData.Any())
3193
                        {
3194
                            this.documents.Remove(qChkData.Dequeue());
3195
                        }
3196
                        this.DocumentListBinding(false);
3197
                        RadMessageBox.Show("Delete is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
3198
                    }
3199
                }
3200
                else
3201
                {
3202
                    RadMessageBox.Show("Please check the DWG.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
3203
                }
3204
            }
3205
            catch (Exception ex)
3206
            {
3207
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
3208
                RadMessageBox.Show("DWG delete failed.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
3209
            }
3210
        }
3211

    
3212
        private void RadButtonElementLevel_Click(object sender, EventArgs e)
3213
        {
3214
            RadMessageBox.Show("도면 Level 자동 조정.", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
3215
        }
3216
        #endregion
3217

    
3218
        #region Markup
3219
        private void RadButtonElementConvert_Click(object sender, EventArgs e)
3220
        {
3221
            if (radGridViewDocuments.SelectedRows?.Count() > 0)
3222
            {
3223
                List<Documents> checkedDocList = this.GetCheckedDatas(true).ToList();
3224

    
3225
                if (checkedDocList.Count > 1)
3226
                {
3227
                    MarkusConvertWorker convertWorker = new MarkusConvertWorker(checkedDocList.ToList(), radGridViewDocuments);
3228

    
3229
                    convertWorker.OnWorkCompletedHandler += (args) =>
3230
                    {
3231
                        if (convertWorker.ErrorDocList.Count() > 0)
3232
                        {
3233
                            var ids = string.Join("\n", convertWorker.ErrorDocList.Select(x => x.DocumentNo));
3234
                            string message = $"Convert Error.\nPlease check the DWG.\n\n{ids}";
3235

    
3236
                            RadMessageBox.Show(message, Globals.Name, MessageBoxButtons.OK);
3237
                        }
3238
                        else
3239
                        {
3240
                            RadMessageBox.Show("Conversion successfully.", Globals.Name, MessageBoxButtons.OK);
3241
                        }
3242
                    };
3243

    
3244
                    convertWorker.StartWork();
3245
                }
3246
                else
3247
                {
3248
                    var item = radGridViewDocuments.SelectedRows.First().DataBoundItem as Documents;
3249
                    MarkusConvert.Call(Properties.Settings.Default.MarkusService, item.RefProjectCode, item.DocumentNo);
3250
                }
3251
            }
3252
        }
3253
        #endregion
3254

    
3255
        #endregion
3256

    
3257
        #region ColumnGroup
3258
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
3259
        {
3260
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
3261

    
3262
            List<string> chkColNames = new List<string>() { "Checked" };
3263

    
3264
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "ID2Connection", "PDFLink", "MarkupLink", "AVEVALink" };
3265
            List<string> docInfoColNames = new List<string>() { "Team", "RefProjectCode", "System", "DocumentNo", "PersonInCharge", "Worker" };
3266
            List<string> docOtherInfoColNames = new List<string>() { "SubSystemCode", "AVEVAPersonInCharge", "AVEVAWorker", "JobLevel", "Simularity", "Simularity2", "RevisonNo" };
3267
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture" };
3268
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" };
3269
            List<string> wkID2ColNames = new List<string>() { "ID2StartDate", "ID2EndDate", "ID2Status", "ID2Issues", "ID2Capture", "ReplyModifications", "ReplyRequester" };
3270
            List<string> wkAVEVAColNames = new List<string>() { "IsConvert", "AVEVAConvertDate", "AVEVAWorkDate", "AVEVAStatus", "AVEVAIssues" };
3271
            List<string> valProdColNames = new List<string>() { "AVEVAReviewDate", "ProdReviewer", "ProdIsResult", "ProdRemarks" };
3272
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" };
3273
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
3274

    
3275
            //체크
3276
            GridViewColumnGroup chkColGrp = new GridViewColumnGroup("√") { IsPinned = true };
3277
            GridViewColumnGroupRow chkColGrpRow = new GridViewColumnGroupRow();
3278
            chkColGrpRow.ColumnNames.AddRange(chkColNames);
3279
            chkColGrp.Rows.Add(chkColGrpRow);
3280

    
3281
            //링크
3282
            GridViewColumnGroup docLinkGrp = new GridViewColumnGroup("프로그램 연동", "link") { IsPinned = true };
3283

    
3284
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
3285
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
3286

    
3287
            docLinkGrp.Rows.Add(docLinkColGrpRow);
3288

    
3289
            //도면
3290
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면정보", "docinfo") { IsPinned = true };
3291

    
3292
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
3293
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
3294

    
3295
            docColGrp.Rows.Add(docInfoColGrpRow);
3296

    
3297
            //도면상세
3298
            GridViewColumnGroup docOtherColGrp = new GridViewColumnGroup("도면상세 ");
3299

    
3300
            GridViewColumnGroupRow docOtherInfoColGrpRow = new GridViewColumnGroupRow();
3301
            docOtherInfoColGrpRow.ColumnNames.AddRange(docOtherInfoColNames);
3302

    
3303
            docOtherColGrp.Rows.Add(docOtherInfoColGrpRow);
3304

    
3305
            //검토
3306
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
3307
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
3308
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
3309

    
3310
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
3311
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
3312

    
3313
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
3314
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
3315

    
3316
            rvToColGrp.Rows.Add(rvToColGrpRow);
3317
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
3318

    
3319
            rvColGrp.Groups.Add(rvToColGrp);
3320
            rvColGrp.Groups.Add(rvFrColGrp);
3321

    
3322
            //작업
3323
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
3324
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
3325
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
3326

    
3327
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
3328
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
3329

    
3330
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
3331
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
3332

    
3333
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
3334
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
3335

    
3336
            wkColGrp.Groups.Add(wkID2ColGrp);
3337
            wkColGrp.Groups.Add(wkAVEVAColGrp);
3338

    
3339
            //Validation
3340
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
3341
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
3342
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
3343

    
3344
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
3345
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
3346

    
3347
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
3348
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
3349

    
3350
            valProdColGrp.Rows.Add(valProdColGrpRow);
3351
            valCntColGrp.Rows.Add(valCntColGrpRow);
3352

    
3353
            valColGrp.Groups.Add(valProdColGrp);
3354
            valColGrp.Groups.Add(valCntColGrp);
3355

    
3356
            //AVEVA Net
3357
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
3358

    
3359
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
3360
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
3361

    
3362
            dtColGrp.Rows.Add(dtColGrpRow);
3363

    
3364
            //Group 추가
3365
            columnGroupsView.ColumnGroups.Add(chkColGrp);
3366
            columnGroupsView.ColumnGroups.Add(docLinkGrp);
3367
            columnGroupsView.ColumnGroups.Add(docColGrp);
3368
            columnGroupsView.ColumnGroups.Add(docOtherColGrp);
3369
            columnGroupsView.ColumnGroups.Add(wkColGrp);
3370
            columnGroupsView.ColumnGroups.Add(rvColGrp);
3371
            columnGroupsView.ColumnGroups.Add(valColGrp);
3372
            columnGroupsView.ColumnGroups.Add(dtColGrp);
3373

    
3374
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
3375

    
3376
            this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36;
3377
            this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = ROW_HEADER_COLUMN_WIDTH;
3378
        }
3379

    
3380
        #region grid view group
3381
        /*
3382
        private void InitGridViewDefinition(RadGridView gridView)
3383
        {
3384
            ColumnGroupsViewDefinition colGrpViewDef = new ColumnGroupsViewDefinition();
3385
            colGrpViewDef.ColumnGroups.AddRange(new[]
3386
            {
3387
                this.SetGridColumnGroup("√", "√", true, true, Enumerable.Empty<GridViewColumnGroup>(),this.SetGridColumnGroupRow(new[] { "Checked" })),
3388
                this.SetGridColumnGroup("프로그램 연동", "link", true, true, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "AutoCADLink", "ID2Connection", "PDFLink", "MarkupLink", "AVEVALink", "Compare" })),
3389
                this.SetGridColumnGroup("도면정보", "docinfo", true, true, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "RefProjectCode", "System", "DocumentNo", "PersonInCharge" })),
3390
                this.SetGridColumnGroup("도면상세", "도면상세", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "SubSystemCode", "Worker", "AVEVAPersonInCharge", "AVEVAWorker", "JobLevel", "RevisonNo" })),
3391
                this.SetGridColumnGroup("작업", "work", true, false, new[]
3392
                {
3393
                    this.SetGridColumnGroup("ID2","ID2", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "ID2StartDate", "ID2EndDate", "ID2Status", "ID2Issues", "ID2Capture", "ReplyModifications", "ReplyRequester" })),
3394
                    this.SetGridColumnGroup("AVEVA","AVEVA", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" }))
3395
                }, null),
3396
                this.SetGridColumnGroup("검토", "review", true, false, new[]
3397
                {
3398
                    this.SetGridColumnGroup("도프텍","도프텍", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture" })),
3399
                    this.SetGridColumnGroup("삼성","삼성", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture" }))
3400
                }, null),
3401
                this.SetGridColumnGroup("Validation", "validation", true, false, new[]
3402
                {
3403
                    this.SetGridColumnGroup("도프텍","도프텍", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "AVEVAReviewDate", "ProdReviewer", "ProdIsResult", "ProdRemarks" })),
3404
                    this.SetGridColumnGroup("삼성전자","삼성전자", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "ClientReviewer", "ClientIsResult", "ClientRemarks" }))
3405
                }, null),
3406
                this.SetGridColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet", true, false, Enumerable.Empty<GridViewColumnGroup>(), this.SetGridColumnGroupRow(new[] { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" }))
3407
            });
3408
            gridView.MasterTemplate.ViewDefinition = colGrpViewDef;
3409
        }
3410

    
3411
        private GridViewColumnGroup SetGridColumnGroup(string groupText, string groupName, bool groupShowHeader, bool groupFreezed, IEnumerable<GridViewColumnGroup> groups, GridViewColumnGroupRow columnGroupRow)
3412
        {
3413
            GridViewColumnGroup colGrp = new GridViewColumnGroup()
3414
            {
3415
                Text = groupText,
3416
                Name = groupName,
3417
                ShowHeader = groupShowHeader,
3418
                IsPinned = groupFreezed
3419
            };
3420
            groups.ForAll(x => colGrp.Groups.Add(x));
3421
            colGrp.Rows.Add(columnGroupRow);
3422
            return colGrp;
3423
        }
3424

    
3425
        private GridViewColumnGroupRow SetGridColumnGroupRow(IEnumerable<string> columnList)
3426
        {
3427
            GridViewColumnGroupRow colGrpRow = new GridViewColumnGroupRow();
3428
            colGrpRow.ColumnNames.AddRange(columnList);
3429
            return colGrpRow;
3430
        }
3431
        */
3432
        #endregion
3433

    
3434
        #endregion
3435

    
3436
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
3437
        {
3438
            if (string.IsNullOrWhiteSpace(txtFullSearch.Text))
3439
                radGridViewDocuments.MasterTemplate.Refresh(null);
3440

    
3441
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
3442
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
3443
        }
3444

    
3445
        private void btnSearchPrevious_Click(object sender, EventArgs e)
3446
        {
3447
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
3448
        }
3449

    
3450
        private void btnSearchNext_Click(object sender, EventArgs e)
3451
        {
3452
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
3453
        }
3454

    
3455
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
3456
        {
3457
            if (e.KeyCode == Keys.Enter)
3458
            {
3459
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
3460
            }
3461
        }
3462

    
3463
        private void commandBarSearch_ItemOverflowed(object sender, EventArgs e)
3464
        {
3465
            commandBarSearch.OverflowButton.AddRemoveButtonsMenuItem.Visibility = ElementVisibility.Collapsed;
3466
            commandBarSearch.OverflowButton.CustomizeButtonMenuItem.Visibility = ElementVisibility.Collapsed;
3467
        }
3468

    
3469
        private void commandBarSearch_ItemOutOfOverflow(object sender, EventArgs e)
3470
        {
3471
            commandBarSearch.OverflowButton.AddRemoveButtonsMenuItem.Visibility = ElementVisibility.Collapsed;
3472
            commandBarSearch.OverflowButton.CustomizeButtonMenuItem.Visibility = ElementVisibility.Collapsed;
3473
        }
3474
    }
3475
}
3476

    
3477
public class FilterColumn
3478
{
3479
    public string Name { get; set; }
3480
    public string FieldName { get; set; }
3481
    public bool IsSelect { get; set; }
3482
}
클립보드 이미지 추가 (최대 크기: 500 MB)