public List <DisplayCounterSet> GetCounterSetByGroup(string group = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } List <CounterSet> css = _counterManager.GetCounterSetByGroup(group); List <DisplayCounterSet> dcss = new List <DisplayCounterSet>(); foreach (CounterSet cs in css) { DisplayCounterSet dcs = new DisplayCounterSet(cs); if (cs.RecordCount > 0) { CounterRecord record = _counterManager.GetSingleCounterRecord(cs.Group, cs.Name, cs.RecordCount - 1); foreach (var cv in record.Value.RelatedValues) { dcs.Entry.Add(new DisplayCounter(cv.Name, cv.Type)); } } dcss.Add(dcs); } return(dcss); }
public List <DisplayCategoryMessage> RetriveAllCategoryMessage(string group = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } List <DisplayCategoryMessage> msgs = new List <DisplayCategoryMessage>(); List <Category> categories = _categoryManager.GetCategoryByGroup(group); foreach (var category in categories) { CategoryMessage msg = _categoryManager.RetriveCategoryMessage(me, category); if (msg != null) { msgs.Add(ToDisplayCategoryMessage(msg, me)); } } return(msgs); }
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)); }
private Category GetCategoryModel(string name, string group = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } if (CacheHelper.Contains(CreateCacheCategoryKey(name, group))) { return(CacheHelper.Get <Category>(CreateCacheCategoryKey(name, group))); } Category result = _categoryManager.GetCategory(name, group); if (result == null) { throw new CategoryNotFoundException(); } CacheHelper.Add(CreateCacheCategoryKey(name, group), result); return(result); }
public DisplayMessage PostMessage(string message, string group = null, string schemaID = "none", string eventID = "none", [FromUri] string[] owner = null, [FromUri] string[] atUser = null, [FromUri] string[] topicName = null, string richMessage = null, [FromUri] string[] attachmentID = null, int importance = 2 ) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } return(new DisplayMessage(_messageManager.PostMessage(whoami(), group, eventID, schemaID, owner, atUser, topicName, message, richMessage, attachmentID, importance, DateTime.UtcNow), new AttachmentManager(), new AccountManager())); //return new ActionResult(); }
public DisplayCategory CreateCategory(string name, string group = null, string description = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } MembershipHelper.CheckAdmin(group, me); return(_categoryManager.CreateCategory(name, group, me, description)); }
public DisplayMessagePagination PublicSquareLine(string group = null, int count = 25, string token = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } MembershipHelper.CheckMembership(group, me); TableContinuationToken tok = Utils.String2Token(token); return(CreateDisplayMsgPag(_messageManager.PublicSquareLine(group, count, tok))); }
public DisplayMetricDataSet CreateDataSet(string instance, string counter, string category, string group = null, string description = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } return(_metricManager.CreateDataSet(me, instance, counter, category, group, description)); }
public CounterSet CreateCounterSet(string name, string group = null, string description = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } return(_counterManager.CreateCounterSet(group, name, description)); }
public DisplayMessagePagination UserLine(string userid, string group, DateTime start, DateTime end, int count = 25, string token = null) { string me = whoami(); if (string.IsNullOrEmpty(userid)) { userid = me; } if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(userid); } MembershipHelper.CheckMembership(group, me); TableContinuationToken tok = Utils.String2Token(token); return(CreateDisplayMsgPag(_messageManager.UserLine(userid, group, start, end, count, tok))); }
/// <summary> /// Get dataset info by properties /// /// example output: /// { /// "Id": 6, /// "Description": "non-description", /// "GroupID": "msgorilladev", /// "Creater": "user1", /// "RecordCount": 1, /// "Category": "test", /// "Counter": "test", /// "Instance": "test" /// } /// </summary> /// <param name="instance">instance name</param> /// <param name="counter">counter name</param> /// <param name="category">category name</param> /// <param name="group">group id</param> /// <returns></returns> public DisplayMetricDataSet GetDataSet(string instance, string counter, string category, string group = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } DisplayMetricDataSet dataset = _metricManager.GetDataSet(instance, counter, category, group); if (dataset == null) { throw new MetricDataSetNotFoundException(); } return(dataset); }
public DisplayCounterChart GetCounterChart(string path, string name, string group = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } CounterSet cs = _counterManager.GetCounterSet(group, name); if (cs == null) { throw new CounterSetNotFoundException(); } CounterRecord record = _counterManager.GetSingleCounterRecord(group, name, cs.RecordCount - 1); CounterRecord.ComplexValue cv = CounterRecordHelper.Get(record, path); if (cv == null) { return(null); } DisplayCounterChart dcc = new DisplayCounterChart(); dcc.Title = cv.Name; dcc.MainCounter = new DisplayCounter(path, cv.Type); dcc.RelatedCounter = new List <DisplayCounter>(); foreach (var value in cv.RelatedValues) { dcc.RelatedCounter.Add(new DisplayCounter(string.Format("{0}.{1}", path, value.Name), value.Type)); } return(dcc); }
public ActionResult InsertRecord([FromUri] string name, [FromUri] string group = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } var task = this.Request.Content.ReadAsStreamAsync(); task.Wait(); Stream requestStream = task.Result; CounterRecord record = new BinaryFormatter().Deserialize(requestStream) as CounterRecord; _counterManager.InsertCounterRecord(record, name, group); return(new ActionResult()); }
public DisplayTopic AddTopic(string name, string group = null, string description = null) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } Topic topic = new Topic(); topic.Name = name; topic.Description = description; topic.MsgCount = 0; topic.GroupID = group; var newtopic = _topicManager.AddTopic(topic); return(new DisplayTopic(newtopic, IsFavouriteTopic(newtopic.Id))); }
public DisplayMessagePagination HomeLine(string userid, string group, DateTime start, DateTime end, int count = 25, string token = null, bool keepUnread = false) { string me = whoami(); if (string.IsNullOrEmpty(userid)) { userid = me; } if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(userid); } MembershipHelper.CheckMembership(group, me); TableContinuationToken tok = Utils.String2Token(token); if (!keepUnread && me.Equals(userid) && token == null) { _notifManager.clearHomelineNotifCount(me); _notifManager.clearImportantMsgCount(me); } return(CreateDisplayMsgPag(_messageManager.HomeLine(userid, group, start, end, count, tok))); }
public DisplayCounterRecords GetCounterRecord(string path, string name, string group = null, int start = 0, int end = -1) { string me = whoami(); if (string.IsNullOrEmpty(group)) { group = MembershipHelper.DefaultGroup(me); } else { MembershipHelper.CheckMembership(group, me); } List <DisplayRecord> records = new List <DisplayRecord>(); foreach (var record in _counterManager.GetCounterRecords(name, group, start, end)) { DisplayRecord rec = new DisplayRecord(record.Key, CounterRecordHelper.GetValue(record, path)); records.Add(rec); } return(new DisplayCounterRecords(name, group, path, start, records)); }
/// <summary> /// Get the default group for the current user. /// /// example output: /// "microsoft" /// </summary> /// <returns></returns> public string GetDefaultGroup() { return(MembershipHelper.DefaultGroup(whoami())); }