Esempio n. 1
0
 /*
  * ----< Function > MainPage
  * ----< Description >
  * Program entry point, initializes the GUI and logger.
  * Also clears the API for usage during the current session.
  * ----< Description >
  * @Param None
  * @Return None
  */
 public MainPage()
 {
     this.InitializeComponent();
     API_Interface.TruncateTestFunctions(); // Will be used to remove any sort of misplaced data on the API side
     logger = new GuiLogger("Initializing Logger", ref this.Logger, ref this.logScrollViewer);
     logger.AddLogMessage("Initializing GUI");
 }
Esempio n. 2
0
        /*
         * ----< Function > parseJSON
         * ----< Description >
         * Given a JSON file this function will read in the JSON data and parse the data
         * to pull out all relevent information about the dll's and functions within and store
         * the data in a list within the class.
         * ----< Description >
         * @Param StorageFile storageFile -- File object that contains the path / name of the JSON file
         */
        public void parseJSON(StorageFile storageFile)
        {
            Debug.WriteLine(jsonData.ToString());

            JArray  jArray  = (JArray)jsonData["dlls"];
            dynamic dllData = jArray;


            Debug.WriteLine("Testing Dynamics");
            if (dllData != null)
            {
                try
                {
                    foreach (dynamic item in dllData)
                    {
                        dllInfo newDll = new dllInfo();
                        newDll.dllName        = item.Name.ToString();
                        newDll.dllLocation    = item.Location.ToString();
                        newDll.jsonSourceName = storageFile.DisplayName;


                        foreach (dynamic functionT in item.Functions)
                        {
                            dllFunction newFunction = new dllFunction();
                            newFunction.FuncName = functionT.FuncName;
                            newDll.functionList.Add(newFunction);
                        }
                        allDLLData.Add(newDll);
                    }

                    Debug.WriteLine("Testing Listing Function");
                    foreach (dllInfo item in allDLLData)
                    {
                        Debug.WriteLine("Name: " + item.dllName);
                        foreach (dllFunction function in item.functionList)
                        {
                            Debug.WriteLine(function.FuncName);
                        }
                        Debug.WriteLine("---------------------");
                    }
                }catch (Exception ex)
                {
                    GuiLogger.logException("Invalid Source JSON", ex.Message);
                    allDLLData.Clear();
                    return;
                }
            }
            else
            {
                GuiLogger.logException("Invalid Source JSON", "Please Correct");
            }
        }
Esempio n. 3
0
        /*
         * ----< Function > DllToggled
         * ----< Description >
         * Once a DLL is toggled the application will call BindDLL(), open a file picker,
         * select the file and bind the physical file to the logic here
         * ----< Description >
         */
        private async void DllToggled(object sender, RoutedEventArgs e)
        {
            int          indexOfCurrentDLLToggled;
            ToggleSwitch toggleSwitch = sender as ToggleSwitch;
            dllInfo      sampleDll    = (dllInfo)((Grid)toggleSwitch.Parent).DataContext;

            Debug.WriteLine(sampleDll.dllName + " Was toggled");

            if (toggleSwitch.IsOn)
            {
                dllBindingClass dllBinder = await BindDLL();

                if (dllBinder != null)
                {
                    Debug.WriteLine("Testing the binder");
                    Debug.WriteLine(dllBinder.dllFullPath + "---" + dllBinder.dllName);

                    Debug.WriteLine("------------");
                    Debug.WriteLine("Before the move: ");
                    indexOfCurrentDLLToggled = fileNamesForListView.IndexOf(sampleDll);
                    if (fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllName == dllBinder.dllName)
                    {
                        Debug.WriteLine(fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation);
                        fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation = dllBinder.dllFullPath;
                        Debug.WriteLine("After the move: ");
                        Debug.WriteLine(fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation);
                    }
                    else
                    {
                        toggleSwitch.IsOn = false;
                        GuiLogger.logException("DLL name in GUI does not match selected DLL file.", "Please Try Again");
                        return;
                    }
                    foreach (dllFunction function in sampleDll.functionList)
                    {
                        function.DllName = fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllName;
                        function.DllPath = fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation;
                        functionForListView.Add(function);
                        this.FunctionList.ItemsSource = functionForListView;
                    }
                }
            }
            else
            {
                foreach (dllFunction function in sampleDll.functionList)
                {
                    functionForListView.Remove(function);
                }
                this.FunctionList.ItemsSource = functionForListView;
            }
        }
Esempio n. 4
0
 /*
  * ----< Function > readInJSON
  * ----< Description >
  * Given a JSON file this function will read in the JSON data and call parseJSON
  * to pull out the required information.
  * ----< Description >
  * @Param StorageFile storageFile -- File object that contains the path / name of the JSON file
  * @Return allDLLData -- A list of all dll's within the JSON file and their corresponding functions.
  */
 public async Task <List <dllInfo> > readInJSON(StorageFile storageFile)
 {
     fileName = storageFile.DisplayName;
     filePath = storageFile.Path;
     try
     {
         using (StreamReader file = new StreamReader(await storageFile.OpenStreamForReadAsync()))
             using (JsonTextReader reader = new JsonTextReader(file))
             {
                 jsonData = (JObject)JToken.ReadFrom(reader);
             }
         parseJSON(storageFile);
     }catch (Exception ex)
     {
         GuiLogger.logException("The JSON Passed in is invalid syntax.", ex.Message);
     }
     return(allDLLData);
 }
Esempio n. 5
0
        /*
         * ----< Function > GetResultsAsync
         * ----< Description >
         * For all test function ID's that have been sent this function will asynchronously
         * reach out to the endpoint /cse687/results ; sending an ID ; and receiving back a
         * JSON object containing the test results for that function.
         * ----< Description >
         * @Param GuiLogger logger -- Logger to write the data to in the GUI
         * @Return void
         */
        public static async void GetResultsAsync(GuiLogger logger)
        {
            foreach (int ID in functionsIDsSent)
            {
                JObject jsonOfIDs = new JObject
                {
                    { "ID", ID }
                };
                HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
                try
                {
                    while (true)
                    {
                        HttpClient        httpClient = new HttpClient();
                        Uri               uri        = new Uri("http://www.kaminfay.com/cse687/results");
                        HttpStringContent content    = new HttpStringContent(jsonOfIDs.ToString());
                        httpResponseMessage = await httpClient.PostAsync(uri, content);

                        if (httpResponseMessage.IsSuccessStatusCode)
                        {
                            string httpResponseBody = await httpResponseMessage.Content.ReadAsStringAsync();

                            if (httpResponseBody != "nil")
                            {
                                completedTestFunction complete = JSONParser.jsonToCompleted(httpResponseBody);
                                Debug.WriteLine(httpResponseBody);
                                logger.TestCompleteLog(complete);
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    return;
                }
            }

            functionsIDsSent.Clear();
        }
Esempio n. 6
0
 /*
  * ----< Function > Level_One_Button_Checked
  * ----< Description >
  * Set the logging level to 1, and reset the other two buttons.
  * ----< Description >
  */
 private void Level_One_Button_Checked(object sender, RoutedEventArgs e)
 {
     GuiLogger.SetLogLevel(1);
     this.Level_Three_Button.IsChecked = false;
     this.Level_Two_Button.IsChecked   = false;
 }