コード例 #1
0
ファイル: TasksService.cs プロジェクト: saedaes/gestion2013
        internal static TasksService FromJObject(JObject jObject)
        {
            TasksService task = new TasksService();

            task.Descripcion          = jObject["Descripcion"].ToString();
            task.Encargado            = jObject["Encargado"].ToString();
            task.Titulo               = jObject["Titulo"].ToString();
            task.coloniaSolicitante   = jObject["coloniaSolicitante"].ToString();
            task.correoSolicitante    = jObject["correoSolicitante"].ToString();
            task.direccionSolicitante = jObject["direccionSolicitante"].ToString();
            task.fechaAlta            = jObject["fechaAlta"].ToString();
            task.fechaAsignacion      = jObject["fechaAsignacion"].ToString();
            task.fechaCompromiso      = jObject["fechaCompromiso"].ToString();
            task.fechaContacto        = jObject["fechaContacto"].ToString();
            task.fechaEdicion         = jObject["fechaEdicion"].ToString();
            task.fechaTermino         = jObject["fechaTermino"].ToString();
            //task.finalizado = jObject["finalizado"].ToString();
            task.idCategoria           = jObject["idCategoria"].ToString();
            task.idPrioridad           = jObject["idPrioridad"].ToString();
            task.idEstatus             = jObject["idEstatus"].ToString();
            task.idResponsable         = jObject["idResponsable"].ToString();
            task.seccion               = jObject["seccion"].ToString();
            task.CveElector            = jObject["CveElector"].ToString();
            task.idTarea               = jObject["idTarea"].ToString();
            task.nombreSolicitante     = jObject["nombreSolicitante"].ToString();
            task.idSolicitante         = jObject["idSolicitante"].ToString();
            task.telCasaSolicitante    = jObject["telCasaSolicitante"].ToString();
            task.telCelularSolicitante = jObject["telCelularSolicitante"].ToString();
            task.usuarioAlta           = jObject["usuarioAlta"].ToString();
            //task.usuarioEdicion = jObject["usuarioEdicion"].ToString();

            return(task);
        }
コード例 #2
0
ファイル: TasksService.cs プロジェクト: saedaes/gestion2013
        public List <TasksService> GetTasks()
        {
            WebClient           client    = new WebClient();
            Stream              stream    = client.OpenRead(TasksURL);
            StreamReader        reader    = new StreamReader(stream);
            JArray              tasksJSON = JArray.Parse(reader.ReadLine());
            List <TasksService> tasks     = new List <TasksService>();

            foreach (JObject jobject in tasksJSON)
            {
                TasksService task = TasksService.FromJObject(jobject);

                tasks.Add(task);
            }

            return(tasks);
        }
コード例 #3
0
ファイル: TasksView.cs プロジェクト: saedaes/gestion2013
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Console.WriteLine(MainView.user);
            this.lblUsuario.Text = MainView.user;
            ts = new TasksService();
            ts.setUser(MainView.user);

            //Escondemos el boton de regreso hacia la pagina de inicio
            this.NavigationItem.HidesBackButton = true;

            //Creamos el boton de cerrar sesion
            UIBarButtonItem cerrarSesion = new UIBarButtonItem();

            cerrarSesion.Style    = UIBarButtonItemStyle.Plain;
            cerrarSesion.Target   = this;
            cerrarSesion.Title    = "Cerrar Sesión";
            cerrarSesion.Clicked += (sender, e) => {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "¿Salir?", Message = "¿Quieres cerrar la sesión?"
                };
                alert.AddButton("Aceptar");
                alert.AddButton("Cancelar");
                alert.Clicked += (s, o) => {
                    if (o.ButtonIndex == 0)
                    {
                        //lg = new LogoutService();
                        //lg.Logout();
                        NavigationController.PopViewControllerAnimated(true);
                    }
                };
                alert.Show();
            };

            //posionamiento del boton
            this.NavigationItem.LeftBarButtonItem = cerrarSesion;

            try{
                List <TasksService> tableItems = ts.All();
                this.tblTasks.Source       = new TasksTableSource(tableItems, this);
                headerView.BackgroundColor = UIColor.Clear;
                tblTasks.TableHeaderView   = headerView;
                Add(tblTasks);
            }catch (System.Net.WebException) {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "ERROR", Message = "No se pudo conectar al servidor, verifique su conexión a internet"
                };
                alert.AddButton("Aceptar");
                alert.Show();
            }

            //Boton de nueva tarea
            btnNuevo.TouchUpInside += (sender, e) => {
                newTaskView = new NewTaskView();
                this.NavigationController.PushViewController(newTaskView, true);
            };

            //Boton de mapa
            btnMap.TouchUpInside += (sender, e) => {
                mapView = new MapViewController();
                this.NavigationController.PushViewController(mapView, true);
            };

            //Boton refrescar
            btnRefresh.TouchUpInside += (sender, e) => {
                try{
                    ts.setUser(MainView.user);
                    List <TasksService> tableItems = ts.All();
                    this.tblTasks.Source = new TasksTableSource(tableItems, this);
                    this.tblTasks.ReloadData();
                }catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pudo conectar al servidor, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            // creacion de la barra de herramientas
            float toolbarHeight = 50;

            toolbar = new UIToolbar(new RectangleF(0
                                                   , this.View.Frame.Height - this.NavigationController.NavigationBar.Frame.Height
                                                   , this.View.Frame.Width, toolbarHeight));
            toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;
            toolbar.TintColor        = UIColor.FromRGB(62, 150, 15);


            // boton Todos
            UIBarButtonItem btnTodos = new UIBarButtonItem("   Todos   ", UIBarButtonItemStyle.Bordered, null);

            btnTodos.Clicked += (s, e) => {
                try{
                    ts.setUser(MainView.user);
                    List <TasksService> tableItems = ts.All();
                    this.tblTasks.Source = new TasksTableSource(tableItems, this);
                    this.tblTasks.ReloadData();
                }catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pudo conectar al servidor, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };
            // fixed width
            //UIBarButtonItem fixedWidth = new UIBarButtonItem (UIBarButtonSystemItem.FixedSpace);
            //fixedWidth.Width = 35;

            // flexible width space
            UIBarButtonItem flexibleWidth0 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);


            // boton Finalizados
            UIBarButtonItem btnFinalizados = new UIBarButtonItem("En Proceso", UIBarButtonItemStyle.Bordered, null);

            btnFinalizados.Clicked += (s, e) => {
                try{
                    String status = "1";
                    ts.setUserandStatus(MainView.user, status);
                    List <TasksService> tableItems = ts.All();
                    this.tblTasks.Source = new TasksTableSource(tableItems, this);
                    this.tblTasks.ReloadData();
                }catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pudo conectar al servidor, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };
            // fixed width
            //UIBarButtonItem fixedWidth = new UIBarButtonItem (UIBarButtonSystemItem.FixedSpace);
            //fixedWidth.Width = 35;

            // flexible width space
            UIBarButtonItem flexibleWidth1 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            // boton En proceso
            UIBarButtonItem btnProceso = new UIBarButtonItem("Finalizados", UIBarButtonItemStyle.Bordered, null);

            btnProceso.Clicked += (s, e) => {
                try{
                    String status = "2";
                    ts.setUserandStatus(MainView.user, status);
                    List <TasksService> tableItems = ts.All();
                    this.tblTasks.Source = new TasksTableSource(tableItems, this);
                    this.tblTasks.ReloadData();
                } catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pudo conectar al servidor, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            // arreglo de botones para toolbar
            UIBarButtonItem[] items = new UIBarButtonItem[] { btnTodos, flexibleWidth0,
                                                              btnFinalizados, flexibleWidth1, btnProceso };

            // agregar los botones a la toolbar
            toolbar.SetItems(items, false);

            // agregar la vista a la pantalla
            this.View.AddSubview(toolbar);
        }
コード例 #4
0
 public void setTask(TasksService task1)
 {
     this.task = task1;
 }