private void SaveToDatabase()
        {
            // Parse Window Data
            ParsedWindow parsedWindow = ParserService.ParseProcess(WindowName, WindowTitle, _foregroundProcess);

            // Save Window Data To Database and Update the object
            UpdateAndSaveForegroundItems(parsedWindow);
        }
Esempio n. 2
0
        public static ParsedWindow ParseProcess(string procName, string procWindowTitle, Process proc)
        {
            ParsedWindow parsedWindow = new ParsedWindow();

            // Add app, file name, file path to parsedWindow object
            GetAppAndFileName(procName, procWindowTitle, proc, parsedWindow);

            parsedWindow.WindowName  = procName;
            parsedWindow.WindowTitle = CleanWindowTitle(procWindowTitle);

            return(parsedWindow);
        }
        private void UpdateAndSaveForegroundItems(ParsedWindow parsedWindow)
        {
            if (parsedWindow.ApplicationName != null)
            {
                _foregroundAppItem = _DBGateway.GetOrCreateApplicationItemFromDB(parsedWindow.ApplicationName, _foregroundProcess);

                if (parsedWindow.FileName != null)
                {
                    _foregroundFileItem = _DBGateway.GetOrCreateFileItemFromDB(parsedWindow.FileName, parsedWindow.FilePath, _foregroundAppItem.ApplicationId);
                }
            }

            int?   appId      = _foregroundAppItem != null ? _foregroundAppItem.ApplicationId : (int?)null;
            int?   fileId     = _foregroundFileItem != null ? _foregroundFileItem.FileId : (int?)null;
            string windowText = parsedWindow.WindowTitle;

            _foregroundWindowItem = _DBGateway.GetOrCreateWindowItemFromDB(appId, fileId, windowText);

            _DBGateway.InsertWindowHistoryItem(_lastUpdateTime, _foregroundWindowItem.WindowId);
        }
Esempio n. 4
0
        private static void GetAppAndFileName(string procName, string procWindowTitle, Process proc, ParsedWindow parsedWindow)
        {
            string appName  = null;
            string filePath = null;
            string fileName = null;

            if (procWindowTitle == null)
            {
                procWindowTitle = "";
            }

            if (procName == "chrome")
            {
                appName = GetChromeDomainWebsite(procWindowTitle);
                if (appName != null)
                {
                    fileName = GetChromeAppFile(procWindowTitle, appName);
                }
            }
            else if (procName == "UiPath.Studio")
            {
                appName  = "UiPath Studio";
                fileName = procWindowTitle.Contains("-") ? procWindowTitle.Split('-')[1] : null;
            }
            else if (procName == "explorer")
            {
                appName = "Explorer";
            }
            else if (procName == "EXCEL")
            {
                appName = "Excel";

                try
                {
                    Microsoft.Office.Interop.Excel.Application excelApp = WindowTracker.ExcelInteropService.GetOpenExcelApplication(proc);
                    fileName = excelApp.ActiveWorkbook.FullName;
                    filePath = excelApp.ActiveWorkbook.Path;
                }
                catch
                {
                    // Do nothing, excel is open but we're not focused on a file.
                }
            }
            else if (procName == "AlteryxGui")
            {
                appName = "Alteryx";

                if (procWindowTitle.Contains("Alteryx Designer x64 - "))
                {
                    string[] splitTitle = procWindowTitle.Split(new string[] { "Alteryx Designer x64" }, StringSplitOptions.None);

                    fileName = splitTitle[1];
                    if (fileName.Last() == '*')
                    {
                        fileName = fileName.Remove(fileName.Length - 1, 1);
                    }
                }
            }

            if (appName == null)
            {
                appName = procName;
            }

            parsedWindow.ApplicationName = appName;
            parsedWindow.FileName        = fileName;
            parsedWindow.FilePath        = filePath;
        }