public void ReceiveData(CommunicationsData data)
 {
     if (this.chkLogDataReception.Checked)
     {
         this.SetListBox_Item(this.lstBoxDataReception, data);
     }
 }
        public void btnRequestFromRemotecomponent_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtDataNameToRequest.Text.Length <= 0)
                {
                    throw (new Exception("No data name specified to request"));
                }

                if (this.txtRemoteComponentToRequestData.Text.Length <= 0)
                {
                    throw (new Exception("No selected component to request data"));
                }

                CommunicationsDataRequest datarequest = new CommunicationsDataRequest(this.txtRemoteComponentToRequestData.Text, this.ComponentName, this.txtDataNameToRequest.Text);
                CommunicationsData        data        = default(CommunicationsData);
                data = ((IUseCNDCommunicationsScheme)this).RequestDataFromRemoteComponent(datarequest);
                this._dataRequestedDataDisplayCtrl.ShowData(data.Value);
            }
            catch (Exception ex)
            {
                string err = ex.Message + " -> " + ex.StackTrace + " -> " + ex.TargetSite.ToString();
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
 public void lstBoxDataReception_SelectedIndexChanged(System.Object sender, System.EventArgs e)
 {
     try
     {
         if (this.lstBoxDataReception.Items.Count > 0)
         {
             if (this.lstBoxDataReception.SelectedIndex >= 0)
             {
                 CommunicationsData data = default(CommunicationsData);
                 data = (CommunicationsData)this.lstBoxDataReception.SelectedItem;
                 this._dataReceptionDataDisplayCtrl.ShowData(data.Value);
             }
             else
             {
                 this._dataReceptionDataDisplayCtrl.ClearData();
             }
         }
         else
         {
             this._dataReceptionDataDisplayCtrl.ClearData();
         }
     }
     catch (Exception)
     {
     }
 }
Example #4
0
            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);
            }
Example #5
0
 public void SendData(CommunicationsData data)
 {
     if (this._remoteHandlersContainer.ContainsHandlerForRemoteComponent(data.AddresseComponentName))
     {
         RemoteComponentComunicationsHandler handler = this._remoteHandlersContainer.GetHandler(data.AddresseComponentName);
         handler.SendData(data);
     }
     else
     {
         RemoteComponentComunicationsHandler newhandler = this.GetRemoteHandlerForComponent(data.AddresseComponentName);
         this._remoteHandlersContainer.AddNewHandler(newhandler);
         newhandler.SendData(data);
     }
 }
 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"));
     }
 }
Example #7
0
            public static CommunicationsData GetCommunicationsDataObject(string addresseComponentName, string senderComponentName, string dataName, object data)
            {
                string             type      = data.GetType().ToString();
                CommunicationsData commsData = default(CommunicationsData);

                switch (type)
                {
                case "System.String":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, System.Convert.ToString(data));
                    break;

                case "System.Int32":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, System.Convert.ToInt32(data));
                    break;

                case "System.Decimal":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, System.Convert.ToDecimal(data));
                    break;

                case "System.Boolean":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, System.Convert.ToString(System.Convert.ToBoolean(data)));
                    break;

                case "System.Data.DataTable":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, (DataTable)data);
                    break;

                case "System.Data.DataSet":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, (DataSet)data);
                    break;

                case "UtilitiesLibrary.Data.CustomHashTable":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, System.Convert.ToString((CustomHashTable)data));
                    break;

                case "UtilitiesLibrary.Data.CustomList":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, (CustomList)data);
                    break;

                case "UtilitiesLibrary.Data.CustomSortedList":
                    commsData = new CommunicationsData(addresseComponentName, senderComponentName, dataName, (CustomSortedList)data);
                    break;

                default:
                    throw (new Exception("Unsupported data type \'" + type + "\' for \'CommunicationsData\' data type "));
                }
                return(commsData);
            }
Example #8
0
            public Services.P2PCommunicationsScheme.Data.P2PData RetrieveData(Services.P2PCommunicationsScheme.Data.P2PDataRequest request, int P2PPortNumber)
            {
                string adresseComponentName = System.Convert.ToString(request.GetRequestParameter("ADDRESSE_COMPONENT"));

                if (adresseComponentName == null)
                {
                    throw (new Exception("Can\'t retrieve data because the parameter \'ADDRESSE_COMPONENT\' was missing in the request structure"));
                }

                string senderComponentName = System.Convert.ToString(request.GetRequestParameter("SENDER_COMPONENT"));

                if (senderComponentName == null)
                {
                    throw (new Exception("Can\'t retrieve data because the parameter \'SENDER_COMPONENT\' was missing in the request structure"));
                }

                CNDCommunicationsEnvironment.Data.CommunicationsDataRequest commdDataRequest = new CNDCommunicationsEnvironment.Data.CommunicationsDataRequest(adresseComponentName, senderComponentName, System.Convert.ToString(request.RequestedDataName));

                CommunicationsData dataResult = ((CNDCommunicationsEnvironment.Interfaces.IUseCNDCommunicationsScheme) this._componentOwner).RetrieveDataToRemoteComponent(commdDataRequest);

                P2PData resultData = P2PData.GetP2PDataObject(dataResult.P2PData.DataName, dataResult.P2PData.Value);

                return(resultData);
            }
        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;
            }
        }
Example #10
0
            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);
            }
 public void SendData(CommunicationsData data)
 {
     CommunicationsManager.GetInstance().SendData(data);
 }
Example #12
0
 internal void SendData(CommunicationsData data)
 {
     this._p2pPortClient.SendData(P2PDataSendMode.AsynchronycalSend, data.P2PData);
 }