public void start(Analysis parent, HttpResponse response, System.Web.SessionState.HttpSessionState session) { ParameterStream stream = ParameterStream.getStream(session); String[] features = (String[])stream.get("selectedFeatures"); int PCs = (int)stream.get("numberOfPCs"); Registry.Registry registry = Registry.Registry.getRegistry(session); System.Data.DataSet ds = (System.Data.DataSet)registry.GetDataset((string)stream.get("dataSetName")); //retrieve dataset table (assume one for now) System.Data.DataTable dt = ds.Tables[0]; //raw data double[,] rawData = new double[dt.Rows.Count, features.Count()]; for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < features.Count(); j++) { rawData[i, j] = (double)dt.Rows[i].ItemArray.ElementAt(dt.Columns[features[j]].Ordinal); } } //Create matrix to hold data for PCA Matrix X = new Matrix(rawData); //Remove mean Vector columnVector; for (int i = 0; i < X.ColumnCount; i++) { columnVector = X.GetColumnVector(i); X.SetColumnVector(columnVector.Subtract(columnVector.Average()), i); } Matrix PCmatrix = new Matrix(X.ColumnCount, PCs, 0); Vector Weights = new Vector(PCs); System.Diagnostics.Stopwatch watch = new Stopwatch(); //Run algorithm and time it watch.Start(); SingularValueDecomposition svd = SVD(X); watch.Stop(); stream.set("algRunTime", watch.ElapsedMilliseconds); /* * response.Buffer = true; * response.Write(PCmatrix.ToString() + "\n"); * response.Write(Weights.ToString() + "\n"); * response.Flush(); */ Debug.WriteLine("Done with PCA"); stream.set("PCmatrix", svd.RightSingularVectors); stream.set("Weights", svd.SingularValues); parent.next(response, session); }
/// <summary> /// /// </summary> /// <param name="categories"></param> /// <param name="inputDir"></param> /// <param name="outputDir"></param> private void RunAutoRip(List <string> categories, string inputDir, string outputDir) { Task.Factory.StartNew(() => { using (new HourGlass(this)) { string[] lines = File.ReadAllLines("autorip.dat"); foreach (string file in System.IO.Directory.EnumerateFiles(inputDir, "*", SearchOption.AllDirectories)) { try { Registry.Registry registry = new Registry.Registry(file); if (registry.HiveType == Registry.HiveType.Unknown) { continue; } foreach (string line in lines) { string[] parts = line.Split(','); if (parts.Length != 3) { continue; } if (registry.HiveType.GetEnumDescription().ToLower() != parts[1].ToLower()) { continue; } UpdateStatusBar("Running " + parts[2] + "..."); ExecutePlugin(file, System.IO.Path.Combine(outputDir, parts[0] + ".txt"), parts[2]); } } catch (Exception ex) { _logger.Error("Error occurred whilst running plugin: (" + file + ") " + ex.Message); } } UpdateStatusBar(string.Empty); UserInterface.DisplayMessageBox(this, "Autorip complete", MessageBoxIcon.Information); } }); }
protected void FeatureList_Init(object sender, EventArgs e) { String dataSetParameterName = "dataSetName"; ParameterStream stream = ParameterStream.getStream(Session); if (stream.contains(dataSetParameterName)) { Registry.Registry appRegistry = Registry.Registry.getRegistry(Session); DataSet ds = appRegistry.GetDataset((String)stream.get(dataSetParameterName)); foreach (DataColumn dc in ds.Tables[0].Columns) { FeatureList.Items.Add(dc.ColumnName); } } }
/// <summary> /// /// </summary> private void RunFolder() { List <string> plugins = new List <string>(); switch (_mode) { case Global.Mode.All: plugins = Functions.GetAllPlugins(listPlugins); break; case Global.Mode.Filter: if (cboFilter.SelectedIndex == -1) { UserInterface.DisplayMessageBox(this, "The filter must be selected", MessageBoxIcon.Exclamation); return; } plugins = Functions.GetFilterPlugins(_regRipperPlugins, cboFilter.Items[cboFilter.SelectedIndex].ToString()); break; case Global.Mode.Multiple: plugins = Functions.GetCheckedPlugins(listPlugins); break; case Global.Mode.Single: plugins = Functions.GetSelectedPlugin(listPlugins); break; } if (plugins.Count == 0) { UserInterface.DisplayMessageBox(this, "No plugins to run", MessageBoxIcon.Exclamation); return; } string folder = string.Empty; using (FormFolder form = new FormFolder()) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel) { return; } folder = form.Folder; } txtOutput.Text = string.Empty; Task.Factory.StartNew(() => { using (new HourGlass(this)) { MethodInvoker methodInvoker = delegate { tabMain.SelectedTab = tabPageOutput; List <Plugin> tempPlugins = listPlugins.Objects.Cast <Plugin>().ToList(); foreach (string file in System.IO.Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories)) { try { Registry.Registry registry = new Registry.Registry(file); if (registry.HiveType == Registry.HiveType.Unknown) { _logger.Error("Unknown hive type: " + file); continue; } foreach (string plugin in plugins) { // Ensure that the plugin hive type is correct for the file hive type if (Functions.IsPluginForHive(tempPlugins, plugin, registry.HiveType) == false) { continue; } ExecutePlugin(file, plugin, true); } } catch (Exception ex) { _logger.Error("Error occurred whilst running plugin: (" + file + ") " + ex.Message); } } }; if (this.InvokeRequired == true) { this.BeginInvoke(methodInvoker); } else { methodInvoker.Invoke(); } } }); }
/// <summary> /// /// </summary> private void RunHive() { List <string> plugins = new List <string>(); switch (_mode) { case Global.Mode.All: plugins = Functions.GetAllPlugins(listPlugins); break; case Global.Mode.Filter: if (cboFilter.SelectedIndex == -1) { UserInterface.DisplayMessageBox(this, "The filter must be selected", MessageBoxIcon.Exclamation); return; } plugins = Functions.GetFilterPlugins(_regRipperPlugins, cboFilter.Items[cboFilter.SelectedIndex].ToString()); break; case Global.Mode.Multiple: plugins = Functions.GetCheckedPlugins(listPlugins); break; case Global.Mode.Single: plugins = Functions.GetSelectedPlugin(listPlugins); break; } if (plugins.Count == 0) { UserInterface.DisplayMessageBox(this, "No plugins to run", MessageBoxIcon.Exclamation); return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select the registry hive"; openFileDialog.Filter = "All Files|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.Cancel) { return; } Task.Factory.StartNew(() => { using (new HourGlass(this)) { MethodInvoker methodInvoker = delegate { try { txtOutput.Text = string.Empty; Registry.Registry registry = new Registry.Registry(openFileDialog.FileName); if (registry.HiveType == Registry.HiveType.Unknown) { _logger.Error("Unknown hive type: " + openFileDialog.FileName); UserInterface.DisplayErrorMessageBox(this, "Unable to determined registry hive type"); return; } tabMain.SelectedTab = tabPageOutput; foreach (string plugin in plugins) { ExecutePlugin(openFileDialog.FileName, plugin, true); } } catch (Exception ex) { UserInterface.DisplayErrorMessageBox(this, "An error occurred: " + ex.Message); return; } }; if (this.InvokeRequired == true) { this.BeginInvoke(methodInvoker); } else { methodInvoker.Invoke(); } } }); }
protected void Page_PreInit(object sender, EventArgs e) { stream = ParameterStream.getStream(Session); registry = Registry.Registry.getRegistry(Session); }