Пример #1
0
        public void chkEmulate_CheckedChanged(System.Object sender, System.EventArgs e)
        {
            if (this.chkEmulate.Checked)
            {
                if (this._STXServicePArametersCont.Count <= 0)
                {
                    MessageBox.Show("No service parameters defined");
                    this.chkEmulate.Checked = false;
                    return;
                }

                if (this.txtSErviceName.Text.Length <= 0)
                {
                    MessageBox.Show("No service name defined");
                    this.chkEmulate.Checked = false;
                    return;
                }

                if (this.chkEmulate.Checked)
                {
                    this.chkEmulate.Text = "Stop" + Constants.vbNewLine + "Emulation";
                    if (this.rbtnNormalMode.Checked)
                    {
                        this._STXServiceHandler = new DiscoverableServiceDefinitionHandlingServer(DiscoverableServiceHandlingOperativeDefs.DiscoverableServiceMode.multipleNetworkInstancesService, this.txtSErviceName.Text, this._STXServicePArametersCont);
                        this._STXServiceHandler.STXServiceQueryReceived         += new DiscoverableServiceDefinitionHandlingServer.STXServiceQueryReceivedEventHandler(this.QueryReceived);
                        this._STXServiceHandler.STXServiceSuccesfullQueryResult += new  DiscoverableServiceDefinitionHandlingServer.STXServiceSuccesfullQueryResultEventHandler(this.SuccessFullQuerieREsult);
                    }
                    else
                    {
                        this._STXServiceHandler = new DiscoverableServiceDefinitionHandlingServer(DiscoverableServiceHandlingOperativeDefs.DiscoverableServiceMode.singletonInstanceNetworkService, this.txtSErviceName.Text, this._STXServicePArametersCont);
                        this._STXServiceHandler.STXServiceQueryReceived         += new DiscoverableServiceDefinitionHandlingServer.STXServiceQueryReceivedEventHandler(this.QueryReceived);
                        this._STXServiceHandler.STXServiceSuccesfullQueryResult += new  DiscoverableServiceDefinitionHandlingServer.STXServiceSuccesfullQueryResultEventHandler(this.SuccessFullQuerieREsult);
                    }
                }
                else
                {
                    this.chkEmulate.Text = "Emulate STX Service";
                    if (!(this._STXServiceHandler == null))
                    {
                        this._STXServiceHandler.Dispose();
                    }
                }
            }
            else
            {
                this.chkEmulate.Text = "Emulate " + Constants.vbNewLine + "STX Service";
                if (!(this._STXServiceHandler == null))
                {
                    this._STXServiceHandler.Dispose();
                }
            }
        }
Пример #2
0
            private CNDService()
            {
                this._remoteComponentLinkTable = new CNDRemoteComponentLinkHandlerTable();
                this._remoteComponentLinkTable.LinkWithRemoteComponentHasBroken += this.LinkWithRemoteComponentHasBroken;

                //************************************************************************************
                //CREATION THE DEFAULT P2P PORT OF THE SERVICE
                try
                {
                    this._serviceP2PPort = new P2PPort(this, CNDServiceDefinitions.CND_SERVICE_DEFAULT_PORT);
                }
                catch (Exception ex)
                {
                    string msg = " Error starting the default P2PPort of CND service : " + ex.Message;
                    CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg);

                    this._serviceP2PPort = new P2PPort(this);

                    msg = "The CND Service default P2PPort was started using a dinamic port number \'" + System.Convert.ToString(this._serviceP2PPort.ListeningPortNumber) + "\' out of the CND service range (" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.INITIAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + "-" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.FINAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + ")";
                    CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg);
                }

                //************************************************************************************
                //CREATION THE MULTICASTING DATA REPLICATOR SERVER
                try
                {
                    this._MultiCastDataReplicationServer = new MultiCastDataReplicationServer(CNDServiceDefinitions.CND_SERVICE_MULTICAST_IP_ADDRESS, CNDServiceDefinitions.CND_SERVICE_MULTICAST_PORT);
                }
                catch (Exception ex)
                {
                    string msg = " Error starting a multicast port for CND service : " + ex.Message;
                    CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg);

                    this._MultiCastDataReplicationServer = new MultiCastDataReplicationServer();

                    msg = "The CND service Multicast Server was started using a dinamic port number \'" + System.Convert.ToString(this._MultiCastDataReplicationServer.MultiCastPortNumber) + "\' out of the CND service range (" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.INITIAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + "-" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.FINAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + ")";
                    CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg);
                }

                this.LoadCNDTableFromFileOrCreateAndEmptyTableIfNotExists();

                this._hostName = System.Net.Dns.GetHostName();
                //crates the service parameters to publish throuGh the STXServiceDefinitionHandlerServer
                this._STXServicePArametersCont = new DiscoverableServiceDefinitionParametersContainer();
                this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_NAME, System.Convert.ToString(CNDServiceDefinitions.CNDSERVICE_PUBLIC_NAME));
                this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_HOSTNAME, System.Convert.ToString(this._hostName));
                this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_IP_ADDRESS, this._serviceP2PPort.IPAddress.ToString());
                this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_P2PPORT_PORTNUMBER, System.Convert.ToString(this._serviceP2PPort.ListeningPortNumber));
                this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_MULTICASTSERVER_IP_ADDRESS, System.Convert.ToString(this._MultiCastDataReplicationServer.MultiCastIPAddress));
                this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_MULTICASTSERVER_PORTNUMBER, System.Convert.ToString(this._MultiCastDataReplicationServer.MultiCastPortNumber));

                this._STXServicePArametersCont.SaveToFile(CNDServiceDefinitions.CND_SERVICE_SERVICE_PARAMETERS_TABLE_FILENAME);

                this._serviceParametersTable = new DataTable("CND Service Parameters");
                this._serviceParametersTable.Columns.Add("Parameter Name");
                this._serviceParametersTable.Columns.Add("Parameter Value");
                IEnumerator enumm      = this._STXServicePArametersCont.ParametersTable.GetEnumerator();
                string      paramName  = "";
                string      ParamValue = "";
                DataRow     paramRow   = default(DataRow);

                while (enumm.MoveNext())
                {
                    paramName   = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
                    ParamValue  = System.Convert.ToString(((DictionaryEntry)enumm.Current).Value);
                    paramRow    = this._serviceParametersTable.NewRow();
                    paramRow[0] = paramName;
                    paramRow[1] = ParamValue;
                    this._serviceParametersTable.Rows.Add(paramRow);
                }

                //creates the service handler as singleton
                this._stxServiceHandler = new DiscoverableServiceDefinitionHandlingServer(DiscoverableServiceHandlingOperativeDefs.DiscoverableServiceMode.singletonInstanceNetworkService, CNDServiceDefinitions.CNDSERVICE_PUBLIC_NAME, this._STXServicePArametersCont);

                CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, "CND Service started succesfully @ " + this._hostName + " on " + DateTime.Now.ToString());
            }