コード例 #1
0
        private void SendEventLogToController()
        {
            do
            {
                List <dc_EventLog> eventLog = m_eventLog.GetLogEvents();

                try
                {
                    m_mutexHostControllerEndpoints.WaitOne();
                    foreach (EndpointAddress ep in m_hostControllerEndpoints)
                    {
                        //Open connection
                        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
                        JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep);

                        serviceClient.Open();
                        serviceClient.RegisterEventLog(eventLog.ToArray());
                        serviceClient.Close();
                    }

                    //Updates the date of the last data collection
                    My.Settings.Default.EventLogLastDataCollection = DateTime.Now;
                }
                catch (Exception ex)
                {
                    LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message);
                }
                finally
                {
                    m_mutexHostControllerEndpoints.ReleaseMutex();
                }

                Thread.Sleep(TIME_SEND_EVENT_LOG_HOST_CONTROLLER);
            } while (true);
        }