Esempio n. 1
0
        private void btnGetCameraDTcv_Click(object sender, EventArgs e)
        {
            Log("Contacting camera...");
            WebRequest r  = WebRequest.Create("http://192.168.1.101/api/2/datetime");
            Stream     rp = r.GetResponse().GetResponseStream();

            Log("Response recieved.");
            StreamReader read     = new StreamReader(rp);
            string       response = read.ReadToEnd();

            Log("Response: " + response);
            TTDateTime dt = JsonConvert.DeserializeObject <TTDateTime>(response);

            Log("The date and time received from the camera was: " + dt.datetime.ToString());
        }
Esempio n. 2
0
        private void btnSetCameraDT_Click(object sender, EventArgs e)
        {
            string currentDT = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
            var    request   = (HttpWebRequest)WebRequest.Create("http://192.168.1.101/api/2/datetime");

            request.ContentType = "application/json";
            request.Method      = "POST";
            TTDateTime dt   = new TTDateTime();
            string     json = JsonConvert.SerializeObject(dt);

            json = currentDT;
            var streamWriter = new StreamWriter(request.GetRequestStream());

            streamWriter.Write(json);
            streamWriter.Flush();
            streamWriter.Close();
            var response = (HttpWebResponse)request.GetResponse();
            var sr       = new StreamReader(response.GetResponseStream());
            var result   = sr.ReadToEnd();
        }