public void createJLDJson(JsonLoginData jld) { JObject loginData = new JObject( new JProperty("server", jld.getServer()), new JProperty("database", jld.getDB()), new JProperty("user", jld.getUID()), new JProperty("password", jld.getPass())); File.WriteAllText("jdl.json", loginData.ToString()); using (StreamWriter file = File.CreateText(path)) using (JsonTextWriter writer = new JsonTextWriter(file)) { loginData.WriteTo(writer); } }
private void storeCredentials() { if (hlr.readJLDFromJson().Property("server").Value.ToString() == "") { JsonLoginData jld = new JsonLoginData(tbServer.Text, tbDB.Text, tbUser.Text, tbPassword.Text); hlr.writeToJson(jld); } else if (tbServer.Text == hlr.readJLDFromJson().Property("server").Value.ToString()) { MessageBox.Show("Login Credentials Updated"); JsonLoginData jld = new JsonLoginData(hlr.readJLDFromJson().Property("server").Value.ToString(), tbDB.Text, tbUser.Text, tbPassword.Text); hlr.writeToJson(jld); JObject jo = hlr.readJLDFromJson(); hlr.setCredentials(jo); } Form1 form = new Form1(); form.Show(); this.Hide(); }
public void writeToJson(JsonLoginData jld) { FileHandler fh = new FileHandler(); fh.createJLDJson(jld); }