Sign in to follow this  
magdykhfee

send request

Recommended Posts

 I Want to send some data to my domain 

i successfully make it C# , i want to make same in DAQFactroy 

how I can make it 

C# code:

public partial class Form3 : Form
    {
        string send_request(int id, int nmore, int nless, double wmore, double wless, double diffm, double diffl)
        {

            string html = string.Empty;
            string url = @"http://mydomain.com/data/add_data.php?bid=";
            url += id;
            url += "&nmore=" + nmore;
            url += "&nless=" + nless;
            url += "&wmore=" + wmore;
            url += "&wless=" + wless;
            url += "&diffm=" + diffm;
            url += "&diffl=" + diffl;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.AutomaticDecompression = DecompressionMethods.GZip;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            using (Stream stream = response.GetResponseStream())
            using (StreamReader reader = new StreamReader(stream))
            {
                html = reader.ReadToEnd();
            }

            return html;
        }
        public Form3()
        {
            InitializeComponent();
        }

        

        private void button1_Click_1(object sender, EventArgs e)

        {
            
            label1.Text = send_request(1, int.Parse(TWEIGHTNO_M.Text), int.Parse(TWEIGHTNO_L.Text), double.Parse(TWEIGHT_M.Text), double.Parse(TWEIGHT_L.Text), double.Parse(DIFFWEIGHT_M.Text), double.Parse(DIFFWEIGHT_L.Text));

        }

 

how i can write same code in Daqfactory 

 

 

 

 

Share this post


Link to post
Share on other sites

Create a sequence function called send_request:

function  send_request(id, nmore,  nless, wmore,  wless, diffm, diffl)
            private string html
            private string url = "http://mydomain.com/data/add_data.php?bid="
            url += id
            url += "&nmore=" + nmore
            url += "&nless=" + nless
            url += "&wmore=" + wmore
            url += "&wless=" + wless
            url += "&diffm=" + diffm
 

function  send_request(id, nmore,  nless, wmore,  wless, diffm, diffl)
  private string html
  private string url = "http://mydomain.com/data/add_data.php?bid="
  url += id
  url += "&nmore=" + nmore
  url += "&nless=" + nless
  url += "&wmore=" + wmore
  url += "&wless=" + wless
  url += "&diffm=" + diffm
  url += "&diffl=" + diffl
  http.get(url)
  return(http)

Something like that.  You might want to add error handling (try/catch) around the http.get().  Note that DAQFactory does not support gZip compression on web pages with http.get() so you'll have to tell your server to not compress.  Of course if you are only posting data, you probably don't care what the response is so can just ignore it.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this