コード例 #1
0
 protected override void OnResume()
 {
     if (App.IsLogged && !string.IsNullOrEmpty(LoggedUser))
     {
         var curPage = ((NavigationPage)Current.MainPage).CurrentPage;
         if (curPage != null)
         {
             if (curPage is ViewInconveniente)
             {
                 try
                 {
                     //Gestione standBy Inconveniente --
                     // controllo la pagina inconveniente.
                     ViewInconveniente inconveniente = (ViewInconveniente)curPage;
                     if (inconveniente != null)
                     {
                         var vm = inconveniente.BindingContext;
                         if (vm != null)
                         {
                             if (vm is InconvenienteViewModel)
                             {
                                 var value = (string)App.Current.Properties["SleepMode"];
                                 InconvenienteViewModel vwModel = (InconvenienteViewModel)vm;
                                 DateTime sleepDate;
                                 if (DateTime.TryParse(value, out sleepDate))
                                 {
                                     vwModel.dtsleepDate = sleepDate;
                                     //vwModel.sleepMode();
                                     //vwModel.InitializeAsync(vwModel.IDCommessa);
                                 }
                             }
                         }
                     }
                 }
                 catch (Exception ecc)
                 {
                     Log.Error("AppOfficina", ecc.Message);
                 }
             }
         }
     }
 }
コード例 #2
0
        protected override void OnSleep()
        {
            // Handle when your app sleeps
            App.Current.Properties["SleepMode"]  = DateTime.Now.ToString("O");
            App.Current.Properties["TimerSlepp"] = timer.Elapsed;

            if (App.IsLogged && !string.IsNullOrEmpty(LoggedUser))
            {
                var curPage = ((NavigationPage)Current.MainPage).CurrentPage;
                if (curPage != null)
                {
                    if (curPage is ViewInconveniente)
                    {
                        try
                        {
                            ViewInconveniente inconveniente = (ViewInconveniente)curPage;
                            if (inconveniente != null)
                            {
                                var vm = inconveniente.BindingContext;
                                if (vm != null)
                                {
                                    if (vm is InconvenienteViewModel)
                                    {
                                        InconvenienteViewModel vwModel = (InconvenienteViewModel)vm;
                                        //MessagingCenter.Send<string>("OK","myService");
                                        //timer.Stop();
                                    }
                                }
                            }
                        }
                        catch (Exception ecc)
                        {
                            Log.Error("AppOfficina", ecc.Message);
                        }
                    }
                }
            }
        }