Ejemplo n.º 1
0
 internal void ApplyTheDifferences(HMtoDashboardData p_hmDataIn)
 {
     if (p_hmDataIn.DailyEmailReportEnabled != m_persistedState.IsDailyEmailReportEnabled)
     {
         m_persistedState.IsDailyEmailReportEnabled = p_hmDataIn.DailyEmailReportEnabled;
         Utils.Logger.Info("IsDailyEmailReportEnabled changed to " + m_persistedState.IsDailyEmailReportEnabled);
     }
     if (p_hmDataIn.RtpsTimerEnabled != m_persistedState.IsRealtimePriceServiceTimerEnabled)
     {
         m_persistedState.IsRealtimePriceServiceTimerEnabled = p_hmDataIn.RtpsTimerEnabled;
         Utils.Logger.Info("IsRealtimePriceServiceTimerEnabled changed to " + m_persistedState.IsRealtimePriceServiceTimerEnabled);
     }
     if (p_hmDataIn.ProcessingVBrokerMessagesEnabled != m_persistedState.IsProcessingVBrokerMessagesEnabled)
     {
         m_persistedState.IsProcessingVBrokerMessagesEnabled = p_hmDataIn.ProcessingVBrokerMessagesEnabled;
         Utils.Logger.Info("IsProcessingVBrokerMessagesEnabled changed to " + m_persistedState.IsProcessingVBrokerMessagesEnabled);
     }
 }
Ejemplo n.º 2
0
        internal void ReportCurrentStateToDashboardInJSON(HMtoDashboardData p_hmData)
        {
            p_hmData.DailyEmailReportEnabled = m_persistedState.IsDailyEmailReportEnabled;

            p_hmData.RtpsTimerEnabled = m_persistedState.IsRealtimePriceServiceTimerEnabled;
            p_hmData.RtpsTimerFrequencyMinutes = cRtpsTimerFrequencyMinutes;

            var rtpsLastDownloadsSnapshot = m_rtpsLastDownloads.ToArray(); // we have to make a snapshot anyway, so the Timer thread can write it while we itarate
            int nDownloadsToReport = (rtpsLastDownloadsSnapshot.Length > 3) ? 3 : rtpsLastDownloadsSnapshot.Length;
            p_hmData.RtpsDownloads = new List<string>(nDownloadsToReport);
            for (int i = nDownloadsToReport; i > 0; i--)    // we need the last elements
            {
                var download = rtpsLastDownloadsSnapshot[rtpsLastDownloadsSnapshot.Length - i];
                p_hmData.RtpsDownloads.Add(download.Item1.ToString("yyyy -MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + " : " + (download.Item2 ? "OK":"ERROR"));
            }

            p_hmData.ProcessingVBrokerMessagesEnabled = m_persistedState.IsProcessingVBrokerMessagesEnabled;

            p_hmData.VBrokerReports = new List<string>();
            lock (m_VBrokerOldReport)
            {
                int nReportsToReport = (m_VBrokerOldReport.Count > 10) ? 10 : m_VBrokerOldReport.Count;
                for (int i = nReportsToReport; i > 0; i--)
                {
                    var report = m_VBrokerOldReport[m_VBrokerOldReport.Count - i];    // Item3 is the whole message, but don't report it; the Dashboard should be brief
                    p_hmData.VBrokerReports.Add(report.Item1.ToString("yyyy -MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + " : " + (report.Item2 ? "OK" : "ERROR"));
                }
            }
        }
Ejemplo n.º 3
0
        internal static string ReportCurrentStateToDashboardInJSON(object p_commandParams)
        {
            var hmDataIn = JsonConvert.DeserializeObject<HMtoDashboardData>(p_commandParams as string);
            HMtoDashboardData hmDataOut = null;
            if (String.Equals(hmDataIn.CommandToBackEnd, "OnlyGetData", StringComparison.InvariantCultureIgnoreCase)) {
                hmDataOut = new HMtoDashboardData() { ResponseToFrontEnd = "OK", StartDate = g_startTime };
                g_healthMonitor.ReportCurrentStateToDashboardInJSON(hmDataOut);
            }
            else if (String.Equals(hmDataIn.CommandToBackEnd, "ApplyTheDifferences", StringComparison.InvariantCultureIgnoreCase))
            {
                // 1. apply new settings
                g_healthMonitor.ApplyTheDifferences(hmDataIn);
                // 2. read out the current state
                hmDataOut = new HMtoDashboardData() { ResponseToFrontEnd = "OK", StartDate = g_startTime };
                g_healthMonitor.ReportCurrentStateToDashboardInJSON(hmDataOut);
            } else
            {
                hmDataOut = new HMtoDashboardData() { ResponseToFrontEnd = "Error: unrecognised CommandToBackEnd" };
            }

            return JsonConvert.SerializeObject(hmDataOut);
        }