public static void LinkParent(TFSBugProvider.QueryArgument arg) { TFSBugProvider.QueryArgument temp = arg.Clone(); CounterRecord.ComplexValue cv = cache[arg.ToString()]; temp.State = null; if (!Equals(temp, arg) && cache.ContainsKey(temp.ToString())) { cache[temp.ToString()].RelatedValues.Add(cv); } temp = arg.Clone(); temp.Keyword = null; if (!Equals(temp, arg) && cache.ContainsKey(temp.ToString())) { cache[temp.ToString()].RelatedValues.Add(cv); } temp = arg.Clone(); temp.Category = null; if (!Equals(temp, arg) && cache.ContainsKey(temp.ToString())) { cache[temp.ToString()].RelatedValues.Add(cv); } temp = arg.Clone(); temp.Creater = null; if (!Equals(temp, arg) && cache.ContainsKey(temp.ToString())) { cache[temp.ToString()].RelatedValues.Add(cv); } }
public static TFSBugProvider.QueryArgument MergeAndQuery(WorkItemCollection workItems, string key, TFSBugProvider.QueryArgument arg) { TFSBugProvider.QueryArgument temp = TFSBugProvider.QueryArgument.Parse(key); if (arg.State != null) { temp.State = arg.State; } if (!string.IsNullOrEmpty(arg.Keyword)) { temp.Keyword = arg.Keyword; } if (arg.Category != null) { temp.Category = arg.Category; } if (!string.IsNullOrEmpty(arg.Creater)) { temp.Creater = arg.Creater; } CounterRecord.ComplexValue cv = new CounterRecord.ComplexValue( SimplifyKey(temp.ToString()), Type, TFSBugProvider.QueryBugCount(workItems, temp)); cache[temp.ToString()] = cv; return(temp); }
public void Work() { DateTime current = DateTime.Now; if (!ShouldIWord(current)) { return; } Logger.Info("Get latest data."); TFSBugProvider bugProvider = TFSBugProvider.GetInstance(); var wic = bugProvider.GetAllWossBugsUntil(current); CounterRecord.ComplexValue cv = TreeBuilder.BuildCVTree(wic); CounterRecord record = new CounterRecord(current.Date.ToString("yyyy-MM-dd")); record.Value.RelatedValues.Add(cv); Logger.Info("Update BugDailyTrend."); client.InsertCounterRecord(record, "BugDailyTrend", "woss"); if (current.DayOfWeek == DayOfWeek.Sunday) { Logger.Info("Update BugWeeklyTrend."); client.InsertCounterRecord(record, "BugWeeklyTrend", "woss"); } if (current.Day == 1) { Logger.Info("Update BugMonthlyTrend."); client.InsertCounterRecord(record, "BugMonthlyTrend", "woss"); } WorkComplete(current); }
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 static CounterRecord.ComplexValue BuildCVTree(WorkItemCollection wiCollection) { cache = new Dictionary <string, CounterRecord.ComplexValue>(); CounterRecord.ComplexValue root = new CounterRecord.ComplexValue("BugTrend", Type, wiCollection.Count); //Add bug State Active, Closed, Resolved foreach (TFSBugProvider.State state in Enum.GetValues(typeof(TFSBugProvider.State))) { TFSBugProvider.QueryArgument arg = new TFSBugProvider.QueryArgument(state); CounterRecord.ComplexValue cv = new CounterRecord.ComplexValue( state.ToString(), Type, TFSBugProvider.QueryBugCount(wiCollection, arg)); root.RelatedValues.Add(cv); cache[arg.ToString()] = cv; } //Add bug type Stress, Func like List <string> MonitorKeywords = new List <string>() { "Stress", "Function" }; List <string> existingNode = GetAllLevelSortedExistingNode(); foreach (var keyword in MonitorKeywords) { TFSBugProvider.QueryArgument arg = new TFSBugProvider.QueryArgument(null, keyword); CounterRecord.ComplexValue cv = new CounterRecord.ComplexValue( keyword, Type, TFSBugProvider.QueryBugCount(wiCollection, arg)); root.RelatedValues.Add(cv); cache[arg.ToString()] = cv; } foreach (var key in existingNode) { foreach (var keyword in MonitorKeywords) { TFSBugProvider.QueryArgument addtionArg = new TFSBugProvider.QueryArgument(null, keyword); TFSBugProvider.QueryArgument curArg = MergeAndQuery(wiCollection, key, addtionArg); LinkParent(curArg); } } //Add Category, Table or Blob existingNode = GetAllLevelSortedExistingNode(); foreach (TFSBugProvider.Category category in Enum.GetValues(typeof(TFSBugProvider.Category))) { TFSBugProvider.QueryArgument arg = new TFSBugProvider.QueryArgument(null, null, category); CounterRecord.ComplexValue cv = new CounterRecord.ComplexValue( category.ToString(), Type, TFSBugProvider.QueryBugCount(wiCollection, arg)); root.RelatedValues.Add(cv); cache[arg.ToString()] = cv; } foreach (var key in existingNode) { foreach (TFSBugProvider.Category category in Enum.GetValues(typeof(TFSBugProvider.Category))) { TFSBugProvider.QueryArgument addtionArg = new TFSBugProvider.QueryArgument(null, null, category); TFSBugProvider.QueryArgument curArg = MergeAndQuery(wiCollection, key, addtionArg); LinkParent(curArg); } } //Add Creater, existingNode = GetAllLevelSortedExistingNode(); foreach (string userid in TFSBugProvider.GetCreaters(wiCollection)) { TFSBugProvider.QueryArgument arg = new TFSBugProvider.QueryArgument(null, null, null, userid); CounterRecord.ComplexValue cv = new CounterRecord.ComplexValue( userid, Type, TFSBugProvider.QueryBugCount(wiCollection, arg)); root.RelatedValues.Add(cv); cache[arg.ToString()] = cv; } foreach (var key in existingNode) { foreach (string userid in TFSBugProvider.GetCreaters(wiCollection)) { TFSBugProvider.QueryArgument addtionArg = new TFSBugProvider.QueryArgument(null, null, null, userid); TFSBugProvider.QueryArgument curArg = MergeAndQuery(wiCollection, key, addtionArg); LinkParent(curArg); } } return(root); }