Пример #1
0
        private void cmdGO_Click(object sender, EventArgs e)
        {
            string strJSON = string.Empty;

            if (!CBMirConnection.Checked)
            {
                RESTClient rClient = new RESTClient();
                rClient.endPoint = txtRequestURI.Text;
                debugOutput("RESTClient Object created.");

                strJSON = rClient.makeRequest();
            }
            else
            {
                RESTClient rClient = new RESTClient();

                rClient.endPoint = "http://www.mir.com/api/v2.0.0/registers/1";

                debugOutput("RESTClient Object created.");
                int iA, iB;
                if (int.TryParse(tbID.Text, out iA) && int.TryParse(tbValue.Text, out iB))
                {
                    strJSON = rClient.makeRequestMir(iB);
                }
                else
                {
                    // Initializes the variables to pass to the MessageBox.Show method.
                    string            message = "Please insert both Numbers";
                    string            caption = "Error";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    DialogResult      result;

                    // Displays the MessageBox.
                    result = MessageBox.Show(message, caption, buttons);
                    //if (result == System.Windows.Forms.DialogResult.Yes)
                    //{
                    //    // Closes the parent form.
                    //    this.Close();
                    //}
                }
            }


            debugOutput(strJSON);
        }
Пример #2
0
        private void OnNotification(object sender, AdsNotificationEventArgs e)
        {
            int    f = 0;
            string sID;

            if (e.NotificationHandle == hConnect[0])
            {
                f = binRead.ReadInt32();
            }

            RESTClient rClient = new RESTClient();

            sID = "http://www.mir.com/api/v2.0.0/registers/xx";
            sID = sID.Replace("xx", m_sVariableNumber);
            rClient.endPoint = sID;

            rClient.makeRequestMir(f);
        }