Exemple #1
0
        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);
        }
Exemple #2
0
        private void BtnCheckDir_Click(object sender, EventArgs e)
        {
            string tmpPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\user.json";

            JsonFileCrud jsonFileCrud = new JsonFileCrud();
            //JObject json = jsonFileCrud.ReadUser();

            //string fileExtension = Path.GetExtension(tmpPath);
            //string filename = Path.GetFileName(tmpPath);
            //string filenameWithoutExtension = Path.GetFileNameWithoutExtension(tmpPath);
            //string rootPath = Path.GetPathRoot(tmpPath);
            //string directory = Path.GetDirectoryName(Application.ExecutablePath);
            //string fullPath = Path.GetFullPath(tmpPath);

            //MessageBox.Show(json.ToString());
        }
Exemple #3
0
        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;
        }
Exemple #4
0
 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());
     }
 }