Ejemplo n.º 1
0
        /// <summary>
        /// Fetches files, 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> GetCleanedFilesWorkedOn(DateTimeOffset date)
        {
            var maxFiles      = 20;
            var files         = WindowTitleArtifactExtractor.GetFilesWorkedOn(date);
            var filesFiltered = files.Where(w => w.DurationInMins > MinDurationInMins).Take(maxFiles).ToList();

            var list = new List <TimeSpentItem>();

            foreach (var w in filesFiltered)
            {
                var title = w.FileName; // + w.FilePath;
                var item  = new TimeSpentItem(TimeSpentType.File, title, w.DurationInMins);
                list.Add(item);
            }

            return(list);

            //WindowTitleArtifactExtractor.GetFileExtensionFromFileName(file.FileName),
            //        WindowTitleArtifactExtractor.GetFileNameWithoutExtension(file.FileName),
            //        Math.Round(file.DurationInMins, 1));
        }
Ejemplo n.º 2
0
        public void GetArtifactDetailsTest()
        {
            // dummy data
            var dummyList = new List <ArtifactTest>();

            dummyList.Add(new ArtifactTest("Document.docx - Word", "WINWORD", "Document.docx"));
            dummyList.Add(new ArtifactTest("Lost Receipts Form V1.doc [Read-Only] [Compatibility Mode] - Word", "WINWORD", "Lost Receipts Form V1.doc"));
            dummyList.Add(new ArtifactTest("Book1 - Excel", "excel", "Book1.xlsx"));
            dummyList.Add(new ArtifactTest("PBI-WSR  [Read-Only] - Excel", "excel", "PBI-WSR.xlsx"));
            dummyList.Add(new ArtifactTest("20150305 - Analytics Experience Review - PowerPoint", "powerpnt", "20150305 - Analytics Experience Review.pptx"));
            dummyList.Add(new ArtifactTest("Publication2 (Read-Only) - Publisher", "mspub", "Publication2.pub"));
            dummyList.Add(new ArtifactTest("Acquisition - OneNote", "onenote", "Acquisition.one"));
            dummyList.Add(new ArtifactTest("B18 TSE Nameplate  [Read-Only] - Visio Professional", "visio", "B18 TSE Nameplate.vsd"));
            dummyList.Add(new ArtifactTest(".gitignore - Notepad", "notepad", ".gitignore"));
            dummyList.Add(new ArtifactTest("Find ", "notepad", ""));
            dummyList.Add(new ArtifactTest("hosts - Notepad", "notepad", "hosts.txt"));
            dummyList.Add(new ArtifactTest("20130617 - Bing Scorecard DAX Queries - Notepad", "notepad", "20130617 - Bing Scorecard DAX Queries.txt"));
            dummyList.Add(new ArtifactTest(@"*C:\DATA\MS-PA\AM.PA.MonitoringTool\Retrospection\Properties\styles_css.txt", "notepad", "styles_css.txt"));
            dummyList.Add(new ArtifactTest(@"c:\EngDev\config\batmon\Q-Prod-Co3\QSignTest\QSignSettings.json - Notepad++ [Administrator]", "notepad++", "QSignSettings.json"));
            dummyList.Add(new ArtifactTest(@"C:\Users\kimh\Downloads\QTestResults.wtt.xml (r_scripts) - Sublime Text 2", "sublime", "QTestResults.wtt.xml"));
            dummyList.Add(new ArtifactTest(@"C:\Users\kimh\AppData\Roaming\Sublime Text 2\Packages\User\Default (Windows).sublime-keymap • (r_scripts) - Sublime Text 2", "sublime", "Default (Windows).sublime-keymap"));
            dummyList.Add(new ArtifactTest("Print ", "foxitreader", ""));
            dummyList.Add(new ArtifactTest("PassportApplicationComplete (1).pdf - Foxit Reader", "foxitreader", "PassportApplicationComplete (1).pdf"));
            dummyList.Add(new ArtifactTest("Nonimmigrant Visa - Confirmation Page.pdf - Adobe Reader", "AcroRd32", "Nonimmigrant Visa - Confirmation Page.pdf"));
            dummyList.Add(new ArtifactTest("Nonimmigrant Visa - Confirmation Page.pdf - Adobe Acrobat Reader DC", "AcroRd32", "Nonimmigrant Visa - Confirmation Page.pdf"));
            dummyList.Add(new ArtifactTest("2015-11-29 MS Covergence 15 Bar 24 by Picturex (1320284).jpg ?- Photos", "Photos", "2015-11-29 MS Covergence 15 Bar 24 by Picturex (1320284).jpg"));

            // run method
            foreach (var row in dummyList)
            {
                var fileName = WindowTitleArtifactExtractor.GetArtifactDetails(row.InputProcess, row.InputTitle);

                Debug.WriteLine(row.OutputExpected + " - vs - " + fileName);
                Assert.AreEqual(row.OutputExpected, fileName);
            }
        }
Ejemplo n.º 3
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);
        }