예제 #1
0
        /*public static async Task<HttpResponseMessage> Listar( user)
         * {
         *  HttpClient httpClient = new HttpClient();
         *  var uri = new UrlMain();
         *  string url = string.Concat(uri.UrlM, "usuario/autenticar");
         *  //  string url = string.Concat(uri.UrlM, "usuario");
         *
         *  String js = JsonConvert.SerializeObject(user);
         *
         *  HttpContent httpContent = new StringContent(js);
         *  httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
         *
         *  var response = await httpClient.PostAsync(url, httpContent).ConfigureAwait(false);
         *
         *  return response;
         * }
         */

        public static async Task <HttpResponseMessage> SaveSwatch(SwatchModel obj)
        {
            HttpClient httpClient = new HttpClient();
            var        uri        = new UrlMain();
            string     url        = string.Concat(uri.UrlM, "Swatches/");

            String js = JsonConvert.SerializeObject(obj);

            HttpContent httpContent = new StringContent(js);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response = await httpClient.PostAsync(url, httpContent).ConfigureAwait(false);

            return(response);
        }
예제 #2
0
        private async void BtbguardarSwatch_Click(object sender, EventArgs e)
        {
            var progress = new ProgressDialog(this)
            {
                Indeterminate = true
            };

            progress.SetProgressStyle(ProgressDialogStyle.Spinner);
            progress.SetMessage("Loading... Please wait...");
            progress.SetCancelable(false);

            try
            {
                if (Validartxt(txtx1) && Validartxt(txtx2) && Validartxt(txtx3) &&
                    Validartxt(txty1) && Validartxt(txty2) && Validartxt(txty2) &&
                    ValidarDiagonaltxt(txtp1) && ValidarDiagonaltxt(txtp2) && idrollo != 0)
                {
                    var culture = new CultureInfo("en-US");

                    var obj = new SwatchModel()
                    {
                        Idrollo = idrollo,
                        X1      = Double.Parse(txtx1.Text, culture.NumberFormat),
                        X2      = Double.Parse(txtx2.Text, culture.NumberFormat),
                        X3      = Double.Parse(txtx3.Text, culture.NumberFormat),
                        Y1      = Double.Parse(txty1.Text, culture.NumberFormat),
                        Y2      = Double.Parse(txty2.Text, culture.NumberFormat),
                        Y3      = Double.Parse(txty3.Text, culture.NumberFormat),
                        P1      = Double.Parse(txtp1.Text, culture.NumberFormat),
                        P2      = Double.Parse(txtp2.Text, culture.NumberFormat),
                        Usuario = "MOD5",
                        Fecha   = DateTimeOffset.Now
                    };

                    var conection = new ConnectivityService();

                    if (conection.IsConnected)
                    {
                        progress.Show();
                        var resp = await Task.Run(() => { return(SwatchServ.SaveSwatch(obj).Result); });

                        if (resp.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            Listarollos.RemoveAt(Listarollos.FindIndex(x => x.Idrollo == idrollo));
                            txtsecuenciaRollo.Text = string.Empty;
                            lblnombrerollo.Text    = "";
                            Toast.MakeText(this, "Ingreso Correcto", ToastLength.Long).Show();
                            idrollo = 0;
                            Limpiartext();
                            Enabled(false);

                            var countItem = Listarollos.Count;
                            lbltotalrollos.Text = string.Concat("Total de rollos por medir: ", countItem.ToString());
                            progress.Dismiss();
                            txtsecuenciaRollo.RequestFocus();
                        }
                    }
                    else
                    {
                        progress.Dismiss();
                        Alerta("Advertencia?", "Verifique su conexion a la red wifi");
                    }
                }
                else
                {
                    progress.Dismiss();
                    Toast.MakeText(this, "llenar correctamente", ToastLength.Long).Show();
                }
            }
            catch (Exception ex)
            {
                progress.Dismiss();
                Alerta("Advertencia?", ex.Message);
            }
        }