public bool HasInterface(int deviceID) { string sql = "SELECT * FROM " + TableName + " WHERE DEVICE_ID=" + deviceID.ToString(); DObjectCollection olist = Select(sql); return(olist == null || olist.Count > 0); }
public bool HasSampleName(string name) { string sql = "SELECT * FROM " + TableName + " WHERE INTERFACE_NAME='" + name + "'"; DObjectCollection olist = Select(sql); return(olist == null || olist.Count > 0); }
private GCDeviceCollection GetDeviceList(DObjectCollection dlist) { GCDeviceCollection deviceList = new GCDeviceCollection(); foreach (DeviceRec d in dlist) { GCDeviceAgent device = new GCDeviceAgent(d); deviceList.Add(device); } return(deviceList); }
public GCInterfaceCollection QueryInterfaceList(bool withStatus) { GCError.ClearLastError(); DObjectCollection dlist = InterfaceTable.SelectAll(); if (dlist == null) { GCError.SetLastError("Access database failed."); return(null); } return(GetInterfaceList(dlist, withStatus)); }
public GCDeviceCollection QueryDeviceList() { GCError.ClearLastError(); DObjectCollection dlist = DeviceTable.SelectAll(); if (dlist == null) { GCError.SetLastError("Access database failed."); return(null); } return(GetDeviceList(dlist)); }
public GCDevice GetDeviceByID(int deviceID) { string sql = "SELECT * FROM " + TableName + " WHERE DEVICE_ID=" + deviceID.ToString(); DObjectCollection dlist = Select(sql); if (dlist == null || dlist.Count < 1) { return(null); } DeviceRec rec = dlist[0] as DeviceRec; return(new GCDeviceAgent(rec)); }
private GCInterfaceCollection GetInterfaceList(DObjectCollection dlist, bool withStatus) { GCInterfaceCollection ilist = new GCInterfaceCollection(); foreach (InterfaceRec r in dlist) { GCInterface i = new GCInterface(r); ilist.Add(i); if (withStatus) { i.Status = ServiceControl.GetServiceStatus(i.InterfaceName); } } return(ilist); }
public bool HasSameDevice(GCDevice device) { DeviceRec rec = DataHelper.CreateDeviceRec(device); if (rec == null) { return(true); } string sql = "SELECT * FROM " + TableName + " WHERE DEVICE_DIRECT='" + rec.Direction + "' AND DEVICE_TYPE='" + rec.Type + "' AND DEVICE_NAME='" + rec.Name + "'"; DObjectCollection dlist = Select(sql); if (dlist == null) { return(true); //db query failed. } if (dlist.Count > 0) { return(true); } return(false); }
public DObjectCollection GetCombinedInterfaces(string interfaceName, DirectionType type) { if (interfaceName == null || interfaceName.Length < 1 || type == DirectionType.UNKNOWN) { return(null); } if (type == DirectionType.BIDIRECTIONAL) { return(new DObjectCollection()); } string strSql = ""; switch (type) { case DirectionType.OUTBOUND: strSql = "SELECT * FROM " + TableName + " WHERE DataOut='" + interfaceName + "'"; break; case DirectionType.INBOUND: strSql = "SELECT * FROM " + TableName + " WHERE DataIn='" + interfaceName + "'"; break; } DObjectCollection clist = Select(strSql); if (clist == null) { return(null); } List <string> outList = new List <string>(); foreach (CombinationRec c in clist) { switch (type) { case DirectionType.OUTBOUND: outList.Add(c.DataIn); break; case DirectionType.INBOUND: outList.Add(c.DataOut); break; } } if (outList.Count < 1) { return(new DObjectCollection()); } strSql = "SELECT * FROM " + interfaceMgt.TableName + " WHERE INTERFACE_NAME IN ("; foreach (string outName in outList) { strSql += "'" + outName + "',"; } strSql = strSql.TrimEnd(',') + ")"; return(interfaceMgt.Select(strSql)); }
private void RefreshDetail(GCInterface gcInterface) { try { this.labelName.Text = ""; this.labelType.Text = ""; this.labelDevice.Text = ""; this.labelVersion.Text = ""; this.labelDirection.Text = ""; this.labelDescription.Text = ""; this.listViewCombination.Items.Clear(); if (gcInterface == null) { return; } DeviceDir dir = gcInterface.Directory; if (dir == null) { MessageBox.Show(this, "Invalid device index file in : " + gcInterface.FolderPath, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string deviceInfor = ""; InterfaceRec rec = gcInterface.InterfaceRec; if (rec != null) { deviceInfor = /*rec.DeviceID + " " + */ rec.DeviceName; } this.labelDevice.Text = deviceInfor; this.labelName.Text = dir.Header.Name; this.labelType.Text = dir.Header.Type.ToString(); this.labelVersion.Text = dir.Header.Version; this.labelDirection.Text = dir.Header.Direction.ToString(); //this.labelDescription.Text = dir.Header.Description; string desc = dir.Header.Description; if (desc.Length < 1) { desc = dir.Header.ConfigurationSummary; } else { desc += " (" + dir.Header.ConfigurationSummary + ")"; } this.labelDescription.Text = desc; DObjectCollection olist = combinationMgt.GetCombinedInterfaces(dir.Header.Name, dir.Header.Direction); this.listViewCombination.Items.Clear(); if (olist == null) { MessageBox.Show(this, "Access combination table failed.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int index = 1; foreach (InterfaceRec o in olist) { ListViewItem item = this.listViewCombination.Items.Add((index++).ToString()); item.SubItems.Add(o.Name); item.SubItems.Add(DataHelper.GetDirection(o.Direction).ToString()); item.SubItems.Add(DataHelper.GetType(o.Type).ToString()); item.SubItems.Add(o.Description); item.Tag = o; } } catch (Exception ex) { } }