internal override void CalculateValue(double value, DateTime timestamp) { GaugeDuration aggregateDuration = base.aggregateDuration; if (aggregateDuration.IsEmpty || ((IValueConsumer)this).GetProvider() == null) { base.CalculateValue(value, timestamp); return; } noMoreData = false; HistoryCollection data = ((IValueConsumer)this).GetProvider().GetData(aggregateDuration, timestamp); HistoryEntry[] array = data.Select(aggregateDuration, timestamp); double num = value; bool flag = false; HistoryEntry[] array2 = array; foreach (HistoryEntry historyEntry in array2) { if (!double.IsNaN(historyEntry.Value)) { num = Math.Max(historyEntry.Value, num); flag = true; } } if (!flag) { num = ((data.Count <= 0) ? double.NaN : data.Top.Value); noMoreData = true; } base.CalculateValue(num, timestamp); }
private void RegenerateIntegralResult() { if (((IValueConsumer)this).GetProvider() is ValueBase) { TimeSpan timeSpan = interval.ToTimeSpan(); ValueBase valueBase = (ValueBase)((IValueConsumer)this).GetProvider(); HistoryCollection history = valueBase.History; integralResult = history.AccumulatedValue / (double)timeSpan.Ticks; int num = history.Locate(valueBase.Date); for (int i = 1; i < num; i++) { integralResult += history[i].Value * (double)(history[i].Timestamp.Ticks - history[i - 1].Timestamp.Ticks) / (double)timeSpan.Ticks; oldValue.Timestamp = history[i].Timestamp; oldValue.Value = history[i].Value; } } }
public void LoadEntries(HistoryCollection sourceHistory) { if (sourceHistory == null) { throw new ApplicationException(Utils.SRGetStr("ExceptionHistoryCannotNull")); } if (parent != null) { parent.IntState = ValueState.DataLoading; parent.Reset(); foreach (HistoryEntry item in sourceHistory) { parent.SetValueInternal(item.Value, item.Timestamp); } parent.IntState = ValueState.Interactive; parent.Invalidate(); return; } foreach (HistoryEntry item2 in sourceHistory) { base.InnerList.Add(item2.Clone()); } }
public object Clone() { HistoryCollection historyCollection = new HistoryCollection(parent); IEnumerator enumerator = GetEnumerator(); try { while (enumerator.MoveNext()) { HistoryEntry historyEntry = (HistoryEntry)enumerator.Current; historyCollection.InnerList.Add(historyEntry.Clone()); } return(historyCollection); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } }
internal ValueBase() { history = new HistoryCollection(this); }
public void DataBind(object dataSource, string valueFieldName, string dateFieldName, string dataMember) { if (IntState != ValueState.Interactive) { throw new ApplicationException(Utils.SRGetStr("ExceptionDatabindState")); } bool closeDataReader; IDbConnection connection; object dataSourceAsIEnumerable = GetDataSourceAsIEnumerable(dataSource, dataMember, out closeDataReader, out connection); try { if (dataSource == null || valueFieldName == string.Empty) { throw new ArgumentException(Utils.SRGetStr("ExceptionBadDatasource_fields")); } object obj = null; object obj2 = null; double num = 0.0; DateTime now = DateTime.Now; HistoryCollection historyCollection = new HistoryCollection(this); try { IntState = ValueState.DataLoading; Reset(); foreach (object item in (IEnumerable)dataSourceAsIEnumerable) { obj = ConvertEnumerationItem(item, valueFieldName); if (dateFieldName != string.Empty) { obj2 = ConvertEnumerationItem(item, dateFieldName); if (obj != null && obj2 != null && obj2 != Convert.DBNull) { num = ((obj != Convert.DBNull) ? Convert.ToDouble(obj, CultureInfo.InvariantCulture) : double.NaN); DateTime timestamp = Convert.ToDateTime(obj2, CultureInfo.InvariantCulture); historyCollection.Add(timestamp, num); } } else if (obj != null) { num = ((obj != Convert.DBNull) ? Convert.ToDouble(obj, CultureInfo.InvariantCulture) : double.NaN); historyCollection.Add(now, num); } } foreach (HistoryEntry item2 in historyCollection) { SetValueInternal(item2.Value, item2.Timestamp); } } finally { IntState = ValueState.Interactive; historyCollection.Clear(); } Invalidate(); } finally { if (closeDataReader) { ((IDataReader)dataSourceAsIEnumerable).Close(); } connection?.Close(); } if (Common != null) { Common.GaugeCore.boundToDataSource = true; } }