Exemplo n.º 1
0
        public async Task obtenerFaseAsync(int faseActual)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://app-produ.herokuapp.com")
            };
            var newFase = new Fase
            {
                fase_type_id = faseActual,
                sampling_id  = (int)Application.Current.Properties["id-sampling"],
                token        = Application.Current.Properties["currentToken"].ToString()
            };
            string jsonData = JsonConvert.SerializeObject(newFase);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await client.PostAsync("/fases/getfase.json", content);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var jobject = JObject.Parse(result);
                    var data    = JsonConvert.DeserializeObject <List <Fase> >(jobject["fase"].ToString());
                    Application.Current.Properties["id-fase"] = data[0].id;
                }
            }
            catch (Exception)
            {
                //Error al realizar consulta al backend
            }
        }
Exemplo n.º 2
0
        //Método para actualizar la flag de si se realizó la pregunta
        public async Task ActualizarFlag(int newvalue)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://app-produ.herokuapp.com")
            };
            var newFase = new Fase
            {
                id        = currentFase.id,
                extraFlag = newvalue,
                token     = Application.Current.Properties["currentToken"].ToString()
            };
            string jsonData = JsonConvert.SerializeObject(newFase);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await client.PostAsync("/fases/updateflag.json", content);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var jobject = JObject.Parse(result);
                    var data    = JsonConvert.DeserializeObject <Fase>(jobject["fase"].ToString());
                    currentFase = data;
                }
            }
            catch (Exception)
            {
                //Error al realizar consulta al backend
            }
        }
        //Método que guarda la productividad (P) y la improductividad (Q) en el backend
        public async Task guardarProductividad()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://app-produ.herokuapp.com")
            };
            var newFase = new Fase
            {
                id           = (int)Application.Current.Properties["id-fase"],
                p            = pG,
                q            = qG,
                error        = 0,
                z            = 0,
                fase_type_id = 0,
                sampling_id  = 0,
                extraFlag    = 0,
                token        = Application.Current.Properties["currentToken"].ToString()
            };
            string jsonData = JsonConvert.SerializeObject(newFase);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await client.PostAsync("/fases/addpq.json", content);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();
                }
            }
            catch (Exception)
            {
                //Error al realizar consulta al backend
            }
        }
Exemplo n.º 4
0
        //Método que guarda el error y el z de alfa/2 elegido para los cálculos, tanto en la fase preliminar como en la nueva definitiva
        public async Task guardarErrorZ()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://app-produ.herokuapp.com")
            };
            var newFase = new Fase
            {
                id    = faseData.id,
                error = faseData.error,
                z     = faseData.z,
                token = Application.Current.Properties["currentToken"].ToString()
            };
            string jsonData = JsonConvert.SerializeObject(newFase);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            try
            {
                //Acá guarda el error y el Z de alfa/2 en la fase preliminar
                HttpResponseMessage response = await client.PostAsync("/fases/updateerrorz.json", content);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var jobject = JObject.Parse(result);
                    var data    = JsonConvert.DeserializeObject <Fase>(jobject["fase"].ToString());
                    try
                    {
                        newFase.id    = (int)Application.Current.Properties["id-fase"];
                        newFase.error = 0;
                        jsonData      = JsonConvert.SerializeObject(newFase);
                        content       = new StringContent(jsonData, Encoding.UTF8, "application/json");

                        //Acá guarda el error y el Z de alfa/2 en la fase definitiva
                        response = await client.PostAsync("/fases/updateerrorz.json", content);

                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            result = await response.Content.ReadAsStringAsync();
                        }
                    }
                    catch (Exception)
                    {
                        //Error al realizar consulta al backend
                    }
                }
            }
            catch (Exception)
            {
                //Error al realizar consulta al backend
            }
        }
        public Estadisticas(Fase pFase)
        {
            InitializeComponent();

            faseData = pFase;

            zValues.Add("1.65", "0,90");
            zValues.Add("1.96", "0,95");
            zValues.Add("2.245", "0,975");
            zValues.Add("2.575", "0,99");
            foreach (string type in zValues.Values)
            {
                zPicker.Items.Add(type);
            }
        }
Exemplo n.º 6
0
        Fase faseData = new Fase(); //Para recibir y manipular la fase actual y guardar los valores correspondientes(N, Z, error)

        //Constructor que recibe el N nuevo calculado, el n actual y la fase actual
        public CalculosHechos(int pN, Fase pFaseData, int pn)
        {
            InitializeComponent();

            N        = pN;
            n        = pn;
            faseData = pFaseData;

            //Despliega los datos en la pantalla
            NEntry.Text = N.ToString();
            nEntry.Text = n.ToString();
            if ((N - n) < 0)
            {
                nDefEntry.Text = (0).ToString();
            }
            else
            {
                nDefEntry.Text = (N - n).ToString();
            }
        }
Exemplo n.º 7
0
        //Método para crear la fase definitiva cuando se finalice la preliminar
        public async Task crearFaseDef()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://app-produ.herokuapp.com")
            };
            var newFase = new Fase
            {
                id           = currentFase.id,
                p            = currentFase.p,
                q            = currentFase.q,
                error        = currentFase.error,
                z            = currentFase.z,
                sampling_id  = currentFase.sampling_id,
                fase_type_id = 2,
                extraFlag    = 0,
                token        = Application.Current.Properties["currentToken"].ToString()
            };
            string jsonData = JsonConvert.SerializeObject(newFase);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await client.PostAsync("/fases/changefase.json", content);

                if (response.StatusCode == HttpStatusCode.Created)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var jobject = JObject.Parse(result);
                    var data    = JsonConvert.DeserializeObject <Fase>(jobject["fase"].ToString());
                    Application.Current.Properties["id-fase"] = data.id;
                }
            }
            catch (Exception)
            {
                //Error al realizar consulta al backend
            }
        }
Exemplo n.º 8
0
        public async Task crearFaseAsync()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://app-produ.herokuapp.com")
            };
            var newFase = new Fase
            {
                fase_type_id = 1,
                sampling_id  = (int)Application.Current.Properties["id-sampling"],
                extraFlag    = 0,
                token        = Application.Current.Properties["currentToken"].ToString()
            };
            string jsonData = JsonConvert.SerializeObject(newFase);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            HttpResponseMessage response = await client.PostAsync("/fases/newfase.json", content);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                var result = await response.Content.ReadAsStringAsync();

                var jobject = JObject.Parse(result);
                var data    = JsonConvert.DeserializeObject <Sampling>(jobject["fase"].ToString());


                try
                {
                    Application.Current.Properties["id-fase"]         = data.id;
                    Application.Current.Properties["preliminar-done"] = 0;
                    Application.Current.Properties["definitive-done"] = 0;
                }
                catch (Exception)
                {
                }
            }
        }