internal CommunicationsData RetrieveData(CNDCommunicationsEnvironment.Data.CommunicationsDataRequest datarequest) { P2PData dataResult = default(P2PData); dataResult = this._p2pPortClient.RetrieveData(datarequest.P2PDataRequest); CommunicationsData dataRetrieved = default(CommunicationsData); dataRetrieved = CommunicationsData.GetCommunicationsDataObject(datarequest.RemoteAddresseComponentName, datarequest.SenderComponentName, dataResult.DataName, dataResult.Value); return(dataRetrieved); }
public CommunicationsData RetrieveDataToRemoteComponent(CommunicationsDataRequest dataRequest) { if (this._dataToRetrieveBackFromRequestContainer.ContainsData(System.Convert.ToString(dataRequest.RequestedDataName))) { Data data = this._dataToRetrieveBackFromRequestContainer.DataItem(System.Convert.ToString(dataRequest.RequestedDataName)); CommunicationsData dataToRetrieve = default(CommunicationsData); dataToRetrieve = CommunicationsData.GetCommunicationsDataObject(dataRequest.SenderComponentName, this.ComponentName, data.DataName, data.data); return(dataToRetrieve); } else { throw (new Exception("The component \'" + this.ComponentName + "\' can retrieve the data \'" + dataRequest.RequestedDataName + "\' becuase it doesn\'t handle it")); } }
public void btnSendDataToComponent_Click(System.Object sender, System.EventArgs e) { try { if (this.txtRemoteComponentNameToSendData.Text.Length <= 0) { throw (new Exception("No selected component to send data")); } if (this._dataToSendContainer.DataCount <= 0) { throw (new Exception("No data available to send")); } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; Data data = this._dataToSendContainer.SelectedData; if (!(data == null)) { CommunicationsData comData = default(CommunicationsData); comData = CommunicationsData.GetCommunicationsDataObject(this.txtRemoteComponentNameToSendData.Text, this.ComponentName, data.DataName, data.data); ((IUseCNDCommunicationsScheme)this).SendData(comData); } else { throw (new Exception("No data selected from list to send")); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Cursor = System.Windows.Forms.Cursors.Default; } }
public void ReceiveData(Services.P2PCommunicationsScheme.Data.P2PData data, int P2PPortNumber) { P2PDataAttributesTable.P2PDataAttribute attr = new P2PDataAttributesTable.P2PDataAttribute(); if (!data.DataAttributesTable.ContainsAttribute("DATA_TYPE")) { throw (new Exception("Can\'t process the Communications data because the attribute \'DATA_TYPE\' is missing")); } else { attr = data.DataAttributesTable.GetAttribute("DATA_TYPE"); if (attr.AttrValue != "CommunicationsData") { throw (new Exception("Invalid P2PData in the \'ComponentCommunicationsHandler\' environment")); } data.DataAttributesTable.RemoveAttribute("DATA_TYPE"); } string adresseComponentName = ""; if (!data.DataAttributesTable.ContainsAttribute("ADDRESSE_COMPONENT")) { throw (new Exception("Can\'t process the Communications data because the attribute \'ADDRESSE_COMPONENT\' is missing")); } else { attr = data.DataAttributesTable.GetAttribute("ADDRESSE_COMPONENT"); adresseComponentName = attr.AttrValue; data.DataAttributesTable.RemoveAttribute("ADDRESSE_COMPONENT"); } string senderComponentName = ""; if (!data.DataAttributesTable.ContainsAttribute("SENDER_COMPONENT")) { throw (new Exception("Can\'t process the Communications data because the attribute \'SENDER_COMPONENT\' is missing")); } else { attr = data.DataAttributesTable.GetAttribute("SENDER_COMPONENT"); senderComponentName = attr.AttrValue; data.DataAttributesTable.RemoveAttribute("SENDER_COMPONENT"); } CommunicationsData commsData = default(CommunicationsData); commsData = CommunicationsData.GetCommunicationsDataObject(adresseComponentName, senderComponentName, System.Convert.ToString(data.DataName), data.Value); P2PDataAttributesTableEnumerator paramsAttrEnum = default(P2PDataAttributesTableEnumerator); paramsAttrEnum = (P2PDataAttributesTableEnumerator)data.DataAttributesTable.GetEnumerator(); while (paramsAttrEnum.MoveNext()) { attr = paramsAttrEnum.Current; commsData.AddDataAttribute(attr.AttrName, attr.AttrValue); } ((CNDCommunicationsEnvironment.Interfaces.IUseCNDCommunicationsScheme) this._componentOwner).ReceiveData(commsData); }