private void BrowseFolderButton_Click(object sender, RoutedEventArgs e) { using (var ofd = new FolderBrowserDialog()) { ofd.RootFolder = Environment.SpecialFolder.MyComputer; ofd.ShowNewFolderButton = true; if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } string path = ofd.SelectedPath; string manifestFile = $"{path}\\manifest.json"; if (!File.Exists(manifestFile)) { using (var file = File.CreateText(manifestFile)) { file.Write("[]"); } } versionService.InstalledVersions = JsonConverterService <List <GodotVersionInstalled> > .Deserialize(manifestFile); GodotInstallLocationTextbox.Text = path; } }
private bool LoadVersionsFile() { try { versionService.AllVersions = JsonConverterService <List <GodotVersion> > .Deserialize("config\\versions.json"); string installedManifest = $"{config.GodotInstallLocation}\\manifest.json"; if (config.GodotInstallLocation != String.Empty && File.Exists(installedManifest)) { versionService.InstalledVersions = JsonConverterService <List <GodotVersionInstalled> > .Deserialize(installedManifest); } else { versionService.InstalledVersions = new List <GodotVersionInstalled>(); } } catch (Exception ex) { logger.Error(ex); CommonUtilsService.PopupExceptionMessage("Error loading versions", ex); return(false); } versionService.AllVersions.Reverse(); return(true); }
private bool ReadOrCreateConfigFile() { string configFile = "config\\config.json"; try { if (!File.Exists(configFile)) { config = new ApplicationConfig { GodotInstallLocation = String.Empty, Show32BitVersions = true, Show64BitVersions = true, ShowMonoVersions = false, ShowUnstableVersions = false, ShowInstalledVersions = true, ShowNotInstalledVersions = true, ShowStableVersions = true, ShowStandardVersions = true, LastUpdateChecked = DateTime.Now, LastSelectedVersion = -1, OnGodotLaunch = Constants.DO_NOTHING_ON_LAUNCH, UseProxy = false, ProxyUrl = String.Empty, ProxyPort = 0, }; JsonConverterService <ApplicationConfig> .Serialize(config, configFile); } config = JsonConverterService <ApplicationConfig> .Deserialize(configFile); if (config.UseProxy && (config.ProxyPort == 0 || config.ProxyUrl == String.Empty)) { config.UseProxy = false; JsonConverterService <ApplicationConfig> .Serialize(config, configFile); } if (config.GodotInstallLocation != String.Empty && !Directory.Exists(config.GodotInstallLocation)) { Directory.CreateDirectory(config.GodotInstallLocation); using (var file = File.CreateText($"{config.GodotInstallLocation}\\manifest.json")) { file.Write("[]"); } } } catch (Exception ex) { logger.Error(ex); CommonUtilsService.PopupExceptionMessage("Error reading config", ex); return(false); } return(true); }
/// <summary> /// /// </summary> /// <remarks>Author: Scott Roberts</remarks> private void PostRegistrationToSSO(string username) { using (HttpClientService client = HttpClientService.Instance) { // Fix this up with a proper url. client.PostAsJson("*****", JsonConverterService.SerializeObject(username)); } }
protected BaseMollieClient(string apiKey, HttpClient httpClient = null) { if (string.IsNullOrWhiteSpace(apiKey)) { throw new ArgumentNullException(nameof(apiKey), "Mollie API key cannot be empty"); } this._jsonConverterService = new JsonConverterService(); this._httpClient = httpClient ?? new HttpClient(); this._apiKey = apiKey; }
public void CanDeserializeNullMetadataValue() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); string metadataJson = @"null"; string paymentJson = @"{""metadata"":" + metadataJson + "}"; // When: We deserialize the JSON PaymentResponse payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.AreEqual(null, payments.Metadata); }
public void Deserialize_StringData_IsDeserialized() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); string metadataJson = "This is my metadata"; string paymentJson = @"{""metadata"":""" + metadataJson + @"""}"; // When: We deserialize the JSON PaymentResponse payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.AreEqual(metadataJson, payments.Metadata); }
public void CanDeserializeStringMetadataValue() { // Given: A JSON metadata value var jsonConverterService = new JsonConverterService(); var metadataJson = "This is my metadata"; var paymentJson = @"{""metadata"":""" + metadataJson + @"""}"; // When: We deserialize the JSON var payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.Equal(metadataJson, payments.Metadata); }
public void CanDeserializeNullMetadataValue() { // Given: A JSON metadata value var jsonConverterService = new JsonConverterService(); var metadataJson = @"null"; var paymentJson = @"{""metadata"":" + metadataJson + "}"; // When: We deserialize the JSON var payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.Null(payments.Metadata); }
public ActionResult VerifySecurityAnswers() { // Read Json from POST body. var json = ParseHttpService.ReadHttpPostBody(Request); // Deserialize the Json String var securityQuestions = JsonConverterService.DeserializeObject <AccountQuestionsDTO>(json); // Proccess any other information. // Verify User's answers. // Redirect User to Account reset password page?? // Return successful response return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ActionResult Index() { // Read Json from POST body. var json = ParseHttpService.ReadHttpPostBody(Request); // Deserialize the Json String var credentials = JsonConverterService.DeserializeObject <AccountCredentialsDTO>(json); // Proccess any other information. // Check app DB for user. // Issue login information // Return successful response return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public void CanDeserializeJsonMetadata() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); string metadataJson = @"{ ""ReferenceNumber"": null, ""OrderID"": null, ""UserID"": ""534721"" }"; string paymentJson = @"{""metadata"":" + metadataJson + "}"; // When: We deserialize the JSON PaymentResponse payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.AreEqual(metadataJson, payments.Metadata); }
public void Serialize_JsonData_IsSerialized() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", RedirectUrl = "http://www.mollie.com", Metadata = "{\"firstName\":\"John\",\"lastName\":\"Doe\"}", }; string expectedJsonValue = "{\"amount\":{\"currency\":\"EUR\",\"value\":\"100.00\"},\"description\":\"Description\",\"redirectUrl\":\"http://www.mollie.com\",\"metadata\":{\"firstName\":\"John\",\"lastName\":\"Doe\"}}"; // When: We serialize the JSON string jsonValue = jsonConverterService.Serialize(paymentRequest); // Then: Assert.AreEqual(expectedJsonValue, jsonValue); }
public ActionResult ChangePassword() { // Read Json from POST body. var json = ParseHttpService.ReadHttpPostBody(Request); // Deserialize the Json String var credentials = JsonConverterService.DeserializeObject <AccountCredentialsDTO>(json); // Proccess any other information. // Submit new password to app DB. // After you finish the resetpassword action, we need to send the finished information to the SSO. PostNewPasswordToSSO(credentials); // Redirect User to Account reset password page?? // Return successful response return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ActionResult Search(string keyword) { if (!User.Identity.IsAuthenticated) { throw new UnauthorizedAccessException(); } if (string.IsNullOrWhiteSpace(keyword)) { return(PartialView("_Movie", new List <Movie>())); } ApiService apiService = new ApiService(); string result = apiService.CallApi(keyword); var jsonConverterService = new JsonConverterService(); var list = jsonConverterService.ConvertToMovieList(result); return(PartialView("_Movie", list)); }
private void StartButton_Click(object sender, RoutedEventArgs e) { int selId = (int)InstalledVersionsCB.SelectedValue; config.LastSelectedVersion = selId; var selectedVersion = versionService.InstalledVersions.FirstOrDefault(x => x.VersionId == selId); Process.Start(selectedVersion.InstallPath); if (config.OnGodotLaunch == Constants.CLOSE_ON_LAUNCH) { Close(); } else if (config.OnGodotLaunch == Constants.MINIMIZE_ON_LAUNCH) { WindowState = WindowState.Minimized; } JsonConverterService <ApplicationConfig> .Serialize(config, "config\\config.json"); }
public ActionResult SubmitUsername() { // Read Json from POST body. var json = ParseHttpService.ReadHttpPostBody(Request); // Deserialize the Json String var credentials = JsonConverterService.DeserializeObject <AccountCredentialsDTO>(json); // Proccess any other information. // Check DB for username // Send User's security questions. using (HttpClientService client = HttpClientService.Instance) { // send to client. } // Return successful response return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
private void ApplyButton_Click(object sender, RoutedEventArgs e) { config.GodotInstallLocation = GodotInstallLocationTextbox.Text; config.OnGodotLaunch = (int)OnGodotLaunchComboBox.SelectedValue; bool proxy = UseProxyCheckBox.IsChecked.Value; if (proxy) { if (ProxyPortTextBox.Text == String.Empty || ProxyUrlTextBox.Text == String.Empty) { CommonUtilsService.PopupWarningMessage("Invalid values", "Please input both an URL and a port number for the proxy."); return; } if (Uri.TryCreate(ProxyUrlTextBox.Text, UriKind.Absolute, out Uri uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps)) { config.ProxyUrl = ProxyUrlTextBox.Text; } else { CommonUtilsService.PopupWarningMessage("Invalid values", "Please input a valid URL for the proxy."); return; } if (Int32.TryParse(ProxyPortTextBox.Text, out int portNum)) { config.ProxyPort = portNum; } else { CommonUtilsService.PopupWarningMessage("Invalid values", "Please input a valid port for the proxy."); return; } } config.UseProxy = proxy; JsonConverterService <ApplicationConfig> .Serialize(config, "config\\config.json"); Close(); }
private void DownloadAndExtractVersion(GodotVersion selectedVersion) { string fileName; try { fileName = config.UseProxy ? DownloadManagerService.DownloadFileSyncWithProxy(selectedVersion.VersionUrl, "temp", config.ProxyUrl, config.ProxyPort, true) : DownloadManagerService.DownloadFileSync(selectedVersion.VersionUrl, "temp", true); } catch (Exception ex) { throw ex; } var extractedFiles = ZipService.UnzipFile(fileName, $"{config.GodotInstallLocation}\\{selectedVersion.VersionName}"); File.Delete(fileName); foreach (var file in extractedFiles) { versionService.InstalledVersions.Add(new GodotVersionInstalled { VersionId = selectedVersion.VersionId, VersionName = selectedVersion.VersionName, BitNum = selectedVersion.BitNum, IsMono = selectedVersion.IsMono, IsStable = selectedVersion.IsStable, InstallPath = file.Replace(@"/", @"\\"), }); } JsonConverterService <List <GodotVersionInstalled> > .Serialize(versionService.InstalledVersions, $"{config.GodotInstallLocation}\\manifest.json"); Dispatcher.Invoke(new Action(() => BuildVersionsTree())); Dispatcher.Invoke(new Action(() => CommonUtilsService.PopupInfoMessage("Info", "Godot version installed successfully!"))); }
private void UninstallButton_Click(object sender, RoutedEventArgs e) { var temp = (KeyValuePair <int, string>)GodotVersionsTree.SelectedItem; var selectedVersion = versionService.AllVersions.FirstOrDefault(x => x.VersionId == temp.Key); var installedVersion = versionService.InstalledVersions.FirstOrDefault(x => x.VersionId == selectedVersion.VersionId); if (File.Exists(installedVersion.InstallPath)) { File.Delete(installedVersion.InstallPath); } string parentDir; if (installedVersion.IsMono) { string monoDirectory = Path.GetDirectoryName(installedVersion.InstallPath); parentDir = Path.GetDirectoryName(monoDirectory); Directory.Delete(monoDirectory, true); } else { parentDir = Path.GetDirectoryName(installedVersion.InstallPath); } if (CommonUtilsService.IsDirectoryEmpty(parentDir)) { Directory.Delete(parentDir, true); } versionService.InstalledVersions.Remove(installedVersion); JsonConverterService <List <GodotVersionInstalled> > .Serialize(versionService.InstalledVersions, $"{config.GodotInstallLocation}\\manifest.json"); BuildVersionsTree(); CommonUtilsService.PopupInfoMessage("Info", "Godot version uninstalled successfully!"); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { JsonConverterService <ApplicationConfig> .Serialize(config, "config\\config.json"); }
public void ConvertDTOToJson() { SSOAccountRegistrationDTO sSOAccountDTO = new SSOAccountRegistrationDTO(); var x = JsonConverterService.SerializeObject(sSOAccountDTO); }
protected BaseMollieClient(HttpClient httpClient = null, string apiEndpoint = ApiEndPoint) { this._apiEndpoint = apiEndpoint; this._jsonConverterService = new JsonConverterService(); this._httpClient = httpClient ?? new HttpClient(); }
public ActionResult RegisterUser() { // Read Json from POST body. var json = ParseHttpService.ReadHttpPostBody(Request); // Deserialize the Json String var userAccount = JsonConverterService.DeserializeObject <AccountRegistrationDTO>(json); // Proccess any other information. //if (ModelState.IsValid) //{ // // Check SSO DB for User. // //PostRegistrationToSSO(userAccount.Username); // // If successful, save user to app DB. If not successful, reject registration. // using (ECSContext context = new ECSContext()) // { // context.Accounts.Add(new Account // { // UserName = userAccount.Username, // Password = HashService.HashPasswordWithSalt(userAccount.Password, HashService.CreateSaltKey()), //ConfirmPassword = userAccount.ConfirmPassword // SecurityAnswers = new ICollection<SecurityQuestionAccount> // { // new SecurityQuestionAccount // { // Answer = userAccount.SecurityAnswers.ElementAt(0), // SecurityQuestion = userAccount.SecurityQuestions.ElementAt(0) // }, // new SecurityQuestionAccount // { // Answer = userAccount.SecurityAnswers.ElementAt(1), // SecurityQuestion = userAccount.SecurityQuestions.ElementAt(1) // }, // new SecurityQuestionAccount // { // Answer = userAccount.SecurityAnswers.ElementAt(2), // SecurityQuestion = userAccount.SecurityQuestions.ElementAt(2) // } // } // }); // context.Users.Add(new User // { // Email = userAccount.Email, // FirstName = userAccount.FirstName, // LastName = userAccount.LastName, // Address = userAccount.Address // }); // context.ZipLocations.Add(new ZipLocation // { // ZipCode = userAccount.ZipCode, // City = userAccount.City, // State = userAccount.State // }); // } // context.SaveChanges(); // // return RedirectToAction(); //} // Return successful response // return View(userAccount); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }