개정판 9ee9b61d
dev issue #1227 : mapping 화면 개발
Change-Id: I8e738f1b849c55887c1e8cc66e48777f4033b409
DTI_PID/APIDConverter/DB/Project_DB.cs | ||
---|---|---|
25 | 25 |
const string Symbol_TABLE = "Symbol"; |
26 | 26 |
const string OPCRelations_TABLE = "OPCRelations"; |
27 | 27 |
|
28 |
#region Only ID2 DB |
|
28 | 29 |
private static SqlConnection GetSqlConnection() |
29 | 30 |
{ |
30 | 31 |
Project_Info projectInfo = Project_Info.GetInstance(); |
... | ... | |
213 | 214 |
|
214 | 215 |
return dt; |
215 | 216 |
} |
217 |
public static DataTable GetLineMappingTable() |
|
218 |
{ |
|
219 |
DataTable dt = new DataTable(); |
|
220 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
221 |
if (projectInfo.DBType == ID2DB_Type.SQLite) |
|
222 |
{ |
|
223 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
224 |
{ |
|
225 |
try |
|
226 |
{ |
|
227 |
connection.Open(); |
|
228 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
229 |
{ |
|
230 |
cmd.CommandText = string.Format(@" |
|
231 |
SELECT l.UID, l.Name, sp.APID_SYMBOL FROM {0} as l |
|
232 |
LEFT OUTER JOIN {1} as sp |
|
233 |
ON l.UID = SP.UID ;", LineTypes_TABLE, APID_SYMBOL_MAPPING_TABLE); |
|
234 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
235 |
dt.Load(dr); |
|
236 |
} |
|
237 |
connection.Close(); |
|
238 |
} |
|
239 |
catch (Exception ex) |
|
240 |
{ |
|
241 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
242 |
} |
|
243 |
finally |
|
244 |
{ |
|
245 |
connection.Dispose(); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
else if (projectInfo.DBType == ID2DB_Type.MSSQL) |
|
250 |
{ |
|
251 |
using (SqlConnection connection = GetSqlConnection()) |
|
252 |
{ |
|
253 |
try |
|
254 |
{ |
|
255 |
if (connection != null && connection.State == ConnectionState.Open) |
|
256 |
{ |
|
257 |
using (SqlCommand cmd = connection.CreateCommand()) |
|
258 |
{ |
|
259 |
cmd.CommandText = string.Format(@" |
|
260 |
SELECT l.UID, l.Name, sp.APID_SYMBOL FROM {0} as l |
|
261 |
LEFT OUTER JOIN {1} as sp |
|
262 |
ON l.UID = SP.UID ;", LineTypes_TABLE, APID_SYMBOL_MAPPING_TABLE); |
|
263 |
using (SqlDataReader dr = cmd.ExecuteReader()) |
|
264 |
dt.Load(dr); |
|
265 |
} |
|
266 |
connection.Close(); |
|
267 |
} |
|
268 |
} |
|
269 |
catch (Exception ex) |
|
270 |
{ |
|
271 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
272 |
} |
|
273 |
finally |
|
274 |
{ |
|
275 |
if (connection != null) |
|
276 |
connection.Dispose(); |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
216 | 280 |
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
#region Only ID2 DB |
|
281 |
return dt; |
|
282 |
} |
|
221 | 283 |
public static DataTable SelectID2SymbolTable() |
222 | 284 |
{ |
223 | 285 |
DataTable dt = new DataTable(); |
DTI_PID/APIDConverter/Form/MappingForm.Designer.cs | ||
---|---|---|
29 | 29 |
private void InitializeComponent() |
30 | 30 |
{ |
31 | 31 |
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MappingForm)); |
32 |
DevExpress.XtraBars.Ribbon.GalleryItemGroup galleryItemGroup3 = new DevExpress.XtraBars.Ribbon.GalleryItemGroup();
|
|
32 |
DevExpress.XtraBars.Ribbon.GalleryItemGroup galleryItemGroup4 = new DevExpress.XtraBars.Ribbon.GalleryItemGroup();
|
|
33 | 33 |
this.ribbonControl = new DevExpress.XtraBars.Ribbon.RibbonControl(); |
34 | 34 |
this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl(); |
35 | 35 |
this.btnRefreshSymbol = new DevExpress.XtraEditors.SimpleButton(); |
... | ... | |
159 | 159 |
// |
160 | 160 |
// |
161 | 161 |
// |
162 |
galleryItemGroup3.Caption = "Items";
|
|
162 |
galleryItemGroup4.Caption = "Items";
|
|
163 | 163 |
this.galleryControlAvevaSymbols.Gallery.Groups.AddRange(new DevExpress.XtraBars.Ribbon.GalleryItemGroup[] { |
164 |
galleryItemGroup3});
|
|
164 |
galleryItemGroup4});
|
|
165 | 165 |
this.galleryControlAvevaSymbols.Gallery.ItemDoubleClick += new DevExpress.XtraBars.Ribbon.GalleryItemClickEventHandler(this.galleryControlAvevaSymbols_Gallery_ItemDoubleClick); |
166 | 166 |
this.galleryControlAvevaSymbols.Location = new System.Drawing.Point(795, 357); |
167 | 167 |
this.galleryControlAvevaSymbols.Name = "galleryControlAvevaSymbols"; |
DTI_PID/APIDConverter/Form/MappingForm.cs | ||
---|---|---|
30 | 30 |
InitializeComponent(); |
31 | 31 |
SetSymbolMappingTable(); |
32 | 32 |
SetAvevaSymbolStructure(); |
33 |
SetLineMappingTable(); |
|
34 |
|
|
35 |
#region Events/UI |
|
33 | 36 |
gridViewSymbol.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(gridViewSymbol_FocusedRowChanged); |
34 | 37 |
treeListAvevaSymbol.FocusedNodeChanged += new FocusedNodeChangedEventHandler(treeListAvevaSymbol_FocusedNodeChanged); |
35 | 38 |
galleryControlAvevaSymbols.Gallery.ItemImageLayout = DevExpress.Utils.Drawing.ImageLayoutMode.ZoomInside; |
36 | 39 |
galleryControlAvevaSymbols.Gallery.ImageSize = new System.Drawing.Size(112, 55); |
37 | 40 |
galleryControlAvevaSymbols.Gallery.ShowItemText = true; |
41 |
#endregion |
|
38 | 42 |
} |
39 | 43 |
|
40 | 44 |
#region Init |
... | ... | |
130 | 134 |
treeListAvevaSymbol.ExpandToLevel(0); |
131 | 135 |
stdStructure.Dispose(); |
132 | 136 |
} |
137 |
private void SetLineMappingTable() |
|
138 |
{ |
|
139 |
DataTable dt = Project_DB.GetLineMappingTable(); |
|
140 |
dt.Columns.Add("Type"); |
|
141 |
foreach (DataRow row in dt.Rows) |
|
142 |
row["Type"] = "Line Property"; |
|
143 |
gridControlLine.DataSource = dt; |
|
144 |
|
|
145 |
gridViewLine.Columns["UID"].Visible = false; |
|
146 |
gridViewLine.Columns["APID_SYMBOL"].Caption = "APID Line"; |
|
147 |
gridViewLine.Columns["Type"].GroupIndex = 0; |
|
148 |
gridViewLine.ExpandAllGroups(); |
|
149 |
|
|
150 |
#region line datatable |
|
151 |
DataTable avevaLineType = new DataTable(); |
|
152 |
avevaLineType.Columns.Add("Type"); |
|
153 |
avevaLineType.Columns.Add("Style"); |
|
154 |
List<string> pipeStyle = APIDUtils.GetPipeStyle(); |
|
155 |
List<string> signalStyle = APIDUtils.GetSignalStyle(); |
|
156 |
foreach (var item in pipeStyle) |
|
157 |
avevaLineType.Rows.Add("Pipe", item); |
|
158 |
foreach (var item in signalStyle) |
|
159 |
avevaLineType.Rows.Add("Signal", item); |
|
160 |
#endregion |
|
161 |
|
|
162 |
#region set lookUpEdit |
|
163 |
RepositoryItemGridLookUpEdit lookUpEdit = new RepositoryItemGridLookUpEdit(); |
|
164 |
lookUpEdit.BeginInit(); |
|
165 |
lookUpEdit.DataSource = avevaLineType; |
|
166 |
lookUpEdit.DisplayMember = "Style"; |
|
167 |
lookUpEdit.ValueMember = "Style"; |
|
168 |
lookUpEdit.NullText = ""; |
|
169 |
lookUpEdit.BestFitMode = BestFitMode.BestFitResizePopup; |
|
170 |
lookUpEdit.KeyUp += lookUpEdit_KeyUp; |
|
171 |
lookUpEdit.Popup += lookUpEdit_Popup; |
|
172 |
lookUpEdit.EndInit(); |
|
173 |
|
|
174 |
lookUpEdit.View.OptionsBehavior.AutoPopulateColumns = false; |
|
175 |
DevExpress.XtraGrid.Columns.GridColumn colType = lookUpEdit.View.Columns.AddField("Type"); |
|
176 |
colType.GroupIndex = 0; |
|
177 |
colType.VisibleIndex = 0; |
|
178 |
DevExpress.XtraGrid.Columns.GridColumn colStyle = lookUpEdit.View.Columns.AddField("Style"); |
|
179 |
colStyle.VisibleIndex = 1; |
|
180 |
#endregion |
|
181 |
|
|
182 |
gridControlLine.RepositoryItems.Add(lookUpEdit); |
|
183 |
gridViewLine.Columns["APID_SYMBOL"].ColumnEdit = lookUpEdit; |
|
184 |
} |
|
133 | 185 |
#endregion |
134 | 186 |
|
135 | 187 |
#region Events |
... | ... | |
340 | 392 |
gridViewSymbol.SetRowCellValue(gridViewSymbol.FocusedRowHandle, "APID_SYMBOL", null); |
341 | 393 |
} |
342 | 394 |
} |
395 |
private void lookUpEdit_KeyUp(object sender, KeyEventArgs e) |
|
396 |
{ |
|
397 |
LookUpEdit edit = sender as LookUpEdit; |
|
398 |
if (e.KeyCode == Keys.Delete) |
|
399 |
{ |
|
400 |
edit.ClosePopup(); |
|
401 |
edit.EditValue = null; |
|
402 |
} |
|
403 |
e.Handled = true; |
|
404 |
} |
|
405 |
private void lookUpEdit_Popup(object sender, EventArgs e) |
|
406 |
{ |
|
407 |
GridLookUpEdit lookUpEdit = sender as GridLookUpEdit; |
|
408 |
lookUpEdit.Properties.View.ExpandAllGroups(); |
|
409 |
} |
|
343 | 410 |
#endregion |
344 | 411 |
|
345 | 412 |
private void GetNodeLoopText(TreeListNode node, ref string result) |
DTI_PID/APIDConverter/Utils/APIDUtils.cs | ||
---|---|---|
45 | 45 |
Aveva.Command.AvevaCommands.projectExplorer.Add(sName, new APIDConverterExplorer()); |
46 | 46 |
Aveva.Command.AvevaCommands.projectExplorer.Activate(Aveva.Command.AvevaCommands.projectExplorer.Count - 1); |
47 | 47 |
} |
48 |
|
|
48 |
} |
|
49 |
|
|
50 |
public static List<string> GetPipeStyle() |
|
51 |
{ |
|
52 |
List<string> list = new List<string>(); |
|
53 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL"); |
|
54 |
object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE"); |
|
55 |
if (objPipeStyle != null) |
|
56 |
{ |
|
57 |
Autodesk.Windows.RibbonCombo pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
|
58 |
foreach (var item in pipeStyleCombo.Items) |
|
59 |
{ |
|
60 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
|
61 |
list.Add(loop.AutomationName); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
return list; |
|
66 |
} |
|
67 |
|
|
68 |
public static List<string> GetSignalStyle() |
|
69 |
{ |
|
70 |
List<string> list = new List<string>(); |
|
71 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL"); |
|
72 |
object objPipeStyle = GUIUtils.FindItem(items, "SIGNALSTYLE"); |
|
73 |
if (objPipeStyle != null) |
|
74 |
{ |
|
75 |
Autodesk.Windows.RibbonCombo pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
|
76 |
foreach (var item in pipeStyleCombo.Items) |
|
77 |
{ |
|
78 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
|
79 |
list.Add(loop.AutomationName); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
return list; |
|
49 | 84 |
} |
50 | 85 |
} |
51 | 86 |
} |
내보내기 Unified diff