private void LogClientForPublicationDataReception(DPE_DataPublicationsClient client, string publicationName) { try { if (this._ClientConnectionsToPublicationsLogTable.ContainsKey(publicationName)) { Hashtable publicationTable = default(Hashtable); publicationTable = (Hashtable)(this._ClientConnectionsToPublicationsLogTable[publicationName]); if (publicationTable.ContainsKey(client.ClientID)) { publicationTable.Remove(client.ClientID); } publicationTable.Add(client.ClientID, client); } else { Hashtable newPublicationTAble = new Hashtable(); newPublicationTAble.Add(client.ClientID, client); this._ClientConnectionsToPublicationsLogTable.Add(publicationName, newPublicationTAble); } } catch (Exception) { } }
public void STXDataSocketClient_Load(System.Object sender, System.EventArgs e) { try { this._STXEventLog = CustomEventLog.GetInstance(); this._STXEventLog.LogEntryReceived += this._STXEventLog_LogEntryReceived; } catch (Exception) { } this._errorsCount = 0; this.txtErrorsCount.Text = System.Convert.ToString(this._errorsCount); try { this._STXDataSocketClient = new DPE_DataPublicationsClient(); this._STXDataSocketClient.ConnectionWithSTXDataServerLost += this.ConnectionWithServerLost; this._STXDataSocketClient.ConnectToServer(); this.ssConnectionLabel.Text = "Connected to Server"; try { this.dgrdServerParameters.DataSource = this._STXDataSocketClient.ServerParametersTable; } catch (Exception ex) { MessageBox.Show(ex.Message); } try { this.dgrdSTXDSSClients.DataSource = this._STXDataSocketClient.GetClientsRegistryTable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { this.dgrdPublihsers.DataSource = this._STXDataSocketClient.GetPublihsersRegistryTable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { this.dgrdPublications.DataSource = this._STXDataSocketClient.GetPublicationsRegistryTable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } catch (Exception ex) { this.btnConnectToServer.Visible = true; MessageBox.Show(ex.Message); } }
internal void LogClientDisconnectionFromPublication(DPE_DataPublicationsClient stxdssClient, string PublicationName) { try { this.UnLogClientForPublicationDataReception(stxdssClient, PublicationName); int connectedClients = this.GetConnectedClientsToPublicationCount(PublicationName); if (connectedClients <= 0) { //removes all the handles to receive data for this publication because nobody will be use it //removes the multicast clientss if exists MultiCastDataReplicatorClient publicationMultiCastClient = default(MultiCastDataReplicatorClient); publicationMultiCastClient = (MultiCastDataReplicatorClient)this._MultiCastDataReplicatorClientsTable[PublicationName]; if (!(publicationMultiCastClient == null)) { publicationMultiCastClient.Dispose(); } this._MultiCastDataReplicatorKeyStringsTable.Remove(PublicationName); this._MultiCastDataReplicatorClientsTable.Remove(PublicationName); SocketsServer listener = default(SocketsServer); listener = (SocketsServer)this._SocketServersListenersTable[PublicationName]; if (!(listener == null)) { listener.Dispose(); } this._SocketServersListenersTable.Remove(PublicationName); } } catch (Exception) { } }
public void btnDisposeClient_Click(System.Object sender, System.EventArgs e) { try { if (this.lstBoxClients.Items.Count <= 0) { throw (new Exception("No clients available to dispose")); } if (this.lstBoxClients.SelectedIndex < 0) { throw (new Exception("No client selected from list")); } int clientTabIndex = this.lstBoxClients.SelectedIndex; DPE_DataPublicationsClient client = (DPE_DataPublicationsClient)this.lstBoxClients.SelectedItem; if (Interaction.MsgBox("Dispose the client \'" + client.ClientName + "\'", (Microsoft.VisualBasic.MsgBoxStyle) 0, null) == MsgBoxResult.Ok) { client.DisconnectFromServer(); client.Dispose(); this.lstBoxClients.Items.Remove(client); this.TabClients.TabPages[clientTabIndex].Dispose(); } this._ClientHandlersDataContainer.RemoveClientHandlerData(client.ClientName); this._ClientHandlersDataContainer.SaveData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public frm_DPE_RandomPublicationCreation(DPE_DataPublicationsClient client) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._client = client; this._variablesCount = 0; }
public frm_DPE_PublicationCreation(DPE_DataPublicationsClient client) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._client = client; this._publicationVariables = new Hashtable(); }
internal DPE_PublicationsPostingManager(DPE_DataPublicationsClient client) { this._STXDataSocketClient = client; this._STXDataSocketClient.ConnectionWithSTXDataServerLost += this._STXDataSocketClient_ConnectionWithSTXDataServerLost; this._ContainerOfPostedPublicationsOnServer = new DPE_PublicationDefinitionsContainer(); this._ContainerOfScheduledPublicationsPostingOnServer = new DPE_PublicationDefinitionsContainer(); this._PublicationScheduleREgistersTable = new Hashtable(); this._publicationsScheduledPostingQueue = new Queue(); }
public CF_DPE_PublicationSubscriptionHandler(DPE_DataPublicationsClient client, string publicationName) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._client = client; this._publicationName = publicationName; }
internal DPE_PublicationsConnectionsManager(DPE_DataPublicationsClient client) { this._STXDataSocketClient = client; this._STXDataSocketClient.ConnectionWithSTXDataServerLost += this._STXDataSocketClient_ConnectionWithSTXDataServerLost; this._STXDSSC_PublicationsProxyConnectionsServerClient = DPE_PublicationsConnectionsProxyServerClient.GetInstance(client.PublicationsMainServerDataBaseConnectionString); this._STXDSSC_PublicationsProxyConnectionsServerClient.ConnectionWithProxyServerLost += this._STXDSSC_PublicationsProxyConnectionsServerClient_ConnectionWithProxyServerLost; this._STXDSSPublicationConnectionHandlersContainer = new DPE_PublicationConnectionHandlersContainer(); this._tableOfConnectionInfoRegistersOfConnectionsToPublications = new Hashtable(); }
public CF_DPE_ClientHandler(ClientHandlerData data) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._client = new DPE_DataPublicationsClient(data.ClientName); this._client.ConnectionWithSTXDataServerLost += this.ConnectionWithServerLost; if (!this._client.IsConnected) { this._client.ConnectToServer(); } this._ClientHandlerData = data; this.lblSErverConnectionStatus.Text = "Status: Connected To Server"; this._PublicationsHandlersContainer = new CF_DPE_PublicationsPostHandlersContainer(this._client, this._ClientHandlerData); this._PublicationsConnectionsHandlersContainer = new CF_DPE_PublicationsSubscriptionsHandlersContainer(this._client, this._ClientHandlerData); //creates all the publications configured for the client IEnumerator enumm = data.PublicationsPostEnumerator; publicationsPosting.PostedPublicationDefinitionData pubPostData = null; while (enumm.MoveNext()) { pubPostData = (publicationsPosting.PostedPublicationDefinitionData)enumm.Current; DPE_ClientPublicationDefinition publication = new DPE_ClientPublicationDefinition(pubPostData.PublicationName); IEnumerator enumm2 = pubPostData.VariablesDefinitionContainer.GetEnumerator(); publicationsPosting.PublicationVariableDefinitionData varDAta = null; while (enumm2.MoveNext()) { varDAta = (publicationsPosting.PublicationVariableDefinitionData)enumm2.Current; publication.AddVaribleToPublication(varDAta.VariableName, varDAta.DataType); } this._client.CreateDataPublication(publication); this._PublicationsHandlersContainer.AddPublicationHandler(publication.PublicationName); } //creates all the connections with publications configured for the client IEnumerator pubCnnEnumm = data.PublicationsConnectionsEnumerator; publicationsConnection.PublicationConnectionData cnndta = default(publicationsConnection.PublicationConnectionData); while (pubCnnEnumm.MoveNext()) { cnndta = (publicationsConnection.PublicationConnectionData)pubCnnEnumm.Current; this._client.ConnectToADataPublication(cnndta.PublicationName, cnndta.ConnectionMode); this._PublicationsConnectionsHandlersContainer.AddPublicationConnectionHandler(cnndta.PublicationName); } }
public CF_DPE_ClientHandler() { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._client = new DPE_DataPublicationsClient(); this._client.ConnectionWithSTXDataServerLost += this.ConnectionWithServerLost; this._client.ConnectToServer(); this.lblSErverConnectionStatus.Text = "Status: Connected To Server"; this._PublicationsHandlersContainer = new CF_DPE_PublicationsPostHandlersContainer(this._client, this._ClientHandlerData); }
public DPE_PublicationConnectionHandler(DPE_PublicationConnectionHandler_Type handlerType, DPE_DataPublicationsClient client, string PublicationName, string PublicationHostName, int publicationsSocketsServerPortNumber, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode) { //************************************************************************************* this._STXDSSC_PublicationsProxyConnectionsServerClient = DPE_PublicationsConnectionsProxyServerClient.GetInstance(client.PublicationsMainServerDataBaseConnectionString); this._STXDSSC_PublicationsProxyConnectionsServerClient.ConnectionWithProxyServerLost += this._STXDSSC_PublicationsProxyConnectionsServerClient_ConnectionWithProxyServerLost; this._STXDSSC_PublicationsProxyConnectionsServerClient.Connect(); this._handlerType = handlerType; this._STXDataSocketClient = client; this._publicationName = PublicationName; this._publicationHostNAme = PublicationHostName; this._publicationPort = publicationsSocketsServerPortNumber; this._connectionMode = connectionMode; //************************************************************************************* //creates the server socket client to the publication's socket server in order to use it as endpoint to detect //when the publication goes off line string clientName = this._publicationName + Guid.NewGuid().ToString(); this._PublicationSocketsServerClient = new SocketsServerClient(clientName, this._publicationHostNAme, this._publicationPort); this._PublicationSocketsServerClient.DataReceived += publicationSocketClient_DataReceived; this._PublicationSocketsServerClient.ConnectionLost += publicationSocketClient_ConnectionLost; this._PublicationSocketsServerClient.Connect(); //becuase only the subscriptors clients will receive data from the publication if (handlerType == DPE_PublicationConnectionHandler_Type.subscriptorHandler) { //***************************************************************************************** try { //asks the proxy server to have a handle to create a sql reader to read locally the publications update this._DSSPublicationsSQLReader = this._STXDSSC_PublicationsProxyConnectionsServerClient.GetPublicationSocketsServerListenerClient(this._publicationName, this._publicationHostNAme); this._DSSPublicationsSQLReader.dataResetFromPublication += EventHandling_DSSPublicationsSQLReader_dataResetFromPublication; this._DSSPublicationsSQLReader.dataUpdateFromPublication += EventHandling_DSSPublicationsSQLReader_dataUpdateFromPublication; this._DSSPublicationsSQLReader.StartReading(); this._STXDSSC_PublicationsProxyConnectionsServerClient.LogClientConnectionFromPublication(this._STXDSSC_PublicationsProxyConnectionsServerClient.SocketsServerClientID, this._STXDataSocketClient, this._publicationName); } catch (Exception ex) { CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString()); } } else if (handlerType == DPE_PublicationConnectionHandler_Type.publisherHandler) { this._DSSPublicationsSQLWriter = new DPE_PublicationsSQLWriter(client.PublicationsMainServerDataBaseConnectionString, this._publicationName); } }
public CF_DPE_PublicationVariableSimulationHandlerContainer(DPE_DataPublicationsClient client) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._variablesTabPagesTable = new Hashtable(); this._handlersTable = new Hashtable(); this._client = client; if (!this._client.IsConnected) { this._client.ConnectToServer(); } }
public CF_DPE_ClientHandler(string clientName, bool DataStatisticsHandling) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. clientName = clientName.ToUpper(); this._client = new DPE_DataPublicationsClient(clientName); this._client.ConnectionWithSTXDataServerLost += this.ConnectionWithServerLost; if (!this._client.IsConnected) { this._client.ConnectToServer(); } this._ClientHandlerData = new ClientHandlerData(clientName, DataStatisticsHandling); this.lblSErverConnectionStatus.Text = "Status: Connected To Server"; this._PublicationsHandlersContainer = new CF_DPE_PublicationsPostHandlersContainer(this._client, this._ClientHandlerData); this._PublicationsConnectionsHandlersContainer = new CF_DPE_PublicationsSubscriptionsHandlersContainer(this._client, this._ClientHandlerData); }
public CF_DPE_PublicationPostHandler(DPE_DataPublicationsClient client, string publicationName, ClientHandlerData ClientHandlerData) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._client = client; this._publicationName = publicationName; this._ClientHandlerData = ClientHandlerData; this._variablesHandlerContainer = new CF_DPE_PublicationVariableSimulationHandlerContainer(this._client); this._variablesHandlerContainer.Dock = System.Windows.Forms.DockStyle.Fill; this.pnlVariablesHandler.Controls.Add(this._variablesHandlerContainer); PostedPublicationDefinitionData data = this._ClientHandlerData.GetPublicationPostDefinition(this._publicationName); if (!(data == null)) { IEnumerator enumm = data.VariablesDefinitionContainer.GetEnumerator(); PublicationVariableDefinitionData var = null; while (enumm.MoveNext()) { var = (PublicationVariableDefinitionData)enumm.Current; this._variablesHandlerContainer.AddVariableHandler(this._publicationName, ref var); } enumm = data.VariablesDefinitionContainer.GetEnumerator(); CF_DPE_PublicationVariableSimulationHandler simHadler = null; while (enumm.MoveNext()) { var = (PublicationVariableDefinitionData)enumm.Current; simHadler = this._variablesHandlerContainer.GetVariableSimulationHandler(var.VariableName); if (var.DataUPDATESimulationStatus == PublicationVariableDefinitionData.variableSimulationStatus.running) { simHadler.StartUPDATESimulation(); } if (var.DataRESETSimulationStatus == PublicationVariableDefinitionData.variableSimulationStatus.running) { simHadler.StartRESETSimulation(); } } } }
public CF_DPE_PublicationVariableSimulationHandler(DPE_DataPublicationsClient client, string publicationName, publicationsPosting.PublicationVariableDefinitionData variableDefinition) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._publicationName = publicationName; this._variableDefinition = variableDefinition; this._client = client; if (!this._client.IsConnected) { this._client.ConnectToServer(); } variableDefinition.SimulationHandlerExists = true; this._statsUpdateTimer = new System.Timers.Timer(250); this._statsUpdateTimer.Elapsed += this._statsUpdateTimer_Elapsed; this._statsUpdateTimer.AutoReset = false; this._statsUpdateTimer.Stop(); }
public void btnConnectToServer_Click(System.Object sender, System.EventArgs e) { try { this.Cursor = Cursors.WaitCursor; this._STXDataSocketClient = new DPE_DataPublicationsClient(); this._STXDataSocketClient.ConnectionWithSTXDataServerLost += this.ConnectionWithServerLost; this._STXDataSocketClient.ConnectToServer(); this.btnConnectToServer.Visible = false; this.ssConnectionLabel.Text = "Connected to Server"; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Cursor = Cursors.Default; } }
internal MultiCastDataReplicatorClient GetPublicationMultiCastDataReplicatorClient(DPE_DataPublicationsClient stxdssClient, string PublicationName, string publicationMultiCastIPAddress, int publicationMultiCastPort) { string requestedMulticastKey = publicationMultiCastIPAddress + System.Convert.ToString(publicationMultiCastPort); if (this._MultiCastDataReplicatorClientsTable.ContainsKey(PublicationName)) { //gets the current multicast client MultiCastDataReplicatorClient currentMultiCastClient = default(MultiCastDataReplicatorClient); currentMultiCastClient = (MultiCastDataReplicatorClient)this._MultiCastDataReplicatorClientsTable[PublicationName]; //gets the current key to verify if the address corresponds to the multicast address and port string currentMulticastKey = ""; currentMulticastKey = System.Convert.ToString(this._MultiCastDataReplicatorKeyStringsTable[PublicationName]); if (!(currentMulticastKey == null)) { if (requestedMulticastKey != currentMulticastKey) { //removes the old key and the old client to create a new one currentMultiCastClient.Dispose(); this._MultiCastDataReplicatorKeyStringsTable.Remove(PublicationName); this._MultiCastDataReplicatorClientsTable.Remove(PublicationName); return(this.GetPublicationMultiCastDataReplicatorClient(stxdssClient, PublicationName, publicationMultiCastIPAddress, publicationMultiCastPort)); } else { this.LogClientForPublicationDataReception(stxdssClient, PublicationName); return(currentMultiCastClient); } } else { currentMultiCastClient.Dispose(); this._MultiCastDataReplicatorKeyStringsTable.Remove(PublicationName); this._MultiCastDataReplicatorClientsTable.Remove(PublicationName); return(this.GetPublicationMultiCastDataReplicatorClient(stxdssClient, PublicationName, publicationMultiCastIPAddress, publicationMultiCastPort)); } } else { MultiCastDataReplicatorClient client = default(MultiCastDataReplicatorClient); client = new MultiCastDataReplicatorClient(publicationMultiCastIPAddress, publicationMultiCastPort); client.Connect(); this._MultiCastDataReplicatorClientsTable.Add(PublicationName, client); this._MultiCastDataReplicatorKeyStringsTable.Add(PublicationName, requestedMulticastKey); this.LogClientForPublicationDataReception(stxdssClient, PublicationName); return(client); } }
internal CommunicationsLibrary.Services.SocketsDataDistribution.SocketsServer GetPublicationSocketsServerListener(DPE_DataPublicationsClient client, string PublicationName) { if (this._SocketServersListenersTable.ContainsKey(PublicationName)) { SocketsServer listener = default(SocketsServer); listener = (SocketsServer)this._SocketServersListenersTable[PublicationName]; this.LogClientForPublicationDataReception(client, PublicationName); return(listener); } else { SocketsServer listener = new SocketsServer(DPE_ServerDefs.INITIAL_TCP_PORT_DPE_SERVICE, DPE_ServerDefs.FINAL_TCP_PORT_DPE_SERVICE); this._SocketServersListenersTable.Add(PublicationName, listener); this.LogClientForPublicationDataReception(client, PublicationName); return(listener); } }
internal DPE_PublicationConnectionHandler CreatePublicationConnectionHandler(DPE_PublicationConnectionHandler_Type handlerType, DPE_DataPublicationsClient client, string PublicationName, string PublicationHostName, int publicationsSocketsServerPortNumber, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode) { //*********************************************************************************************** //creates the handler according to the type of connection DPE_PublicationConnectionHandler publicationCnnHandler = null; publicationCnnHandler = new DPE_PublicationConnectionHandler(handlerType, client, PublicationName, PublicationHostName, publicationsSocketsServerPortNumber, connectionMode); if (!(publicationCnnHandler == null)) { try { //evaluates if the client is not the publisher of the publication, in order to avoid thepublisher client to //receive its own publication update if (!this._STXDataSocketClient.PublicationsPostManager.ContainsPublicationDefinition(PublicationName)) { if (publicationCnnHandler.HandlerType == DPE_PublicationConnectionHandler_Type.subscriptorHandler) { publicationCnnHandler.PublicationDataReceived += STXDSSPublicationConnectionHandler_PublicationDataReceived; publicationCnnHandler.PublicationDataResetReceived += STXDSSPublicationConnectionHandler_PublicationDataResetReceived; } } //for both type of handlers is created a handler to the connectio lost event in order to know when a connection to a publication //is lost publicationCnnHandler.ConnectionToPublicationLost += STXDSSPublicationConnectionHandler_ConnectionLost; } catch (Exception) { publicationCnnHandler.PublicationDataReceived -= STXDSSPublicationConnectionHandler_PublicationDataReceived; publicationCnnHandler.ConnectionToPublicationLost -= STXDSSPublicationConnectionHandler_ConnectionLost; publicationCnnHandler.PublicationDataResetReceived -= STXDSSPublicationConnectionHandler_PublicationDataResetReceived; } try { this._STXDSSPublicationConnectionHandlersContainer.AddPublicationConnectionHandler(publicationCnnHandler); } catch (Exception ex) { CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString()); } if (handlerType == DPE_PublicationConnectionHandler_Type.subscriptorHandler) { //--------------------------------------- //saves into a has table the publication name and its connection mode for further reference when is needed to perfofm //automatic reconnections just for connections handlers defined as subscriptors handler PublicationConnectionInfo cnnInfo = new PublicationConnectionInfo(); cnnInfo.connectionType = handlerType; cnnInfo.PublicationName = PublicationName; cnnInfo.ConnectionMode = connectionMode; try { //saves the connection information for the subscriptors connection type handlers if (this._tableOfConnectionInfoRegistersOfConnectionsToPublications.ContainsKey(PublicationName)) { this._tableOfConnectionInfoRegistersOfConnectionsToPublications.Remove(PublicationName); } this._tableOfConnectionInfoRegistersOfConnectionsToPublications.Add(PublicationName, cnnInfo); } catch (Exception ex) { CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString()); } } } //--------------------------------------- return(publicationCnnHandler); }