public ViewInconveniente(CommessaDTO commessaDTO = null, InconvenienteDTO inconveniente = null)
        {
            InitializeComponent();

            this._commessa = commessaDTO.NumeroCommessa;
            this._targa    = commessaDTO.TargaCommessa;
            _vm            = (InconvenienteViewModel)(ServiceLocator.Current.GetInstance(typeof(InconvenienteViewModel)));

            _vm.Navigation            = this.Navigation;
            _vm.selectedCommessa      = commessaDTO;
            _vm.IDCommessa            = _commessa;
            _vm.targaVeicolo          = _targa;
            _vm.codiceCliente         = commessaDTO.codice;
            _vm.ragioneSociale        = commessaDTO.ragioneSociale;
            _vm.telefono              = commessaDTO.telefono;
            _vm.mail                  = commessaDTO.email;
            _vm.numeroTelaio          = commessaDTO.Telaio;
            _vm.nomeVeicolo           = commessaDTO.DescrizioneVeicolo;
            _vm.selectedInconveniente = inconveniente;
            _vm.defCommessa           = "Commessa N :" + _commessa + ",Targa Veicolo : " + _targa + " , Telaio : " + commessaDTO.Telaio + " , Veicolo : " + commessaDTO.DescrizioneVeicolo;
            BindingContext            = _vm;
            ((InconvenienteViewModel)BindingContext).Initialize(this);


            //MessagingCenter.Subscribe<string, string>(MessagingCenterEvents.Subscriber, MessagingCenterEvents.AlertError, async (sender, msg) =>
            //{
            //    await DisplayAlert("Informazioni", msg, "OK");
            //});

            MessagingCenter.Subscribe <Application, DisplayAlertMessage>(this, "Attenzione!", async(sender, message) =>
            {
                const string title  = "Informazioni";
                const string cancel = "No";

                var result = true;
                if (!string.IsNullOrEmpty(message.Accept) && !string.IsNullOrEmpty(message.Message))
                {
                    result = await DisplayAlert(title, message.Message, message.Accept, cancel);
                }

                if (message.OnCompleted != null)
                {
                    message.OnCompleted(result);
                }
            }, Application.Current);

            SetBackgroundColorButton();
        }
Пример #2
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);
                 }
             }
         }
     }
 }
Пример #3
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);
                        }
                    }
                }
            }
        }