/// <summary> /// Close application event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button5_Click(object sender, EventArgs e) { _tcpListener?.Stop(); if (ScannerCaching.IsCacheSet()) { ScannerCaching.SaveCache(); } if (Application.MessageLoop) { if (MainServerControl.ActiveTcpClients != null) { foreach (var client in MainServerControl.ActiveTcpClients) { client.Close(); } MainServerControl._clientListener.Stop(); } Application.Exit(); } else { // Console app //Environment.Exit(1); Application.Exit(); } }
public void ScanUsingBinarySearch() { ba_createData.Properties.Settings.Default.EncryptionLength = 32; ba_createData.Properties.Settings.Default.Test = false; var saveString = new StringBuilder(); // Without caching if (MemoryDatabase.SuffixArray == null) { MemoryDatabase.LoadDataIntoMemory(); } ba_createData.Properties.Settings.Default.EncryptionLength = 32; ba_createData.Properties.Settings.Default.UseSQL = false; ba_createData.Properties.Settings.Default.UseBinaryWLcp = false; ba_createData.Properties.Settings.Default.UseBinary = true; ba_createData.Properties.Settings.Default.UseRAMOnly = true; ba_createData.Properties.Settings.Default.UseHDDOnly = false; ba_createData.Properties.Settings.Default.SplitOption = 1; ba_createData.Properties.Settings.Default.UseCashing = false; var testFolderPath = Thread.GetDomain().BaseDirectory + "\\Testresults"; var fileLocation = testFolderPath + "\\binarysearchtest.txt"; saveString.Append(@"Binary Search Without cashing:".ToUpper() + Environment.NewLine + Environment.NewLine); var stopWatch = new Stopwatch(); stopWatch.Start(); var result = Scanner.ScanFile("C495AAE02CE54133A0FEFF7E488C3B96$".ToLower()); stopWatch.Stop(); // Write tesresult to file saveString.Append(@"Result: " + result + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var result1 = Scanner.ScanFile("54697A0CC91DCC69E688FBF1EEE55FD0$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + result1 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var result2 = Scanner.ScanFile("74DFF0B6ECCEA35521A65B9A742EB735$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + result2 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var result3 = Scanner.ScanFile("3C9AE0FE669D6AF30B11268118C3179A$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + result3 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var result4 = Scanner.ScanFile("F9FDF8364F7A01247A561C67AE1A4A5B$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + result4 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var result5 = Scanner.ScanFile("A4C21BE59ECEC716B2F646F8D55AC622$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + result5 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var result6 = Scanner.ScanFile("f7198035cce341240181d005c7b022e0$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + result6 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); stopWatch.Start(); var results7 = Scanner.ScanFile("2d75cc1bf8e57872781f9cd04a529256$".ToLower()); stopWatch.Stop(); saveString.Append(@"Result: " + results7 + @" - found in " + stopWatch.Elapsed + Environment.NewLine); stopWatch.Reset(); File.WriteAllText(fileLocation, saveString.ToString()); Assert.AreEqual(false, result1); Assert.AreEqual(false, result); Assert.AreEqual(false, result3); Assert.AreEqual(false, result2); Assert.AreEqual(false, result4); Assert.AreEqual(false, result5); Assert.AreEqual(true, results7); Assert.AreEqual(true, result6); // Save cache ScannerCaching.SaveCache(); }