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 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)); }
public DisplayMetricChart CreateChart(string chartName, string group, string title, string subtitle = null) { string me = whoami(); MembershipHelper.CheckMembership(group, me); return(_metricManager.CreateChart(chartName, group, title, subtitle)); }
public List <DisplayMetricChart> GetChartsByGroup(string group) { string me = whoami(); MembershipHelper.CheckMembership(group, me); return(_metricManager.GetAllChartByGroup(group)); }
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 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 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 async Task <ActionResult> Follow(string userid) { string me = whoami(); UserProfile user = _accountManager.FindUser(userid); if (userid == null) { throw new UserNotFoundException(userid); } if (user.IsRobot) { GroupManager groupManager = new GroupManager(); MembershipHelper.CheckMembership(groupManager.GetJoinedGroup(user.Userid)[0].GroupID, me); } Task <Boolean> ret = _accountManager.Follow(me, userid); Boolean result = await ret; if (result) { return(new ActionResult()); } return(new MSGorillaBaseException().toActionResult()); }
public List <MetricRecord> RetriveLastestDataRecord(int id, int count = 30) { MetricDataSet dataset = _metricManager.GetDataSet(id); MembershipHelper.CheckMembership(dataset.GroupID, whoami()); return(_metricManager.RetriveLastestDataRecord(dataset, count)); }
public List <MetricRecord> RetriveDataRecord(int id, int startIndex, int endIndex) { MetricDataSet dataset = _metricManager.GetDataSet(id); MembershipHelper.CheckMembership(dataset.GroupID, whoami()); return(_metricManager.RetriveDataRecord(dataset.Id, startIndex, endIndex)); }
public DisplayMetricChart GetChart(string chartName) { string me = whoami(); DisplayMetricChart chart = _metricManager.GetChart(chartName); MembershipHelper.CheckMembership(chart.GroupID, me); return(chart); }
public ActionResult InsertRecord(int id, string key, double value) { MetricDataSet dataset = _metricManager.GetDataSet(id); MembershipHelper.CheckMembership(dataset.GroupID, whoami()); _metricManager.AppendDataRecord(id, key, value.ToString()); return(new ActionResult()); }
public DisplayMessagePagination PublicSquareLine(string group, DateTime start, DateTime end, int count = 25, string token = null) { string me = whoami(); MembershipHelper.CheckMembership(group, me); TableContinuationToken tok = Utils.String2Token(token); return(CreateDisplayMsgPag(_messageManager.PublicSquareLine(group, start, end, count, tok))); }
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 List <MembershipView> GetAllGroupMember(string groupID) { string me = whoami(); MembershipHelper.CheckMembership(groupID, me); //List<MembershipView> result = new List<MembershipView>(); //foreach(Membership member in _groupManager.GetAllGroupMember(groupID)) //{ // result.Add(member); //} //return result; return(_groupManager.GetGroupMembershipView(groupID, me)); }
public DisplayMetricChart AddDataSet(string chartName, int dataSetID, string legend, string type) { string me = whoami(); DisplayMetricDataSet dataset = GetDataSet(dataSetID); if (dataset == null) { throw new MetricDataSetNotFoundException(); } MembershipHelper.CheckMembership(dataset.GroupID, me); return(_metricManager.AddDataSet(chartName, dataSetID, legend, type)); }
public List <DisplayMetricDataSet> GetDataSetByGroup(string group) { string me = whoami(); MembershipHelper.CheckMembership(group, me); List <DisplayMetricDataSet> ans = new List <DisplayMetricDataSet>(); foreach (var dataset in _metricManager.GetAllDataSetByGroup(group)) { ans.Add(dataset); } return(ans); }
public ActionResult AddFavouriteTopic(int topicID) { string me = whoami(); Topic topic = _topicManager.FindTopic(topicID); if (topic == null) { throw new TopicNotFoundException(); } MembershipHelper.CheckMembership(topic.GroupID, me); _topicManager.AddFavouriteTopic(whoami(), topicID); return(new ActionResult()); }
public DisplayTopic FindTopic(int topicid) { string me = whoami(); Topic topic = _topicManager.FindTopic(topicid); if (topic == null) { throw new TopicNotFoundException(); } MembershipHelper.CheckMembership(topic.GroupID, me); return(new DisplayTopic(topic, IsFavouriteTopic(topicid))); }
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 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 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))); }
public DisplayMetricChart TryGetChart(string chartName) { string me = whoami(); DisplayMetricChart chart = _metricManager.GetChart(chartName); if (chart != null) { MembershipHelper.CheckMembership(chart.GroupID, me); return(chart); } else { //check chart name format if (string.IsNullOrEmpty(chartName)) { return(null); } string[] split = chartName.Split('_'); string group = split[0]; string category = split.Length > 1 ? split[1] : null; string counter = split.Length > 2 ? split[2] : null; string instance = split.Length > 3 ? split[3] : null; MembershipHelper.CheckMembership(group, me); //Try create chart if not exist List <MetricDataSet> datasets = _metricManager.QueryDataSet(group, category, counter, instance); if (datasets.Count == 0) { return(null); } chart = _metricManager.CreateChart(chartName, group, chartName); foreach (var dataset in datasets) { _metricManager.AddDataSet(chartName, dataset.Id, dataset.Instance, "line"); } chart = _metricManager.GetChart(chartName); } return(chart); }
/// <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 RemoveFavouriteTopic(string topic, string group = null) { string me = whoami(); Topic t = null; if (string.IsNullOrEmpty(group)) { t = _topicManager.FindTopicByName(topic, MembershipHelper.JoinedGroup(me)); } else { MembershipHelper.CheckMembership(group, me); t = _topicManager.FindTopicByName(topic, group); } if (t == null) { throw new TopicNotFoundException(); } _topicManager.Remove(me, t.Id); return(new ActionResult()); }
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 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)); }
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))); }