void HandleTimerCallback(object state) { TimeSpan runTime = DateTime.UtcNow.Subtract(startTime); Log.Debug(TAG, $"This service has been running for {runTime:c} (since ${state})."); s.Sincronizar(); }
private void BtnSincronizar_Click(object sender, EventArgs e) { ProgressDialog progressBar; ColaSincronizacion _cola = new ColaSincronizacion(); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Sincronización Manual"); alert.SetMessage("¿Desea sincronizar los datos manualmente?"); alert.SetPositiveButton("Sí", (senderAlert, args) => { if (Conectividad.IsConnected) { progressBar = new ProgressDialog(this); progressBar.SetCancelable(true); progressBar.SetMessage("Sincronizando con Central...."); progressBar.SetProgressStyle(ProgressDialogStyle.Spinner); progressBar.Progress = 0; progressBar.Max = 100; progressBar.Show(); new Thread(new ThreadStart(delegate { Sincronizacion _sincro = new Sincronizacion(); _sincro.Sincronizar(); RunOnUiThread(() => { progressBar.Dismiss(); txtAvisosSinSincronizar.Text = String.Format("Sin sincronizar - {0}", new Database().PendientesDeSincronizar().ToString()); Toast.MakeText(this, "Sincronizando", ToastLength.Short).Show(); }); })).Start(); } else { Utilidades.MostrarMensaje(this, Constantes.SinConexion); } }); alert.SetNegativeButton("No", (senderAlert, args) => { Toast.MakeText(this, "Cancelado!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (!Settings._TieneAcceso || !Settings._RecordarAcceso) { SetContentView(Resource.Layout.Login); //Lanzo sincronización //StartService(new Android.Content.Intent(this, typeof(Sincronizador.Sincronizador))); btnLogin = FindViewById <Button>(Resource.Id.button1); txtNombreUsuario = FindViewById <EditText>(Resource.Id.editText1); txtPassUsuario = FindViewById <EditText>(Resource.Id.editText2); swButton_RecordarAcceso = FindViewById <Switch>(Resource.Id.Recodar_DatosAcceso); swButton_RecordarAcceso.Checked = Settings._RecordarAcceso; this.Window.AddFlags(Android.Views.WindowManagerFlags.Fullscreen); this.Window.AddFlags(Android.Views.WindowManagerFlags.KeepScreenOn); btnLogin.Click += BtnLogin_Click; } else { if (Conectividad.IsConnected) { progressBar = new ProgressDialog(this); progressBar.SetCancelable(true); progressBar.SetMessage("Actualizando Datos ..."); progressBar.SetProgressStyle(ProgressDialogStyle.Spinner); progressBar.Progress = 0; progressBar.Max = 100; progressBar.Show(); new Thread(new ThreadStart(delegate { Sincronizacion s = new Sincronizacion(); s.Sincronizar(); RunOnUiThread(() => { progressBar.Dismiss(); StartActivity(typeof(MenuApp)); }); })).Start(); } else { StartActivity(typeof(MenuApp)); } } }
private void BtnLogin_Click(object sender, System.EventArgs e) { if (txtNombreUsuario.Text == string.Empty || txtPassUsuario.Text == string.Empty) { Utilidades.MostrarMensaje(this, Constantes.DatosIncompletos); } else { progressBar = new ProgressDialog(this); progressBar.SetCancelable(true); progressBar.SetMessage("Actualizando Datos ..."); progressBar.SetProgressStyle(ProgressDialogStyle.Spinner); progressBar.Progress = 0; progressBar.Max = 100; progressBar.Show(); new Thread(new ThreadStart(delegate { Settings._Usuario = txtNombreUsuario.Text; if (Conectividad.IsConnected) { Sincronizacion s = new Sincronizacion(); s.Sincronizar(); } RunOnUiThread(() => { progressBar.Dismiss(); if (Login.TieneAcceso(txtNombreUsuario.Text, txtPassUsuario.Text)) { Settings._RecordarAcceso = swButton_RecordarAcceso.Checked; Settings._TieneAcceso = true; StartActivity(typeof(MenuApp)); } else { Utilidades.MostrarMensaje(this, Constantes.SinPermiso); } }); })).Start(); } }