예제 #1
0
		internal object DoWork(){
			//	Invoke the worker method and return any results.
			WaitWindowEventArgs e = new WaitWindowEventArgs(_Parent, _Parent._Args);
			if ((_Parent._WorkerMethod != null)){
				_Parent._WorkerMethod(this, e);
			}
			return e.Result;
		}
예제 #2
0
        internal object DoWork()
        {
            //	Invoke the worker method and return any results.
            WaitWindowEventArgs e = new WaitWindowEventArgs(this._Parent, this._Parent._Args);

            if ((this._Parent._WorkerMethod != null))
            {
                this._Parent._WorkerMethod(this, e);
            }
            return(e.Result);
        }
예제 #3
0
 private void SaveAsPdf(object sender, WaitWindowEventArgs e)
 {
     string fileName = e.Arguments[0].ToString();
     string pathToSave = "";
     bool thrown = false;
     try
     {
         using (MagickImage image = new MagickImage(filePath))
         {
             image.Format = MagickFormat.Pdf;
             pathToSave = Path.Combine(Constants.ContainerLocation, Constants.Directories.GetSpecifiedCaseDirectory(action), fileName + SaveableFileTypes.Pdf);
             image.Write(pathToSave);
             e.Window.Message = "Rehashing PDF";
             Hash = OsirtHelper.GetFileHash(pathToSave);
             successful = true;
         }
     }
     catch (Exception ex) when (ex is MagickErrorException || ex is System.Runtime.InteropServices.SEHException || ex is ArgumentException || ex is System.Reflection.TargetInvocationException /*|| ex is System.AccessViolationException || ex is Exception*/)
     {
         thrown = true;
         var message = "Unable to save as PDF. Reverting to saving as PNG.";
         Invoke((MethodInvoker)(() => uiFileExtensionComboBox.SelectedIndex = uiFileExtensionComboBox.Items.IndexOf(SaveableFileTypes.Png)));
         e.Window.Message = message;
         Task.Delay(2000).Wait(); //just so the user can see we're saving as PNG instead
         SaveAsPng(fileName);
     }
     finally
     {
         //delete temp pdf file
         if (thrown)
         {
             if (File.Exists(pathToSave))
             {
                 File.Delete(pathToSave);
             }
         }
     }
 }
 private void CreateCase(object sender, WaitWindowEventArgs e)
 {
     new CaseCreator((Dictionary<string, string>)e.Arguments[0], new DatabaseTableHelper());
 }
예제 #5
0
 private void GetScreenshot(object sender, WaitWindowEventArgs e)
 {
     DirectoryInfo directory = new DirectoryInfo(Constants.CacheLocation);
     FileSystemInfo[] files = directory.GetFileSystemInfos();
     ScreenshotHelper.CombineScreenshot(files, e);
 }
 private void VerifyPassword(object sender, WaitWindowEventArgs e)
 {
     string password = e.Arguments[0].ToString();
     e.Result = ZipFile.CheckZipPassword(file.FullName, password);
 }
        private void LoadCase(object sender, WaitWindowEventArgs e)
        {
            string password = e.Arguments[0].ToString();
            DirectoryInfo parentDir = Directory.GetParent(file.FullName);
            using (ZipFile zip = ZipFile.Read(file.FullName))
            {
                zip.Password = password;
                zip.ExtractAll(parentDir.FullName, ExtractExistingFileAction.OverwriteSilently);
            }

            try
            {
                File.Delete(file.FullName);
            }
            catch (IOException io)
            {
                MessageBox.Show($"Unable to delete: {io}");
            }

            Constants.CasePath = parentDir.FullName;
            Constants.CaseContainerName = Path.GetFileName(file.FullName.Replace(Constants.ContainerExtension, ""));

            if (password != "")
            {
                e.Window.Message = "Re-encrypting password... Please Wait";
                string hash = SecurePasswordHasher.Hash(password);
                UpdateCaseTableWithPassword(hash);
            }

            if(!isReport)
                Logger.Log(new OsirtActionsLog(Actions.CaseLoaded, uiFileHashTextBox.Text, Constants.CaseContainerName));

        }
예제 #8
0
 private void CreatePDF(object sender, WaitWindowEventArgs e)
 {
     //TODO: When audit log is exported and case notes are then exported (or vice-verca) as PDF, the application hangs...
     string path = e.Arguments[0].ToString();
     string html = CaseNotesToHtml.CreateHtml();
     HtmLtoPdf.SaveHtmltoPdf(html, "" ,"Case Notes", path);
     string hash = OsirtHelper.GetFileHash(path);
     Logger.Log(new OsirtActionsLog(Enums.Actions.CaseNotes, hash, System.IO.Path.GetFileName(path)));
 }
예제 #9
-1
        /// <summary>
        /// Combines the screenshots into one contiguous screenshot
        /// </summary>
        /// <param name="files">The files (images) to combine</param>
        /// <param name="e">For UX, an output progress message</param>
        public static void CombineScreenshot(FileSystemInfo[] files, WaitWindowEventArgs e)
        {
           

            string screenshotLocation = Path.Combine(Constants.CacheLocation, "temp.png");

            using (MagickImageCollection images = new MagickImageCollection())
            {
                // Add the first image
                var orderedFiles = files.OrderBy(f => f.CreationTime);
                foreach (FileSystemInfo file in orderedFiles)
                {
                    MagickImage first = new MagickImage(file.FullName);
                    e.Window.Message = "Obtaining Snapshots... Please Wait";
                    images.Add(first);
                }

                using (MagickImage result = images.AppendVertically())
                {
                    e.Window.Message = "Building Screenshot... Please Wait" + System.Environment.NewLine + "This can take a minute.";
                    try
                    {
                        result.Write(screenshotLocation);
                    } catch (MagickImageErrorException err)
                    {
                        Debug.WriteLine($"Error: {err}");
                    }
                   
                }
        
            }
        }