예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public static TFSBugProvider GetInstance()
        {
            if (_obj == null)
            {
                _obj = new TFSBugProvider();
            }

            return(_obj);
        }
예제 #4
0
        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);
        }