예제 #1
0
        public DisplayCounterRecords GetLatestCounterRecord(string path, string name, string group = null, int count = 30)
        {
            string me = whoami();

            if (string.IsNullOrEmpty(group))
            {
                group = MembershipHelper.DefaultGroup(me);
            }
            else
            {
                MembershipHelper.CheckMembership(group, me);
            }

            CounterSet counterSet = _counterManager.GetCounterSet(group, name);

            if (counterSet == null)
            {
                throw new CounterSetNotFoundException();
            }

            int start = counterSet.RecordCount - count > 0 ? counterSet.RecordCount - count : 0;
            List <DisplayRecord> records = new List <DisplayRecord>();

            foreach (var record in _counterManager.GetCounterRecords(name, group, start))
            {
                DisplayRecord rec = new DisplayRecord(record.Key, CounterRecordHelper.GetValue(record, path));
                records.Add(rec);
            }

            return(new DisplayCounterRecords(name, group, path, start, records));
        }