hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ dec3a5e2
이력 | 보기 | 이력해설 | 다운로드 (37.8 KB)
1 | 96a2080c | gaqhf | 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 | using Microsoft.VisualBasic; |
||
11 | 1278ba59 | gaqhf | using DevExpress.XtraEditors.Repository; |
12 | using DevExpress.XtraEditors.Controls; |
||
13 | using DevExpress.XtraEditors; |
||
14 | 23eb98bf | gaqhf | using System.Globalization; |
15 | using System.Threading; |
||
16 | using System.IO; |
||
17 | d19ae675 | gaqhf | using Ingr.RAD2D; |
18 | using Converter.BaseModel; |
||
19 | b8e2644e | gaqhf | using Converter.SPPID.Properties; |
20 | using Converter.SPPID.DB; |
||
21 | using Converter.SPPID.Util; |
||
22 | using Converter.SPPID.Form; |
||
23 | using Converter.SPPID.Model; |
||
24 | 4d4dce52 | esham21 | using Plaice; |
25 | using Llama; |
||
26 | ea54adc8 | gaqhf | |
27 | 96a2080c | gaqhf | |
28 | b8e2644e | gaqhf | namespace Converter.SPPID |
29 | 96a2080c | gaqhf | { |
30 | public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
||
31 | { |
||
32 | bca86986 | gaqhf | private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
33 | 4314b3f3 | gaqhf | private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
34 | public List<SPPID_Document> Documents { get { return _Documents; } } |
||
35 | bca86986 | gaqhf | private DataTable _ConverterDT = new DataTable(); |
36 | private DataTable _SPPIDSymbolPathDT = new DataTable(); |
||
37 | 635a8747 | gaqhf | private DataTable _SPPIDUnitDT = new DataTable(); |
38 | e88aae98 | gaqhf | private DataTable _SPPIDAttributeDT = new DataTable(); |
39 | 23eb98bf | gaqhf | private RepositoryItemComboBox templateComboBox; |
40 | 4f0c0ed6 | gaqhf | private RepositoryItemComboBox bulkRuleComboBox; |
41 | 23eb98bf | gaqhf | |
42 | bca86986 | gaqhf | |
43 | private DataTable _ID2SymbolDT = new DataTable(); |
||
44 | 4b4dbca9 | gaqhf | private DataTable _ID2ChildSymbolDT = new DataTable(); |
45 | bca86986 | gaqhf | private DataTable _ID2LineDT = new DataTable(); |
46 | 1efc25a3 | gaqhf | private DataTable _ID2AttributeDT = new DataTable(); |
47 | 306a0af9 | gaqhf | private DataTable _ID2DrawingAttributeDT = new DataTable(); |
48 | bca86986 | gaqhf | private DataTable _ID2LinePropertyDT = new DataTable(); |
49 | f1c9dbaa | gaqhf | private DataTable _ID2SymbolTypeDT = new DataTable(); |
50 | 4d2571ab | gaqhf | private DataTable _ID2SymbolTable = new DataTable(); |
51 | f1c9dbaa | gaqhf | |
52 | bca86986 | gaqhf | |
53 | private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
||
54 | 4b4dbca9 | gaqhf | private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>(); |
55 | bca86986 | gaqhf | private List<LineMapping> lineMappings = new List<LineMapping>(); |
56 | private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
||
57 | 1efc25a3 | gaqhf | private List<AttributeMapping> attributeMappings = new List<AttributeMapping>(); |
58 | bca86986 | gaqhf | |
59 | ea54adc8 | gaqhf | string TemplatePath; |
60 | |||
61 | 96a2080c | gaqhf | public ConverterForm() |
62 | { |
||
63 | InitializeComponent(); |
||
64 | 1278ba59 | gaqhf | |
65 | 523f5fe3 | gaqhf | CultureInfo culture = CultureInfo.GetCultureInfo("en"); |
66 | b048c104 | gaqhf | Msg.Culture = culture; |
67 | 23eb98bf | gaqhf | |
68 | ea54adc8 | gaqhf | this._SPPIDUnitDT = SPPIDUtil.GetUnitInfo(); |
69 | TemplatePath = SPPIDUtil.T_OPTIONSETTING_Value("PID Template Path"); |
||
70 | |||
71 | bca86986 | gaqhf | InitUsedDataTable(); |
72 | 1278ba59 | gaqhf | InitGridControl(); |
73 | fab4f207 | gaqhf | InitID2Project(); |
74 | 0632775b | gaqhf | |
75 | // |
||
76 | 0760d1ad | gaqhf | //labelID2ProjectName.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
77 | //labelDBType.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
78 | //labelID2ProjectStatus.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
79 | //labelSPPIDPlantName.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
80 | //labelSPPIDDBStatus.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
81 | //labelItemMappingStatus.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
82 | 1278ba59 | gaqhf | } |
83 | |||
84 | bca86986 | gaqhf | private void InitUsedDataTable() |
85 | 1278ba59 | gaqhf | { |
86 | bca86986 | gaqhf | // Converter Table |
87 | DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
||
88 | 1278ba59 | gaqhf | col.Caption = "Drawing File Name"; |
89 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
90 | 0d8062b2 | gaqhf | col.Caption = "DrawingFilePath"; |
91 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUnit"); |
92 | 1278ba59 | gaqhf | col.Caption = "Unit"; |
93 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colTemplate"); |
94 | 1278ba59 | gaqhf | col.Caption = "Template"; |
95 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingNumber"); |
96 | 1278ba59 | gaqhf | col.Caption = "Drawing Number"; |
97 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingName"); |
98 | 1278ba59 | gaqhf | col.Caption = "Drawing Name"; |
99 | 4f0c0ed6 | gaqhf | col = _ConverterDT.Columns.Add("colRuleName"); |
100 | col.Caption = "Bulk Rule Name"; |
||
101 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colStatus"); |
102 | 1278ba59 | gaqhf | col.Caption = "Status"; |
103 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUID"); |
104 | |||
105 | col = _ID2LineDT.Columns.Add("UID"); |
||
106 | col = _ID2LineDT.Columns.Add("Name"); |
||
107 | col.Caption = "Name"; |
||
108 | col = _ID2LineDT.Columns.Add("Type"); |
||
109 | col.Caption = "Type"; |
||
110 | col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH"); |
||
111 | col.Caption = "SPPID Symbol Path"; |
||
112 | col = _ID2LineDT.Columns.Add("Clear"); |
||
113 | col.Caption = ""; |
||
114 | } |
||
115 | |||
116 | private void InitGridControl() |
||
117 | { |
||
118 | #region Converter Page |
||
119 | gridViewConverter.OptionsSelection.MultiSelect = true; |
||
120 | gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
||
121 | |||
122 | gridControlConverter.DataSource = _ConverterDT; |
||
123 | 1278ba59 | gaqhf | |
124 | templateComboBox = new RepositoryItemComboBox(); |
||
125 | templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
126 | 635a8747 | gaqhf | templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
127 | 1278ba59 | gaqhf | gridControlConverter.RepositoryItems.Add(templateComboBox); |
128 | gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
||
129 | |||
130 | 4f0c0ed6 | gaqhf | bulkRuleComboBox = new RepositoryItemComboBox(); |
131 | bulkRuleComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
132 | bulkRuleComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
||
133 | gridControlConverter.RepositoryItems.Add(bulkRuleComboBox); |
||
134 | gridViewConverter.Columns["colRuleName"].ColumnEdit = bulkRuleComboBox; |
||
135 | |||
136 | 635a8747 | gaqhf | gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
137 | 1278ba59 | gaqhf | gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
138 | gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
||
139 | gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
||
140 | 0d8062b2 | gaqhf | gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
141 | 1278ba59 | gaqhf | gridViewConverter.Columns["colUID"].Visible = false; |
142 | |||
143 | gridViewConverter.BestFitColumns(); |
||
144 | #endregion |
||
145 | } |
||
146 | f1c9dbaa | gaqhf | |
147 | 635a8747 | gaqhf | private void templateComboBox_EditValueChanged(object sender, EventArgs e) |
148 | { |
||
149 | gridViewConverter.CloseEditor(); |
||
150 | gridViewConverter.UpdateCurrentRow(); |
||
151 | } |
||
152 | |||
153 | private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
||
154 | { |
||
155 | 4f0c0ed6 | gaqhf | if (e.Column.Name == "colcolTemplate" || e.Column.Name == "colcolRuleName") |
156 | 635a8747 | gaqhf | { |
157 | gridViewConverter.ShowEditor(); |
||
158 | (gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup(); |
||
159 | } |
||
160 | else if (e.Column.Name == "colcolUnit") |
||
161 | { |
||
162 | UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
||
163 | if (unitForm.ShowDialog() == DialogResult.OK) |
||
164 | { |
||
165 | gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit); |
||
166 | gridViewConverter.CloseEditor(); |
||
167 | gridViewConverter.UpdateCurrentRow(); |
||
168 | } |
||
169 | } |
||
170 | } |
||
171 | 1278ba59 | gaqhf | |
172 | 8847ea67 | gaqhf | private void btnID2DB_Click(object sender, EventArgs e) |
173 | 23eb98bf | gaqhf | { |
174 | 8847ea67 | gaqhf | ID2DBSetting form = new ID2DBSetting(); |
175 | e7427d3c | gaqhf | DialogResult dialogResult = form.ShowDialog(); |
176 | 8847ea67 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
177 | _ProjectInfo.DefaultPath = Settings.Default.ProjectPath; |
||
178 | _ProjectInfo.DBType = (ID2DB_Type)Settings.Default.ProjectDBType; |
||
179 | _ProjectInfo.ServerIP = Settings.Default.ProjectServerIP; |
||
180 | _ProjectInfo.Port = Settings.Default.ProjectPort; |
||
181 | _ProjectInfo.DBUser = Settings.Default.ProjectDBUser; |
||
182 | _ProjectInfo.DBPassword = Settings.Default.ProjectDBPassword; |
||
183 | |||
184 | e7427d3c | gaqhf | if (dialogResult == DialogResult.OK) |
185 | 23eb98bf | gaqhf | { |
186 | fab4f207 | gaqhf | if (InitID2Project()) |
187 | MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
188 | else |
||
189 | 23eb98bf | gaqhf | MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
190 | } |
||
191 | } |
||
192 | |||
193 | fab4f207 | gaqhf | private bool InitID2Project() |
194 | 23eb98bf | gaqhf | { |
195 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
196 | fab4f207 | gaqhf | if (Project_DB.ConnTestAndCreateTable()) |
197 | 23eb98bf | gaqhf | { |
198 | fab4f207 | gaqhf | _ProjectInfo.Enable = true; |
199 | 8847ea67 | gaqhf | labelDBType.Text = _ProjectInfo.DBType.ToString(); |
200 | labelDBType.AppearanceItemCaption.ForeColor = Color.Blue; |
||
201 | 23eb98bf | gaqhf | labelID2ProjectName.Text = _ProjectInfo.Name; |
202 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
203 | labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
||
204 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
205 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
206 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
||
207 | 23eb98bf | gaqhf | } |
208 | else |
||
209 | { |
||
210 | fab4f207 | gaqhf | _ProjectInfo.Enable = false; |
211 | da84b14b | gaqhf | labelDBType.Text = " "; |
212 | 23eb98bf | gaqhf | labelID2ProjectName.Text = " "; |
213 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
||
214 | labelID2ProjectStatus.Text = Msg.ConnectionFail; |
||
215 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
216 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
217 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
218 | bca86986 | gaqhf | } |
219 | fab4f207 | gaqhf | |
220 | bca86986 | gaqhf | InitMapping(); |
221 | InitSPPIDDB(); |
||
222 | |||
223 | return _ProjectInfo.Enable; |
||
224 | } |
||
225 | |||
226 | private void InitMapping() |
||
227 | { |
||
228 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
229 | if (_ProjectInfo.Enable) |
||
230 | { |
||
231 | 4d2571ab | gaqhf | if (_ID2SymbolTable != null) |
232 | { |
||
233 | _ID2SymbolTable.Dispose(); |
||
234 | _ID2SymbolTable = null; |
||
235 | } |
||
236 | _ID2SymbolTable = Project_DB.SelectID2SymbolTable(); |
||
237 | 7e680366 | gaqhf | |
238 | if (_ID2SymbolTypeDT != null) |
||
239 | { |
||
240 | _ID2SymbolTypeDT.Dispose(); |
||
241 | _ID2SymbolTypeDT = null; |
||
242 | } |
||
243 | _ID2SymbolTypeDT = Project_DB.SelectSymbolType(); |
||
244 | bca86986 | gaqhf | InitID2Symbol(); |
245 | InitID2Line(); |
||
246 | InitID2LineNumber(); |
||
247 | 1efc25a3 | gaqhf | InitID2Attribute(); |
248 | 306a0af9 | gaqhf | InitID2DrawingAttribute(); |
249 | e00e891d | gaqhf | |
250 | InitETCSetting(); |
||
251 | } |
||
252 | } |
||
253 | fbdb9f2a | gaqhf | |
254 | e00e891d | gaqhf | private void InitETCSetting() |
255 | { |
||
256 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
257 | if (_ProjectInfo.Enable) |
||
258 | { |
||
259 | 7cbb1038 | gaqhf | DataTable dt = Project_DB.SelectSetting(); |
260 | foreach (DataRow item in dt.Rows) |
||
261 | { |
||
262 | string settingType = item["SettingType"].ToString(); |
||
263 | if (settingType == "ETCSetting") |
||
264 | SPPIDUtil.ConvertToETCSetting(item["JsonString"].ToString()); |
||
265 | else if (settingType == "GridSetting") |
||
266 | SPPIDUtil.ConvertToGridSetting(item["JsonString"].ToString()); |
||
267 | } |
||
268 | bca86986 | gaqhf | } |
269 | } |
||
270 | |||
271 | private void InitID2Symbol() |
||
272 | { |
||
273 | using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
||
274 | { |
||
275 | symbolMappings.Clear(); |
||
276 | _ID2SymbolDT = symbolDT; |
||
277 | _ID2SymbolDT.Columns.Add("Clear"); |
||
278 | _ID2SymbolDT.Columns["Clear"].Caption = ""; |
||
279 | foreach (DataRow row in symbolDT.Rows) |
||
280 | { |
||
281 | symbolMappings.Add(new SymbolMapping() |
||
282 | { |
||
283 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
284 | SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
285 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
286 | cf924377 | gaqhf | LEADERLINE = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"] |
287 | bca86986 | gaqhf | }); |
288 | } |
||
289 | 4b4dbca9 | gaqhf | |
290 | MergeID2ChildSymbol(); |
||
291 | } |
||
292 | } |
||
293 | |||
294 | private void MergeID2ChildSymbol() |
||
295 | { |
||
296 | using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol()) |
||
297 | { |
||
298 | childSymbolMappings.Clear(); |
||
299 | _ID2ChildSymbolDT = childSymbolDT; |
||
300 | _ID2ChildSymbolDT.Columns.Add("Clear"); |
||
301 | _ID2ChildSymbolDT.Columns["Clear"].Caption = ""; |
||
302 | foreach (DataRow row in childSymbolDT.Rows) |
||
303 | { |
||
304 | childSymbolMappings.Add(new ChildSymbolMapping() |
||
305 | { |
||
306 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
307 | SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
308 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
309 | }); |
||
310 | } |
||
311 | |||
312 | _ID2SymbolDT.Merge(_ID2ChildSymbolDT); |
||
313 | bca86986 | gaqhf | } |
314 | } |
||
315 | |||
316 | private void InitID2Line() |
||
317 | { |
||
318 | using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
||
319 | { |
||
320 | lineMappings.Clear(); |
||
321 | _ID2LineDT.Rows.Clear(); |
||
322 | foreach (DataRow row in lineTypes.Rows) |
||
323 | { |
||
324 | DataRow newRow = _ID2LineDT.NewRow(); |
||
325 | newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
||
326 | newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
||
327 | newRow["Type"] = "Line"; |
||
328 | newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
||
329 | _ID2LineDT.Rows.Add(newRow); |
||
330 | |||
331 | lineMappings.Add(new LineMapping() |
||
332 | { |
||
333 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
334 | LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
335 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
336 | }); |
||
337 | } |
||
338 | } |
||
339 | } |
||
340 | |||
341 | private void InitID2LineNumber() |
||
342 | { |
||
343 | using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
||
344 | { |
||
345 | lineNumberMappings.Clear(); |
||
346 | _ID2LinePropertyDT = linePropertiesDT; |
||
347 | _ID2LinePropertyDT.Columns.Add("Type"); |
||
348 | foreach (DataRow row in linePropertiesDT.Rows) |
||
349 | { |
||
350 | row["Type"] = "Line Property"; |
||
351 | lineNumberMappings.Add(new LineNumberMapping() |
||
352 | { |
||
353 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
354 | DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
||
355 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
356 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
||
357 | }); |
||
358 | } |
||
359 | } |
||
360 | } |
||
361 | |||
362 | 1efc25a3 | gaqhf | private void InitID2Attribute() |
363 | bca86986 | gaqhf | { |
364 | 1efc25a3 | gaqhf | using (DataTable attributeDT = Project_DB.SelectProjectAttribute()) |
365 | bca86986 | gaqhf | { |
366 | 1efc25a3 | gaqhf | attributeMappings.Clear(); |
367 | _ID2AttributeDT = attributeDT; |
||
368 | _ID2AttributeDT.Columns.Add("Clear"); |
||
369 | _ID2AttributeDT.Columns["Clear"].Caption = ""; |
||
370 | foreach (DataRow row in attributeDT.Rows) |
||
371 | bca86986 | gaqhf | { |
372 | 1efc25a3 | gaqhf | attributeMappings.Add(new AttributeMapping() |
373 | bca86986 | gaqhf | { |
374 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
375 | DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
||
376 | Type = row["Type"] == null ? "" : row["Type"].ToString(), |
||
377 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
378 | 1a3a74a8 | gaqhf | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
379 | 1ba9c671 | gaqhf | Location = DBNull.Value.Equals(row["LOCATION"]) ? Model.Location.None : (Location)row["LOCATION"], |
380 | 1ecaaba8 | gaqhf | LeaderLine = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"], |
381 | IsText = DBNull.Value.Equals(row["ISTEXT"]) ? false : (bool)row["ISTEXT"] |
||
382 | bca86986 | gaqhf | }); |
383 | } |
||
384 | 23eb98bf | gaqhf | } |
385 | } |
||
386 | |||
387 | 306a0af9 | gaqhf | private void InitID2DrawingAttribute() |
388 | { |
||
389 | using (DataTable drawingAttributeDT = Project_DB.SelectDrawingProjectAttribute()) |
||
390 | { |
||
391 | _ID2DrawingAttributeDT = drawingAttributeDT; |
||
392 | } |
||
393 | } |
||
394 | |||
395 | fab4f207 | gaqhf | private void InitSPPIDDB() |
396 | 23eb98bf | gaqhf | { |
397 | 12b7a2a8 | gaqhf | buttonEditDefaultUnit.TextChanged -= new EventHandler(buttonEditDefaultUnit_TextChanged); |
398 | comboBoxEditDefaultTemplate.SelectedIndexChanged -= new EventHandler(comboBoxEditDefaultTemplate_SelectedIndexChanged); |
||
399 | 4f0c0ed6 | gaqhf | comboBoxEditBulk.SelectedIndexChanged -= new System.EventHandler(this.comboBoxEditBulk_SelectedIndexChanged); |
400 | 12b7a2a8 | gaqhf | |
401 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
402 | fab4f207 | gaqhf | if (_ProjectInfo.Enable) |
403 | { |
||
404 | DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
||
405 | ec0c7045 | gaqhf | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
406 | SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
||
407 | else |
||
408 | SPPID_DBInfo.Clear(); |
||
409 | fab4f207 | gaqhf | } |
410 | ec0c7045 | gaqhf | |
411 | 635a8747 | gaqhf | templateComboBox.Items.Clear(); |
412 | d73c791c | gaqhf | comboBoxEditDefaultTemplate.SelectedIndex = -1; |
413 | comboBoxEditDefaultTemplate.Properties.Items.Clear(); |
||
414 | buttonEditDefaultUnit.Text = ""; |
||
415 | |||
416 | 4f0c0ed6 | gaqhf | |
417 | // Bulk Attribute |
||
418 | RefreshBulkRule(); |
||
419 | |||
420 | ec0c7045 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
421 | 23eb98bf | gaqhf | if (_SPPIDInfo.Enable) |
422 | { |
||
423 | labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
||
424 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
425 | labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
||
426 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
427 | 635a8747 | gaqhf | |
428 | if (!string.IsNullOrEmpty(TemplatePath)) |
||
429 | d73c791c | gaqhf | { |
430 | List<string> templateFiles = Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList(); |
||
431 | templateComboBox.Items.AddRange(templateFiles); |
||
432 | comboBoxEditDefaultTemplate.Properties.Items.AddRange(templateFiles); |
||
433 | } |
||
434 | |||
435 | e88aae98 | gaqhf | if (_SPPIDAttributeDT != null) |
436 | { |
||
437 | _SPPIDAttributeDT.Dispose(); |
||
438 | _SPPIDAttributeDT = null; |
||
439 | } |
||
440 | |||
441 | _SPPIDAttributeDT = SPPID_DB.GetSPPIDAttribute(); |
||
442 | if (_SPPIDAttributeDT != null) |
||
443 | { |
||
444 | _SPPIDAttributeDT.Columns["DISPLAYNAME"].ColumnName = "DISPLAY NAME"; |
||
445 | } |
||
446 | 12b7a2a8 | gaqhf | |
447 | if (!string.IsNullOrEmpty(Settings.Default.DefaultTemplate) && comboBoxEditDefaultTemplate.Properties.Items.Contains(Settings.Default.DefaultTemplate)) |
||
448 | comboBoxEditDefaultTemplate.SelectedItem = Settings.Default.DefaultTemplate; |
||
449 | |||
450 | 4f0c0ed6 | gaqhf | if (!string.IsNullOrEmpty(Settings.Default.DefaultBulkRule) && comboBoxEditBulk.Properties.Items.Contains(Settings.Default.DefaultBulkRule)) |
451 | comboBoxEditBulk.SelectedItem = Settings.Default.DefaultBulkRule; |
||
452 | |||
453 | 12b7a2a8 | gaqhf | // Unit 있는지 없는지 검사 필요 |
454 | if (!string.IsNullOrEmpty(Settings.Default.DefaultUnit)) |
||
455 | buttonEditDefaultUnit.Text = Settings.Default.DefaultUnit; |
||
456 | 23eb98bf | gaqhf | } |
457 | else |
||
458 | { |
||
459 | labelSPPIDPlantName.Text = " "; |
||
460 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
461 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
462 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
463 | } |
||
464 | bca86986 | gaqhf | |
465 | 635a8747 | gaqhf | _DicDocuments.Clear(); |
466 | _ConverterDT.Rows.Clear(); |
||
467 | bca86986 | gaqhf | InitSPPIDSymbolTreeTable(); |
468 | 12b7a2a8 | gaqhf | |
469 | buttonEditDefaultUnit.TextChanged += new EventHandler(buttonEditDefaultUnit_TextChanged); |
||
470 | comboBoxEditDefaultTemplate.SelectedIndexChanged += new EventHandler(comboBoxEditDefaultTemplate_SelectedIndexChanged); |
||
471 | 4f0c0ed6 | gaqhf | comboBoxEditBulk.SelectedIndexChanged += new System.EventHandler(this.comboBoxEditBulk_SelectedIndexChanged); |
472 | 23eb98bf | gaqhf | } |
473 | |||
474 | bca86986 | gaqhf | private void InitSPPIDSymbolTreeTable() |
475 | 23eb98bf | gaqhf | { |
476 | 26c6f818 | gaqhf | try |
477 | { |
||
478 | _SPPIDSymbolPathDT = new DataTable(); |
||
479 | _SPPIDSymbolPathDT.Columns.Add("ID"); |
||
480 | _SPPIDSymbolPathDT.Columns.Add("Parent"); |
||
481 | _SPPIDSymbolPathDT.Columns.Add("Name"); |
||
482 | _SPPIDSymbolPathDT.Columns.Add("FullPath"); |
||
483 | bca86986 | gaqhf | |
484 | ea54adc8 | gaqhf | string symbolPath = SPPIDUtil.T_OPTIONSETTING_Value("Catalog Explorer root path"); |
485 | DirectoryInfo info = new DirectoryInfo(symbolPath); |
||
486 | _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
||
487 | loop(info, "0", symbolPath); |
||
488 | 26c6f818 | gaqhf | } |
489 | catch (Exception ex) |
||
490 | 23eb98bf | gaqhf | { |
491 | 26c6f818 | gaqhf | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
492 | 23eb98bf | gaqhf | } |
493 | bca86986 | gaqhf | } |
494 | 23eb98bf | gaqhf | |
495 | bca86986 | gaqhf | private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
496 | { |
||
497 | DirectoryInfo[] infos = parentInfo.GetDirectories(); |
||
498 | foreach (DirectoryInfo info in infos) |
||
499 | { |
||
500 | string uid = Guid.NewGuid().ToString(); |
||
501 | _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
||
502 | loop(info, uid, defaultPath); |
||
503 | |||
504 | FileInfo[] files = info.GetFiles("*.sym"); |
||
505 | foreach (FileInfo fileInfo in files) |
||
506 | { |
||
507 | _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
||
508 | } |
||
509 | } |
||
510 | 23eb98bf | gaqhf | } |
511 | |||
512 | 1278ba59 | gaqhf | private void btnLoadFile_Click(object sender, EventArgs e) |
513 | { |
||
514 | 0a111e7d | gaqhf | List< BaseModel.Document> validationFailDocs = new List<BaseModel.Document>(); |
515 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
516 | d73c791c | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
517 | if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable) |
||
518 | 23eb98bf | gaqhf | { |
519 | d73c791c | gaqhf | MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
520 | 23eb98bf | gaqhf | return; |
521 | } |
||
522 | 1278ba59 | gaqhf | |
523 | 171142c5 | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
524 | 23eb98bf | gaqhf | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
525 | 1278ba59 | gaqhf | { |
526 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
527 | 1278ba59 | gaqhf | { |
528 | 7e680366 | gaqhf | SPPID_Document document = new SPPID_Document(fileName, _ID2SymbolTypeDT); |
529 | 4314b3f3 | gaqhf | |
530 | 68e9394a | gaqhf | document.SymbolTable = _ID2SymbolTable; |
531 | document.SymbolMappings = symbolMappings; |
||
532 | document.ChildSymbolMappings = childSymbolMappings; |
||
533 | document.LineMappings = lineMappings; |
||
534 | document.LineNumberMappings = lineNumberMappings; |
||
535 | document.AttributeMappings = attributeMappings; |
||
536 | document.ETCSetting = ETCSetting.GetInstance(); |
||
537 | document.SetSPPIDInfo(); |
||
538 | |||
539 | |||
540 | if (!document.SetSPPIDMapping()) |
||
541 | { |
||
542 | document.Enable = false; |
||
543 | document.MappingValidation = false; |
||
544 | } |
||
545 | |||
546 | bca86986 | gaqhf | DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
547 | 0d8062b2 | gaqhf | if (rows.Length == 0) |
548 | { |
||
549 | f9cc5190 | gaqhf | DataRow row = _ConverterDT.NewRow(); |
550 | 0d8062b2 | gaqhf | row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
551 | row["colDrawingFilePath"] = fileName; |
||
552 | row["colDrawingNumber"] = document.DWGNAME; |
||
553 | row["colDrawingName"] = document.DWGNAME; |
||
554 | if (document.Enable) |
||
555 | row["colStatus"] = "Ready"; |
||
556 | else |
||
557 | row["colStatus"] = "Error"; |
||
558 | row["colUID"] = ""; |
||
559 | d73c791c | gaqhf | if (comboBoxEditDefaultTemplate.SelectedIndex > -1) |
560 | 12b7a2a8 | gaqhf | row["colTemplate"] = comboBoxEditDefaultTemplate.SelectedItem; |
561 | 4f0c0ed6 | gaqhf | if (comboBoxEditBulk.SelectedIndex > -1) |
562 | row["colRuleName"] = comboBoxEditBulk.SelectedItem; |
||
563 | d73c791c | gaqhf | if (!string.IsNullOrEmpty(buttonEditDefaultUnit.Text)) |
564 | row["colUnit"] = buttonEditDefaultUnit.Text; |
||
565 | |||
566 | bca86986 | gaqhf | _ConverterDT.Rows.Add(row); |
567 | 442bd51e | gaqhf | |
568 | if (document.Enable && document.Validation && document.MappingValidation) |
||
569 | gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row))); |
||
570 | 0d8062b2 | gaqhf | } |
571 | f9cc5190 | gaqhf | else |
572 | { |
||
573 | foreach (DataRow row in rows) |
||
574 | { |
||
575 | if (document.Enable) |
||
576 | row["colStatus"] = "Ready"; |
||
577 | else |
||
578 | row["colStatus"] = "Error"; |
||
579 | d73c791c | gaqhf | |
580 | if (comboBoxEditDefaultTemplate.SelectedIndex > -1) |
||
581 | row["colTemplate"] = comboBoxEditDefaultTemplate.SelectedItem; |
||
582 | 4f0c0ed6 | gaqhf | if (comboBoxEditBulk.SelectedIndex > -1) |
583 | row["colRuleName"] = comboBoxEditBulk.SelectedItem; |
||
584 | d73c791c | gaqhf | if (!string.IsNullOrEmpty(buttonEditDefaultUnit.Text)) |
585 | row["colUnit"] = buttonEditDefaultUnit.Text; |
||
586 | 442bd51e | gaqhf | |
587 | if (document.Enable && document.Validation && document.MappingValidation) |
||
588 | gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row))); |
||
589 | f9cc5190 | gaqhf | } |
590 | } |
||
591 | 0d8062b2 | gaqhf | if (!_DicDocuments.ContainsKey(fileName)) |
592 | _DicDocuments.Add(fileName, null); |
||
593 | |||
594 | 68e9394a | gaqhf | if (!document.Validation || !document.MappingValidation) |
595 | 0a111e7d | gaqhf | validationFailDocs.Add(document); |
596 | e613d0e8 | gaqhf | |
597 | 0d8062b2 | gaqhf | _DicDocuments[fileName] = document; |
598 | 1278ba59 | gaqhf | } |
599 | 0a111e7d | gaqhf | if (validationFailDocs.Count > 0) |
600 | { |
||
601 | MessageForm messageForm = new MessageForm(validationFailDocs); |
||
602 | messageForm.ShowDialog(); |
||
603 | } |
||
604 | 1278ba59 | gaqhf | } |
605 | 65a1ed4b | gaqhf | } |
606 | 17f2a3a7 | gaqhf | |
607 | 5a9396ae | humkyung | /// <summary> |
608 | /// 선택한 도면의 정보를 로딩한다 |
||
609 | /// </summary> |
||
610 | /// <param name="sender"></param> |
||
611 | /// <param name="e"></param> |
||
612 | 1278ba59 | gaqhf | private void btnRun_Click(object sender, EventArgs e) |
613 | { |
||
614 | d73c791c | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
615 | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
||
616 | if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable) |
||
617 | { |
||
618 | MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
619 | return; |
||
620 | } |
||
621 | |||
622 | 6924abc6 | gaqhf | if (gridViewConverter.GetSelectedRows().Length == 0) |
623 | e0bb889b | gaqhf | { |
624 | MessageBox.Show(Msg.SelectDocument, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
625 | 6924abc6 | gaqhf | return; |
626 | e0bb889b | gaqhf | } |
627 | 154d8f43 | gaqhf | DataTable tDrawing = Project_DB.SelectDrawings(); |
628 | 5a9396ae | humkyung | this._Documents.Clear(); |
629 | 17f2a3a7 | gaqhf | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
630 | { |
||
631 | string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
||
632 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
633 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
634 | string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
||
635 | string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
||
636 | 4f0c0ed6 | gaqhf | string _RuleName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colRuleName"); |
637 | 154d8f43 | gaqhf | DataRow[] rows = tDrawing.Select(string.Format("NAME = '{0}'", Path.GetFileNameWithoutExtension(_FilePath) + ".png")); |
638 | if (rows.Length != 1) |
||
639 | continue; |
||
640 | |||
641 | 17f2a3a7 | gaqhf | SPPID_Document document = _DicDocuments[_FilePath]; |
642 | document.Unit = _Unit; |
||
643 | document.Template = _Template; |
||
644 | document.DrawingNumber = _DrawingNumber; |
||
645 | document.DrawingName = _DrawingName; |
||
646 | 154d8f43 | gaqhf | document.UID = rows[0]["UID"].ToString(); |
647 | 4f0c0ed6 | gaqhf | document.BulkAttributeName = _RuleName; |
648 | 712860bb | gaqhf | |
649 | 4d2571ab | gaqhf | document.SymbolTable = _ID2SymbolTable; |
650 | 712860bb | gaqhf | document.SymbolMappings = symbolMappings; |
651 | document.ChildSymbolMappings = childSymbolMappings; |
||
652 | document.LineMappings = lineMappings; |
||
653 | document.LineNumberMappings = lineNumberMappings; |
||
654 | document.AttributeMappings = attributeMappings; |
||
655 | document.ETCSetting = ETCSetting.GetInstance(); |
||
656 | document.SetSPPIDInfo(); |
||
657 | |||
658 | e3e2d41f | gaqhf | if (document.SetSPPIDMapping() && document.Enable) |
659 | 5a9396ae | humkyung | this._Documents.Add(document); |
660 | 17f2a3a7 | gaqhf | } |
661 | 5dfb8a24 | gaqhf | |
662 | 154d8f43 | gaqhf | if (_Documents.Count > 50) |
663 | checkEditCloseDocument.Checked = true; |
||
664 | |||
665 | tDrawing.Dispose(); |
||
666 | d19ae675 | gaqhf | DialogResult = DialogResult.OK; |
667 | 96a2080c | gaqhf | } |
668 | 23eb98bf | gaqhf | |
669 | private void btnSPPIDDB_Click(object sender, EventArgs e) |
||
670 | { |
||
671 | SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
||
672 | if (form.ShowDialog() == DialogResult.OK) |
||
673 | fab4f207 | gaqhf | InitSPPIDDB(); |
674 | 23eb98bf | gaqhf | } |
675 | df4559fc | gaqhf | |
676 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
677 | { |
||
678 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
679 | d73c791c | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
680 | if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable) |
||
681 | df4559fc | gaqhf | { |
682 | d73c791c | gaqhf | MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
683 | df4559fc | gaqhf | return; |
684 | } |
||
685 | |||
686 | 306a0af9 | gaqhf | MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT, _SPPIDAttributeDT, _ID2DrawingAttributeDT); |
687 | df4559fc | gaqhf | form.ShowDialog(); |
688 | bca86986 | gaqhf | InitMapping(); |
689 | 4f0c0ed6 | gaqhf | RefreshBulkRule(); |
690 | df4559fc | gaqhf | } |
691 | 4314b3f3 | gaqhf | private List<int> prevSelectedList = new List<int>(); |
692 | |||
693 | private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
||
694 | { |
||
695 | if (e.Action == CollectionChangeAction.Add) |
||
696 | { |
||
697 | string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
||
698 | string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
||
699 | |||
700 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
701 | gridViewConverter.UnselectRow(e.ControllerRow); |
||
702 | } |
||
703 | else if (e.Action == CollectionChangeAction.Refresh) |
||
704 | { |
||
705 | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
706 | { |
||
707 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
708 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
709 | |||
710 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
711 | gridViewConverter.UnselectRow(rowHandle); |
||
712 | } |
||
713 | |||
714 | List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
||
715 | var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
||
716 | var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
||
717 | 635a8747 | gaqhf | |
718 | 4314b3f3 | gaqhf | if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
719 | { |
||
720 | this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
721 | gridViewConverter.ClearSelection(); |
||
722 | this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
723 | } |
||
724 | } |
||
725 | |||
726 | prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
||
727 | } |
||
728 | d73c791c | gaqhf | |
729 | private void buttonEditDefaulUnit_ButtonClick(object sender, ButtonPressedEventArgs e) |
||
730 | { |
||
731 | UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
||
732 | if (unitForm.ShowDialog() == DialogResult.OK) |
||
733 | { |
||
734 | buttonEditDefaultUnit.Text = unitForm.SelectedUnit; |
||
735 | } |
||
736 | } |
||
737 | 02a45794 | gaqhf | |
738 | private void btnRefresh_Click(object sender, EventArgs e) |
||
739 | { |
||
740 | List<BaseModel.Document> validationFailDocs = new List<BaseModel.Document>(); |
||
741 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
742 | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
||
743 | if (!_ProjectInfo.Enable || !_SPPIDInfo.Enable) |
||
744 | { |
||
745 | MessageBox.Show(Msg.PleaseSetProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
746 | return; |
||
747 | } |
||
748 | |||
749 | foreach (DataRow row in _ConverterDT.Rows) |
||
750 | { |
||
751 | string fileName = row["colDrawingFilePath"].ToString(); |
||
752 | 7e680366 | gaqhf | SPPID_Document document = new SPPID_Document(fileName, _ID2SymbolTypeDT); |
753 | 68e9394a | gaqhf | document.SymbolTable = _ID2SymbolTable; |
754 | document.SymbolMappings = symbolMappings; |
||
755 | document.ChildSymbolMappings = childSymbolMappings; |
||
756 | document.LineMappings = lineMappings; |
||
757 | document.LineNumberMappings = lineNumberMappings; |
||
758 | document.AttributeMappings = attributeMappings; |
||
759 | document.ETCSetting = ETCSetting.GetInstance(); |
||
760 | document.SetSPPIDInfo(); |
||
761 | |||
762 | |||
763 | if (!document.SetSPPIDMapping()) |
||
764 | { |
||
765 | document.Enable = false; |
||
766 | document.MappingValidation = false; |
||
767 | } |
||
768 | |||
769 | 02a45794 | gaqhf | row["colDrawingNumber"] = document.DWGNAME; |
770 | row["colDrawingName"] = document.DWGNAME; |
||
771 | if (document.Enable) |
||
772 | row["colStatus"] = "Ready"; |
||
773 | else |
||
774 | row["colStatus"] = "Error"; |
||
775 | |||
776 | if (!_DicDocuments.ContainsKey(fileName)) |
||
777 | _DicDocuments.Add(fileName, null); |
||
778 | |||
779 | 68e9394a | gaqhf | if (!document.Validation || !document.MappingValidation) |
780 | 02a45794 | gaqhf | validationFailDocs.Add(document); |
781 | |||
782 | _DicDocuments[fileName] = document; |
||
783 | 442bd51e | gaqhf | |
784 | if (document.Enable && document.Validation && document.MappingValidation) |
||
785 | gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row))); |
||
786 | 02a45794 | gaqhf | } |
787 | |||
788 | |||
789 | if (validationFailDocs.Count > 0) |
||
790 | { |
||
791 | MessageForm messageForm = new MessageForm(validationFailDocs); |
||
792 | messageForm.ShowDialog(); |
||
793 | } |
||
794 | } |
||
795 | 12b7a2a8 | gaqhf | |
796 | private void buttonEditDefaultUnit_TextChanged(object sender, EventArgs e) |
||
797 | { |
||
798 | Settings.Default.DefaultUnit = buttonEditDefaultUnit.Text; |
||
799 | Settings.Default.Save(); |
||
800 | } |
||
801 | |||
802 | private void comboBoxEditDefaultTemplate_SelectedIndexChanged(object sender, EventArgs e) |
||
803 | { |
||
804 | Settings.Default.DefaultTemplate = comboBoxEditDefaultTemplate.SelectedItem.ToString(); |
||
805 | Settings.Default.Save(); |
||
806 | } |
||
807 | 8847ea67 | gaqhf | |
808 | 4f0c0ed6 | gaqhf | private void comboBoxEditBulk_SelectedIndexChanged(object sender, EventArgs e) |
809 | { |
||
810 | Settings.Default.DefaultBulkRule = comboBoxEditBulk.SelectedItem.ToString(); |
||
811 | Settings.Default.Save(); |
||
812 | } |
||
813 | |||
814 | private void RefreshBulkRule() |
||
815 | { |
||
816 | ETCSetting eTCSetting = ETCSetting.GetInstance(); |
||
817 | bulkRuleComboBox.Items.Clear(); |
||
818 | bulkRuleComboBox.Items.Add(""); |
||
819 | foreach (var item in eTCSetting.BulkAttributes) |
||
820 | if (!bulkRuleComboBox.Items.Contains(item.RuleName)) |
||
821 | bulkRuleComboBox.Items.Add(item.RuleName); |
||
822 | |||
823 | for (int i = 0; i < gridViewConverter.DataRowCount; i++) |
||
824 | { |
||
825 | DataRow row = gridViewConverter.GetDataRow(i); |
||
826 | object data = row["colRuleName"]; |
||
827 | if (data != null && !DBNull.Value.Equals(data)) |
||
828 | { |
||
829 | string sData = data.ToString(); |
||
830 | if (eTCSetting.BulkAttributes.Find(x => x.RuleName.Equals(sData)) == null) |
||
831 | row["colRuleName"] = string.Empty; |
||
832 | } |
||
833 | } |
||
834 | |||
835 | comboBoxEditBulk.Properties.Items.Clear(); |
||
836 | comboBoxEditBulk.Properties.Items.Add(""); |
||
837 | foreach (var item in eTCSetting.BulkAttributes) |
||
838 | if (!comboBoxEditBulk.Properties.Items.Contains(item.RuleName)) |
||
839 | comboBoxEditBulk.Properties.Items.Add(item.RuleName); |
||
840 | if (eTCSetting.BulkAttributes.Find(x => x.RuleName.Equals(comboBoxEditBulk.Text)) == null) |
||
841 | comboBoxEditBulk.SelectedIndex = 0; |
||
842 | } |
||
843 | |||
844 | 8847ea67 | gaqhf | |
845 | 96a2080c | gaqhf | } |
846 | } |