Esempio n. 1
0
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            try
            {
                //Console.WriteLine(sender);
                dtPlan  selectedPlan = Shift1Dgv.SelectedItem as dtPlan;
                dynamic postApiBody  = new JObject();
                postApiBody.timeWorkId      = 0;
                postApiBody.activeDate      = selectedPlan.activeDate;
                postApiBody.deviceId        = selectedPlan.deviceId;
                postApiBody.productId       = selectedPlan.productId;
                postApiBody.productDetailId = selectedPlan.productDetailId;
                postApiBody.updUsrId        = 1;
                postApiBody.palletAmount    = 1;
                string jsonData = JsonConvert.SerializeObject(postApiBody);
                //Console.WriteLine(jsonData);

                HttpWebRequest request =
                    (HttpWebRequest)WebRequest.Create(@"http://" +
                                                      Properties.Settings.Default.serverIp + ":" +
                                                      Properties.Settings.Default.serverPort +
                                                      @"/robot/rest/" + "plan/createPlanPallet");

                request.Method      = "POST";
                request.ContentType = "application/json";

                System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                Byte[] byteArray = encoding.GetBytes(jsonData);
                request.ContentLength = byteArray.Length;
                using (Stream dataStream = request.GetRequestStream())
                {
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    dataStream.Flush();
                }

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    int          result = 0;
                    int.TryParse(reader.ReadToEnd(), out result);
                    Console.WriteLine("PalletId=" + result);
                }
            }
            catch (Exception ex)
            {
                logFile.Error(ex.Message);
            }
        }
Esempio n. 2
0
 public dtTempPlan(dtPlan plan)
 {
     planId = plan.planId;
 }