개정판 3823b4ab
dev issue #826 : edit form logic
DTI_PID/SPPIDConverter_AutoModeling/MainControl.cs | ||
---|---|---|
14 | 14 |
using SPPID.Modeling; |
15 | 15 |
using SPPID.Model; |
16 | 16 |
using SPPID.Utill; |
17 |
using SPPID.DB; |
|
17 | 18 |
using Microsoft.VisualBasic; |
19 |
using Newtonsoft.Json; |
|
18 | 20 |
|
19 | 21 |
namespace SPPIDConverter_AutoModeling |
20 | 22 |
{ |
21 | 23 |
public partial class MainControl : UserControl |
22 | 24 |
{ |
25 |
Thread autoModelingThread; |
|
26 |
|
|
23 | 27 |
private Dictionary<string, string> symbolMapping = new Dictionary<string, string>(); |
24 | 28 |
private Dictionary<string, string> attributeMapping = new Dictionary<string, string>(); |
25 |
Thread autoModelingThread; |
|
29 |
private DataTable dUnit = new DataTable(); |
|
30 |
private string TemplatePath; |
|
31 |
private string SymbolPath; |
|
26 | 32 |
|
27 | 33 |
public MainControl() |
28 | 34 |
{ |
29 | 35 |
InitializeComponent(); |
30 |
SetPath(); |
|
31 |
} |
|
32 |
|
|
33 |
private void btnLoadFiles_Click(object sender, EventArgs e) |
|
34 |
{ |
|
35 |
OpenFileDialog dia = new OpenFileDialog(); |
|
36 |
dia.Multiselect = true; |
|
37 |
dia.Filter = "Xml Files(*.xml)|*.xml"; |
|
38 |
if (dia.ShowDialog() == DialogResult.OK) |
|
36 |
|
|
37 |
if (SetPath()) |
|
38 |
{ |
|
39 |
if (SPPIDUtill.LoadDB()) |
|
40 |
InitDBInformation(); |
|
41 |
else |
|
42 |
MessageBox.Show("Please Check DB Setting", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
43 |
InitGridViewDB(); |
|
44 |
} |
|
45 |
else |
|
39 | 46 |
{ |
40 |
SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
|
41 | 47 |
|
42 |
foreach (string fileName in dia.FileNames) |
|
43 |
{ |
|
44 |
GridViewDataRowInfo row = new GridViewDataRowInfo(gridViewDrawingList.MasterView); |
|
45 |
Document document = Document.Load(fileName, symbolMapping, attributeMapping); |
|
46 |
|
|
47 |
row.Cells["colCheckBox"].Value = false; |
|
48 |
row.Cells["colDrawingName"].Value = fileName; |
|
49 |
row.Cells["colStatus"].Value = "Ready"; |
|
50 |
row.Cells["colDrawingFullName"].Value = fileName; |
|
51 |
gridViewDrawingList.Rows.Add(row); |
|
52 |
} |
|
53 | 48 |
} |
54 | 49 |
} |
55 | 50 |
|
56 |
private void SetPath()
|
|
51 |
private bool SetPath()
|
|
57 | 52 |
{ |
58 | 53 |
try |
59 | 54 |
{ |
... | ... | |
68 | 63 |
SPPIDUtill.defaultPath = ID2.GetValue("Path").ToString(); |
69 | 64 |
Log.logPath = SPPIDUtill.defaultPath + @"Converter\SPPID Converter.log"; |
70 | 65 |
SPPIDUtill.mappingFilePath = SPPIDUtill.defaultPath + @"Converter\mapping.xml"; |
66 |
SPPIDUtill.dbFilePath = SPPIDUtill.defaultPath + @"Converter\DB.config"; |
|
67 |
|
|
68 |
return true; |
|
71 | 69 |
} |
72 | 70 |
} |
73 | 71 |
} |
74 | 72 |
catch (Exception ex) |
75 | 73 |
{ |
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
return false; |
|
78 |
} |
|
79 |
|
|
80 |
#region Init Data Setting |
|
81 |
|
|
82 |
public void InitDBInformation() |
|
83 |
{ |
|
84 |
// Unit DataTable |
|
85 |
dUnit = DB.GetUnitTree(); |
|
86 |
|
|
87 |
// Template List |
|
88 |
TemplatePath = DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
|
89 |
GridViewComboBoxColumn colTemplate = gridViewDrawingList.Columns["colTemplate"] as GridViewComboBoxColumn; |
|
90 |
colTemplate.DataSource = Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)); |
|
91 |
|
|
92 |
// Load Mapping |
|
93 |
SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
|
94 |
|
|
95 |
// Symbol Path |
|
96 |
SymbolPath = DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
|
97 |
GridViewComboBoxColumn colSPPIDName = gridViewItemMapping.Columns["colSPPIDName"] as GridViewComboBoxColumn; |
|
98 |
colSPPIDName.DataSource = Directory.GetFiles(SymbolPath, "*.sym", SearchOption.AllDirectories).ToList().Select(symbol => symbol.Remove(0, SymbolPath.Length)); |
|
99 |
|
|
100 |
// Load Mapping |
|
101 |
SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
|
102 |
gridViewItemMapping.BeginUpdate(); |
|
103 |
foreach (var item in symbolMapping) |
|
104 |
gridViewItemMapping.Rows.Add(new object[] {item.Key,item.Value, "View" }); |
|
105 |
gridViewItemMapping.BestFitColumns(); |
|
106 |
gridViewItemMapping.EndUpdate(); |
|
107 |
|
|
108 |
|
|
109 |
// Attribute |
|
110 |
GridViewComboBoxColumn colSPPIDAttribute = gridViewAttribute.Columns["colSPPIDAttribute"] as GridViewComboBoxColumn; |
|
111 |
colSPPIDAttribute.DataSource = DB.GetSPPIDAttribute(); |
|
112 |
|
|
113 |
// Load Attribute |
|
114 |
gridViewAttribute.BeginUpdate(); |
|
115 |
foreach (var item in attributeMapping) |
|
116 |
gridViewAttribute.Rows.Add(new object[] { item.Key, item.Value, "View" }); |
|
117 |
gridViewAttribute.BestFitColumns(); |
|
118 |
gridViewAttribute.EndUpdate(); |
|
119 |
} |
|
120 |
|
|
121 |
#endregion |
|
122 |
|
|
123 |
|
|
124 |
#region Setting Page |
|
125 |
private const string _DBType = "DB Type"; |
|
126 |
private const string _ServiceName = "Service Name"; |
|
127 |
private const string _SiteName = "Site Name"; |
|
128 |
private const string _ServerIP = "Server IP"; |
|
129 |
private const string _Port = "Port"; |
|
130 |
private const string _DBUser = "DB User"; |
|
131 |
private const string _DBPassword = "DB Password"; |
|
132 |
|
|
133 |
private void InitGridViewDB() |
|
134 |
{ |
|
135 |
DBInformation dbInfo = DBInformation.GetInstance(); |
|
136 |
|
|
137 |
gridViewDB.Rows.Add(new object[] { _DBType , dbInfo.DBType}); |
|
138 |
gridViewDB.Rows.Add(new object[] { _ServiceName, dbInfo.Service }); |
|
139 |
gridViewDB.Rows.Add(new object[] { _SiteName, dbInfo.Site}); |
|
140 |
gridViewDB.Rows.Add(new object[] { _ServerIP, dbInfo.ServerIP}); |
|
141 |
gridViewDB.Rows.Add(new object[] { _Port, dbInfo.Port}); |
|
142 |
gridViewDB.Rows.Add(new object[] { _DBUser, dbInfo.DBUser}); |
|
143 |
gridViewDB.Rows.Add(new object[] { _DBPassword, dbInfo.DBPassword}); |
|
144 |
gridViewDB.BestFitColumns(); |
|
145 |
|
|
146 |
this.gridViewDB.RowFormatting += new Telerik.WinControls.UI.RowFormattingEventHandler(this.gridViewDB_RowFormatting); |
|
147 |
this.gridViewDB.CellBeginEdit += new Telerik.WinControls.UI.GridViewCellCancelEventHandler(this.gridViewDB_CellBeginEdit); |
|
148 |
this.gridViewDB.CellValueChanged += new Telerik.WinControls.UI.GridViewCellEventHandler(this.gridViewDB_CellValueChanged); |
|
149 |
} |
|
150 |
|
|
151 |
private void gridViewDB_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) |
|
152 |
{ |
|
153 |
string sKey = (string)e.Row.Cells["colKey"].Value; |
|
154 |
if (sKey == _DBType || |
|
155 |
sKey == _ServiceName || |
|
156 |
sKey == _SiteName) |
|
157 |
{ |
|
158 |
e.Cancel = true; |
|
159 |
} |
|
160 |
else |
|
161 |
{ |
|
162 |
|
|
163 |
} |
|
164 |
} |
|
76 | 165 |
|
166 |
private void gridViewDB_RowFormatting(object sender, RowFormattingEventArgs e) |
|
167 |
{ |
|
168 |
string sKey = (string)e.RowElement.RowInfo.Cells["colKey"].Value; |
|
169 |
if (sKey == _DBType || |
|
170 |
sKey == _ServiceName || |
|
171 |
sKey == _SiteName) |
|
172 |
{ |
|
173 |
e.RowElement.DrawFill = true; |
|
174 |
e.RowElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid; |
|
175 |
e.RowElement.BackColor = Color.Aquamarine; |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
private void gridViewDB_CellValueChanged(object sender, GridViewCellEventArgs e) |
|
180 |
{ |
|
181 |
btnSave.Enabled = false; |
|
182 |
} |
|
183 |
|
|
184 |
private void btnLoadiniFile_Click(object sender, EventArgs e) |
|
185 |
{ |
|
186 |
try |
|
187 |
{ |
|
188 |
OpenFileDialog dialog = new OpenFileDialog(); |
|
189 |
dialog.Multiselect = false; |
|
190 |
dialog.Filter = "ini File(*.ini)|*.ini"; |
|
191 |
if (dialog.ShowDialog() == DialogResult.OK) |
|
192 |
{ |
|
193 |
string sDBTYPE = string.Empty; |
|
194 |
string sSERVICENAME = string.Empty; |
|
195 |
string sUID = string.Empty; |
|
196 |
|
|
197 |
string[] texts = File.ReadAllLines(dialog.FileName); |
|
198 |
|
|
199 |
bool find = false; |
|
200 |
for (int i = 0; i < texts.Length; i++) |
|
201 |
{ |
|
202 |
string text = texts[i]; |
|
203 |
|
|
204 |
if (text.Trim() == "[SITESCHEMA]") |
|
205 |
find = true; |
|
206 |
|
|
207 |
if (find) |
|
208 |
{ |
|
209 |
if (text.StartsWith("DBTYPE=") && string.IsNullOrEmpty(sDBTYPE)) |
|
210 |
sDBTYPE = text.Remove(0, "DBTYPE=".Length); |
|
211 |
else if (text.StartsWith("DBSERVER=") && string.IsNullOrEmpty(sSERVICENAME)) |
|
212 |
sSERVICENAME = text.Remove(0, "DBSERVER=".Length); |
|
213 |
else if (text.StartsWith("UID=") && string.IsNullOrEmpty(sUID)) |
|
214 |
sUID = text.Remove(0, "UID=".Length); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
if (string.IsNullOrEmpty(sDBTYPE) || string.IsNullOrEmpty(sSERVICENAME) || string.IsNullOrEmpty(sUID)) |
|
219 |
MessageBox.Show("Unavailable ini file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
220 |
else |
|
221 |
{ |
|
222 |
foreach (GridViewRowInfo rowInfo in gridViewDB.Rows) |
|
223 |
{ |
|
224 |
string sKey = (string)rowInfo.Cells["colKey"].Value; |
|
225 |
if (sKey == _DBType) |
|
226 |
rowInfo.Cells["colValue"].Value = sDBTYPE; |
|
227 |
else if (sKey == _ServiceName) |
|
228 |
rowInfo.Cells["colValue"].Value = sSERVICENAME; |
|
229 |
else if (sKey == _SiteName) |
|
230 |
rowInfo.Cells["colValue"].Value = sUID; |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
catch (Exception ex) |
|
236 |
{ |
|
237 |
MessageBox.Show("Unavailable ini file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
238 |
} |
|
239 |
} |
|
240 |
|
|
241 |
private void btnSPPIDDBTest_Click(object sender, EventArgs e) |
|
242 |
{ |
|
243 |
DBInformation dbInfo = DBInformation.GetInstance(); |
|
244 |
dbInfo.Status = false; |
|
245 |
foreach (GridViewRowInfo rowInfo in gridViewDB.Rows) |
|
246 |
{ |
|
247 |
string sKey = (string)rowInfo.Cells["colKey"].Value; |
|
248 |
string sValue = (string)rowInfo.Cells["colValue"].Value; |
|
249 |
|
|
250 |
switch (sKey) |
|
251 |
{ |
|
252 |
case _DBType: |
|
253 |
dbInfo.DBType = sValue; |
|
254 |
break; |
|
255 |
case _ServiceName: |
|
256 |
dbInfo.Service = sValue; |
|
257 |
break; |
|
258 |
case _SiteName: |
|
259 |
dbInfo.Site = sValue; |
|
260 |
break; |
|
261 |
case _ServerIP: |
|
262 |
dbInfo.ServerIP = sValue; |
|
263 |
break; |
|
264 |
case _Port: |
|
265 |
dbInfo.Port = sValue; |
|
266 |
break; |
|
267 |
case _DBUser: |
|
268 |
dbInfo.DBUser = sValue; |
|
269 |
break; |
|
270 |
case _DBPassword: |
|
271 |
dbInfo.DBPassword = sValue; |
|
272 |
break; |
|
273 |
default: |
|
274 |
break; |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
if (DB.CheckAndSetDBInformation()) |
|
279 |
{ |
|
280 |
btnSave.Enabled = true; |
|
281 |
MessageBox.Show("Test Connection Success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
282 |
} |
|
283 |
else |
|
284 |
{ |
|
285 |
MessageBox.Show("Check DB Information!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
private void gridViewDB_CellFormatting(object sender, CellFormattingEventArgs e) |
|
290 |
{ |
|
291 |
if (e.Column.Name == "colValue" && (string)e.Row.Cells["colKey"].Value == _DBPassword) |
|
292 |
{ |
|
293 |
object value = e.CellElement.RowInfo.Cells["colValue"].Value; |
|
294 |
string text = string.Empty; |
|
295 |
if (value != null) |
|
296 |
{ |
|
297 |
int passwordLen = Convert.ToString(value).Length + 1; |
|
298 |
text = string.Join("*", new string[passwordLen]); |
|
299 |
} |
|
300 |
|
|
301 |
e.CellElement.Text = text; |
|
302 |
} |
|
303 |
} |
|
304 |
|
|
305 |
private void btnSave_Click(object sender, EventArgs e) |
|
306 |
{ |
|
307 |
DBInformation dbInfo = DBInformation.GetInstance(); |
|
308 |
if (dbInfo != null) |
|
309 |
{ |
|
310 |
dbInfo.Status = true; |
|
311 |
string sJson = JsonConvert.SerializeObject(dbInfo); |
|
312 |
SPPIDUtill.SaveDB(sJson); |
|
313 |
|
|
314 |
MessageBox.Show("Save Success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
315 |
} |
|
316 |
else |
|
317 |
{ |
|
318 |
|
|
319 |
} |
|
320 |
} |
|
321 |
|
|
322 |
#endregion |
|
323 |
|
|
324 |
#region Convert Page |
|
325 |
const string _Ready = "Ready"; |
|
326 |
const string _LoadFail = "Can't Load"; |
|
327 |
const string _NeedMapping = "Need Mapping"; |
|
328 |
const string _NeedUnit = "Select Unit"; |
|
329 |
const string _NeedTemplate = "Select Template"; |
|
330 |
|
|
331 |
private void btnLoadFiles_Click(object sender, EventArgs e) |
|
332 |
{ |
|
333 |
OpenFileDialog dia = new OpenFileDialog(); |
|
334 |
dia.Multiselect = true; |
|
335 |
dia.Filter = "Xml Files(*.xml)|*.xml"; |
|
336 |
if (dia.ShowDialog() == DialogResult.OK) |
|
337 |
{ |
|
338 |
gridViewDrawingList.CellValueChanged -= new GridViewCellEventHandler(this.gridViewDrawingList_CellValueChanged); |
|
339 |
foreach (string fileName in dia.FileNames) |
|
340 |
{ |
|
341 |
try |
|
342 |
{ |
|
343 |
GridViewDataRowInfo row = new GridViewDataRowInfo(gridViewDrawingList.MasterView); |
|
344 |
Document document = Document.Load(fileName, symbolMapping, attributeMapping); |
|
345 |
row.Tag = document; |
|
346 |
|
|
347 |
if (document == null) |
|
348 |
{ |
|
349 |
row.Cells["colDrawingFileName"].Value = fileName; |
|
350 |
row.Cells["colStatus"].Value = _LoadFail; |
|
351 |
row.Cells["colDrawingFullName"].Value = fileName; |
|
352 |
} |
|
353 |
else |
|
354 |
{ |
|
355 |
row.Cells["colCheckBox"].Value = false; |
|
356 |
row.Cells["colDrawingFileName"].Value = document.DWGNAME; |
|
357 |
row.Cells["colDrawingNumber"].Value = document.DWGNAME; |
|
358 |
row.Cells["colDrawingName"].Value = document.DWGNAME; |
|
359 |
row.Cells["colDrawingFullName"].Value = fileName; |
|
360 |
} |
|
361 |
|
|
362 |
gridViewDrawingList.Rows.Add(row); |
|
363 |
CheckValidateDrawing(row); |
|
364 |
} |
|
365 |
catch (Exception ex) |
|
366 |
{ |
|
367 |
|
|
368 |
} |
|
369 |
} |
|
370 |
gridViewDrawingList.CellValueChanged += new GridViewCellEventHandler(this.gridViewDrawingList_CellValueChanged); |
|
77 | 371 |
} |
78 | 372 |
} |
79 | 373 |
|
... | ... | |
82 | 376 |
try |
83 | 377 |
{ |
84 | 378 |
dynamic application = Interaction.GetObject("", "PIDAutomation.Application"); |
85 |
for (int i = 0; i < 4; i++) |
|
379 |
|
|
380 |
foreach (GridViewRowInfo rowInfo in gridViewDrawingList.Rows) |
|
86 | 381 |
{ |
87 |
dynamic newDrawing = application.Drawings.Add("PA", @"\\server70\DOFTECHSITE\P&ID Reference Data\Template Files\STIM A1.pid", "Test" + i, "Test" + i); |
|
88 |
application.ActiveWindow.Fit(); |
|
89 |
Thread.Sleep(10); |
|
90 |
application.ActiveWindow.Zoom = 2000; |
|
91 |
Thread.Sleep(10); |
|
382 |
try |
|
383 |
{ |
|
384 |
bool bChecked = (bool)rowInfo.Cells["colCheckBox"].Value; |
|
385 |
string sStatus = rowInfo.Cells["colStatus"].Value.ToString(); |
|
92 | 386 |
|
387 |
if (bChecked && sStatus == _Ready) |
|
388 |
{ |
|
389 |
string sUnit = rowInfo.Cells["colUnit"].Value.ToString(); |
|
390 |
string sTemplate = TemplatePath + @"\" + rowInfo.Cells["colTemplate"].Value.ToString(); |
|
391 |
string sDrawingNumber = rowInfo.Cells["colDrawingNumber"].Value.ToString(); |
|
392 |
string sDrawingName = rowInfo.Cells["colDrawingName"].Value.ToString(); |
|
93 | 393 |
|
394 |
// |
|
395 |
dynamic newDrawing = application.Drawings.Add(sUnit, sTemplate, sDrawingNumber, sDrawingName); |
|
396 |
application.ActiveWindow.Fit(); |
|
397 |
Thread.Sleep(10); |
|
398 |
application.ActiveWindow.Zoom = 2000; |
|
399 |
Thread.Sleep(10); |
|
400 |
// |
|
94 | 401 |
|
402 |
Document document = rowInfo.Tag as Document; |
|
95 | 403 |
|
96 | 404 |
|
97 |
newDrawing.CloseDrawing(true); |
|
98 |
application.ActiveWindow.Fit(); |
|
99 |
Thread.Sleep(10); |
|
100 |
} |
|
101 | 405 |
|
102 |
//MessageBox.Show("End"); |
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
newDrawing.CloseDrawing(true); |
|
414 |
application.ActiveWindow.Fit(); |
|
415 |
Thread.Sleep(10); |
|
416 |
} |
|
417 |
} |
|
418 |
catch (Exception ex) |
|
419 |
{ |
|
420 |
|
|
421 |
} |
|
422 |
} |
|
103 | 423 |
} |
104 | 424 |
catch (Exception ex) |
105 | 425 |
{ |
106 | 426 |
MessageBox.Show(ex.Message); |
107 | 427 |
} |
108 | 428 |
} |
429 |
|
|
430 |
private void gridViewDrawingList_CellValueChanged(object sender, GridViewCellEventArgs e) |
|
431 |
{ |
|
432 |
CheckValidateDrawing(e.Row); |
|
433 |
} |
|
434 |
|
|
435 |
private void CheckValidateDrawing(GridViewRowInfo rowInfo) |
|
436 |
{ |
|
437 |
if ((string)rowInfo.Cells["colStatus"].Value != _LoadFail) |
|
438 |
{ |
|
439 |
StringBuilder sStatus = new StringBuilder(); |
|
440 |
// Unit Check |
|
441 |
if (string.IsNullOrEmpty((string)rowInfo.Cells["colUnit"].Value)) |
|
442 |
sStatus.AppendLine(_NeedUnit); |
|
443 |
// Template Check |
|
444 |
if (string.IsNullOrEmpty((string)rowInfo.Cells["colTemplate"].Value)) |
|
445 |
sStatus.AppendLine(_NeedTemplate); |
|
446 |
// ReMapping |
|
447 |
Document document = rowInfo.Tag as Document; |
|
448 |
if (!document.ReMapping(new List<string>(), new List<string>())) |
|
449 |
sStatus.AppendLine(_NeedMapping); |
|
450 |
|
|
451 |
// IF READY |
|
452 |
if (sStatus.Length == 0) |
|
453 |
sStatus.Append(_Ready); |
|
454 |
|
|
455 |
rowInfo.Cells["colStatus"].Value = sStatus.ToString().Trim(); |
|
456 |
} |
|
457 |
|
|
458 |
if ((string)rowInfo.Cells["colStatus"].Value != _Ready) |
|
459 |
rowInfo.Cells["colCheckBox"].Value = false; |
|
460 |
} |
|
461 |
|
|
462 |
private void gridViewDrawingList_CellClick(object sender, GridViewCellEventArgs e) |
|
463 |
{ |
|
464 |
try |
|
465 |
{ |
|
466 |
if (e.RowIndex == -1) |
|
467 |
return; |
|
468 |
|
|
469 |
if (e.Column.Name == "colUnit") |
|
470 |
{ |
|
471 |
SelectUnitForm form = new SelectUnitForm(dUnit); |
|
472 |
if (form.ShowDialog() == DialogResult.OK) |
|
473 |
{ |
|
474 |
gridViewDrawingList.Rows[e.RowIndex].Cells["colUnit"].Value = form.SelectedUnit; |
|
475 |
} |
|
476 |
} |
|
477 |
} |
|
478 |
catch (Exception ex) |
|
479 |
{ |
|
480 |
|
|
481 |
} |
|
482 |
} |
|
483 |
|
|
484 |
private void gridViewDrawingList_CellFormatting(object sender, CellFormattingEventArgs e) |
|
485 |
{ |
|
486 |
try |
|
487 |
{ |
|
488 |
GridCommandCellElement cmdCell = e.CellElement as GridCommandCellElement; |
|
489 |
if (cmdCell != null) |
|
490 |
{ |
|
491 |
cmdCell.CommandButton.TextAlignment = ContentAlignment.MiddleCenter; |
|
492 |
} |
|
493 |
} |
|
494 |
catch (Exception ex) |
|
495 |
{ |
|
496 |
|
|
497 |
} |
|
498 |
} |
|
499 |
|
|
500 |
#endregion |
|
501 |
|
|
502 |
#region Mapping Page |
|
503 |
|
|
504 |
private void gridViewItemMapping_CellFormatting(object sender, CellFormattingEventArgs e) |
|
505 |
{ |
|
506 |
try |
|
507 |
{ |
|
508 |
GridCommandCellElement cmdCell = e.CellElement as GridCommandCellElement; |
|
509 |
if (cmdCell != null) |
|
510 |
{ |
|
511 |
cmdCell.CommandButton.TextAlignment = ContentAlignment.MiddleCenter; |
|
512 |
} |
|
513 |
} |
|
514 |
catch (Exception ex) |
|
515 |
{ |
|
516 |
|
|
517 |
} |
|
518 |
} |
|
519 |
|
|
520 |
private void gridViewAttribute_CellFormatting(object sender, CellFormattingEventArgs e) |
|
521 |
{ |
|
522 |
try |
|
523 |
{ |
|
524 |
GridCommandCellElement cmdCell = e.CellElement as GridCommandCellElement; |
|
525 |
if (cmdCell != null) |
|
526 |
{ |
|
527 |
cmdCell.CommandButton.TextAlignment = ContentAlignment.MiddleCenter; |
|
528 |
} |
|
529 |
} |
|
530 |
catch (Exception ex) |
|
531 |
{ |
|
532 |
|
|
533 |
} |
|
534 |
} |
|
535 |
|
|
536 |
private void btnMappingSave_Click(object sender, EventArgs e) |
|
537 |
{ |
|
538 |
symbolMapping.Clear(); |
|
539 |
foreach (GridViewRowInfo row in gridViewItemMapping.Rows) |
|
540 |
{ |
|
541 |
if (row.Cells["colItemName"].Value != null && row.Cells["colSPPIDName"].Value != null) |
|
542 |
{ |
|
543 |
string key = row.Cells["colItemName"].Value.ToString(); |
|
544 |
string value = row.Cells["colSPPIDName"].Value.ToString(); |
|
545 |
|
|
546 |
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) |
|
547 |
{ |
|
548 |
if (symbolMapping.ContainsKey(key)) |
|
549 |
symbolMapping[key] = value; |
|
550 |
else |
|
551 |
symbolMapping.Add(key, value); |
|
552 |
} |
|
553 |
|
|
554 |
} |
|
555 |
} |
|
556 |
|
|
557 |
attributeMapping.Clear(); |
|
558 |
foreach (GridViewRowInfo row in gridViewAttribute.Rows) |
|
559 |
{ |
|
560 |
if (row.Cells["colAttribute"].Value != null && row.Cells["colSPPIDAttribute"].Value != null) |
|
561 |
{ |
|
562 |
string key = row.Cells["colAttribute"].Value.ToString(); |
|
563 |
string value = row.Cells["colSPPIDAttribute"].Value.ToString(); |
|
564 |
|
|
565 |
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) |
|
566 |
{ |
|
567 |
if (attributeMapping.ContainsKey(key)) |
|
568 |
attributeMapping[key] = value; |
|
569 |
else |
|
570 |
attributeMapping.Add(key, value); |
|
571 |
} |
|
572 |
|
|
573 |
} |
|
574 |
} |
|
575 |
|
|
576 |
SPPIDUtill.SaveMapping(symbolMapping, attributeMapping); |
|
577 |
|
|
578 |
foreach (GridViewRowInfo rowInfo in gridViewDrawingList.Rows) |
|
579 |
CheckValidateDrawing(rowInfo); |
|
580 |
} |
|
581 |
|
|
582 |
#endregion |
|
583 |
|
|
584 |
private void pageView_SelectedPageChanged(object sender, EventArgs e) |
|
585 |
{ |
|
586 |
if (pageView.SelectedPage.Name == "pageItemMapping") |
|
587 |
{ |
|
588 |
// Load Item Mapping |
|
589 |
gridViewItemMapping.BeginUpdate(); |
|
590 |
gridViewItemMapping.Rows.Clear(); |
|
591 |
foreach (var item in symbolMapping) |
|
592 |
gridViewItemMapping.Rows.Add(new object[] { item.Key, item.Value, "View" }); |
|
593 |
|
|
594 |
// Load Attribute |
|
595 |
gridViewAttribute.BeginUpdate(); |
|
596 |
gridViewAttribute.Rows.Clear(); |
|
597 |
foreach (var item in attributeMapping) |
|
598 |
gridViewAttribute.Rows.Add(new object[] { item.Key, item.Value, "View" }); |
|
599 |
|
|
600 |
List<string> needSymbolMapping = new List<string>(); |
|
601 |
List<string> needAttributeMapping = new List<string>(); |
|
602 |
foreach (GridViewRowInfo rowInfo in gridViewDrawingList.Rows) |
|
603 |
{ |
|
604 |
Document document = rowInfo.Tag as Document; |
|
605 |
if (document != null) |
|
606 |
document.ReMapping(needSymbolMapping, needAttributeMapping); |
|
607 |
} |
|
608 |
|
|
609 |
needSymbolMapping = needSymbolMapping.Distinct().ToList(); |
|
610 |
needAttributeMapping = needAttributeMapping.Distinct().ToList(); |
|
611 |
|
|
612 |
foreach (string item in needSymbolMapping) |
|
613 |
gridViewItemMapping.Rows.Add(new object[] { item, "", "View" }); |
|
614 |
|
|
615 |
foreach (string item in needAttributeMapping) |
|
616 |
gridViewAttribute.Rows.Add(new object[] { item, "", "View" }); |
|
617 |
|
|
618 |
gridViewItemMapping.BestFitColumns(); |
|
619 |
gridViewItemMapping.EndUpdate(); |
|
620 |
|
|
621 |
gridViewAttribute.BestFitColumns(); |
|
622 |
gridViewAttribute.EndUpdate(); |
|
623 |
} |
|
624 |
} |
|
109 | 625 |
} |
110 | 626 |
} |
내보내기 Unified diff