private void button1_Click(object sender, EventArgs e)           //OCR button
        {
            String    folderWithScreenshotsPath = this.userpath + "\\Captures\\";
            String    outputDirectoryPath       = folderWithScreenshotsPath + "OCR\\";
            OcrEngine ocrEngine = new OcrEngine(folderWithScreenshotsPath, outputDirectoryPath);

            Directory.CreateDirectory(outputDirectoryPath);

            //Create thread and run OCR in that so the program doesn't lag as much
            Thread ocrThread = new Thread(ocrEngine.readScreenshots);

            ocrThread.Start();
        }
Example #2
0
        public Report(Event e, EventValues idt, string title, ScreenshotStruct screenshotStruct)
        {
            // todo: dynamic OS

            TimeStamp  = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            Id         = idt.entryId ?? "";
            UserName   = Environment.UserName;
            MacAddress =
                (
                    from nic in NetworkInterface.GetAllNetworkInterfaces()
                    where nic.OperationalStatus == OperationalStatus.Up
                    select nic.GetPhysicalAddress().ToString()
                ).FirstOrDefault();
            IPHostName = Dns.GetHostName();

            // get all ip addresses
            IPAddress[] addresses      = Dns.GetHostAddresses(IPHostName);
            ArrayList   addressStrings = new ArrayList();

            foreach (IPAddress ip in addresses)
            {
                addressStrings.Add(ip.ToString());
            }

            var ocrResult = Task <string> .Run(() => OcrEngine.asyncReadFromImage(screenshotStruct.ScreenshotFilePath));

            var base64Screenshot = Task <string> .Run(() => ScreenshotBase64Generator.JpegToBase64(screenshotStruct.ScreenshotFilePath));

            screenshotStruct.ScreenshotBase64String = base64Screenshot.Result;

            OS                     = "Windows";
            Process                = e.process ?? "";
            IPAddress              = JsonConvert.SerializeObject(addressStrings);
            Url                    = e.url ?? "";
            Title                  = title ?? "";
            Duration               = $"{idt.ts.Hours:00}:{idt.ts.Minutes:00}:{idt.ts.Seconds:00}";
            Idle                   = $"{idt.idle.Hours:00}:{idt.idle.Minutes:00}:{idt.idle.Seconds:00}";
            Active                 = $"{idt.active.Hours:00}:{idt.active.Minutes:00}:{idt.active.Seconds:00}";
            ScreenShotFileName     = screenshotStruct.ScreenshotFileName ?? "";
            ScreenShotBase64String = screenshotStruct.ScreenshotBase64String ?? "";
            ScreenShotOcrResult    = ocrResult.Result ?? "";
        }