Exemple #1
0
        private async void Parser_StatusDeleted(object sender, DeleteStreamEventArgs e)
        {
            // Yes the same id shouldn't be there more than once, but this happens sometimes.
            // so delete all statuses that match the id.
            var toDelete = StatusCollection.Where(s => s.Id == e.Id).ToArray();

            foreach (var status in toDelete)
            {
                await Dispatcher.RunAsync(() => StatusCollection.Remove(status));
            }

            await Cache.RemoveStatus(e.Id);
        }
Exemple #2
0
        void GetTop10Alarms()
        {
            var z = StatusCollection.Where(m => m.StatusInfo.AlarmContent != "运行中").Where(w => w.StatusInfoId != -1)
                    .GroupBy(x => x.StatusInfo.Id)
                    .Select(x => new
            {
                Key   = x.First().StatusInfo.AlarmContent,
                Value = x.Sum(y => y.Span.TotalSeconds)
            }).OrderByDescending(x => x.Value);

            if (z.Any())
            {
                var q = z.ToList();
                if (q.Count() > 10)
                {
                    var top10 = q.Take(10);
                    var other = q.Skip(10).Sum(x => x.Value);
                    Top10SeriesCollection[0].Values.Clear();
                    foreach (var v in top10)
                    {
                        Top10SeriesCollection[0].Values.Add(new ObservableValue(v.Value));
                    }
                    Top10SeriesCollection[0].Values.Add(new ObservableValue(other));
                    var l = new List <string>();
                    l.AddRange(top10.Select(x => x.Key).ToArray());
                    l.Add("Others");
                    _top10Labels.Clear();
                    _top10Labels.AddRange(l.ToArray());
                }
                else
                {
                    Top10SeriesCollection[0].Values.Clear();
                    foreach (var v in q)
                    {
                        Top10SeriesCollection[0].Values.Add(new ObservableValue(v.Value));
                    }
                    _top10Labels.Clear();
                    _top10Labels.AddRange(q.Select(x => x.Key));
                }
            }
            else
            {
                Top10SeriesCollection[0].Values.Clear();
                _top10Labels.Clear();

                //   return;
            }
        }