public void InitializeCounters(string id, string category, CounterTypeEnum counterType, IDictionary <string, MetricValue> counters) { if (counterType == CounterTypeEnum.Increment) { bool hasID = false; foreach (var key in _incrementalCounters.Keys) { if (key.Id == id && key.Category == category) { hasID = true; break; } } if (!hasID) { _incrementalCounters.Add(new MetricKey { Id = id, Category = category }, counters); } } _subject.OnNext(new MetricsEnvelope( id, category, counterType, counters, DateTime.UtcNow )); }
public void PublishCounter(string id, string category, CounterTypeEnum counterType, string counter, long value, MetricUnit unit) { PublishCounters(id, category, counterType, new Dictionary <string, MetricValue>() { { counter, new MetricValue(value, unit) } }); }
public DataCache(ModuleTypeEnum module, CounterTypeEnum counter) { this.ModuleType = module; this.CounterType = counter; //启动数据整合 ,根据小时整合 AddByCondense(); }
private void SaveCounter(string mark, CounterTypeEnum ct, int num, int level) { num = num >= 0 ? 1 : num; level = level <= 0 ? 0 : level; BaseModel model = new BaseModel() { ModuleType = ModuleTypeEnum.OnceData, Count = num, Level = level, CounterType = ct, Mark = mark }; OnceDataStorage.AddData(model); }
/// <summary> /// 获取并清除这部分数据 /// </summary> /// <returns></returns> public static IList <BaseModel> GetAndClear(ModuleTypeEnum module, CounterTypeEnum counter) { IList <BaseModel> r = new List <BaseModel>(); lock ("Medivh.Content.CacheCenter.operation") { r = list.Where(x => x.ModuleType == module && x.CounterType == counter).ToList(); list.RemoveAll(x => x.ModuleType == module && x.CounterType == counter); //删除dict里面的数据 foreach (BaseModel baseModel in r) { dict.Remove(GetKey(baseModel)); } } return(r); }
public void PublishCounters(string id, string category, CounterTypeEnum counterType, IDictionary <string, MetricValue> counters) { //Cache a copy of current global counters to publish to new subscribers if (string.IsNullOrEmpty(id) && counterType == CounterTypeEnum.CurrentValue) { foreach (var kv in counters) { _currentCounters[kv.Key] = kv.Value; } } ; _subject.OnNext(new MetricsEnvelope( id, category, counterType, counters, DateTime.UtcNow )); }
public void PublishCounters(string id, string category, CounterTypeEnum counterType, IDictionary <string, MetricValue> counters) { foreach (var counter in counters) { var key = new MetricKey { Id = id, Category = category, Name = counter.Key }; Metrics.AddOrUpdate(key, addValueFactory: (k, val) => val, updateValueFactory: (k, old, val) => { var newVal = counterType == CounterTypeEnum.CurrentValue ? val.Value : old.Value + val.Value; return(new MetricValue(newVal, old.Unit)); }, factoryArgument: counter.Value); Metrics[key] = counter.Value; } }
/// <summary> /// Format string based on CounterType. /// </summary> /// <param name="value"></param> /// <param name="type"></param> /// <returns></returns> string GetFormatedText(double value, CounterTypeEnum type) { string text = string.Empty; if (type == CounterTypeEnum.Double) { text = value.ToString("F2"); } else if (type == CounterTypeEnum.Currency) { CurrencyConverter currencyConverter = new CurrencyConverter(); text = currencyConverter.Convert(value, typeof(double), null, CultureInfo.CurrentCulture).ToString(); } else { text = ((int)value).ToString(); } return(text); }
private void PublishCounter(string name, CounterTypeEnum counterType, long count) => _metrics?.PublishCounter(string.Empty, MetricsConstants.CATEGORY_PLUGIN, counterType, $"{UpdateMetricsConstants.Prefix}{name}", count, MetricUnit.Count);
public Counter() { _id = 1; _backColor = Color.Black; _fontColor = Color.WhiteSmoke; //_fontSize = 219; _userTime = 0; _enabled = false; _direction = true; //_onScreen = false; SzovegesOra = true; _monitorQuantity = Screen.AllScreens.Length; _currentMonitor = 0; _counterType = CounterTypeEnum.Counter; _hideText = false; _figylmeztetVisszaszamlalasnal = false; _villogasEffect = false; _figyelmeztetIdo = 60; _villogasEffectSebesseg = 500; }
public void InitializeCounters(string id, string category, CounterTypeEnum counterType, IDictionary <string, MetricValue> counters) => PublishCounters(id, category, counterType, counters);
public MetricsEnvelope(string id, string category, CounterTypeEnum counterType, IDictionary <string, MetricValue> counters, DateTime timestamp) : base(counters, timestamp) { this.Id = id; this.Category = category; this.CounterType = counterType; }
private void PublishCounters(string id, string category, CounterTypeEnum counterType, Dictionary <string, MetricValue> counters) { ConfigPathToSessionMap[DefaultConfigPath] .PublishServiceLevelCounter(id, category, counterType, counters); }
public MetricsEnvelope(string id, string category, CounterTypeEnum counterType, IDictionary <string, MetricValue> counters) : base(counters) { Id = id; Category = category; CounterType = counterType; }