示例#1
0
        public clsListadoObra getObjObra(Object varjson)
        {
            JObject        json  = (JObject)varjson;
            clsListadoObra objob = new clsListadoObra
            {
                idobra            = Int32.Parse(json["idobra"].ToString()),
                nombre            = json["nombre"].ToString(),
                porcentajeavance  = Double.Parse(json["porcentaje"].ToString()),
                noclasificacioens = Int32.Parse(json["noclasificaciones"].ToString())
            };

            return(objob);
        }
示例#2
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            int indicearreglo = indexPath.Row;

            UITableViewCell cell;
            clsListadoObra  objobra = lstObras.ElementAt(indicearreglo);


            if (indicearreglo % 2 == 0)
            {
                string idcell = celdaObrasBlack + objobra.idobra.ToString() + objobra.porcentajeavance.ToString();
                cell = tableView.DequeueReusableCell(idcell) as CustomListadoObrasCellBlack;

                if (cell == null)
                {
                    cell = new CustomListadoObrasCellBlack((NSString)idcell, objobra.porcentajeavance);
                }
            }
            else
            {
                string idcell = celdaObrasWhite + objobra.idobra.ToString() + objobra.porcentajeavance.ToString();
                cell = tableView.DequeueReusableCell(idcell) as CustomListadoObrasCellWhite;

                if (cell == null)
                {
                    cell = new CustomListadoObrasCellWhite((NSString)idcell, objobra.porcentajeavance);
                }
            }



            String strClasificaciones = objobra.noclasificacioens + " Clasificaciones";

            ((CustomListadoObrasCell)cell).UpdateCell(objobra.nombre, strClasificaciones);
            cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;

            return(cell);
        }
示例#3
0
        public async Task <Boolean> buscaObras()
        {
            var bounds = UIScreen.MainScreen.Bounds;

            loadPop = new LoadingOverlay(bounds, "Buscando obras...");
            View.Add(loadPop);
            client         = new HttpClient();
            client.Timeout = new System.TimeSpan(0, 0, 0, 10, 0);
            string url = Consts.ulrserv + "controldeobras/BuscaObras";
            var    uri = new Uri(string.Format(url));

            Dictionary <string, string> pet = new Dictionary <string, string>();

            pet.Add("strBusqueda", txtBusquedaObra.Text);
            var json = JsonConvert.SerializeObject(pet);

            string responseString = string.Empty;

            responseString = await funciones.llamadaRest(client, uri, loadPop, json, Consts.token);


            if (responseString.Equals("-1") || responseString.Equals("-2"))
            {
                funciones.SalirSesion(this);
            }

            JArray jrarray;

            try
            {
                var objectjson = JObject.Parse(responseString);

                var result = objectjson["result"];
                if (result != null)
                {
                    loadPop.Hide();
                    if (result.ToString().Equals("0"))
                    {
                        funciones.MessageBox("Aviso", "No existen obras actualmente");
                    }
                    else
                    {
                        funciones.MessageBox("Error", objectjson["error"].ToString());
                    }
                    return(false);
                }

                jrarray = JArray.Parse(objectjson["obras"].ToString());
            }
            catch (Exception e)
            {
                loadPop.Hide();
                var    jsonresponse = JObject.Parse(responseString);
                string mensaje      = "al transformar el arreglo" + e.HResult;
                var    jtokenerror  = jsonresponse["error"];
                if (jtokenerror != null)
                {
                    mensaje = jtokenerror.ToString();
                }
                funciones.MessageBox("Error", mensaje);
                return(false);
            }

            foreach (var obra in jrarray)
            {
                clsListadoObra objob = getObjObra(obra);
                lstObras.Add(objob);
            }
            return(true);
        }