public static Entity.Trending.EtyEntity getDPInGridViewTSS( TrendViewer.View.OPCDataSelector target, System.Int32 p) { EtyEntity ety = new EtyEntity(); return(ety); }
public EtyEntity getDPInGridView(int p) { EtyEntity dp = new EtyEntity(); dp.Pkey = Convert.ToUInt64(opcItemDataGridView.Rows[p].Cells[0].Value.ToString()); dp.Name = opcItemDataGridView.Rows[p].Cells[1].Value.ToString(); dp.Description = opcItemDataGridView.Rows[p].Cells[2].Value.ToString(); return(dp); }
public void TestNotifyObserver() { NotifyObject notifyObj = new NotifyObject(); notifyObj.Name = "dldl"; dataPointDataController.NotifyObserver(notifyObj); notifyObj.Name = TestConst.TEST_VIEW_ID; notifyObj.Type = DataNotificaitonConst.DPSelected; EtyEntity ety = new EtyEntity(); ety.Name = "bb"; notifyObj.Body = ety; dataPointDataController.NotifyObserver(notifyObj); }
public void TestNotifyObserver() { NotifyObject obj = new NotifyObject(); obj.Name = "AnotherViewID"; histDataPointDataController.NotifyObserver(obj); obj.Name = TestConst.TEST_VIEW_ID; obj.Type = DataNotificaitonConst.DPSelected; EtyEntity ety = new EtyEntity(); ety.Name = "dpName"; obj.Body = ety; histDataPointDataController.NotifyObserver(obj); }
/*public int GetTotalDataPointCount(string opcServerName, string filterString) * { * return OPCNodeNDataPointDAO.GetInstance().GetOPCDataPointCount(opcServerName, filterString); * }*/ /// <summary> /// Get all the DataNode from the Database of specified server root (Parent Entity)name . /// </summary> /// <param name="serverRootName">Root entity name</param> /// <param name="opcServerName">Server name</param> /// <returns>DataNode Entity List</returns> /*public List<EtyOPCDataNode> GetAllOPCDataNodes(string serverRootName, string opcServerName) * { * return OPCNodeNDataPointDAO.GetInstance().GetAllOPCDataNode(serverRootName, opcServerName); * }*/ public List <EtyOPCDataNode> GetAllOPCDataNodes(string serverRootName, string opcServerName) { List <EtyOPCDataNode> etyDataNodeList = new List <EtyOPCDataNode>(); EntityDAO entityDao = new EntityDAO(); Dictionary <ulong, EtyEntity> dataNodelist = entityDao.GetAllDataNodesByServerRootName(serverRootName); foreach (KeyValuePair <ulong, EtyEntity> pair in dataNodelist) { EtyOPCDataNode etyDataNode = new EtyOPCDataNode(); etyDataNode.OPCDataNodeId = pair.Key; EtyEntity etyEntity = pair.Value; etyDataNode.OPCDataNodeName = etyEntity.Name; etyDataNode.OPCDataNodeDesc = etyEntity.Description; etyDataNodeList.Add(etyDataNode); } return(etyDataNodeList); }
public void TestEtyEntity01() { EtyEntity etyEntity = new EtyEntity(); string s = etyEntity.Description; etyEntity.Description = s; s = etyEntity.DisplayName; etyEntity.DisplayName = s; s = etyEntity.Name; etyEntity.Name = s; ulong pkey = etyEntity.Pkey; etyEntity.Pkey = pkey; }
/// <summary> /// Returns all Child Datanode of the specified parent Datanode /// </summary> /// <param name="parentNode">parent datanode name</param> /// <param name="opcServerName">server name</param> /// <returns>Datanode entity List</returns> public List <EtyOPCDataNode> GetChildOPCDataNodes(string parentNode, string opcServerName) { // return OPCNodeNDataPointDAO.GetInstance().GetChildOPCDataNode(parentNode, opcServerName); ulong parentkey = Convert.ToUInt64(parentNode); List <EtyOPCDataNode> etyDataNodeList = new List <EtyOPCDataNode>(); EntityDAO entityDao = new EntityDAO(); Dictionary <ulong, EtyEntity> dataNodelist = entityDao.GetDataNodeChildrenByPkey(parentkey); foreach (KeyValuePair <ulong, EtyEntity> pair in dataNodelist) { EtyOPCDataNode etyDataNode = new EtyOPCDataNode(); etyDataNode.OPCDataNodeId = pair.Key; EtyEntity etyEntity = pair.Value; etyDataNode.OPCDataNodeName = etyEntity.Name; etyDataNode.OPCDataNodeDesc = etyEntity.Description; etyDataNodeList.Add(etyDataNode); } return(etyDataNodeList); }
public override void NotifyObserver(NotifyObject notifyObj) { if (notifyObj.Name != m_View.ViewID) { return; } //will only handle the notification when the ViewID is matching. if (notifyObj.Type == DataNotificaitonConst.DPSelected) { EtyEntity dp = (EtyEntity)(notifyObj.Body); m_dp.EntityKey = dp.Pkey; //sometimes it maybe doesn't have pkey(when the dp is not selected from the select page) m_dp.DPName = dp.Name; if (dp.Name.CompareTo("") != 0) { m_dp.DPLblName = dp.Name.Length > 50 ? (dp.Name).Substring(0, 50) : dp.Name; } m_View.UpdateHistDPNameAndLabel(m_dp); } }
public void opcItemDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { string Function_Name = "opcItemDataGridView_CellDoubleClick"; try { if (e.RowIndex < 0) { return; } EtyEntity dp = m_View.getDPInGridView(e.RowIndex); NotifyManager.GetInstance().Send(DataNotificaitonConst.DPSelected, m_View.ViewID, dp); m_View.Close(); } catch (Exception localException) { LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString()); } }
public override void NotifyObserver(NotifyObject notifyObj) { if (notifyObj.Name != m_View.ViewID) { return; } //will only handle the notification when the ViewID is matching. if (notifyObj.Type == DataNotificaitonConst.DPSelected) { EtyEntity dp = (EtyEntity)(notifyObj.Body); m_dp.PKey = dp.Pkey; m_dp.DPName = dp.Name; if (dp.Name.CompareTo("") != 0) { m_dp.DPLblName = dp.Name.Length > 50 ? (dp.Name).Substring(0, 50) : dp.Name; } m_View.UpdateDPNameAndLabel(m_dp); } }
public void TestLoadDataPointToGridView_getDPInGridView() { Accessor oPCDataSelectorAccessor = ReflectionAccessor.Wrap(oPCDataSelector); oPCDataSelectorAccessor.Call("InitializeOpcItemDataGridView"); Dictionary <ulong, EtyEntity> entityMap = new Dictionary <ulong, EtyEntity>(); EtyEntity e1 = new EtyEntity(); e1.Name = "test1"; e1.Pkey = 1; e1.Description = "des1"; EtyEntity e2 = new EtyEntity(); e2.Name = "test2"; e2.Pkey = 2; e2.Description = "des2"; entityMap.Add(1, e1); entityMap.Add(2, e2); oPCDataSelector.LoadDataPointToGridView(entityMap); oPCDataSelector.getDPInGridView(0); }
public void TestDisplay_getSelectedNode_LoadDataNodeChildren() { Dictionary <ulong, EtyEntity> entityMap = new Dictionary <ulong, EtyEntity>(); EtyEntity e1 = new EtyEntity(); e1.Name = "test1"; e1.Pkey = 1; EtyEntity e2 = new EtyEntity(); e2.Name = "test2"; e2.Pkey = 2; entityMap.Add(1, e1); entityMap.Add(2, e2); oPCDataSelector.Display(entityMap); oPCDataSelector.getSelectedNode(); Accessor oPCDataSelectorAccessor = ReflectionAccessor.Wrap(oPCDataSelector); System.Windows.Forms.TreeView treeOpcItems = (System.Windows.Forms.TreeView)(oPCDataSelectorAccessor.GetField("treeOpcItems")); TreeNode treeNode = treeOpcItems.Nodes[0]; oPCDataSelector.LoadDataNodeChildren(ref treeNode, entityMap); }
/// <summary> /// Get All child data point by a given entity pkey /// </summary> /// <param name="pkey">the parent entity pkey</param> /// <returns></returns> public Dictionary <ulong, EtyEntity> GetDataPointByDNPkey(ulong pkey) { string Function_Name = "GetDataPointByDNPkey"; LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered"); Dictionary <ulong, EtyEntity> res = new Dictionary <ulong, EtyEntity>(); // localSQL = " SELECT KEYID,DATA_PT_NAME,DATA_PT_DESC,DISABLE " + // " FROM OPC_DT_PT " + // " WHERE PKEYID = " + parentKeyID + // " AND DATA_PT_HOST = '" + opcServerHostBox.Text.Trim() + "' AND DATA_PT_SERVER = '" + serverNameBox.Text.Trim() + "' " + // " ORDER BY DATA_PT_NAME"; string localSQL = " SELECT PKEY,CONCAT(NAME,'.Value') as LONGNAME,DESCRIPTION " + " FROM ENTITY " + " WHERE PARENTKEY = " + pkey.ToString() + " AND TYPEKEY IN (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataPoint' ) " + " AND DELETED = 0 "; /*if (checkLoc) * { * localSQL = string.Concat(localSQL, " AND LOCATIONKEY=", locKey); * }*/ string LocationClauseStr = DAOHelper.CheckLocationAndAddSQL(COLUMN_LOCATIONKEY); if (LocationClauseStr.Length != 0) { localSQL += " AND" + LocationClauseStr; } localSQL = localSQL + " ORDER BY NAME"; System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL); try { while (drReader != null && drReader.Read()) { EtyEntity entity = new EtyEntity(); if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_PKEY))) { entity.Pkey = Convert.ToUInt64(drReader[COLUMN_PKEY]); } if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_LONGNAME))) { entity.Name = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_LONGNAME].ToString()); } if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_DESCRIPTION))) { entity.Description = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_DESCRIPTION].ToString()); } res.Add(entity.Pkey, entity); } } catch (System.Exception ex) { LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString()); } if (drReader != null) { drReader.Close(); drReader.Dispose(); //SimpleDatabase.GetInstance().CloseCurrentSession(); } LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); return(res); }
/// <summary> /// Get all the child data node by an entity pkey /// </summary> /// <param name="pkey">the parent entity pkey</param> /// <returns></returns> public Dictionary <ulong, EtyEntity> GetDataNodeChildrenByPkey(ulong pkey) { string Function_Name = "GetDataNodeChildrenByPkey"; LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered"); Dictionary <ulong, EtyEntity> res = new Dictionary <ulong, EtyEntity>(); string localSQL = " SELECT PKEY,NAME,DESCRIPTION " + " FROM ENTITY " + " WHERE PARENTKEY = " + pkey.ToString() + " AND TYPEKEY IN (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataNode' ) " + " AND DELETED = 0 "; /* if (checkLoc) * { * //localSQL = localSQL + " AND LOCATIONKEY=" + locKey.ToString; * localSQL = string.Concat(localSQL, " AND LOCATIONKEY=", locKey); * }*/ string LocationClauseStr = DAOHelper.CheckLocationAndAddSQL(COLUMN_LOCATIONKEY); if (LocationClauseStr.Length != 0) { localSQL += " AND" + LocationClauseStr; } localSQL = localSQL + " ORDER BY NAME"; System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL); try { while (drReader != null && drReader.Read()) { EtyEntity entity = new EtyEntity(); if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_PKEY))) { entity.Pkey = Convert.ToUInt64(drReader[COLUMN_PKEY]); } if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_NAME))) { entity.Name = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_NAME].ToString()); } if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_DESCRIPTION))) { entity.Description = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_DESCRIPTION].ToString()); } res.Add(entity.Pkey, entity); } } catch (System.Exception ex) { LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString()); } if (drReader != null) { drReader.Close(); drReader.Dispose(); //SimpleDatabase.GetInstance().CloseCurrentSession(); } LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); return(res); }