예제 #1
0
        protected override void OnResume()
        {
            base.OnResume();
            Tracking.StartUsage(this);
            CheckApp();
            CustomContentResolver.GetCustomContentResolver(this).Sync(this);
            var result = modelActivity.dbGenericActivity.GetUsersIDsLogged();

            if (result == null || result.Count <= 0)
            {
                StartActivity(typeof(Login));
                OverridePendingTransition(Resource.Animation.abc_slide_in_top,
                                          Resource.Animation.abc_slide_out_top);
                Finish();
            }
            modelActivity.myToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(modelActivity.myToolbar);
            if (controller.IsHrDeAlmoco())
            {
                IniPopUpAlmoco(Resources.GetString(Resource.String.dialog_confirm_end_almoco));
            }
            if (isToRunning || (modelActivity.dialog == null || !modelActivity.dialog.IsShowing))
            {
                if (Sincronizador.context == null || Sincronizador.context != ApplicationContext)
                {
                    Sincronizador.context = ApplicationContext;
                }
                Sincronizador.TryExecSync();
            }
        }
예제 #2
0
 public void FecharActivity()
 {
     if (Sincronizador.context == null || Sincronizador.context != ApplicationContext)
     {
         Sincronizador.context = ApplicationContext;
     }
     Sincronizador.TryExecSync();
     MoveTaskToBack(true);
     OverridePendingTransition(Resource.Animation.abc_slide_in_bottom,
                               Resource.Animation.abc_slide_out_bottom);
 }
예제 #3
0
        public void OnButtonLoginClicked(View v)
        {
            var empresa = FindViewById <EditText>(Resource.Id.empresa_editTxtUser);
            var senha   = FindViewById <EditText>(Resource.Id.login_editTxtPass);
            var usuario = FindViewById <EditText>(Resource.Id.login_editTxtUser);

            progressDialog = ProgressDialog.Show(this, Resources.GetString(Resource.String.carregando), Resources.GetString(Resource.String.msg_popup_login), true);
            new Thread(new ThreadStart(delegate
            {
                try
                {
                    var infoUser = controller.DoLogin(empresa.Text, usuario.Text, senha.Text);
                    infoUser     = GetAvatarDeUsuario(infoUser);
                    RunOnUiThread(delegate
                    {
                        controller.InsertNewUser(infoUser);
                        Sincronizador.context = ApplicationContext;
                        Sincronizador.TryExecSync();
                    });
                    if (Intent.GetBooleanExtra("isToAddNewUser", false))
                    {
                        RunOnUiThread(() => Toast.MakeText(this, Resources.GetString(Resource.String.msg_new_user_ok), ToastLength.Long).Show());
                    }
                    progressDialog.Dismiss();
                    StartActivity(typeof(MenuPdvs));
                    OverridePendingTransition(Resource.Animation.abc_slide_in_bottom,
                                              Resource.Animation.abc_slide_out_bottom);
                }
                catch (InvalidLoginException loginError)
                {
                    RunOnUiThread(() => Toast.MakeText(this, loginError.Message, ToastLength.Long).Show());
                    if ((progressDialog != null) && progressDialog.IsShowing)
                    {
                        progressDialog.Dismiss();
                    }
                }
                catch (Exception)
                {
                    RunOnUiThread(() => Toast.MakeText(this, Resources.GetString(Resource.String.msg_erro_inesperado_login), ToastLength.Long).Show());
                    if ((progressDialog != null) && progressDialog.IsShowing)
                    {
                        progressDialog.Dismiss();
                    }
                }
            })).Start();
        }
예제 #4
0
 void OnClickSync()
 {
     AlertDialog.Builder dialogBuilder;
     dialogBuilder = new AlertDialog.Builder(this, Resource.Style.DialogTheme);
     dialogBuilder.SetTitle(Resources.GetString(Resource.String.sincronizar));
     dialogBuilder.SetMessage(Resources.GetString(Resource.String.aguarde));
     dialogBuilder.SetCancelable(false);
     model.modelGeneric.dialog = dialogBuilder.Create();
     RunOnUiThread(() => model.modelGeneric.dialog.Show());
     new Thread(() =>
     {
         try
         {
             Sincronizador.ExecSyncUI();
             if (!string.IsNullOrEmpty(Sincronizador.controller.exceptionMessage))
             {
                 throw new Exception(Sincronizador.controller.exceptionMessage);
             }
             RunOnUiThread(() => Toast.MakeText(this, Resources.GetString(Resource.String.sync_ok), ToastLength.Long).Show());
             SendBroadcast(new Intent(MenuPDVsModel.ACTION_FINISHED_SYNC));
             RunOnUiThread(() => model.modelGeneric.dialog.Dismiss());
         }
         catch (Exception ex)
         {
             RunOnUiThread(() => model.modelGeneric.dialog.Dismiss());
             if (ex.InnerException != null)
             {
                 if (ex.InnerException.InnerException != null)
                 {
                     ErrorSync(ex.InnerException.InnerException);
                 }
                 else
                 {
                     ErrorSync(ex.InnerException);
                 }
             }
             else
             {
                 ErrorSync(ex);
             }
         }
     }).Start();
 }
예제 #5
0
        protected override void OnResume()
        {
            base.OnResume();
            Instance = this;
            var manager = (NotificationManager)GetSystemService(NotificationService);

            model.modelGeneric.gps = GPS.GetGPSTracker(this.ApplicationContext);
            modelActivity.gps.UpdateLocation();
            manager.Cancel((int)TipoNotificacao.NovosPdvs);
            model.infoUsuario = model.dbPdvs.GetUserInfoLogged();
            var visita = model.dbPdvs.GetVisitaAtual();

            if (visita != null && visita.Count > 0)
            {
                var listIdsPDVs = new List <ListTypePDV>();
                foreach (var item in visita)
                {
                    listIdsPDVs.Add(new ListTypePDV(item.ID));
                }
                var listIdsUsers = new List <string>();
                foreach (var itemUser in model.infoUsuario)
                {
                    listIdsUsers.Add(itemUser.ID);
                }

                var i = new Intent(this, typeof(MenuTarefas));
                i.PutExtra("lojaSelecionada", visita[0].ENDERECO);
                i.PutStringArrayListExtra("idUser", listIdsUsers);
                i.PutExtra("visitas", new ListTypePDV().ToIntentVar(listIdsPDVs));
                StartActivity(i);
                OverridePendingTransition(Resource.Animation.abc_slide_in_bottom,
                                          Resource.Animation.abc_slide_out_bottom);
                Finish();
            }
            CreateMapList();
            if (controller.CheckOutVisita(model.pdvs.Count))
            {
                Sincronizador.itsRunning  = false;
                Sincronizador.lastHitSync = new DateTime();
                Sincronizador.TryExecSync();
                CheckOutMessage();
            }
        }
예제 #6
0
        protected override void OnPause()
        {
            Tracking.StopUsage(this);
            if (isToRunning && (modelActivity.dialog == null || !modelActivity.dialog.IsShowing))
            {
                RunOnUiThread(delegate
                {
                    if (Sincronizador.context == null || Sincronizador.context != ApplicationContext)
                    {
                        Sincronizador.context = ApplicationContext;
                    }
                    Sincronizador.TryExecSync();
                });
            }

            if ((modelActivity.dialog != null) && modelActivity.dialog.IsShowing)
            {
                modelActivity.dialog.Dismiss();
            }
            modelActivity.dialog = null;
            base.OnPause();
        }