private void LogClientIntoRegistryTable(DPE_Client client)
            {
                try
                {
                    DataRow clientRow = default(DataRow);
                    clientRow = this._clientsRegistryDataTable.NewRow();
                    clientRow["Client HostName"]      = client.HostName;
                    clientRow["Client AppDomain"]     = client.ApplicationDomainName;
                    clientRow["Client Name"]          = client.Name;
                    clientRow["Client ID"]            = client.ClientID;
                    clientRow["Network ID"]           = client.NetworkID;
                    clientRow["Connection Date Time"] = client.ConnectionDateTime;
                    switch (client.ClientType)
                    {
                    case DPE_ClientType.PublisherSubscriberClientType:
                        clientRow["Type"] = "Publisher / Subscriber";
                        break;

                    case DPE_ClientType.StatusViewerClientType:
                        clientRow["Type"] = "Status Viewer";
                        break;

                    default:
                        clientRow["Type"] = "Unknown";
                        break;
                    }
                    this._clientsRegistryDataTable.Rows.Add(clientRow);
                }
                catch (Exception)
                {
                }
            }
예제 #2
0
            internal void STXDSSClientConnectionIdentificationAndConnection(DPE_Client client, string publicationConnectionHandlerID, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
            {
                if (client.ClientID != this.publisherSTXDSSClient.ClientID)
                {
                    //only registers as sbscriptors other client different from the publisher

                    if (this._STXDSS_PublicationClientConnectionsManager.Set_STXDSSClientConnection(client, publicationConnectionHandlerID, connectionMode))
                    {
                        //------------------------------------------------------------------------------------------
                        //sends to the client the last update of the publication
                        SocketsServerClientConnectionHandler handler = default(SocketsServerClientConnectionHandler);
                        handler = this._STXDSS_PublicationClientConnectionsManager.GetClientPublicationConnectionHandler(client);
                        if (!(handler == null))
                        {
                            if (connectionMode == DPE_ServerDefs.DPE_PublicationConnectionMode.ReceiveLastPublicationStatus)
                            {
                                this.SchedulePublicationUpdateOnClientConnection(handler);
                            }
                        }
                        //-------------------------------------------------------------------------------------------

                        try
                        {
                            this.RaiseNewConnectionEvent(client);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
예제 #3
0
            public DPE_Publication(string publicationsDataBAseConnectionString, string publicationsGroup, string publicationName, DPE_Client STXDSSClient)
            {
                //sets the publication name
                this._publicationsGroup = publicationsGroup.ToUpper();

                this._publicationName     = publicationName.ToUpper();
                this._publicationCreation = DateTime.Now;

                this._variablesPublishedRegistry = new DPE_PublishedVariablesRegistry(publicationName);

                //saves reference to the datra socket server that creates the publication
                this._publisherSTXDSSClient = STXDSSClient;

                //creates a sockets server to support the link between the client and the publication
                this._publicationSocketsServer = new SocketsServer(DPE_ServerDefs.INITIAL_TCP_PORT_DPE_SERVICE, DPE_ServerDefs.FINAL_TCP_PORT_DPE_SERVICE);
                this._publicationSocketsServer.NewClientConnection      += this.NewIncommingConnectionCDB;
                this._publicationSocketsServer.ClientConnectionFinished += this.ClientConnectionFinishCDB;

                this._STXDSS_PublicationClientConnectionsManager = new DPE_PublicationClientConnectionsManager(this);

                this._updatePublicationOnClientConnectionQueue = new Queue();

                this._publicationsDataBaseConnectionString = publicationsDataBAseConnectionString;

                //**************************************************************************************************
                //creates the publication in the data base according with the connection string passed by attribute
                CreatePublicationDataTable(this._publicationsDataBaseConnectionString, this._publicationName);

                CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, "Publication \'" + this._publicationName + "\'    ->     CREATED succesfully");
            }
예제 #4
0
            private void ClientConnectionFinishCDB(SocketsServer server, SocketsServerClientConnectionHandler ClientHandler)
            {
                this._STXDSS_PublicationClientConnectionsManager.UnlogPendingSocketClientMatchConnectionWithSTXDSSClientTable(ClientHandler);

                DPE_Client client = default(DPE_Client);

                client = this._STXDSS_PublicationClientConnectionsManager.GetSubscriptorClient(ClientHandler);
                if (!(client == null))
                {
                    try
                    {
                        this._STXDSS_PublicationClientConnectionsManager.RemoveClientSubscription(ClientHandler);
                    }
                    catch (Exception)
                    {
                    }
                    try
                    {
                        if (SubscriptionDeattachmentEvent != null)
                        {
                            SubscriptionDeattachmentEvent(this, client);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            internal CustomList GetListOfClientPostedPublications(DPE_Client client)
            {
                string publisherClientID = "";

                publisherClientID = client.ClientID;

                if (this._referenceTableOFPublicationsCreatedBySTXDSSClients.ContainsKey(publisherClientID))
                {
                    Hashtable publicationsOFCLientTable = default(Hashtable);
                    publicationsOFCLientTable = (Hashtable)(this._referenceTableOFPublicationsCreatedBySTXDSSClients[publisherClientID]);
                    string      publicationName = "";
                    CustomList  list            = new CustomList();
                    IEnumerator enumm           = default(IEnumerator);
                    enumm = publicationsOFCLientTable.GetEnumerator();
                    while (enumm.MoveNext())
                    {
                        publicationName = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
                        list.Add(publicationName);
                    }
                    return(list);
                }
                else
                {
                    throw (new Exception("The client \'" + client.Name + "\' is not registered as a publisher"));
                }
            }
예제 #6
0
 internal PublicationConnectionClientMatchRegister(DPE_Client client, string publicationConnectionHandlerID, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
 {
     this._client = client;
     this._publicationConnectionHandlerID = publicationConnectionHandlerID;
     this._connectionMode    = connectionMode;
     this._insertionDateTime = DateTime.Now;
 }
            internal DataTable GetTableOfPublicationsPostedByClient(DPE_Client client)
            {
                string publisherClientID = "";

                publisherClientID = client.ClientID;

                if (this._referenceTableOFPublicationsCreatedBySTXDSSClients.ContainsKey(publisherClientID))
                {
                    DataTable             dt = new DataTable();
                    string                selectionCriteria = "";
                    System.Data.DataRow[] resultRows        = null;
                    selectionCriteria = "[Publication Owner Name] = \'" + client.Name + "\'";
                    resultRows        = this._publicationsDataTable.Select(selectionCriteria);

                    if (resultRows.Length > 0)
                    {
                        dt = (DataTable)resultRows.CopyToDataTable();
                        return(dt);
                    }
                    else
                    {
                        throw (new Exception("The client \'" + client.Name + "\' is not registered as a publisher"));
                    }
                }
                else
                {
                    throw (new Exception("The client \'" + client.Name + "\' is not registered as a publisher"));
                }
            }
 internal void DisposeClientPublications(DPE_Client client)
 {
     try
     {
         CustomList      pubList     = this.GetListOfClientPostedPublications(client);
         IEnumerator     enumm       = pubList.GetEnumerator();
         string          pubName     = "";
         DPE_Publication publication = default(DPE_Publication);
         while (enumm.MoveNext())
         {
             pubName     = System.Convert.ToString(enumm.Current);
             publication = this.GetPublication(pubName);
             try
             {
                 publication.ShutDownPublication();
                 publication.Dispose();
             }
             catch (Exception)
             {
             }
         }
     }
     catch (Exception)
     {
     }
 }
 private void RemoveClientConnectionToAPublicationRegister(DPE_Client client, DPE_Publication publication)
 {
     if (this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient.ContainsKey(client.ClientID))
     {
         CustomHashTable list = default(CustomHashTable);
         list = (CustomHashTable)this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient[client.ClientID];
         if (list.ContainsKey(publication.PublicationName))
         {
             list.Remove(publication.PublicationName);
         }
     }
 }
예제 #10
0
 internal void RaiseNewConnectionEvent(DPE_Client client)
 {
     try
     {
         if (NewSubscriptionAttachementEvent != null)
         {
             NewSubscriptionAttachementEvent(this, client);
         }
     }
     catch (Exception)
     {
     }
 }
예제 #11
0
 internal DPE_Client GetSubscriptorClient(SocketsServerClientConnectionHandler publicationConnectionHandler)
 {
     if (this._socketConnectionHandlerToClientREferenceTable.ContainsKey(publicationConnectionHandler.ClientID))
     {
         DPE_Client client = default(DPE_Client);
         client = (DPE_Client)this._socketConnectionHandlerToClientREferenceTable[publicationConnectionHandler.ClientID];
         return(client);
     }
     else
     {
         return(null);
     }
 }
            internal void AddClient(DPE_Client client)
            {
                if (!this._registeredClientsTableByID.ContainsKey(client.ClientID))
                {
                    this._registeredClientsTableByID.Add(client.ClientID, client);
                }

                if (!this._registeredClientsTableByNetworkID.ContainsKey(client.NetworkID))
                {
                    this._registeredClientsTableByNetworkID.Add(client.NetworkID, client);
                }

                this.LogClientIntoRegistryTable(client);
            }
            internal void RemoveClient(DPE_Client client)
            {
                if (this._registeredClientsTableByID.ContainsKey(client.ClientID))
                {
                    this._registeredClientsTableByID.Remove(client.ClientID);
                }

                if (this._registeredClientsTableByNetworkID.ContainsKey(client.NetworkID))
                {
                    this._registeredClientsTableByNetworkID.Remove(client.NetworkID);
                }

                this.UnlogClientFromRegistryTable(client);
            }
            private void DecreasePublisherClientPublicationsCount(DPE_Client client)
            {
                string selectionCriteria = "";

                DataRow[] resultRows = null;
                selectionCriteria = "[Client ID] = \'" + client.ClientID + "\'";
                resultRows        = this._publisherClientsRegistryTable.Select(selectionCriteria);
                if (resultRows.Length > 0)
                {
                    DataRow clientRow = resultRows[0];
                    int     count     = System.Convert.ToInt32(clientRow["Publications Count"]);
                    count--;
                    clientRow["Publications Count"] = count;
                    this._publisherClientsRegistryTable.AcceptChanges();
                }
            }
 private void AddClientConnectionToaPublicationRegister(DPE_Client client, DPE_Publication publication)
 {
     if (!this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient.ContainsKey(client.ClientID))
     {
         CustomHashTable list = new CustomHashTable();
         list.Add(publication.PublicationName, publication.PublicationName);
         this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient.Add(client.ClientID, list);
     }
     else
     {
         CustomHashTable list = default(CustomHashTable);
         list = (CustomHashTable)this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient[client.ClientID];
         if (!list.ContainsKey(publication.PublicationName))
         {
             list.Add(publication.PublicationName, publication.PublicationName);
         }
     }
 }
 private void UnlogClientAsPublisher(DPE_Client client)
 {
     try
     {
         string    selectionCriteria = "";
         DataRow[] resultRows        = null;
         selectionCriteria = "[Client ID] = \'" + client.ClientID + "\'";
         resultRows        = this._publisherClientsRegistryTable.Select(selectionCriteria);
         if (resultRows.Length > 0)
         {
             DataRow clientRow = resultRows[0];
             this._publisherClientsRegistryTable.Rows.Remove(clientRow);
             this._publisherClientsRegistryTable.AcceptChanges();
         }
     }
     catch (Exception)
     {
     }
 }
예제 #17
0
            internal dynamic Set_STXDSSClientConnection(DPE_Client client, string publicationConnectionHandlerID, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
            {
                if (this._PendingSocketClientMatchWithSTXDSSClientTable.ContainsKey(publicationConnectionHandlerID))
                {
                    SocketsServerClientConnectionHandler socketConnectionHandler = default(SocketsServerClientConnectionHandler);
                    socketConnectionHandler = (SocketsServerClientConnectionHandler)this._PendingSocketClientMatchWithSTXDSSClientTable[publicationConnectionHandlerID];
                    if (socketConnectionHandler == null)
                    {
                        throw (new Exception("There is not registered a socket connection handler of the client \'" + client.Name + "\' in the publication named \'" + this._publicationOwner.PublicationName + "\'"));
                    }

                    this.RegisterNewSubscriptorToPublication(client, socketConnectionHandler, connectionMode);

                    //regisers in a table the relation of the socket client that belong to the stxdssclient for
                    //further reference
                    if (!this._socketConnectionHandlerToClientREferenceTable.ContainsKey(socketConnectionHandler.ClientID))
                    {
                        this._socketConnectionHandlerToClientREferenceTable.Add(socketConnectionHandler.ClientID, client);
                    }

                    //regiosters the relation of the socket connection woth the client for further reference
                    if (!this._STXDSSClientTosocketConnectionHandlerReferenceTable.ContainsKey(client.ClientID))
                    {
                        this._STXDSSClientTosocketConnectionHandlerReferenceTable.Add(client.ClientID, socketConnectionHandler);
                    }

                    //removes from a table the pending match registration
                    this.UnlogPendingSocketClientMatchConnectionWithSTXDSSClientTable(socketConnectionHandler);

                    return(true);
                }
                else
                {
                    //the connection to the publication throuh the socket server don't exists when this happens so then the match is scheduled in a task
                    PublicationConnectionClientMatchRegister matchLog = new PublicationConnectionClientMatchRegister(client, publicationConnectionHandlerID, connectionMode);

                    this._posponedMatchQueue.Enqueue(matchLog);
                    this._posponedMatchTimer.Start();

                    return(false);
                }
            }
 private void LogClientAsPublisher(DPE_Client client)
 {
     try
     {
         if (!this.IsClientRegisteredAsPublisher(client))
         {
             DataRow clientRow = default(DataRow);
             clientRow = this._publisherClientsRegistryTable.NewRow();
             clientRow["Client Hostname"]    = client.HostName;
             clientRow["Client AppDomain"]   = client.ApplicationDomainName;
             clientRow["Client ID"]          = client.ClientID;
             clientRow["Network ID"]         = client.NetworkID;
             clientRow["Client Name"]        = client.Name;
             clientRow["Publications Count"] = 0;
             this._publisherClientsRegistryTable.Rows.Add(clientRow);
         }
     }
     catch (Exception)
     {
     }
 }
예제 #19
0
            private void RegisterNewSubscriptorToPublication(DPE_Client subscriptorClient, SocketsServerClientConnectionHandler connectionHandler, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
            {
                try
                {
                    DataRow clientRow = this._STXDSSClienstSubscribedRegistryTable.NewRow();
                    clientRow["Client Name"]          = subscriptorClient.Name;
                    clientRow["Client ID"]            = subscriptorClient.ClientID;
                    clientRow["Client HostName"]      = subscriptorClient.HostName;
                    clientRow["Client AppDomain"]     = subscriptorClient.ApplicationDomainName;
                    clientRow["Connection Date Time"] = System.Convert.ToString(DateTime.Now);
                    clientRow["Client Network ID"]    = System.Convert.ToString(connectionHandler.ClientID);

                    string cnnmode = "";
                    switch (connectionMode)
                    {
                    case DPE_ServerDefs.DPE_PublicationConnectionMode.NotReceiveLastPublicationStatus:
                        cnnmode = "Not Receive Last Status";
                        break;

                    case DPE_ServerDefs.DPE_PublicationConnectionMode.ReceiveLastPublicationStatus:
                        cnnmode = "Receive Last Status";
                        break;

                    default:
                        cnnmode = "Undefined Status";
                        break;
                    }
                    clientRow["Connection Mode"] = cnnmode;

                    lock (this._STXDSSClienstSubscribedRegistryTable)
                    {
                        this._STXDSSClienstSubscribedRegistryTable.Rows.Add(clientRow);
                    }

                    CustomEventLog.DisplayEvent(EventLogEntryType.Information, "Client \'" + subscriptorClient.Name + "\' connected to publication \'" + this._publicationOwner.PublicationName + "\'");
                }
                catch (Exception)
                {
                }
            }
 public bool IsClientRegisteredAsPublisher(DPE_Client client)
 {
     try
     {
         string    selectionCriteria = "";
         DataRow[] resultRows        = null;
         selectionCriteria = "[Client ID] = \'" + client.ClientID + "\'";
         resultRows        = this._publisherClientsRegistryTable.Select(selectionCriteria);
         if (resultRows.Length > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 internal CustomList GetClientListOfConnectionsToPublications(DPE_Client client)
 {
     if (this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient.ContainsKey(client.ClientID))
     {
         CustomList      list            = new CustomList();
         string          publicationName = "";
         IEnumerator     enumm           = default(IEnumerator);
         CustomHashTable table           = (CustomHashTable)this._referenceTableOFConnectionsToPublicationsOfASTXDSSClient[client.ClientID];
         enumm = table.GetEnumerator();
         while (enumm.MoveNext())
         {
             publicationName = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
             list.Add(publicationName);
         }
         return(list);
     }
     else
     {
         //returns an empty list becuase the cliebt is not conencyed to any publication
         return(new CustomList());
     }
 }
예제 #22
0
            internal void RemoveClientSubscription(SocketsServerClientConnectionHandler publicationConnectionHandler)
            {
                DPE_Client client = default(DPE_Client);

                client = this.GetSubscriptorClient(publicationConnectionHandler);
                if (!(client == null))
                {
                    this.UnregisterSubscriptorFromPublication(client);
                }

                if (this._STXDSSClientTosocketConnectionHandlerReferenceTable.ContainsKey(client.ClientID))
                {
                    this._STXDSSClientTosocketConnectionHandlerReferenceTable.Remove(client.ClientID);
                }

                if (this._socketConnectionHandlerToClientREferenceTable.ContainsKey(publicationConnectionHandler.ClientID))
                {
                    this._socketConnectionHandlerToClientREferenceTable.Remove(publicationConnectionHandler.ClientID);
                }

                this.UnlogPendingSocketClientMatchConnectionWithSTXDSSClientTable(publicationConnectionHandler);
            }
예제 #23
0
 private void UnregisterSubscriptorFromPublication(DPE_Client subscriptorClient)
 {
     try
     {
         lock (this._STXDSSClienstSubscribedRegistryTable)
         {
             string    selectionCriteria = "";
             DataRow[] resultRows        = null;
             selectionCriteria = "[Client ID] = \'" + subscriptorClient.ClientID + "\'";
             resultRows        = this._STXDSSClienstSubscribedRegistryTable.Select(selectionCriteria);
             if (resultRows.Length > 0)
             {
                 DataRow subscriptorRow = resultRows[0];
                 this._STXDSSClienstSubscribedRegistryTable.Rows.Remove(subscriptorRow);
                 this._STXDSSClienstSubscribedRegistryTable.AcceptChanges();
             }
         }
     }
     catch (Exception)
     {
     }
 }
 private void SubscriptionDeattachment_EventHandlerFcn(DPE_Publication publication, DPE_Client client)
 {
     try
     {
         this.SetPublicationAttachmentsCounterOnDataTableRegistry(publication);
         this.RemoveClientConnectionToAPublicationRegister(client, publication);
     }
     catch (Exception)
     {
     }
 }
예제 #25
0
 internal SocketsServerClientConnectionHandler GetClientPublicationConnectionHandler(DPE_Client client)
 {
     if (this._STXDSSClientTosocketConnectionHandlerReferenceTable.ContainsKey(client.ClientID))
     {
         return((SocketsServerClientConnectionHandler)this._STXDSSClientTosocketConnectionHandlerReferenceTable[client.ClientID]);
     }
     else
     {
         return(null);
     }
 }
예제 #26
0
 internal bool STXDSSClientSocketConnectionInquiry(DPE_Client client, string publicationConnectionHandlerID)
 {
     return(this._STXDSS_PublicationClientConnectionsManager.ContainsClientSocketConnectionHandler(publicationConnectionHandlerID));
 }
            internal void CreateClientRegistration(DPE_ClientType clientType, string clientID, string networkID, string clientName, string clientHostName, string clientAppDomain)
            {
                DPE_Client newClient = new DPE_Client(clientType, clientID, networkID, clientName, clientHostName, clientAppDomain);

                this.AddClient(newClient);
            }