private static string GetApiURL(string method) { JsonFileCrud jsonFile = new JsonFileCrud(); string baseUrl = jsonFile.ReadJson("resource").GetValue("baseUrl").ToString(); string path = jsonFile.ReadJson("resource").GetValue(method).ToString(); return(baseUrl + path); }
private async void BtnGenerateToken_Click(object sender, EventArgs e) { string username = jsonFile.ReadJson("login").GetValue("username").ToString(); string password = jsonFile.ReadJson("login").GetValue("password").ToString(); PaymentResponse resp = await PostTokenAsync(username, password); var jsonObj = JObject.Parse(resp.data.ToString()); var token = jsonObj.GetValue("access_token").ToString(); txtToken.Text = token; //MessageBox.Show(resp.data.ToString()); }
private void Form1_Load(object sender, EventArgs e) { try { txtTrxNo.Text = Guid.NewGuid().ToString(); jsonFile = new JsonFileCrud(); txtPosId.Text = jsonFile.ReadJson("client").GetValue("deviceId").ToString();; string BrokerAddress = "mqtt.eclipse.org"; client = new MqttClient(BrokerAddress); // use a unique id as client id, each time we start the application clientId = Guid.NewGuid().ToString(); client.Connect(clientId); if (client.IsConnected) { listBox1.Items.Add("Client Connected"); client.MqttMsgPublishReceived += new MqttClient.MqttMsgPublishEventHandler(EventPublished); //subcribe("/Pairing/" + txtPosId.Text); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Form2_Load(object sender, EventArgs e) { jsonFile = new JsonFileCrud(); string deviceId = jsonFile.ReadJson("client").GetValue("deviceId").ToString(); string deviceDesc = jsonFile.ReadJson("client").GetValue("description").ToString(); string username = jsonFile.ReadJson("login").GetValue("username").ToString(); string password = jsonFile.ReadJson("login").GetValue("password").ToString(); string baseUrl = jsonFile.ReadJson("resource").GetValue("baseUrl").ToString(); string mqttHost = jsonFile.ReadJson("mqtt").GetValue("host").ToString(); string mqttPort = jsonFile.ReadJson("mqtt").GetValue("port").ToString(); txtUserName.Text = username; txtPassword.Text = password; txtPassword.PasswordChar = '*'; txtDeviceId.Text = deviceId; txtDeviceDescription.Text = deviceDesc; txtBaseUrl.Text = baseUrl; txtMqttHost.Text = mqttHost + ":" + mqttPort; }