private void EventHandling_DATA_UPDATE_PCQ_NewItemDetected(object item)
            {
                try
                {
                    lock (this._locker)
                    {
                        DPE_PublicationData data = (DPE_PublicationData)item;
                        try
                        {
                            this._UPDATE_StatisticsHandler.LogEvent(data.VariableName);
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            if (dataUpdateFromPublicationEvent != null)
                            {
                                dataUpdateFromPublicationEvent(data);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }
            internal void ScheduleConnectionTaskToAPublication(string PublicationName, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
            {
                //this function is intended to be used by subscribers clients
                try
                {
                    if (!this._tableOfConnectionRegistersForScheduledConnectionTasks.ContainsKey(PublicationName))
                    {
                        string msg = "";
                        msg = "Task to connect with publication \'" + PublicationName + "\' was scheduled and started";
                        CustomEventLog.WriteEntry(EventLogEntryType.Information, msg);

                        PublicationConnectionTaskInfo reg = new PublicationConnectionTaskInfo(DPE_PublicationConnectionHandler_Type.subscriptorHandler, PublicationName, connectionMode);
                        lock (this._tableOfConnectionRegistersForScheduledConnectionTasks)
                        {
                            this._tableOfConnectionRegistersForScheduledConnectionTasks.Add(PublicationName, reg);
                        }
                        lock (this._queueOfScheduledConnectionTasks)
                        {
                            this._queueOfScheduledConnectionTasks.Enqueue(reg);
                        }

                        if (this._publicationsConnectionThread == null)
                        {
                            this._publicationsConnectionThread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadedFcn_ConnectionToEnqueuedDataPublications));
                            this._publicationsConnectionThread.IsBackground = true;
                            this._publicationsConnectionThread.Priority     = System.Threading.ThreadPriority.Normal;
                            this._publicationsConnectionThread.Start();
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }
            private void EventHandling_DATA_RESET_PCQ_NewItemDetected(object item)
            {
                try
                {
                    lock (this._locker)
                    {
                        string _dataName = System.Convert.ToString(item);

                        try
                        {
                            this._RESET_StatisticsHandler.LogEvent(_dataName);
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            if (dataResetFromPublicationEvent != null)
                            {
                                dataResetFromPublicationEvent(this._publicationName, _dataName);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }
Example #4
0
 public void BroadCastData(SocketData Data)
 {
     lock (this._connectedClientsTable)
     {
         IEnumerator enumm = default(IEnumerator);
         SocketsServerClientConnectionHandler client = default(SocketsServerClientConnectionHandler);
         enumm = this._connectedClientsTable.GetEnumerator();
         if (this._connectedClientsTable.NumOfConnectedClients > 0)
         {
             while (enumm.MoveNext())
             {
                 client = (SocketsServerClientConnectionHandler)enumm.Current;
                 try
                 {
                     this.SendDataToClient(client, Data);
                 }
                 catch (ObjectDisposedException)
                 {
                 }
                 catch (Exception ex)
                 {
                     string msg = "";
                     msg = "Error broadcasting data to connected clients : " + ex.ToString();
                     CustomEventLog.DisplayEvent(EventLogEntryType.Error, msg);
                 }
             }
         }
     }
 }
Example #5
0
            private bool disposedValue = false;             // To detect redundant calls

            // IDisposable
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposedValue)
                {
                    if (disposing)
                    {
                        // TODO: free other state (managed objects).

                        try
                        {
                            this._publicationSocketsServer.Dispose();
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            DisposePublicationDataTable(this._publicationsDataBaseConnectionString, this.PublicationName);
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            CustomEventLog.DisplayEvent(EventLogEntryType.Information, "Publication \'" + this.PublicationName + "\' was disposed properly");
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                this.disposedValue = true;
            }
        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);
            }
        }
Example #7
0
            private void ClientConnectionCallback(IAsyncResult ar)
            {
                Socket listener = default(Socket);
                Socket handler  = default(Socket);
                SocketsServerClientConnectionHandler newClientConnectionHandler = null;

                try
                {
                    this._tcpLsn.Server.BeginAccept(new AsyncCallback(ClientConnectionCallback), this._tcpLsn.Server);
                }
                catch (Exception)
                {
                }

                try
                {
                    listener = (Socket)ar.AsyncState;
                    handler  = listener.EndAccept(ar);
                    newClientConnectionHandler = new SocketsServerClientConnectionHandler(handler);
                }
                catch (ObjectDisposedException)
                {
                    //do nothing
                }
                catch (Exception ex2)
                {
                    CustomEventLog.WriteEntry(EventLogEntryType.Error, ex2.ToString());
                    newClientConnectionHandler = null;
                }

                if (!(newClientConnectionHandler == null))
                {
                    try
                    {
                        this.ClientsConnectionsTable.AddClientSocketHandler(newClientConnectionHandler);
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        if (NewClientConnectionEvent != null)
                        {
                            NewClientConnectionEvent(newClientConnectionHandler);
                        }
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        newClientConnectionHandler.handlerSocket.BeginReceive(newClientConnectionHandler.DataReceptionBuffer, 0, newClientConnectionHandler.DataReceptionBufferSize, (System.Net.Sockets.SocketFlags) 0, new AsyncCallback(ClientDataReceptionCallback), newClientConnectionHandler);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        public void frmCNDServiceApplication_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                this._stxeventLog = CustomEventLog.GetInstance();
                this._stxeventLog.LogEntryReceived += this._stxeventLog_LogEntryReceived;
            }
            catch (Exception)
            {
            }
            frmServiceIndex frm = new frmServiceIndex();

            try
            {
                this._CNDService = CNDService.GetInstance();
                this._CNDService.CNDTableStatusChanged += this.CNDTableStatusChanged;
                this.dgrdServiceParameters.DataSource   = this._CNDService.ServiceParametersTable;
                this.dgrdCNDTable.DataSource            = this._CNDService.ComponentNetworkDirectoryTable;
                this.dgrdCNDTable.Columns[0].Width      = (int)((double)dgrdCNDTable.Width / 2);
                this.dgrdCNDTable.Columns[1].Width      = (int)((double)dgrdCNDTable.Width / 2);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                frm.Dispose();
            }
        }
            private bool disposedValue = false;             // To detect redundant calls

            // IDisposable
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposedValue)
                {
                    if (disposing)
                    {
                        // TODO: free other state (managed objects).
                        //disposes all the available dedicated ports
                        IEnumerator enumm = default(IEnumerator);
                        enumm = this._dedicatedPortsTable.GetEnumerator();
                        P2PPort port = default(P2PPort);
                        while (enumm.MoveNext())
                        {
                            try
                            {
                                port = (P2PPort)(((DictionaryEntry)enumm.Current).Value);
                                port.Dispose();
                            }
                            catch (Exception ex)
                            {
                                CustomEventLog.WriteEntry(ex);
                            }
                        }
                        this._dedicatedPortsTable.Clear();
                    }

                    // TODO: free your own state (unmanaged objects).
                    // TODO: set large fields to null.
                }
                this.disposedValue = true;
            }
        public void frmDataSocketServerApplication_Load(System.Object sender, System.EventArgs e)
        {
            AppRunCheck.Check_If_IAm_Running_ExitIfTrue_And_ShowMessage();

            try
            {
                _eventLog = CustomEventLog.GetInstance();
                _eventLog.LogEntryReceived += _stxEventLog_LogEntryReceived;
            }
            catch (Exception)
            {
            }
            this._errorsCount = 0;

            this.txtErrorsCount.Text = System.Convert.ToString(this._errorsCount);

            try
            {
                this._DPEDataPublicationsServer       = DPE_DataPublicationsServer.GetInstance();
                this.dgrdServiceParameters.DataSource = this._DPEDataPublicationsServer.ServiceParametersTable;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #11
0
        public frmSocketsServerClientTest(string host, int port)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();
            try
            {
                // Add any initialization after the InitializeComponent() call.
                this._dataSocketClient = new SocketsServerClient(host, port);
                this._dataSocketClient.DataReceived   += this.DataReceived;
                this._dataSocketClient.ConnectionLost += this.Disconnection;
                this._dataSocketClient.Connect();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                this._stxEventLog = CustomEventLog.GetInstance();
                this._stxEventLog.LogEntryReceived += this._stxEventLog_LogEntryReceived;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            try
            {
                this.Text = "Sockets Server Client on : " + host + " : " + System.Convert.ToString(port);
            }
            catch (Exception)
            {
            }
        }
            private void CreateSocketPortClientDataStatisticsTables()
            {
                try
                {
                    //creation of the general statistics
                    this._generalStatisticsTable = new DataTable("P2PPortClientGeneralStatisticsTable");
                    this._generalStatisticsTable.Columns.Add("Client Port Event", System.Type.GetType("System.String"));
                    this._generalStatisticsTable.Columns.Add("Count", System.Type.GetType("System.Int64"));

                    //creation of the data sending statistics table
                    this._dataSendingStatisticsTable = new DataTable("P2PPortClientDataReceptionStatisticsTable");
                    this._dataSendingStatisticsTable.Columns.Add("DataName", System.Type.GetType("System.String"));
                    this._dataSendingStatisticsTable.Columns.Add("DataType", System.Type.GetType("System.String"));
                    this._dataSendingStatisticsTable.Columns.Add("Count", System.Type.GetType("System.Int64"));
                    this._dataSendingStatisticsTable.Columns.Add("FirstSendDateTime", System.Type.GetType("System.DateTime"));
                    this._dataSendingStatisticsTable.Columns.Add("LastSendDateTime", System.Type.GetType("System.DateTime"));

                    //creation of the data recepction statistics table
                    this._dataRequestStatisticsTable = new DataTable("P2PPortClientDataRequestsStatisticsTable");
                    this._dataRequestStatisticsTable.Columns.Add("DataName", System.Type.GetType("System.String"));
                    this._dataRequestStatisticsTable.Columns.Add("Successful", System.Type.GetType("System.Int64"));
                    this._dataRequestStatisticsTable.Columns.Add("Failed", System.Type.GetType("System.Int64"));
                    this._dataRequestStatisticsTable.Columns.Add("FirstRequestDateTime", System.Type.GetType("System.DateTime"));
                    this._dataRequestStatisticsTable.Columns.Add("LastRequestDateTime", System.Type.GetType("System.DateTime"));
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }
            private void STXDSSPublicationConnectionHandler_ConnectionLost(string publicationName)
            {
                //this events happens when a connection to a publications gets lost

                //**********************************************************************
                //writes a mesage to the log
                string msg = "";

                msg = "Connection with Remote Publication \'" + publicationName + "\' Lost. Client : " + this._STXDataSocketClient.ClientName;
                CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg);

                //***********************************************************************
                //removes the local connection hanlder
                this.DisposeConnectionHandler(publicationName);

                //***********************************************************************
                //launch a recconection task
                this.ReconnectToDataPublication(publicationName);

                //***********************************************************************
                //sends and event
                try
                {
                    if (ConnectionToPublicationLostEvent != null)
                    {
                        ConnectionToPublicationLostEvent(publicationName);
                    }
                }
                catch (Exception)
                {
                }
            }
Example #14
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");
            }
            internal void PostPublicationOnServer(DPE_ClientPublicationDefinition PublicationDefinition)
            {
                //crates the publication definition into a P2PData to send to the server
                CustomHashTable varsToPublish = new CustomHashTable();
                string          variableName  = "";

                DPE_ServerDefs.PublicationVariableDataType variableDataType = default(DPE_ServerDefs.PublicationVariableDataType);
                string variableDataTypeAsString = "";

                IEnumerator enumm = PublicationDefinition.VariablesToPublishTable.GetEnumerator();

                while (enumm.MoveNext())
                {
                    variableName             = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
                    variableDataType         = (DPE_ServerDefs.PublicationVariableDataType)(((DictionaryEntry)enumm.Current).Value);
                    variableDataTypeAsString = DPE_ServerDefs.Get_String_FromPublicationVariableDataType(variableDataType);
                    varsToPublish.Add(variableName, variableDataTypeAsString);
                }

                P2PData data = new P2PData(DPE_ServerDefs.DPE_CMD_CREATE_PUBLICATION, varsToPublish);

                data.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATIONS_GROUP, PublicationDefinition.PublicationsGroup);
                data.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_CLIENT_ID, this._STXDataSocketClient.ClientID);
                data.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATION_NAME, PublicationDefinition.PublicationName);

                Services.P2PCommunicationsScheme.P2PPortClient p2pclient = default(Services.P2PCommunicationsScheme.P2PPortClient);
                try
                {
                    p2pclient = new Services.P2PCommunicationsScheme.P2PPortClient(this._STXDataSocketClient.DSSServerHostName, this._STXDataSocketClient.PublicationsPost_PortNumber);
                    p2pclient.Connect();

                    //sends the information to the server in order to create it
                    p2pclient.SendData(P2PDataSendMode.SyncrhonicalSend, data);

                    p2pclient.Dispose();

                    //it the publication was created in the server then ists definition is saved in the publications posted manager
                    //in order to allow it to re create ii if needed
                    this.AddPublicationDefinitionAfterCreation(PublicationDefinition);

                    string msg = "Publication \'" + PublicationDefinition.PublicationName + "\'    ->    POSTED succesfully.";
                    CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, msg);
                }
                catch (Exception ex)
                {
                    try
                    {
                        this.RemovePublicationDefinition(PublicationDefinition);
                    }
                    catch (Exception)
                    {
                    }
                    string errMSg = "";
                    errMSg = "Error creating the publication \'" + PublicationDefinition.PublicationName + "\' : " + ex.Message;
                    throw (new Exception(errMSg));
                }
            }
Example #16
0
 public void ResetPublicationVariable(string variableName)
 {
     try
     {
         this._DATA_RESET_PCQ.Enqueue(variableName);
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(ex);
     }
 }
Example #17
0
 public void UpdatePublicationVariable(DPE_PublicationData data)
 {
     try
     {
         this._DATA_UPDATE_PCQ.Enqueue(data);
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(ex);
     }
 }
Example #18
0
 private void EventHandling_DATA_UPDATE_PCQ_NewItemDetected(object item)
 {
     try
     {
         DPE_PublicationData data = (DPE_PublicationData)item;
         this.WriteDataUPDATE(data);
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(ex);
     }
 }
Example #19
0
 private void EventHandling_DATA_RESET_PCQ_NewItemDetected(object item)
 {
     try
     {
         string variableName = System.Convert.ToString(item);
         this.WriteDataRESET(variableName);
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(ex);
     }
 }
 protected override void OnStop()
 {
     // Add code here to perform any tear-down necessary to stop your service.
     try
     {
         this._CNDService.Dispose();
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
     }
 }
 private void _STXDSSC_PublicationsProxyConnectionsServerClient_ConnectionWithProxyServerLost()
 {
     try
     {
         //Me._STXDSSC_PublicationsProxyConnectionsServer = STXDSSC_PublicationsConnectionsProxyServer.GetInstance
         //Me._STXDSSC_PublicationsProxyConnectionsServerClient = STXDSSC_PublicationsConnectionsProxyServerClient.GetInstance
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
     }
 }
Example #22
0
            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 void ClientDataReceptionCallback(IAsyncResult ar)
            {
                try
                {
                    int bytesRead = 0;

                    // Read data from the client socket.
                    try
                    {
                        bytesRead = this._BroadCastlisteningSocket.EndReceive(ar);
                    }
                    catch (Exception)
                    {
                    }

                    if (bytesRead > 0)
                    {
                        byte[] RealBuffer = new byte[bytesRead - 1 + 1];

                        System.Array.Copy(this._ReceiveDataBuffer, RealBuffer, bytesRead);


                        if (this._DataReceivedTreatmentAndHandling)
                        {
                            try
                            {
                                lock (this._DataReceivedTreatmentAndHandlingQueue)
                                {
                                    this._DataReceivedTreatmentAndHandlingQueue.Enqueue(RealBuffer);
                                }

                                this._DataReceivedTreatmentAndHandlingTimer.Start();
                            }
                            catch (Exception)
                            {
                            }
                        }

                        System.Array.Clear(this._ReceiveDataBuffer, 0, this._ReceiveDataBuffer.Length);

                        this._BroadCastlisteningSocket.BeginReceive(this._ReceiveDataBuffer, 0, this._ReceiveDataBuffer.Length, (System.Net.Sockets.SocketFlags) 0, new AsyncCallback(ClientDataReceptionCallback), null);
                    }
                }
                catch (SocketException ex)
                {
                    CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
                }
            }
 protected override void OnStart(string[] args)
 {
     // Add code here to start your service. This method should set things
     // in motion so your service can do its work.
     try
     {
         this._CNDService = CNDService.GetInstance();
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
     }
 }
Example #25
0
            public void ClientDataReceptionCallback(IAsyncResult ar)
            {
                try
                {
                    int bytesRead = 0;

                    // Read data from the client socket.
                    try
                    {
                        bytesRead = this._BroadCastlisteningSocket.EndReceive(ar);
                    }
                    catch (Exception)
                    {
                    }

                    if (bytesRead > 0)
                    {
                        byte[] RealBuffer = new byte[bytesRead - 1 + 1];

                        System.Array.Copy(this._ReceiveDataBuffer, RealBuffer, bytesRead);

                        if (!(RealBuffer == null))
                        {
                            Services.BroadCasting.Handling.DataBroadCastHandler receivedBroadCastHandler = Services.BroadCasting.Handling.DataBroadCastHandler.Deserialize(RealBuffer);

                            try
                            {
                                if (DataReceivedEvent != null)
                                {
                                    DataReceivedEvent(receivedBroadCastHandler);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }

                        System.Array.Clear(this._ReceiveDataBuffer, 0, this._ReceiveDataBuffer.Length);

                        this._BroadCastlisteningSocket.BeginReceive(this._ReceiveDataBuffer, 0, this._ReceiveDataBuffer.Length, (System.Net.Sockets.SocketFlags) 0, new AsyncCallback(ClientDataReceptionCallback), null);
                    }
                }
                catch (SocketException ex)
                {
                    CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
                }
            }
 internal void SchedulePublicationUpdate(SocketData newData)
 {
     try
     {
         //sends the compressed data to the multicast server
         byte[] compressedData = null;
         compressedData = UtilitiesLibrary.Services.DataCompression.DataCompressionUtilities.CompressData(newData.DataBytes);
         this._MultiCastDataReplicationServer.BroadCastData(compressedData);
     }
     catch (Exception ex)
     {
         string msg = "";
         msg = "Error broadcasting update for publication \'" + this._publicationOwnerName + "\' : " + ex.Message;
         CustomEventLog.WriteEntry(EventLogEntryType.Error, msg);
     }
 }
Example #27
0
            internal void SchedulePublicationUpdateOnClientConnection(SocketsServerClientConnectionHandler clientHandler)
            {
                try
                {
                    this._updatePublicationOnClientConnectionQueue.Enqueue(clientHandler);

                    System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(THREAD_FCN_UpdatePublicatonOnSubscriptorConnection));
                    thread.IsBackground = true;
                    thread.Priority     = ThreadPriority.Normal;
                    thread.Start();
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString());
                }
            }
Example #28
0
 private void publicationSocketClient_DataReceived(SocketData data, SocketsServerClient sender)
 {
     try
     {
         //data received from the publication to this specific client
         //the data incomming from this is intended to be recived as when the client connects to the publication
         //and receives the current publication data to this point
         //*******************************************************
         this.ProcessPublicationUpdateDataReceivedOnConnection(data);
         //*******************************************************
     }
     catch (Exception ex)
     {
         CustomEventLog.WriteEntry(ex);
     }
 }
Example #29
0
            private void ClearTable()
            {
                try
                {
                    lock (this._locker)
                    {
                        using (System.Data.SqlClient.SqlConnection cnn = new System.Data.SqlClient.SqlConnection(this._dataBaseConnectionString))
                        {
                            cnn.Open();

                            using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                            {
                                cmd.Connection = cnn;
                                TimeSpan timespan             = new TimeSpan(0, 5, 0);
                                DateTime serverDateTime       = this.GetPublicationsServerDAtetime();
                                DateTime dtFrameLimit         = serverDateTime.Subtract(timespan);
                                string   dtFrameLimitAsString = NowToStandardODBCStringFormat(dtFrameLimit);

                                cmd.CommandText = "Delete From " + this._publicationName + " where [datetime] <= \'" + dtFrameLimitAsString + "\'";
                                try
                                {
                                    cmd.ExecuteNonQuery();
                                }
                                catch (System.Data.SqlClient.SqlException ex1)
                                {
                                    if (ex1.ErrorCode != -2146232060)                                     // the error code reaises when a table dont exists
                                    {
                                        string    msg   = "Error CLEARING old data of publication \'" + this._publicationName + "\' : " + ex1.Message;
                                        Exception newEX = new Exception(msg);
                                        throw (newEX);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    string    msg   = "Error CLEARING old data of publication \'" + this._publicationName + "\' : " + ex.Message;
                                    Exception newEX = new Exception(msg);
                                    throw (newEX);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }
Example #30
0
            private void WriteDataUPDATE(DPE_PublicationData data)
            {
                try
                {
                    lock (_locker)
                    {
                        using (var cnn = new System.Data.SqlClient.SqlConnection(this._dataBaseConnectionString))
                        {
                            cnn.Open();

                            using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                            {
                                cmd.Connection = cnn;


                                this._dataType  = DPE_GlobalDefinitions.GetPublicationValueDataTypeAsString(data.Value);
                                this._dataValue = DPE_GlobalDefinitions.GetPublicationValueAsString(data.VariableName, System.Convert.ToInt32(data.Value));

                                string attributesAsString = "";
                                if (data.DataAttributesTable.Count > 0)
                                {
                                    CustomHashTable table = data.DataAttributesTable.ToSTXHashTable();
                                    attributesAsString = UtilitiesLibrary.Data.XMLDataFormatting.GetValueAsString(data.VariableName, table);
                                }

                                cmd.CommandText = "INSERT into " + this._publicationName + "(dataname,dataType, value, attributesTable , isDataReset)" +
                                                  "VALUES(\'" + data.VariableName + "\',\'" + this._dataType + "\',\'" + this._dataValue + "\',\'" + attributesAsString + "\',0)";
                                try
                                {
                                    cmd.ExecuteNonQuery();
                                    this._UPDATE_StatisticsHandler.LogEvent(data.VariableName);
                                }
                                catch (Exception ex)
                                {
                                    string    msg   = "Error performing UPDATE on \'" + data.VariableName + "\' from publication \'" + this._publicationName + "\': " + ex.Message;
                                    Exception newEX = new Exception(msg);
                                    throw (newEX);
                                }
                            }                     //--------- cmd
                        }                         //using del sql connection
                    }
                }
                catch (Exception ex)
                {
                    CustomEventLog.WriteEntry(ex);
                }
            }