프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ c0420a29

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

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

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

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

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

    
26
using GemBox.Spreadsheet;
27

    
28
using Newtonsoft.Json;
29
using System.Diagnostics;
30

    
31
namespace ID2.Manager
32
{
33
    public partial class Main : RadRibbonForm
34
    {
35
        readonly Informations informations = Informations.Instance;
36
        bool IsID2Manager = false;
37
        List<MarkupText> Markups = new List<MarkupText>();
38
        List<Documents> documents = new List<Documents>();
39
        List<Documents> orgDocuments = null;
40

    
41
        private readonly Color _SummaryColor = Color.FromArgb(255, 108, 55);
42

    
43
        public Main()
44
        {
45
            InitializeComponent();
46

    
47
            Telerik.WinControls.RadControlSpy.RadControlSpyForm radControlSpyForm = new Telerik.WinControls.RadControlSpy.RadControlSpyForm();
48
            radControlSpyForm.Show();
49

    
50
            SpreadsheetInfo.SetLicense(Properties.Settings.Default.GemBoxLicense);
51

    
52
            this.Load += Main_Load;
53

    
54
            this.radButtonElementRefreshCommand.Click += RadButtonElementRefreshCommand_Click;
55
            this.radButtonElementSaveCommand.Click += RadButtonElementSaveCommand_Click;
56

    
57
            this.radButtonElementSave.Click += RadButtonElementSave_Click;
58
            this.radButtonElementSync.Click += RadButtonElementSync_Click;
59
            this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click;
60
            this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click;
61

    
62
            this.radCheckBox1.CheckStateChanged += RadCheckBox_CheckStateChanged;
63
            this.radCheckBox2.CheckStateChanged += RadCheckBox_CheckStateChanged;
64
            this.radCheckBox3.CheckStateChanged += RadCheckBox_CheckStateChanged;
65
            this.radCheckBox4.CheckStateChanged += RadCheckBox_CheckStateChanged;
66
            this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown;
67
            this.radButtonSearch.Click += RadButtonSearch_Click;
68

    
69
            this.radGridViewDocuments.SelectionChanged += RadGridViewDocuments_SelectionChanged;
70
            this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting;
71
            this.radGridViewDocuments.CreateRow += RadGridViewDocuments_CreateRow;
72
            this.radGridViewDocuments.CreateRowInfo += RadGridViewDocuments_CreateRowInfo;
73
            this.radGridViewDocuments.CreateCell += RadGridViewDocuments_CreateCell1;
74
            this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit;
75
            this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick;
76
            this.radGridViewDocuments.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
77

    
78
            this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36;
79
            this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36;
80
            //this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ;
81
            this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false;
82

    
83
            var detailGridview = new DetailGridViewTemplate();
84
            detailGridview.DataSource = Markups;
85
            this.radGridViewDocuments.MasterTemplate.Templates.Add(detailGridview);
86

    
87
            GridViewRelation relation = new GridViewRelation(this.radGridViewDocuments.MasterTemplate);
88
            relation.ChildTemplate = detailGridview;
89
            relation.RelationName = "MarkupTextRelation";
90
            relation.ParentColumnNames.Add("DocumentNo");
91
            relation.ChildColumnNames.Add("DOCUMENT_ID");
92
            this.radGridViewDocuments.Relations.Add(relation);
93

    
94
            var openProjectView = new OpenProjectView()
95
            {
96
                Dock = DockStyle.Fill
97
            };
98
            this.backstageViewPageOpenProject.Controls.Add(openProjectView);
99
            openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick;
100
            openProjectView.CloseProjectClick += OpenProjectView_OpenProjectClick;
101
            this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click;
102
            this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click;
103
            this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened;
104
            this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed;
105

    
106
            this.InitColumnGroupsViewDefinition(this.radGridViewDocuments);
107

    
108
            this.Initialize();
109
        }
110

    
111
        private void RadGridViewDocuments_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
112
        {
113
            if (e.RowInfo is GridViewSearchRowInfo)
114
            {
115
                e.RowInfo = new SearchRow(e.ViewInfo);
116
            }
117

    
118
        }
119

    
120
        private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
121
        {
122
            if (e.SearchFinished)
123
            {
124
                
125
            }
126
        }
127

    
128
        /// <summary>
129
        /// 선택된 행의 AutoCAD와 PDF 파일을 보여준다.
130
        /// </summary>
131
        /// <param name="sender"></param>
132
        /// <param name="e"></param>
133
        private void RadGridViewDocuments_SelectionChanged(object sender, EventArgs e)
134
        {
135
            void ShowAutoCADFile(string FilePath)
136
            {
137
                Controls.AutoCADViewer viewer = null;
138
                foreach (var control in this.radPageViewPageAutoCAD.Controls)
139
                {
140
                    if (control is Controls.AutoCADViewer _viewer)
141
                    {
142
                        viewer = _viewer;
143
                        break;
144
                    }
145
                }
146

    
147
                if (viewer == null)
148
                {
149
                    viewer = new Controls.AutoCADViewer() { Dock = DockStyle.Fill };
150
                    this.radPageViewPageAutoCAD.Controls.Add(viewer);
151
                }
152
                else
153
                {
154
                    viewer.Visible = true;
155
                }
156

    
157
                if (File.Exists(FilePath) && viewer != null) viewer.ReadDWG(FilePath);
158
            }
159

    
160
            void ShowPDFFile(string FilePath)
161
            {
162
                Controls.PDFViewer viewer = null;
163
                foreach (var control in this.radPageViewPagePDF.Controls)
164
                {
165
                    if (control is Controls.PDFViewer _viewer)
166
                    {
167
                        viewer = _viewer;
168
                        break;
169
                    }
170
                }
171

    
172
                if (viewer == null)
173
                {
174
                    viewer = new Controls.PDFViewer() { Dock = DockStyle.Fill };
175
                    this.radPageViewPagePDF.Controls.Add(viewer);
176
                }
177
                else
178
                {
179
                    viewer.Visible = true;
180
                }
181

    
182
                if (File.Exists(FilePath) && viewer != null) viewer.ReadPDF(FilePath);
183
            }
184

    
185
            if (this.radGridViewDocuments.SelectedRows.Count() > 0 && this.radGridViewDocuments.SelectedRows.First().DataBoundItem is Documents doc)
186
            {
187
                string dwgExtension = ".dwg";
188
                string dwgFilePath = Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", "Native", $"{doc.DocumentNo}{dwgExtension}");
189
                ShowAutoCADFile(dwgFilePath);
190
      
191
                string pdfExtension = ".pdf";
192
                string pdfFilePath = Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), "drawings", $"{doc.DocumentNo}{pdfExtension}");
193
                ShowPDFFile(pdfFilePath);
194

    
195
                //if (informations.ActiveUser.ID != doc.PersonInCharge)
196
                //{
197
                //    var row = this.radGridViewDocuments.SelectedRows.First();
198
                //    foreach(var cell in row.Cells)
199
                //    {
200
                //        cell.ReadOnly = true;
201
                //    }
202
                //}
203
            }
204
        }
205

    
206
        #region Init, Load
207
        private void Initialize()
208
        {
209
            this.Text = Globals.Name;
210

    
211
            this.ID2ManagerRadRibbonBar.Expanded = false;
212

    
213
            this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}";
214

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

    
217
            if (this.IsID2Manager)
218
            {
219
                this.backstageViewPageOpenProject.Controls[0].Visible = true;
220
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible;
221
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible;
222
            }
223
            else
224
            {
225
                if (string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
226
                {
227
                    this.backstageViewPageOpenProject.Controls[0].Visible = true;
228
                }
229
                else
230
                {
231
                    foreach (Control ctrl in this.backstageViewPageOpenProject.Controls)
232
                    {
233
                        ctrl.Visible = false;
234
                    }
235
                }
236
                this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed;
237
                this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed;
238
            }
239
        }
240

    
241
        protected override void OnLoad(EventArgs e)
242
        {
243
            if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID))
244
            {
245
                informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID);
246
                informations.ProjectList = new ProjectController().GetAllProjectList().ToList();
247

    
248
                this.LoadProject();
249
            }
250
            else
251
            {
252
                this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement);
253
            }
254

    
255
            base.OnLoad(e);
256
        }
257

    
258
        public Point GetBackstageLocation()
259
        {
260
            Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
261
            location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
262
            location.Offset(this.ID2ManagerRadRibbonBar.Location);
263

    
264
            return location;
265
        }
266

    
267
        private void Main_Load(object sender, EventArgs e)
268
        {
269
            InitializeSearch();
270
            InitializeGridViewDetail();
271

    
272
            this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
273

    
274
        }
275

    
276
        private void InitializeSearch()
277
        {
278
            var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI");
279

    
280
            lbSearch.Text = "\ue13E";
281
            btnSearchNext.Text = "\ue006";
282
            btnSearchPrevious.Text = "\ue004";
283

    
284
            var chkbox = new RadCheckBoxElement();
285
            chkbox.Text = "Match Case";
286
            chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; };
287

    
288
            btnMatchCase.HostedItem = chkbox;
289

    
290
            var chkbox1 = new RadCheckBoxElement();
291
            chkbox1.Text = "Show All Detail";
292
            chkbox1.CheckStateChanged += (snd, evt) => 
293
            { 
294
                radGridViewDocuments.MasterView.ChildRows.ForAll(x=>x.IsExpanded = chkbox1.Checked); 
295
            };
296

    
297
            btnShowAllDetail.HostedItem = chkbox1;
298

    
299
            var chkbox2 = new RadCheckBoxElement();
300
            chkbox2.Text = "Search from current position";
301
            chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; };
302

    
303
            btnSearchFormCurrent.HostedItem = chkbox2;
304

    
305
            var columns = radGridViewDocuments.Columns.Where(x => x.AllowSearching).Select(x =>
306
                                 new FilterColumn
307
                                 {
308
                                     Name = x.HeaderText,
309
                                     FieldName = x.FieldName,
310
                                     IsSelect = x.AllowSearching
311
                                 });
312

    
313
            var panel = new StackLayoutElement();
314
            panel.Orientation = Orientation.Vertical;
315
            
316
            var btnComboColumns = new RadCheckedDropDownListElement();
317
            btnComboColumns.ShowCheckAllItems = true;
318
            btnComboColumns.CheckAllItem.Checked = true;
319
            btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns";
320
            btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true;
321
            btnComboColumns.DropDownMinSize = new Size(200, 200);
322
            btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
323
            btnComboColumns.DisplayMember = "Name";
324
            btnComboColumns.CheckedMember = "IsSelect";
325
            btnComboColumns.ValueMember = "FieldName";
326
            btnComboColumns.TextBox.CustomFont = font1.Name;
327
            btnComboColumns.TextBox.Text = "\ue13A";
328

    
329
            btnComboColumns.DataSource = columns;
330

    
331
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
332
            {
333
                radGridViewDocuments.MasterTemplate.Refresh(null);
334
            };
335

    
336
            btnComboColumns.PopupOpening += (snd, evt) =>
337
            {
338
                (snd as RadCheckedDropDownListElement).CheckAllItem.Checked = (snd as RadCheckedDropDownListElement).Items.All(x => (x.DataBoundItem as FilterColumn).IsSelect);
339
            };
340

    
341
            btnComboColumns.PopupClosed += (snd, evt) =>
342
            {
343
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
344
                {
345
                    radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
346
                }
347
            };
348

    
349
            btnFilters.HostedItem = btnComboColumns;
350
        }
351

    
352
        private void InitializeGridViewDetail()
353
        {
354
            this.radGridViewDocuments.ChildViewExpanded += RadGridViewDocuments_ChildViewExpanded;
355
        }
356

    
357
        private void RadGridViewDocuments_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
358
        {
359
            //e.ChildRow.ChildViewInfos[0].ChildRows[0].Height = 152;
360
            //e.ChildRow.ChildViewInfos[2].ChildRows[0].Height = 152;
361
            e.ChildRow.Height = 224;
362
        }
363

    
364
        #endregion
365

    
366
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
367
        {
368
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
369
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
370
        }
371

    
372
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
373
        {
374
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
375

    
376
            foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls)
377
            {
378
                if (ctrl is OpenProjectView)
379
                {
380
                    var openProjectView = ctrl as OpenProjectView;
381
                    openProjectView.GetProjectGroups();
382
                    break;
383
                }
384
            }
385
        }
386

    
387
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
388
        {
389
            if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
390
            {
391
                var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
392

    
393
                informations.ActiveProject = prjArgs.ProjectInfo;
394

    
395
                this.radRibbonBarBackstageViewID2Manager.Tag = null;
396

    
397
                this.LoadProject();
398
            }
399
        }
400

    
401
        private void LoadProject()
402
        {
403
            #region 도면
404
            //Project List
405
            if (this.radDropDownListProject.Items.Count > 0)
406
                this.radDropDownListProject.Items.Clear();
407
            informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
408
                                    .ForEach(x =>
409
                                    {
410
                                        this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
411
                                    });
412
            var allProject = new RadListDataItem("== 전체 ==", string.Empty);
413
            this.radDropDownListProject.Items.Insert(0, allProject);
414
            allProject.Selected = true;
415

    
416
            //담당자 List
417
            if (this.radDropDownListPersonInCharge.Items.Count > 0)
418
                this.radDropDownListPersonInCharge.Items.Clear();
419
            informations.UserList.ForEach(x =>
420
            {
421
                if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
422
                    this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
423
            });
424
            var allUser = new RadListDataItem("== 전체 ==", string.Empty);
425
            this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
426
            allUser.Selected = true;
427

    
428
            //난이도
429
            if (this.radDropDownListJobLevel.Items.Count > 0)
430
                this.radDropDownListJobLevel.Items.Clear();
431
            informations.JobLevel.ForEach(x =>
432
            {
433
                this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
434
            });
435
            var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
436
            this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
437
            allJobLevel.Selected = true;
438

    
439
            //도면번호 조회조건
440
            this.radTextBoxDocumentNo.Text = string.Empty;
441
            #endregion
442

    
443
            #region 검토
444
            //문의(DOF)
445
            if (this.radDropDownListToIsDiscussion.Items.Count > 0)
446
                this.radDropDownListToIsDiscussion.Items.Clear();
447
            informations. IsYesNo.ForEach(x =>
448
            {
449
                this.radDropDownListToIsDiscussion.Items.Add(new RadListDataItem(x, x));
450
            });
451
            var allToIsDiscussion = new RadListDataItem("== 전체 ==", string.Empty);
452
            this.radDropDownListToIsDiscussion.Items.Insert(0, allToIsDiscussion);
453
            allToIsDiscussion.Selected = true;
454

    
455
            //회신(DS)
456
            if (this.radDropDownListFrReviewStatus.Items.Count > 0)
457
                this.radDropDownListFrReviewStatus.Items.Clear();
458
            informations.ClientStatus.ForEach(x =>
459
            {
460
                this.radDropDownListFrReviewStatus.Items.Add(new RadListDataItem(x, x));
461
            });
462
            var allFrReviewStatus = new RadListDataItem("== 전체 ==", string.Empty);
463
            this.radDropDownListFrReviewStatus.Items.Insert(0, allFrReviewStatus);
464
            allFrReviewStatus.Selected = true;
465

    
466
            //ID2 작업가능
467
            if (this.radDropDownListIsID2Work.Items.Count > 0)
468
                this.radDropDownListIsID2Work.Items.Clear();
469
            informations.IsYesNo.ForEach(x =>
470
            {
471
                var item = new RadListDataItem(x, x);
472
                if (x.Equals("Yes"))
473
                    item.Selected = true;
474
                this.radDropDownListIsID2Work.Items.Add(item);
475
                
476
            });
477
            var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty);
478
            this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work);
479
            #endregion
480

    
481
            #region 작업
482
            //ID2 Status
483
            if (this.radDropDownListID2Status.Items.Count > 0)
484
                this.radDropDownListID2Status.Items.Clear();
485
            informations.JobStatus.ForEach(x =>
486
            {
487
                this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
488
            });
489
            var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
490
            this.radDropDownListID2Status.Items.Insert(0, allID2Status);
491
            allID2Status.Selected = true;
492

    
493
            //AVEVA Status
494
            if (this.radDropDownListAVEVAStatus.Items.Count > 0)
495
                this.radDropDownListAVEVAStatus.Items.Clear();
496
            informations.JobStatus.ForEach(x =>
497
            {
498
                this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
499
            });
500
            var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
501
            this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
502
            allAVEVAStatus.Selected = true;
503
            #endregion
504

    
505
            #region 확인
506
            //도프텍 결과
507
            if (this.radDropDownListProdIsResult.Items.Count > 0)
508
                this.radDropDownListProdIsResult.Items.Clear();
509
            informations.ValidationResult.ForEach(x =>
510
            {
511
                this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
512
            });
513
            var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
514
            this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
515
            allProdIsResult.Selected = true;
516

    
517
            //삼성 결과
518
            if (this.radDropDownListClientIsResult.Items.Count > 0)
519
                this.radDropDownListClientIsResult.Items.Clear();
520
            informations.ValidationResult.ForEach(x =>
521
            {
522
                this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
523
            });
524
            var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
525
            this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
526
            allClientIsResult.Selected = true;
527
            #endregion
528

    
529
            this.GetDocList();
530
            this.DocumentListBinding();
531
        }
532

    
533
        #region Document List 조회
534
        public void GetDocList()
535
        {
536
            if (this.radDropDownListProject.SelectedValue != null)
537
            {
538
                string projectCode = this.radDropDownListProject.SelectedValue.ToString();
539
                string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
540
                string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();//
541
                string documentNo = this.radTextBoxDocumentNo.Text.Trim();
542

    
543
                string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
544
                string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
545
                string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();//
546

    
547
                string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();//
548
                string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();//
549

    
550
                string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();//
551
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();//
552

    
553
                var (dwgs, totalCnt) = new DocumentController().GetDocuments(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
554

    
555
                this.documents = dwgs.ToList();
556
                this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents));
557
                this.lbSelectAndTotal.Text = totalCnt.ToString();
558

    
559
                List<string> projectCodes = new List<string>();
560

    
561
                if(!string.IsNullOrWhiteSpace(projectCode))
562
                {
563
                    projectCodes.Add(projectCode);
564
                }
565
                else
566
                {
567
                    projectCodes = informations.ProjectList.Select(x => x.Code).ToList();
568
                }
569

    
570
                this.Markups = new List<MarkupText>(new MarkusInfoController().GetMarkupData(projectCodes, this.documents.Select(x => x.DocumentNo)));
571
            }
572
        }
573

    
574
        public void GetDocListbyID2()
575
        {
576
            if (this.radDropDownListProject.SelectedValue != null)
577
            {
578
                string projectCode = this.radDropDownListProject.SelectedValue.ToString();
579
                string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
580
                string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();
581
                string documentNo = this.radTextBoxDocumentNo.Text.Trim();
582

    
583
                string isToIsDiscussion = this.radDropDownListToIsDiscussion.SelectedValue.ToString();
584
                string isFrReviewStatus = this.radDropDownListFrReviewStatus.SelectedValue.ToString();
585
                string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();
586

    
587
                string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();
588
                string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();
589

    
590
                string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();
591
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();
592

    
593
                var id2Prjs = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).Select(x => x.ID2Info).ToList();
594
                var(dwgs, totalCnt) = new DocumentController().GetDocuments(id2Prjs, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
595
                this.documents = dwgs.ToList();
596
                this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents));
597
                this.lbSelectAndTotal.Text = totalCnt.ToString();
598
            }
599
        }
600

    
601
        public void DocumentListBinding()
602
        {
603
            GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
604
            ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
605
            ColProjects.DisplayMember = "Name";
606
            ColProjects.ValueMember = "Code";
607

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

    
611
            GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
612
            ColPersonInCharge.DataSource = workUsers;
613
            ColPersonInCharge.DisplayMember = "Name";
614
            ColPersonInCharge.ValueMember = "ID";
615

    
616
            GridViewComboBoxColumn ColWorker = this.radGridViewDocuments.Columns["Worker"] as GridViewComboBoxColumn;
617
            ColWorker.DataSource = workUsers;
618
            ColWorker.DisplayMember = "Name";
619
            ColWorker.ValueMember = "ID";
620

    
621
            GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
622
            ColToCreator.DataSource = workUsers;
623
            ColToCreator.DisplayMember = "Name";
624
            ColToCreator.ValueMember = "ID";
625

    
626
            GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
627
            ColFrCreator.DataSource = clientUsers;
628
            ColFrCreator.DisplayMember = "Name";
629
            ColFrCreator.ValueMember = "ID";
630

    
631
            GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
632
            ColProdReviewer.DataSource = workUsers;
633
            ColProdReviewer.DisplayMember = "Name";
634
            ColProdReviewer.ValueMember = "ID";
635

    
636
            GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
637
            ColClientReviewer.DataSource = clientUsers;
638
            ColClientReviewer.DisplayMember = "Name";
639
            ColClientReviewer.ValueMember = "ID";
640

    
641
            //Data
642
            if (this.radGridViewDocuments.DataSource != null)
643
                this.radGridViewDocuments.DataSource = null;
644

    
645
            /*
646
            var info = informations.ProjectList.Where(x => x.Name.Equals("APAO")).FirstOrDefault().ID2Info;
647
            var id2Datas = new DocumentController(info).GetID2DrawingsByProject(info);
648
            var test = from doc in this.documents
649
                       join id2 in id2Datas on doc.DocumentNo equals id2.DOCNAME into gj
650
                       from docs in gj.DefaultIfEmpty()
651
                       select new Documents()
652
                       {
653
                           DocumentNo = doc.DocumentNo,
654
                           ID2EndDate = docs?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(docs?.DATETIME)
655
                           //ProdRemarks = docs.DATETIME ?? null
656
                       };
657
            */
658

    
659
            this.radGridViewDocuments.DataSource = new BindingList<Documents>(this.documents);
660

    
661
            if (this.radGridViewDocuments.SummaryRowsBottom != null)
662
                this.radGridViewDocuments.SummaryRowsBottom.Clear();
663

    
664
            string totalCount = String.Format("{0:#,###}", this.documents.Count());
665

    
666
            //Summary
667
            GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem()
668
            {
669
                new GridViewSummaryItem("DocumentNo", "{0:#,###} / " + totalCount, GridAggregateFunction.Count)
670
            };
671
            this.radGridViewDocuments.SummaryRowsBottom.Add(summaryRowItem);
672
            this.radGridViewDocuments.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Bottom;
673
            this.radGridViewDocuments.MasterTemplate.BottomPinnedRowsMode = GridViewBottomPinnedRowsMode.Fixed;
674
        }
675
        #endregion
676

    
677
        #region Button, Checkbox event
678
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
679
        {
680
            if (sender is RadCheckBox)
681
            {
682
                RadCheckBox checkBox = sender as RadCheckBox;
683

    
684
                if (checkBox.Tag != null)
685
                {
686
                    ColumnGroupsViewDefinition columnGroupsView =  this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
687
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
688
                    if (colGroup != null)
689
                        colGroup.IsVisible = checkBox.Checked;
690
                }
691
            }
692

    
693
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
694
        }
695

    
696
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
697
        {
698
            if (e.KeyCode == Keys.Enter)
699
            {
700
                this.radButtonSearch.Focus();
701
                this.radButtonSearch.PerformClick();
702
            }
703
        }
704

    
705
        private void RadButtonSearch_Click(object sender, EventArgs e)
706
        {
707
            this.GetDocList();
708
            this.DocumentListBinding();
709
        }
710

    
711
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
712
        {
713
            using (var frm = new SetupUser())
714
            {
715
                if (frm.ShowDialog(this) == DialogResult.OK)
716
                {
717
                    
718
                }
719
            }
720
        }
721

    
722
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
723
        {
724
            Application.Exit();
725
        }
726
        #endregion
727

    
728
        #region Grid event
729
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
730
        {
731
            if (e.Row is GridViewNewRowInfo)
732
            {
733
                
734
            }
735
            else
736
            {
737
                string extension = string.Empty;
738

    
739
                switch (e.Column.Name)
740
                {
741
                    case "MarkupLink":
742
                        {
743
                            if (e.Row.DataBoundItem is Documents doc)
744
                            {
745
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(informations.ActiveUser.ID))
746
                                {
747
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, informations.ActiveUser.ID);
748
                                }
749
                            }
750
                        }
751
                        break;
752
                    case "AVEVALink":
753
                    case "AVEVAConnection":
754
                        MessageBox.Show($"{e.Column.Name} 실행");
755
                        break;
756
                    case "ReviewFileName"://일단주석
757
                        MessageBox.Show($"{e.Column.Name} 실행");
758
                        break;
759
                    case "SystemLink":
760
                        MessageBox.Show($"{e.Column.Name} 실행");
761
                        break;
762
                    case "ToCapture":
763
                    case "FrCapture":
764

    
765
                        if (e.Row.DataBoundItem is Documents dd)
766
                        {
767
                            using (var frm = new ImageView(dd.DocID))
768
                            {
769
                                frm.ShowDialog(this);
770
                            }
771
                        }
772
                        break;
773
                    case "ID2Connection":
774
                        try
775
                        {
776
                            if (e.Row.DataBoundItem is Documents doc)
777
                            {
778
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port);
779

    
780
                                try
781
                                {
782
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
783
                                    {
784
                                        DocID = doc.DocID,
785
                                        ID2StartDate = DateTime.Now,
786
                                        Worker = informations.ActiveUser.ID
787
                                    }, informations.ActiveUser.ID);
788

    
789
                                    if (returnDoc != null)
790
                                    {
791
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
792
                                        doc.Worker = returnDoc.Worker;
793
                                        doc.ID2JobTime = returnDoc.ID2JobTime;
794
                                    }
795
                                }
796
                                catch { }
797
                            }
798
                        }
799
                        catch (Exception ex)
800
                        {
801
                            if (e.Row.DataBoundItem is Documents doc)
802
                            {
803
                                try
804
                                {
805
                                    var returnDoc = new DocumentController().SetID2Worker(new Documents()
806
                                    {
807
                                        DocID = doc.DocID,
808
                                        ID2StartDate = DateTime.Now,
809
                                        Worker = informations.ActiveUser.ID
810
                                    }, informations.ActiveUser.ID);
811

    
812
                                    if (returnDoc != null)
813
                                    {
814
                                        doc.ID2StartDate = returnDoc.ID2StartDate;
815
                                        doc.Worker = returnDoc.Worker;
816
                                        doc.ID2JobTime = returnDoc.ID2JobTime;
817
                                    }
818
                                }
819
                                catch { }
820
                            }
821

    
822
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
823
                        }
824
                        break;
825
                }
826
            }
827
        }
828

    
829
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
830
        {
831
            if (e.ActiveEditor is RadDropDownListEditor)
832
            {
833
                switch (e.Column.Name)
834
                {
835
                    case "JobLevel":
836
                        GridViewComboBoxColumn colJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
837
                        colJobLevel.DataSource = informations.JobLevel;
838
                        break;
839
                    case "IsTypical":
840
                    case "ToIsDiscussion":
841
                    case "ToIsMarkup":
842
                    case "FrIsMarkup":
843
                    case "IsID2Work":
844
                    case "DTIsImport":
845
                        GridViewComboBoxColumn colYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
846
                        colYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
847
                        break;
848
                    case "DTIsGateWay":
849
                    case "DTIsRegSystem":
850
                        GridViewComboBoxColumn colSuccess = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
851
                        colSuccess.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsSuccess);
852
                        break;
853
                    case "ID2Status":
854
                    case "AVEVAStatus":
855
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
856
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
857
                        break;
858
                    case "FrReviewStatus"://삼성의견status
859
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
860
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
861
                        break;
862
                    case "ProdIsResult":
863
                    case "ClientIsResult":
864
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
865
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
866
                        break;
867
                }
868
            }
869
        }
870

    
871
        private void RadGridViewDocuments_CreateRow(object sender, GridViewCreateRowEventArgs e)
872
        {
873
            if (e.RowType == typeof(GridDetailViewRowElement))
874
            {
875
                //if (e.RowInfo.ChildRows.Count() > 0)
876
                //{
877
                    e.RowElement = new RowDetailViewRowElement();
878
                
879
                //}
880
                //else
881
                //{
882
                //    e.RowElement = null;
883
                //}
884
            }
885
        }
886

    
887

    
888
        private void RadGridViewDocuments_CreateCell1(object sender, GridViewCreateCellEventArgs e)
889
        {
890
            if (e.CellType == typeof(GridDetailViewCellElement))
891
            {
892
                //if (e.Row.RowInfo.ChildRows.Count() > 0)
893
                //{
894
                e.CellElement = new MarkupDetailCellElement(e.Column, e.Row);
895
                //}
896
            }
897
        }
898

    
899

    
900
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
901
        {
902
            if (e.Row is GridViewDataRowInfo)
903
            {
904
                if (e.CellElement is GridRowHeaderCellElement)
905
                {
906
                   // if (e.CellElement.RowIndex > -1)
907
                  //      e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
908
                }
909
                else
910
                {
911
                    var result = e.Row.DataBoundItem as Documents;
912
                    if (result != null || e.Row is GridViewNewRowInfo)
913
                    {
914
                        switch (e.CellElement.ColumnInfo.Name)
915
                        {
916
                            case "AutoCADLink":
917
                            case "PDFLink":
918
                            case "MarkupLink":
919
                            case "AVEVALink":
920
                            case "AVEVAConnection":
921
                            case "ReviewFileName"://일단주석
922
                            case "SystemLink":
923
                            case "ToCapture":
924
                            case "FrCapture":
925
                            case "ID2Connection":
926
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name);
927
                                break;
928
                        }
929
                    }
930
                    else
931
                    {
932

    
933
                    }
934
                }
935
            }
936
            else if (e.Row is GridViewSummaryRowInfo)
937
            {
938
                if (e.CellElement is GridRowHeaderCellElement)
939
                {
940
                    e.CellElement.Text = "Count";
941
                }
942
                else if (e.CellElement is GridSummaryCellElement)
943
                {
944
                    e.CellElement.ForeColor = this._SummaryColor;
945
                    e.CellElement.TextAlignment = ContentAlignment.BottomRight;
946
                    e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
947
                }
948
                else
949
                {
950

    
951
                }
952
            }
953
            else if(e.Row is GridViewDetailsRowInfo)
954
            {
955
                if(e.CellElement is MarkupDetailCellElement element)
956
                {
957
                    //element.UpdateInfo();
958
                }
959
            }
960
            else
961
            {
962

    
963
            }
964
        }
965

    
966
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName)
967
        {
968
            RadButtonElement btnElem = null;
969
            Bitmap bitmap = null; ;
970

    
971
            switch (colName)
972
            {
973
                case "AutoCADLink":
974
                    bitmap = new Bitmap(Properties.Resources.cad18);
975
                    break;
976
                case "PDFLink":
977
                    bitmap = new Bitmap(Properties.Resources.pdf18);
978
                    break;
979
                case "MarkupLink":
980
                    bitmap = new Bitmap(Properties.Resources.markus18);
981
                    break;
982
                case "AVEVALink":
983
                case "AVEVAConnection":
984
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
985
                    break;
986
                case "ReviewFileName"://일단주석
987
                    bitmap = new Bitmap(Properties.Resources.pdf18);
988
                    break;
989
                case "SystemLink":
990
                    bitmap = new Bitmap(Properties.Resources.link18_yellow);
991
                    break;
992
                case "ToCapture":
993
                case "FrCapture":
994
                    bitmap = new Bitmap(Properties.Resources.files18);
995
                    break;
996
                case "ID2Connection":
997
                    bitmap = new Bitmap(Properties.Resources.id218);
998
                    break;
999
            }
1000

    
1001
            switch (colName)
1002
            {
1003
                case "AutoCADLink":
1004
                case "PDFLink":
1005
                case "MarkupLink":
1006
                case "AVEVALink":
1007
                case "AVEVAConnection":
1008
                case "ReviewFileName"://일단주석
1009
                case "SystemLink":
1010
                case "ToCapture":
1011
                case "FrCapture":
1012
                case "ID2Connection":
1013
                    btnElem = (RadButtonElement)elem;
1014
                    btnElem.Margin = new Padding(0);
1015
                    btnElem.Padding = new Padding(0);
1016
                    btnElem.BorderElement.Opacity = 0;
1017
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
1018
                    btnElem.DisplayStyle = DisplayStyle.Image;
1019
                    btnElem.Image = bitmap;
1020
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
1021
                    btnElem.MaxSize = bitmap.Size;
1022
                    break;
1023
            }
1024

    
1025
            return btnElem;
1026
        }
1027
        #endregion
1028

    
1029
        #region Excel
1030
        private UserInfo GetUser(string user)
1031
        {
1032
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
1033
            if (userInfo != null) return userInfo;
1034

    
1035
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
1036
            if (userInfo != null) return userInfo;
1037

    
1038
            return userInfo ?? new UserInfo();
1039
        }
1040

    
1041
        private ProjectInfo GetProject(string project)
1042
        {
1043
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault();
1044
            if (prjInfo != null) return prjInfo;
1045

    
1046
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
1047
            if (prjInfo != null) return prjInfo;
1048

    
1049
            return prjInfo ?? new ProjectInfo();
1050
        }
1051

    
1052
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
1053
        {
1054
            using (OpenFileDialog ofd = new OpenFileDialog()
1055
            {
1056
                Filter = "Excel files (*.xlsx)|*.xlsx",
1057
                Title = "Open an Excel File",
1058
                RestoreDirectory = true
1059
            })
1060
            {
1061
                if (ofd.ShowDialog() == DialogResult.OK)
1062
                {
1063
                    //Error Message
1064
                    StringBuilder sbErrMsg = new StringBuilder();
1065

    
1066
                    var exFile = ExcelFile.Load(ofd.FileName);
1067
                    var ws = exFile.Worksheets[0];
1068

    
1069
                    int rowCount = ws.Rows.Count;
1070
                    int columnCount = ws.CalculateMaxUsedColumns();
1071
                    int exRow = 8;
1072

    
1073
                    #region Excel 유효성검사
1074

    
1075
                    //Excel 포멧체크
1076
                    if (rowCount < 10 || columnCount != 45)
1077
                    {
1078
                        RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1079
                        return;
1080
                    }
1081

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

    
1088
                    if (sbErrMsg.Length > 0)
1089
                    {
1090
                        string errMsg = sbErrMsg.ToString().Substring(2);
1091
                        if (errMsg.Length > 100)
1092
                        {
1093
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1094
                        }
1095

    
1096
                        RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1097
                        return;
1098
                    }
1099
                    #endregion
1100

    
1101
                    #region 엑셀 도명명 중복 값 체크
1102
                    ws.Rows.SelectMany(row => row.AllocatedCells)
1103
                                                 .Where(col => col.Column.Index == 6 && col.Row.Index > exRow)
1104
                                                 .GroupBy(g => g.Row.Index)
1105
                                                 .Select(p => new {
1106
                                                     rowIndex = p.Key,
1107
                                                     docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
1108
                                                 })
1109
                                                 .GroupBy(g => g.docNo)
1110
                                                 .Where(p => p.Count() > 1)
1111
                                                 .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
1112
                                                                                            .Aggregate((x, y) => x.ToString() + "," + y.ToString())
1113
                                                                                            .ToString())
1114
                                                 .ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
1115
                    if (sbErrMsg.Length > 0)
1116
                    {
1117
                        sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
1118
                        string errMsg = sbErrMsg.ToString();
1119
                        if (errMsg.Length > 100)
1120
                        {
1121
                            errMsg = $"{errMsg.Substring(0, 100)}...";
1122
                        }
1123

    
1124
                        RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
1125
                        return;
1126
                    }
1127
                    #endregion
1128

    
1129
                    #endregion
1130

    
1131
                    List<Documents> appendDocuments = new List<Documents>();
1132

    
1133
                    ws.Rows.Where(row => row.Index > exRow)
1134
                           .ToList()
1135
                           .ForEach(p => appendDocuments.Add(new Documents()
1136
                           {
1137
                               //UID = string.Empty,
1138
                               //Type = this.radTextBoxInsulationType.Text,
1139
                               //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
1140
                               //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
1141
                               //NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
1142
                               //Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value)
1143

    
1144
                               RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1145
                               DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
1146
                               PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
1147
                               JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
1148
                               IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
1149
                               RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
1150
                               ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
1151
                               ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
1152
                               ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
1153
                               //ToCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1154
                               //ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1155
                               FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
1156
                               FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
1157
                               FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
1158
                               //FrCapture = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1159
                               //FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1160
                               IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
1161
                               //ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1162
                               ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
1163
                               ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
1164
                               //ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1165
                               ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
1166
                               ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
1167
                               //AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
1168
                               AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
1169
                               AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
1170
                               AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
1171
                               AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
1172
                               ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
1173
                               ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
1174
                               ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
1175
                               ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
1176
                               ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
1177
                               ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
1178
                               DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
1179
                               DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
1180
                               DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
1181
                               DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
1182
                           }));
1183

    
1184
                    this.documents.AddRange(appendDocuments);
1185
                    if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
1186
                    this.DocumentListBinding();
1187

    
1188
                    //foreach (Documents appDoc in appendDocuments)
1189
                    //{
1190
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
1191

    
1192
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1193
                    //    {
1194
                    //        if (fieldInfo.GetValue(appDoc) != null)
1195
                    //        {
1196
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
1197

    
1198
                    //            if (cols.Any())
1199
                    //            {
1200
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
1201
                    //            }
1202
                    //        }
1203
                    //    }
1204
                    //}
1205
                }
1206
            }
1207
        }
1208

    
1209
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
1210
        {
1211
            string sPrefixName = "Samsung Elec Task Management";
1212
            string extension = ".xlsx";
1213

    
1214
            using (SaveFileDialog sfd = new SaveFileDialog()
1215
            {
1216
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
1217
                Filter = "Excel|*.xlsx",
1218
                Title = "Save an Excel File",
1219
                CheckFileExists = false,
1220
                CheckPathExists = true,
1221
                OverwritePrompt = true
1222
            })
1223
            {
1224
                if (sfd.ShowDialog() == DialogResult.OK)
1225
                {
1226
                    string fileName = $"{sPrefixName}{extension}";
1227
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
1228
                    string templateFilePath = Path.Combine(templateFolder, fileName);
1229
                    if (!File.Exists(templateFilePath))
1230
                    {
1231
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
1232
                        return;
1233
                    }
1234

    
1235
                    if (this.radGridViewDocuments.Rows.Count > 0)
1236
                    {
1237
                        var templateExcelFile = ExcelFile.Load(templateFilePath);
1238
                        var templateWorksheets = templateExcelFile.Worksheets;
1239
                        var templateWorksheet = templateWorksheets[0];
1240

    
1241
                        int rowIndex = 9;
1242
                        //int colIndex = 1;
1243

    
1244
                        foreach (var row in this.radGridViewDocuments.Rows)
1245
                        {
1246
                            var doc = row.DataBoundItem as Documents;
1247

    
1248
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
1249
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
1250
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
1251
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
1252
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
1253
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
1254
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
1255
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
1256
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
1257
                            templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
1258
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
1259
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
1260
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
1261
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
1262
                            templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapture;
1263
                            templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
1264
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
1265
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
1266
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
1267
                            templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapture;
1268
                            templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
1269
                            templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
1270
                            templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
1271
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
1272
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
1273
                            templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
1274
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
1275
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
1276
                            templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
1277
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
1278
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
1279
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
1280
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
1281
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
1282
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
1283
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
1284
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
1285
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
1286
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
1287
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
1288
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
1289
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
1290
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
1291
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
1292
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
1293
                            rowIndex++;
1294
                        }
1295

    
1296
                        templateExcelFile.Save(sfd.FileName);
1297
                        RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1298
                    }
1299
                }
1300
            }
1301
        }
1302
        #endregion
1303

    
1304
        #region Save event
1305

    
1306
        private void SetSaved()
1307
        {
1308
            if (RadMessageBox.Show("Do you want to Save?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1309
            {
1310
                List<Documents> setDocuments = new List<Documents>();
1311
                List<Documents> delDocuments = new List<Documents>();
1312

    
1313
                var worker = new DocumentsWorker(this.documents, this.orgDocuments, setDocuments, delDocuments, this.radGridViewDocuments);
1314
                worker.OnWorkCompletedHandler += () =>
1315
                {
1316
                    bool result = new DocumentController().SetDocumentData(setDocuments, delDocuments, informations.ActiveUser.ID);
1317

    
1318
                    bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1319

    
1320
                    var users = new UserController().GetAllUserInfo();
1321

    
1322
                    bool markusMembersResult = new MarkusInfoController().SetMembers(users);
1323

    
1324
                    if (result && markusResult && markusMembersResult)
1325
                    {
1326
                        RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1327

    
1328
                        this.GetDocList();
1329
                    }
1330
                    else if (!result)
1331
                    {
1332
                        RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1333
                    }
1334
                    else if (!markusResult)
1335
                    {
1336
                        RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1337
                    }
1338
                    else if (!markusMembersResult)
1339
                    {
1340
                        RadMessageBox.Show("Markus Members Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1341
                    }
1342
                };
1343
                worker.StartWork();
1344
            }
1345
        }
1346

    
1347
        private void RadButtonElementSaveCommand_Click(object sender, EventArgs e)
1348
        {
1349
            try
1350
            {
1351
                this.SetSaved();
1352
            }
1353
            catch (Exception ex)
1354
            {
1355
                Program.logger.Error(ex);
1356
            }
1357
        }
1358

    
1359
        private void RadButtonElementSave_Click(object sender, EventArgs e)
1360
        {
1361
            try
1362
            {
1363
                this.SetSaved();
1364
            }
1365
            catch (Exception ex)
1366
            {
1367
                Program.logger.Error(ex);
1368
            }
1369
        }
1370

    
1371
        private void RadButtonElementSync_Click(object sender, EventArgs e)
1372
        {
1373
            if (RadMessageBox.Show("Do you want to ID2 Sync?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
1374
            {
1375
                var id2Prjs = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).Select(x => x.ID2Info).ToList();
1376

    
1377
                bool result = new DocumentController().SetID2Sync(id2Prjs, informations.ActiveUser.ID);
1378

    
1379
                if (result)
1380
                {
1381
                    this.GetDocListbyID2();
1382
                    this.DocumentListBinding();
1383
                }
1384
            }
1385
        }
1386

    
1387
        private void RadButtonElementRefreshCommand_Click(object sender, EventArgs e)
1388
        {
1389
            RadMessageBox.Show("Refresh click!!", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1390
        }
1391
        #endregion
1392

    
1393
        #region ColumnGroup
1394
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
1395
        {
1396
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
1397

    
1398
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" };
1399
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "DocumentNo", "PersonInCharge", "Worker", "JobLevel", "IsTypical", "RevisonNo" };
1400
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapture", "ToIsMarkup" };
1401
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapture", "FrIsMarkup" };
1402
            List<string> rvEtcColNames = new List<string>() { "IsID2Work" };
1403
            List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" };
1404
            List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" };
1405
            List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" };
1406
            List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks" };
1407
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" };
1408
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
1409

    
1410
            //도면
1411
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 ");
1412
            GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크");
1413
            GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보");
1414

    
1415
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
1416
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
1417

    
1418
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
1419
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
1420

    
1421
            docLinkColGrp.Rows.Add(docLinkColGrpRow);
1422
            docColGrp.Groups.Add(docLinkColGrp);
1423
            docInfoColGrp.Rows.Add(docInfoColGrpRow);
1424
            docColGrp.Groups.Add(docInfoColGrp);
1425

    
1426
            //검토
1427
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
1428
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
1429
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
1430
            GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타");
1431

    
1432
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
1433
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
1434

    
1435
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
1436
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
1437

    
1438
            GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow();
1439
            rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames);
1440

    
1441
            rvToColGrp.Rows.Add(rvToColGrpRow);
1442
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
1443
            rvEtcColGrp.Rows.Add(rvEtcColGrpRow);
1444

    
1445

    
1446
            rvColGrp.Groups.Add(rvToColGrp);
1447
            rvColGrp.Groups.Add(rvFrColGrp);
1448
            rvColGrp.Groups.Add(rvEtcColGrp);
1449

    
1450

    
1451
            //작업
1452
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
1453
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
1454
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
1455

    
1456
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
1457
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
1458

    
1459
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
1460
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
1461

    
1462
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
1463
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
1464

    
1465
            wkColGrp.Groups.Add(wkID2ColGrp);
1466
            wkColGrp.Groups.Add(wkAVEVAColGrp);
1467

    
1468

    
1469
            //Validation
1470
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
1471
            GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크");
1472
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
1473
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
1474

    
1475
            GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow();
1476
            valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames);
1477

    
1478
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
1479
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
1480

    
1481
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
1482
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
1483

    
1484
            valLinkColGrp.Rows.Add(valLinkColGrpRow);
1485
            valProdColGrp.Rows.Add(valProdColGrpRow);
1486
            valCntColGrp.Rows.Add(valCntColGrpRow);
1487

    
1488
            valColGrp.Groups.Add(valLinkColGrp);
1489
            valColGrp.Groups.Add(valProdColGrp);
1490
            valColGrp.Groups.Add(valCntColGrp);
1491

    
1492
            //AVEVA Net
1493
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
1494

    
1495
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
1496
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
1497

    
1498
            dtColGrp.Rows.Add(dtColGrpRow);
1499

    
1500
            //Group 추가
1501
            columnGroupsView.ColumnGroups.Add(docColGrp);
1502
            columnGroupsView.ColumnGroups.Add(rvColGrp);
1503
            columnGroupsView.ColumnGroups.Add(wkColGrp);
1504
            columnGroupsView.ColumnGroups.Add(valColGrp);
1505
            columnGroupsView.ColumnGroups.Add(dtColGrp);
1506

    
1507
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
1508
        }
1509
        #endregion
1510

    
1511
        class DocumentsWorker : BaseWorker
1512
        {
1513
            public delegate void OnWorkCompleted();
1514
            public OnWorkCompleted OnWorkCompletedHandler;
1515

    
1516
            List<Documents> docList { get; set; }
1517
            List<Documents> orgList { get; set; }
1518
            List<Documents> setList { get; set; }
1519
            List<Documents> delList { get; set; }
1520

    
1521
            public DocumentsWorker(List<Documents> docList, List<Documents> orgDocList, List<Documents> setDocList, List<Documents> delDocList, Control parent = null) : base(parent)
1522
            {
1523
                this.docList = docList;
1524
                this.orgList = orgDocList;
1525
                this.setList = setDocList;
1526
                this.delList = delDocList;
1527
            }
1528
            protected override void DoWork(BackgroundWorker worker)
1529
            {
1530
                //수정리스트
1531
                this.docList.Where(x => !this.orgList.Any(y => y.Equals(x)))
1532
                              .ToList().ForEach(x => this.setList.Add(x));
1533
                //삭제리스트
1534
                this.delList.AddRange(this.orgList.Except(this.docList, new DocumentsKeyComparer()));
1535
            }
1536

    
1537
            protected override void WorkCompleted()
1538
            {
1539
                if (this.OnWorkCompletedHandler != null) this.OnWorkCompletedHandler();
1540
            }
1541
        }
1542

    
1543
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
1544
        {
1545
            if(string.IsNullOrWhiteSpace(txtFullSearch.Text))
1546
                radGridViewDocuments.MasterTemplate.Refresh(null);
1547

    
1548
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
1549
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
1550
        }
1551

    
1552
        private void btnSearchPrevious_Click(object sender, EventArgs e)
1553
        {
1554
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
1555
        }
1556

    
1557
        private void btnSearchNext_Click(object sender, EventArgs e)
1558
        {
1559
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
1560
        }
1561

    
1562
        private void txtFullSearch_KeyDown(object sender, KeyEventArgs e)
1563
        {
1564
            if(e.KeyCode == Keys.Enter)
1565
            {
1566
                radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
1567
            }
1568
        }
1569
    }
1570
}
1571

    
1572
public class FilterColumn
1573
{
1574
    public string Name { get; set; }
1575
    public string FieldName { get; set; }
1576
    public bool IsSelect { get; set; }
1577
}
클립보드 이미지 추가 (최대 크기: 500 MB)