Beispiel #1
0
        public void GetCodeReviewsDoneTest()
        {
            // CodeFLow Code Reviews

            // dummy data
            var dummyList = new List <ArtifactTest>();

            dummyList.Add(new ArtifactTest("Set all Year columns to Year category - CodeFlow", "", "Set all Year columns to Year category"));
            dummyList.Add(new ArtifactTest("Synchronizing Review... - CodeFlow", "", ""));
            dummyList.Add(new ArtifactTest("Compensating table query - CodeFlow", "", "Compensating table query"));

            // run method
            foreach (var row in dummyList)
            {
                var review = WindowTitleCodeExtractor.GetReviewName(row.InputTitle);

                Debug.WriteLine(row.OutputExpected + " - vs - " + review);
                Assert.AreEqual(row.OutputExpected, review);
            }

            ///////////////////////////////////////////////////////////
            // VS Code Reviews
            var dummyList2 = new List <ArtifactTest>();

            dummyList2.Add(new ArtifactTest("Code Review - Site.css", "", "Site.css"));
            dummyList2.Add(new ArtifactTest("AM.PA.MonitoringTool(Running) - Microsoft Visual Studio", "", ""));

            foreach (var row in dummyList2)
            {
                var review = WindowTitleCodeExtractor.GetVsReviewName(row.InputTitle);

                Debug.WriteLine(row.OutputExpected + " - vs - " + review);
                Assert.AreEqual(row.OutputExpected, review);
            }
        }
        /// <summary>
        /// Fetches code reviews, cleanes them for the MinDuration.
        /// Hint: no need to sort, as they already comed sorted by duration.
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        internal static List <TimeSpentItem> GetCleanedCodeReviewsDone(DateTimeOffset date)
        {
            var maxCodeReviews = 15;
            var reviews        = WindowTitleCodeExtractor.GetCodeReviewsDone(date);

            var list = new List <TimeSpentItem>();

            foreach (var p in reviews)
            {
                var item = new TimeSpentItem(TimeSpentType.CodeReview, p.Key, p.Value);
                list.Add(item);
            }

            return(list.Where(w => w.DurationInMins > MinDurationInMins).Take(maxCodeReviews).ToList());
        }
        /// <summary>
        /// Fetches VS projects, cleanes them for the MinDuration.
        /// Hint: no need to sort, as they already comed sorted by duration.
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        internal static List <TimeSpentItem> GetCleanedVisualStudioProjects(DateTimeOffset date)
        {
            var maxVsProjects = 10;
            var vsProjects    = WindowTitleCodeExtractor.GetVisualStudioProjects(date);

            var list = new List <TimeSpentItem>();

            foreach (var p in vsProjects)
            {
                var item = new TimeSpentItem(TimeSpentType.VsProject, p.Key, p.Value);
                list.Add(item);
            }

            return(list.Where(w => w.DurationInMins > MinDurationInMins).Take(maxVsProjects).ToList());
        }
Beispiel #4
0
        public void GetVisualStudioProjectsTest()
        {
            // dummy data
            var dummyList = new List <ArtifactTest>();

            dummyList.Add(new ArtifactTest("ConsoleApplication1 (Debugging) - Microsoft Visual Studio (Administrator)", "", "ConsoleApplication1"));
            dummyList.Add(new ArtifactTest("ConsoleApplication1 (Running) - Microsoft Visual Studio (Administrator)", "", "ConsoleApplication1"));
            dummyList.Add(new ArtifactTest("ConsoleApplication1 - Microsoft Visual Studio", "", "ConsoleApplication1"));
            dummyList.Add(new ArtifactTest("Add New Item - SchemaGenerator", "", ""));
            dummyList.Add(new ArtifactTest("Add New Item - Query Service Model", "", ""));
            dummyList.Add(new ArtifactTest("sources_dev_transportsync_src_common.dgml - Microsoft Visual Studio", "", "sources_dev_transportsync_src_common.dgml"));
            dummyList.Add(new ArtifactTest("Microsoft Visual Studio", "", ""));

            // run method
            foreach (var row in dummyList)
            {
                var title = WindowTitleCodeExtractor.GetProjectName(row.InputTitle);

                Debug.WriteLine(row.OutputExpected + " - vs - " + title);
                Assert.AreEqual(row.OutputExpected, title);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Fetches the activities a developer has on his computer for a given date in an
        /// ordered list according to time.
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        internal static List <WindowsActivity> GetDayTimelineData(DateTimeOffset date)
        {
            var orderedActivityList = new List <WindowsActivity>();

            try
            {
                var query = "SELECT t1.time as 'tsStart', t2.time as 'tsEnd', t1.window, t1.process, (strftime('%s', t2.time) - strftime('%s', t1.time)) as 'durInSec' " //t1.id, t1.time as 'from', t2.time as 'to'
                            + "FROM " + Settings.DbTable + " t1 LEFT JOIN " + Settings.DbTable + " t2 on t1.id + 1 = t2.id "
                            + "WHERE " + Database.GetInstance().GetDateFilteringStringForQuery(VisType.Day, date, "t1.time") + " and " + Database.GetInstance().GetDateFilteringStringForQuery(VisType.Day, date, "t2.time") + " "
                            + "ORDER BY t1.time;";

                var table = Database.GetInstance().ExecuteReadQuery(query);

                WindowsActivity _previousWindowsActivityEntry = null;

                foreach (DataRow row in table.Rows)
                {
                    // fetch items from database
                    var e = new WindowsActivity();
                    e.StartTime         = DateTime.Parse((string)row["tsStart"], CultureInfo.InvariantCulture);
                    e.EndTime           = DateTime.Parse((string)row["tsEnd"], CultureInfo.InvariantCulture);
                    e.DurationInSeconds = row.IsNull("durInSec") ? 0 : Convert.ToInt32(row["durInSec"], CultureInfo.InvariantCulture);
                    var processName = (string)row["process"];

                    // make window titles more readable (TODO: improve!)
                    var windowTitle = (string)row["window"];
                    windowTitle = WindowTitleWebsitesExtractor.GetWebsiteDetails(processName, windowTitle);
                    windowTitle = WindowTitleArtifactExtractor.GetArtifactDetails(processName, windowTitle);
                    windowTitle = WindowTitleCodeExtractor.GetProjectName(windowTitle);

                    // map process and window to activity
                    ProcessToActivityMapper.Map(e, processName, windowTitle);

                    // check if we add a new item, or merge with the previous one
                    if (_previousWindowsActivityEntry != null)
                    {
                        // previous item is same, update it (duration and tsEnd)
                        if (e.ActivityCategory == _previousWindowsActivityEntry.ActivityCategory)
                        {
                            var lastItem = orderedActivityList.Last();
                            lastItem.DurationInSeconds += e.DurationInSeconds;
                            lastItem.EndTime            = e.EndTime;
                            lastItem.WindowProcessList.Add(new WindowProcessItem(processName, windowTitle));
                        }
                        // previous item is different, add it to list
                        else
                        {
                            e.WindowProcessList.Add(new WindowProcessItem(processName, windowTitle));
                            orderedActivityList.Add(e);
                        }
                    }
                    else // first item
                    {
                        orderedActivityList.Add(e);
                    }
                    _previousWindowsActivityEntry = e;
                }
                table.Dispose();
            }
            catch (Exception e)
            {
                Logger.WriteToLogFile(e);
            }

            return(orderedActivityList);
        }