Ejemplo n.º 1
0
        /// <summary>	Default constructor. </summary>
        public SenderJobs()
        {
            // Set up a timer to trigger every send command frequency.
            int sendCommandFrequencyInSeconds = int.Parse(System.Configuration.ConfigurationManager.AppSettings[cSendCommandFrequencyName]);

            OdataServiceUrl = System.Configuration.ConfigurationManager.AppSettings[cOdataService];
            OPCServerUrl    = System.Configuration.ConfigurationManager.AppSettings[cOPCServerUrl];
            SenderMonitorEvent.SendMonitorEvent(EventLog, string.Format("ODataServiceUrl = {0}", OdataServiceUrl), EventLogEntryType.Information, 1);
            SenderMonitorEvent.SendMonitorEvent(EventLog, string.Format("OPCServerUrl = {0}", OPCServerUrl), EventLogEntryType.Information, 1);

            try
            {
                wmiProductInfo = new KEPSenderServiceProductInfo(cServiceTitle,
                                                                 Environment.MachineName,
                                                                 Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                                                                 DateTime.Now,
                                                                 sendCommandFrequencyInSeconds,
                                                                 OdataServiceUrl);
            }
            catch// (Exception ex)
            {
                //SenderMonitorEvent.sendMonitorEvent(vpEventLog, string.Format("Failed to initialize WMI = {0}", ex.ToString()), EventLogEntryType.Error);
            }

            m_SenderTimer = new System.Timers.Timer
            {
                Interval = sendCommandFrequencyInSeconds * 1000 // seconds to milliseconds
            };
            m_SenderTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnSenderTimer);

            SenderMonitorEvent.SendMonitorEvent(EventLog, string.Format("Send Command Frequncy = {0}", sendCommandFrequencyInSeconds), EventLogEntryType.Information, 1);
        }