Exemplo n.º 1
0
        public void endTutorial()
        {
            // post del tour
            if (countStep == 0)
            {
                new PopupNotification("Error", "Debe agregar al menos un paso.");
            }
            else
            {
                loadingForm = new LoadingForm();
                loadingForm.Show();

                var tourController = new TourController();

                tour.user_id = Constants.user._id;
                var tourResponse = tourController.PostAsync(tour).Result;

                // post de los audios
                var allAudioResponse = true;
                for (int i = 0; i < countStep; i++)
                {
                    var nameTourWithoutSpace = tour.name.Replace(" ", "");
                    var audioName            = "/Audio" + nameTourWithoutSpace + i + ".wav";
                    var filename             = Constants.audioPath + audioName;
                    if (File.Exists(filename))
                    {
                        allAudioResponse = allAudioResponse && tourController.PostAudio(filename, tourResponse._id, tourResponse.steps[i]._id).Result;
                    }
                }

                loadingForm.Close();

                webBrowser.Refresh();

                if (tourResponse._id != null && allAudioResponse)
                {
                    new PopupNotification("Fin del tutorial", "Tutorial Terminado! Se guardaron " + countStep.ToString() + " pasos");
                }
                else
                {
                    new PopupNotification("Error", "Un error ha ocurrido tratando de conectar al servidor.");
                }

                formBar.Hide();
                stepsBar.Hide();
                tourBar.Hide();
                if (!(textPopup == null))
                {
                    textPopup.Hide();
                }

                Constants.tours = tourController.GetAllToursAsync().Result;
                asistimeAppBar.Show();
            }
        }
        async private void DeleteTour(object sender, EventArgs e)
        {
            DialogResult result1 = MessageBox.Show(Constants.DeleteTourConfirmation1
                                                   + tourAsociado.name + Constants.DeleteTourConfirmation2,
                                                   Constants.DeleteTourTitle,
                                                   MessageBoxButtons.YesNo);

            if (result1 == DialogResult.Yes)
            {
                var tourController = new TourController();
                var result         = await tourController.DeleteTourAsync(this.tourAsociado._id);

                Constants.tours = tourController.GetAllToursAsync().Result;
                this.Hide();
                MenuForm2 parent = this.Parent as MenuForm2;
                parent.ArrangeCardGrid();
            }
        }
Exemplo n.º 3
0
        public static void DoWork()
        {
            while (true)
            {
                Thread.Sleep(30000);

                var notificationController = new NotificationController();
                var notificacion           = notificationController.GetNotification().Result;
                if (notificacion.Count > 0)
                {
                    var userController = new UserController();
                    var tourController = new TourController();

                    Constants.user  = userController.GetUser().Result;
                    Constants.tours = tourController.GetAllToursAsync().Result;

                    Program.asistimeLogin.Invoke((MethodInvoker) delegate()
                    {
                        new PopupNotification("Nuevo tour", "Te asignaron un tour");
                    });
                }
            }
        }
Exemplo n.º 4
0
        protected void LogUser(object sender, EventArgs e)
        {
            if (userTextBox.TextName != string.Empty)
            {
                if (passwrdTextBox.TextName != string.Empty)
                {
                    var userController = new UserController();
                    var user           = new User();
                    user.email    = userTextBox.TextName;
                    user.password = passwrdTextBox.TextName;

                    loadingForm = new LoadingForm();
                    loadingForm.Show();

                    var token = userController.LoginAsync(user).Result;

                    if (token != null)
                    {
                        Constants.token = token.access_token;
                        Constants.user  = new User();
                        Constants.user  = token.user;

                        // Obtengo los tours

                        var tourController = new TourController();
                        Constants.tours = tourController.GetAllToursAsync().Result;

                        loadingForm.Close();

                        new PopupNotification("App Asistime!", "Bienvenido " + token.user.name);

                        if (token.user.rol == "Adulto")
                        {
                            ////Active notifications of new tours
                            Thread threadNewTour = new Thread(NewTourThread.DoWork);
                            threadNewTour.IsBackground = true;
                            threadNewTour.Start();

                            NavigatorAdult mod = new NavigatorAdult();
                            mod.Show();
                            this.WindowState   = FormWindowState.Minimized;
                            this.ShowInTaskbar = false;
                        }
                        else if (token.user.rol == "Responsable")
                        {
                            ////Active notifications
                            Thread threadNotification = new Thread(NotificationThread.DoWork);
                            threadNotification.IsBackground = true;
                            threadNotification.Start();

                            NavigatorAssistant mod = new NavigatorAssistant();
                            mod.Show();
                            this.WindowState   = FormWindowState.Minimized;
                            this.ShowInTaskbar = false;
                        }
                    }
                    else
                    {
                        loadingForm.Close();
                        new PopupNotification("Error Login", "Usuario o contraseña incorrecta.");
                        userTextBox.TextName    = "";
                        passwrdTextBox.TextName = "";
                    }
                }
            }
            else
            {
                new PopupNotification("Error Login", "Todos los campos deben tenes un valor.");
            }
        }