/// <summary> /// Compares the current <see cref="ExportRecord"/> object to <paramref name="obj"/>. /// </summary> /// <param name="obj">Object against which the current <see cref="ExportRecord"/> object is to be compared.</param> /// <returns> /// Negative value if the current <see cref="ExportRecord"/> object is less than <paramref name="obj"/>, /// Zero if the current <see cref="ExportRecord"/> object is equal to <paramref name="obj"/>, /// Positive value if the current <see cref="ExportRecord"/> object is greater than <paramref name="obj"/>. /// </returns> public virtual int CompareTo(object obj) { ExportRecord other = obj as ExportRecord; if (other == null) { return(1); } else { int result = string.Compare(m_instance, other.Instance, true); if (result != 0) { return(result); } else { return(m_identifier.CompareTo(other.Identifier)); } } }
private void ProcessRealTimeExport(RealTimeData[] items) { DataSet rawData; IList <ExportRecord> exportRecords; foreach (RealTimeData item in items) { try { lock (m_rawData) { m_rawData.TryGetValue(item.Export.Name, out rawData); } if (rawData != null) { // Buffer-up the parsed data for the export. exportRecords = item.Export.FindRecords(item.Listener.ID); if (exportRecords.Count == 1 && exportRecords[0].Identifier == -1) { // Include all data from the listener. if (Monitor.TryEnter(rawData)) { try { foreach (IDataPoint dataPoint in item.Data) { rawData.Tables[0].Rows.Add(item.Listener.ID, dataPoint.HistorianID, dataPoint.Time.ToString(), dataPoint.Value, (int)dataPoint.Quality); } } catch { throw; } finally { Monitor.Exit(rawData); } } } else { // Buffer data for selected records only (filtered). ExportRecord comparer = new ExportRecord(item.Listener.ID, -1); if (Monitor.TryEnter(rawData)) { try { foreach (IDataPoint dataPoint in item.Data) { if (exportRecords.FirstOrDefault(record => record.Identifier == dataPoint.HistorianID) != null) { rawData.Tables[0].Rows.Add(item.Listener.ID, dataPoint.HistorianID, dataPoint.Time.ToString(), dataPoint.Value, (int)dataPoint.Quality); } } } catch { throw; } finally { Monitor.Exit(rawData); } } } } } catch (Exception ex) { OnStatusUpdate(string.Format("Data prep failed for export \"{0}\" - {1}", item.Export.Name, ex.Message)); } } }
private void ProcessRealTimeExport(RealTimeData[] items) { DataSet rawData; IList<ExportRecord> exportRecords; foreach (RealTimeData item in items) { try { lock (m_rawData) { m_rawData.TryGetValue(item.Export.Name, out rawData); } if (rawData != null) { // Buffer-up the parsed data for the export. exportRecords = item.Export.FindRecords(item.Listener.ID); if (exportRecords.Count == 1 && exportRecords[0].Identifier == -1) { // Include all data from the listener. if (Monitor.TryEnter(rawData)) { try { foreach (IDataPoint dataPoint in item.Data) { rawData.Tables[0].Rows.Add(item.Listener.ID, dataPoint.HistorianID, dataPoint.Time.ToString(), dataPoint.Value, (int)dataPoint.Quality); } } catch { throw; } finally { Monitor.Exit(rawData); } } } else { // Buffer data for selected records only (filtered). ExportRecord comparer = new ExportRecord(item.Listener.ID, -1); if (Monitor.TryEnter(rawData)) { try { foreach (IDataPoint dataPoint in item.Data) { if (exportRecords.FirstOrDefault(record => record.Identifier == dataPoint.HistorianID) != null) rawData.Tables[0].Rows.Add(item.Listener.ID, dataPoint.HistorianID, dataPoint.Time.ToString(), dataPoint.Value, (int)dataPoint.Quality); } } catch { throw; } finally { Monitor.Exit(rawData); } } } } } catch (Exception ex) { OnStatusUpdate(string.Format("Data prep failed for export \"{0}\" - {1}", item.Export.Name, ex.Message)); } } }