Beispiel #1
0
        private async void sendProduct()
        {
            DBConn_Product dbp         = new DBConn_Product();
            List <Product> productList = dbp.GetAllProduct();

            Uri     requestUri  = new Uri("http://" + ip + "/action_refreshProduct.php");
            dynamic dynamicJson = new ExpandoObject();

            dynamicJson.Product = productList;

            string json = "";

            json = "{\"PosId\":\"" + POS_main.PosId + "\"," + Newtonsoft.Json.JsonConvert.SerializeObject(dynamicJson).Substring(1);

            var objClint = new HttpClient();
            HttpResponseMessage respon = objClint.PostAsync(requestUri, new StringContent(json, System.Text.Encoding.UTF8, "application/json")).Result;

            String strRespon = await respon.Content.ReadAsStringAsync();

            if (!strRespon.Equals("1"))
            {
                MessageDialog messageDialog = new MessageDialog("상품들의 정보가 정상적으로 전송되지 않았습니다.");
                await messageDialog.ShowAsync();
            }
        }
Beispiel #2
0
        private void btn_Send_Click(object sender, RoutedEventArgs e)
        {
            DBConn_Product dbp         = new DBConn_Product();
            List <Product> productList = dbp.GetAllProduct();

            Uri     requestUri  = new Uri("http://localhost/actionTest.php");
            dynamic dynamicJson = new ExpandoObject();
            Random  r           = new Random();

            dynamicJson.product = productList;

            string json = "";

            json = Newtonsoft.Json.JsonConvert.SerializeObject(dynamicJson);
            var objClint = new HttpClient();
            //HttpResponseMessage respon = objClint.PostAsync(requestUri, new StringContent(json, System.Text.Encoding.UTF8, "application/json")).Result;
        }