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 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); } }