From 21fb769e51a1567ba2601211b28a827168af60f5 Mon Sep 17 00:00:00 2001 From: J0seph0 Date: Wed, 24 Jan 2024 10:26:12 -0800 Subject: [PATCH 01/94] started to implement saving querie with the new format --- FAFB-PowerShell-Tool/MainWindowViewModel.cs | 36 +++++++++++++++++++ .../PowerShell/CustomQueries.cs | 35 ++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/FAFB-PowerShell-Tool/MainWindowViewModel.cs b/FAFB-PowerShell-Tool/MainWindowViewModel.cs index 869ffc0..23485a7 100644 --- a/FAFB-PowerShell-Tool/MainWindowViewModel.cs +++ b/FAFB-PowerShell-Tool/MainWindowViewModel.cs @@ -1,3 +1,4 @@ +using FAFB_PowerShell_Tool; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; @@ -128,4 +129,39 @@ protected virtual void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + //This + private RelayCommand savedQueries; + // + public ICommand SavedQueries => savedQueries ??= new RelayCommand(PerformSavedQueries); + // + private void PerformSavedQueries(object commandParameter) + { + // Try to get the content within the drop downs + try + { + // Get the Command + //GuiCommand? command = ComboBoxCommandList.SelectedValue as GuiCommand; + string commandString = SelectedCommand.CommandText + SelectedCommand.Parameters.ToString(); + query + + Trace.WriteLine(commandString); + // string commandParameters = cmbParameters.Text; + + Button newButton = new() + { + Content = "Special Command", + Height = 48 + }; + // Adds the query to the Queries serializable list + + // Adds the button in the stack panel + + // Saves the Queries to the file + + } + catch (Exception ex) + { + Console.Write(ex); + } + } } diff --git a/FAFB-PowerShell-Tool/PowerShell/CustomQueries.cs b/FAFB-PowerShell-Tool/PowerShell/CustomQueries.cs index c16e0c7..d8cd58f 100644 --- a/FAFB-PowerShell-Tool/PowerShell/CustomQueries.cs +++ b/FAFB-PowerShell-Tool/PowerShell/CustomQueries.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.IO; +using System.Management.Automation.Runspaces; using System.Text.Json; using System.Text.Json.Serialization; @@ -12,7 +13,20 @@ namespace FAFB_PowerShell_Tool.PowerShell /// internal class CustomQueries { - public List Queries = new List(); + public class query { + string commandName; + string[] commandParams; + + public query(string cN, string[] commandParams) { + this.commandName = cN; + this.commandParams = commandParams; + } + public query(string cN) { + this.commandName = cN; + } + } + + public List Queries = new List(); /// /// This a variable for feeding options to the Json serializer /// @@ -42,6 +56,23 @@ public void SerializeMethod() } } /// + /// This method is for serializing a command type, so it converts the type to a query and then serializes it + /// + public void SerializeCommand(Command cmnd) { + string[] cparams = new string[cmnd.Parameters.Count]; + query newQuery = new query(cmnd.CommandText); + + // Iterate over the parameters and add them to the string + int i = 0; + foreach (var param in cmnd.Parameters) + { + //need to adjust this filling out + cparams[i] = param.Name; + i++; + } + + } + /// /// This method Loads the string from the saved file "CustomQueries.dat" then gives it to the Queries List /// public void LoadData() @@ -49,7 +80,7 @@ public void LoadData() try { string json = File.ReadAllText("CustomQueries.dat"); - Queries = JsonSerializer.Deserialize>(json, _options); + Queries = JsonSerializer.Deserialize>(json, _options); } catch (Exception ex) { From 8708adc6def63e1a7c66b97349257532425eaab5 Mon Sep 17 00:00:00 2001 From: Hunter T Date: Wed, 24 Jan 2024 15:27:15 -0800 Subject: [PATCH 02/94] Add GUI elements for future functionality --- FAFB-PowerShell-Tool/MainWindow.xaml | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml index 35d0156..d7640cf 100644 --- a/FAFB-PowerShell-Tool/MainWindow.xaml +++ b/FAFB-PowerShell-Tool/MainWindow.xaml @@ -9,7 +9,7 @@ - + @@ -67,7 +67,16 @@ - + + + + + + + + + + @@ -82,6 +91,10 @@ + + + + + IsEditable="True" Grid.Column="1" /> @@ -115,7 +128,7 @@ - +