markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / ConvertExcelDialogViewModel.cs @ f25fc1d9
이력 | 보기 | 이력해설 | 다운로드 (5.6 KB)
1 | 037ab674 | semi | using Markus.Service.StationController.Data; |
---|---|---|---|
2 | using Markus.Service.StationController.Extensions; |
||
3 | using System.Collections.Generic; |
||
4 | using Microsoft.Win32; |
||
5 | using Telerik.Windows.Controls; |
||
6 | using System.Collections.ObjectModel; |
||
7 | |||
8 | namespace Markus.Service.StationController.ViewModel |
||
9 | { |
||
10 | class ConvertExcelDialogViewModel : Mvvm.ToolKit.ViewModelBase |
||
11 | { |
||
12 | #region Construrtor |
||
13 | |||
14 | public ConvertExcelDialogViewModel() |
||
15 | { |
||
16 | ALL_SelectedCommand = new DelegateCommand(ALL_Selected); |
||
17 | ALL_DeletedCommand = new DelegateCommand(ALL_Deleted); |
||
18 | SaveCommand = new DelegateCommand(Save); |
||
19 | } |
||
20 | |||
21 | #endregion |
||
22 | |||
23 | #region Propertise |
||
24 | |||
25 | public ObservableCollection<CheckBoxItem> _ItemsSource; |
||
26 | public ObservableCollection<CheckBoxItem> ItemsSource |
||
27 | { |
||
28 | get |
||
29 | { |
||
30 | if (_ItemsSource == null) |
||
31 | { |
||
32 | ItemsSource = new ObservableCollection<CheckBoxItem> |
||
33 | { |
||
34 | new CheckBoxItem { IsChecked=true, Name="ServiceID"}, |
||
35 | new CheckBoxItem { IsChecked=true, Name="ConvertID"}, |
||
36 | new CheckBoxItem { IsChecked=true, Name="ProjectNumber"}, |
||
37 | new CheckBoxItem { IsChecked=true, Name="ConvertState"}, |
||
38 | new CheckBoxItem { IsChecked=true, Name="CurrentPageNo"}, |
||
39 | new CheckBoxItem { IsChecked=true, Name="TotalPage"}, |
||
40 | new CheckBoxItem { IsChecked=true, Name="OriginfilePath"}, |
||
41 | new CheckBoxItem { IsChecked=true, Name="ConvertPath"}, |
||
42 | new CheckBoxItem { IsChecked=true, Name="CreateTime"}, |
||
43 | new CheckBoxItem { IsChecked=true, Name="StartTime"}, |
||
44 | new CheckBoxItem { IsChecked=true, Name="EndTime"}, |
||
45 | new CheckBoxItem { IsChecked=true, Name="Exception"}, |
||
46 | new CheckBoxItem { IsChecked=true, Name="ReConverter"}, |
||
47 | new CheckBoxItem { IsChecked=true, Name="Revision"}, |
||
48 | new CheckBoxItem { IsChecked=true, Name="UniqueKey"}, |
||
49 | 19d6b221 | semi | new CheckBoxItem { IsChecked=true, Name="GroupNo"}, |
50 | new CheckBoxItem { IsChecked=true, Name="DocumentNo"}, |
||
51 | new CheckBoxItem { IsChecked=true, Name="DocumentName"}, |
||
52 | new CheckBoxItem { IsChecked=true, Name="DocumnetURL"}, |
||
53 | new CheckBoxItem { IsChecked=true, Name="MarkusLink"} |
||
54 | 037ab674 | semi | }; |
55 | } |
||
56 | |||
57 | return _ItemsSource; |
||
58 | } |
||
59 | set |
||
60 | { |
||
61 | _ItemsSource = value; |
||
62 | OnPropertyChanged(() => ExcelSource); |
||
63 | } |
||
64 | } |
||
65 | private System.Collections.ObjectModel.ObservableCollection<ConvertPDF> _ExcelSource; |
||
66 | public System.Collections.ObjectModel.ObservableCollection<ConvertPDF> ExcelSource |
||
67 | { |
||
68 | get |
||
69 | { |
||
70 | if (_ExcelSource == null) |
||
71 | { |
||
72 | _ExcelSource = new System.Collections.ObjectModel.ObservableCollection<ConvertPDF>(); |
||
73 | _ExcelSource = DataBaseItemsModel.Return_FilterConvertSource(); |
||
74 | } |
||
75 | return _ExcelSource; |
||
76 | } |
||
77 | set |
||
78 | { |
||
79 | _ExcelSource = value; |
||
80 | OnPropertyChanged(() => ExcelSource); |
||
81 | } |
||
82 | } |
||
83 | |||
84 | #endregion |
||
85 | |||
86 | #region Command |
||
87 | |||
88 | public DelegateCommand ALL_SelectedCommand { get; private set; } |
||
89 | public DelegateCommand ALL_DeletedCommand { get; private set; } |
||
90 | public DelegateCommand SaveCommand { get; private set; } |
||
91 | |||
92 | #endregion |
||
93 | |||
94 | #region Fuction |
||
95 | |||
96 | #region ALL_Selected |
||
97 | |||
98 | public void ALL_Selected(object obj) |
||
99 | { |
||
100 | foreach(var ItemsSource in ItemsSource) |
||
101 | { |
||
102 | ItemsSource.IsChecked = true; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | #endregion |
||
107 | |||
108 | #region ALL_Deleted |
||
109 | |||
110 | public void ALL_Deleted(object obj) |
||
111 | { |
||
112 | foreach (var ItemsSource in ItemsSource) |
||
113 | { |
||
114 | ItemsSource.IsChecked = false; |
||
115 | } |
||
116 | } |
||
117 | |||
118 | #endregion |
||
119 | |||
120 | #region Save |
||
121 | |||
122 | public void Save(object obj) |
||
123 | { |
||
124 | SaveFileDialog saveFileDialog = new SaveFileDialog(); |
||
125 | |||
126 | 50b63148 | semi | saveFileDialog.FileName = "Document"; |
127 | saveFileDialog.DefaultExt = ".txt"; |
||
128 | saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; |
||
129 | 037ab674 | semi | |
130 | if (saveFileDialog.ShowDialog() == true) |
||
131 | { |
||
132 | if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName)) |
||
133 | { |
||
134 | var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension; |
||
135 | |||
136 | if (extension == ".xlsx" || extension == ".csv") |
||
137 | { |
||
138 | List<HeaderMember> headers = new List<HeaderMember>(); |
||
139 | foreach(var ItemsSource in ItemsSource) |
||
140 | { |
||
141 | if (ItemsSource.IsChecked == true) |
||
142 | { |
||
143 | headers.Add(new HeaderMember { HeaderName = ItemsSource.Name, Property = ItemsSource.Name }); |
||
144 | } |
||
145 | } |
||
146 | |||
147 | DataExport dataExport = new DataExport(); |
||
148 | dataExport.DataExportExcel(saveFileDialog.FileName, "Convert PDF", ExcelSource, headers); |
||
149 | } |
||
150 | } |
||
151 | } |
||
152 | } |
||
153 | |||
154 | #endregion |
||
155 | |||
156 | #endregion |
||
157 | |||
158 | } |
||
159 | } |