private async void LoadPredators() { CloudDataStore data = new CloudDataStore(); var returns = await data.GetItemsAsync("predators/"); foreach (var p in returns) { CoreGraphics.CGPoint loc = new CoreGraphics.CGPoint(p.Latitude, p.Longitude); var annotation = new MKPointAnnotation { Coordinate = map.ConvertPoint(loc, map), Title = p.Name, Subtitle = p.Date.ToString() }; map.AddAnnotation(annotation); } }
public static void Revert(CloudDataStore store) { var alias = MainApplication.Current.getCertificateAlias(); if (alias == null) { return; } var ks = KeyStore.GetInstance("AndroidKeyStore"); ks.Load(null); ks.DeleteEntry(alias); store.Certificate = null; MainApplication.Current.preference.Edit() .PutString(MainApplication.CERT_NAME, null) .PutInt(MainApplication.LOGIN_COUNT, 0) .Apply(); }
public static void Extend(CloudDataStore store, Action action) { var alias = MainApplication.Current.getCertificateAlias(); if (alias == null) { GetCertificate(new HttpCallback(store, action)); } else { var ks = KeyStore.GetInstance("AndroidKeyStore"); ks.Load(null); var certificate = ks.GetCertificate(alias); store.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate(certificate.GetEncoded()); action.Invoke(); } }
protected internal void SincronizarClick(object sender, EventArgs e) { CloudData = new CloudDataStore(); db = new DataBase(); TextView TVResult = FindViewById <TextView>(Resource.Id.TVResultado); ProgressDialog pbar = new ProgressDialog(this); pbar.SetCancelable(false); pbar.SetMessage("Sincronizando dados do sistema..."); pbar.SetProgressStyle(ProgressDialogStyle.Horizontal); pbar.Progress = 0; pbar.Max = 100; pbar.Show(); new Thread(new ThreadStart(async delegate { // Baixa o conteúdo da Web pro App; if (await CloudData.BaixarPlantio(null)) { pbar.Progress += 5; } if (await CloudData.BaixarInstalacao(null)) { pbar.Progress += 5; } if (await CloudData.BaixarManutencao(null)) { pbar.Progress += 10; } if (await CloudData.BaixarPlanejamentoAplic(null) && await CloudData.BaixarAplicacao(null)) { pbar.Progress += 10; } if (await CloudData.BaixarPlanejamentoAval(null) && await CloudData.BaixarAvaliacao(null)) { pbar.Progress += 10; } if (await CloudData.MunicipiosSync(null) && await CloudData.LocalidadeSync(null)) { pbar.Progress += 5; if (await CloudData.UsuarioSync(null)) { pbar.Progress += 5; } } if (await CloudData.BaixarCultura(null) && await CloudData.BaixarEquipamento(null)) { pbar.Progress += 10; } if (await CloudData.BaixarEstudos(null) && await CloudData.BaixarAplicPlan(null) && await CloudData.BaixarAvalPlan(null)) { pbar.Progress += 5; } if (await CloudData.BaixarVariedade(null) && await CloudData.BaixarTipoAvaliacao(null)) { pbar.Progress += 10; } if (await CloudData.BaixarSafra(null) && await CloudData.BaixarAlvo(null)) { pbar.Progress += 5; } if (await CloudData.BaixarUmidade(null) && await CloudData.BaixarGleba(null)) { pbar.Progress += 5; } if (await CloudData.BaixarProdutos(null) && await CloudData.BaixarBBCHEstagio(null) /* && * await CloudData.BaixarBBCH(null)*/) { pbar.Progress += 5; } if (await CloudData.BaixarSolo(null) && await CloudData.BaixarCobertura(null)) { pbar.Progress += 5; } if (await CloudData.BaixarManutencaoTipo(null) && await CloudData.BaixarManutencaoObj(null) && await CloudData.BaixarUnidadeMedida(null)) { pbar.Progress += 5; } if (pbar.Progress >= 100) { Thread.Sleep(800); RunOnUiThread(() => { TVResult.Text = "Sincronização efetuada com sucesso!"; TVResult.SetTextColor(Android.Graphics.Color.DarkGreen); }); RunOnUiThread(() => { Toast.MakeText(this, "Dados importados com sucesso.", ToastLength.Long).Show(); }); pbar.Dismiss(); } else { RunOnUiThread(() => { TVResult.Text = "Erro ao baixar os dados do servidor!"; TVResult.SetTextColor(Android.Graphics.Color.Red); }); pbar.Dismiss(); } RunOnUiThread(() => { pbar.SetMessage("Dados importados..."); }); })).Start(); }
protected internal void TransmitirClick(object sender, EventArgs e) { CloudData = new CloudDataStore(); db = new DataBase(); TextView TVResult = FindViewById <TextView>(Resource.Id.TVResultado); ProgressDialog pbar = new ProgressDialog(this); pbar.SetCancelable(false); pbar.SetMessage("Sincronizando dados do sistema..."); pbar.SetProgressStyle(ProgressDialogStyle.Horizontal); pbar.Progress = 0; pbar.Max = 100; pbar.Show(); new Thread(new ThreadStart(async delegate { // Envia do App para a Web; if (await CloudData.AddPlantio(null)) { pbar.Progress += 10; //Plantio if (await CloudData.BaixarPlantio(null)) { pbar.Progress += 5; } //Instalacao if (await CloudData.AddInstalacao(null)) { pbar.Progress += 5; if (await CloudData.BaixarInstalacao(null)) { pbar.Progress += 5; } if (await CloudData.AddManutencao(null)) { pbar.Progress += 5; if (await CloudData.BaixarManutencao(null)) { pbar.Progress += 5; } } if (await CloudData.AddPlanejamentoAplic(null)) { pbar.Progress += 10; if (await CloudData.AddAplicacao(null)) { pbar.Progress += 5; if (await CloudData.BaixarPlanejamentoAplic(null) && await CloudData.BaixarAplicacao(null)) { pbar.Progress += 10; } } } if (await CloudData.AddPlanejamentoAval(null)) { pbar.Progress += 10; if (await CloudData.BaixarPlanejamentoAval(null)) { pbar.Progress += 10; if (await CloudData.AddAvaliacao(null)) { pbar.Progress += 5; if (await CloudData.BaixarPlanejamentoAval(null) && await CloudData.BaixarAvaliacao(null)) { pbar.Progress += 10; } if (await CloudData.AddAvaliacaoImagem(null)) { pbar.Progress += 5; } } } } } } ////Avaliacao_Imagem //if (await CloudData.AddAvaliacaoImagem(null)) //{ // pbar.Progress += 5; //} if (pbar.Progress >= 100) { Thread.Sleep(800); RunOnUiThread(() => { TVResult.Text = "Sincronização efetuada com sucesso!"; TVResult.SetTextColor(Android.Graphics.Color.DarkGreen); }); RunOnUiThread(() => { Toast.MakeText(this, "Dados importados com sucesso.", ToastLength.Long).Show(); }); pbar.Dismiss(); } else { RunOnUiThread(() => { TVResult.Text = "Erro ao baixar os dados do servidor!"; TVResult.SetTextColor(Android.Graphics.Color.Red); }); pbar.Dismiss(); } RunOnUiThread(() => { pbar.SetMessage("Dados importados..."); }); })).Start(); }
public HttpCallback(CloudDataStore store, Action action) { _store = store; _action = action; }
void SaveButton_Click(object sender, EventArgs e) { CloudData = new CloudDataStore(); db = new DataBase(); ProgressDialog pbar = new ProgressDialog(this); pbar.SetCancelable(false); pbar.SetMessage("Validando chave..."); pbar.SetProgressStyle(ProgressDialogStyle.Horizontal); pbar.Progress = 0; pbar.Max = 100; pbar.Show(); bool sucesso = false; new Thread(new ThreadStart(async delegate { if (await CloudData.ValidarChave(licenca.Text)) { sucesso = true; } if (sucesso) { RunOnUiThread(() => { Toast.MakeText(this, "Chave validada com sucesso.", ToastLength.Long).Show(); }); RunOnUiThread(() => { pbar.SetMessage("Sincronizando dados básicos..."); }); pbar.Progress += 25; if (await CloudData.MunicipiosSync(licenca.Text) && await CloudData.LocalidadeSync(licenca.Text)) { pbar.Progress += 25; bool result = await CloudData.UsuarioSync(licenca.Text); if (result) { pbar.Progress += 25; var conf2 = new Config { Descricao = "carga_inicial", Valor = "1" }; if (db.InserirConfig(conf2)) { pbar.Progress += 25; } } } Thread.Sleep(400); if (pbar.Progress >= 100) { var intent = new Intent(this, typeof(LoginActivity));; StartActivity(intent); Finish(); pbar.Dismiss(); } RunOnUiThread(() => { pbar.SetMessage("Dados importados..."); }); RunOnUiThread(() => { Toast.MakeText(this, "Dados importados com sucesso.", ToastLength.Long).Show(); }); // SyncInstall(); } else { pbar.Dismiss(); RunOnUiThread(() => { Toast.MakeText(this, "Chave não encontrada.", ToastLength.Long).Show(); }); } })).Start(); // Finish(); }
public static void Extend(CloudDataStore store, Action action) { }
public static void Revert(CloudDataStore store) { }