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 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) { } } }
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 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"); }
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); } }
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); } }
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) { } }
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); } }
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)); } }
public void UpdatePublicationVariable(DPE_PublicationData data) { try { this._DATA_UPDATE_PCQ.Enqueue(data); } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } }
public void ResetPublicationVariable(string variableName) { try { this._DATA_RESET_PCQ.Enqueue(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 EventHandling_DATA_RESET_PCQ_NewItemDetected(object item) { try { string variableName = System.Convert.ToString(item); this.WriteDataRESET(variableName); } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } }
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); } }
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()); } }
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()); } }
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); } }
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()); } }
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); } }
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); } }
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()); } }
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._serviceP2PPort.Dispose(); } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } //Try // Me._serviceSocketsServer.Dispose() //Catch ex As Exception // CustomEventLog.WriteEntry(ex) //End Try try { this._stxServiceHandler.Dispose(); } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } try { this._MultiCastDataReplicationServer.Dispose(); } catch (Exception) { } string msg = ""; string hostname = Dns.GetHostName(); msg = "CND service Shutdown @ " + hostname + " on " + DateTime.Now.ToString(); CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg); } // TODO: free your own state (unmanaged objects). // TODO: set large fields to null. } this.disposedValue = true; }
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); } }
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); } }
public bool EnsureStorage() { try { if (!dataStorageConfiguration.IsDataProviderInstalled()) { dataStorageConfiguration.InstallDataProvider(); } return(true); } catch (Exception e) { CustomEventLog.WriteEntry(e); return(false); } }
private DateTime GetPublicationsServerDAtetime() { DateTime dtime = DateTime.Now; 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; cmd.CommandText = "Select getdate()"; using (System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter()) { da.SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); if (dt.Rows.Count > 0) { dtime = System.Convert.ToDateTime(dt.Rows[0][0]); } else { dtime = DateTime.Now; } } } } } } } catch (Exception ex) { string msg = "Error retrieving server date and time : " + ex.Message; CustomEventLog.WriteEntry(EventLogEntryType.Error, msg); } return(dtime); }
private void ScheduleTasksToRestorePreviousPostedPublicationsAfterConnectionLost() { try { if (this._ContainerOfPostedPublicationsOnServer.Count > 0) { DPE_ClientPublicationDefinition publicationDef = null; Collection listOfPublicationsToPostAfterServerDesconection = new Collection(); IEnumerator enumm = null; lock (this._ContainerOfPostedPublicationsOnServer) { enumm = this._ContainerOfPostedPublicationsOnServer.GetEnumerator(); while (enumm.MoveNext()) { publicationDef = (DPE_ClientPublicationDefinition)enumm.Current; listOfPublicationsToPostAfterServerDesconection.Add(publicationDef, null, null, null); } //clears the container of posted publications this._ContainerOfPostedPublicationsOnServer.Clear(); } enumm = listOfPublicationsToPostAfterServerDesconection.GetEnumerator(); while (enumm.MoveNext()) { publicationDef = (DPE_ClientPublicationDefinition)enumm.Current; this.ScheduleTaskToPostAPublicationOnServer(publicationDef); try { if (PublicationPostLostOnServerEvent != null) { PublicationPostLostOnServerEvent(publicationDef.PublicationName); } } catch (Exception) { } } } } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } }
private void NewComponentRegistrationDetected(CNDAddressingReg ComponentCNDRegister) { try { //when a remote component is registred in the CNDService then is detected and is creted locally // a handler to communicate with it RemoteComponentComunicationsHandler newhandler = this.GetRemoteHandlerForComponent(ComponentCNDRegister.ComponentName); this._remoteHandlersContainer.AddNewHandler(newhandler); if (CNDTableChangedEvent != null) { CNDTableChangedEvent(this.CNDTable); } } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } }
protected override void OnShutdown() { try { base.OnShutdown(); } catch (Exception ex) { CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString()); } try { this._CNDService.Dispose(); } catch (Exception ex) { CustomEventLog.WriteEntry(EventLogEntryType.Error, ex.ToString()); } }