// do the creation job private void CreateNotificationsImpl(ProgressDialog progressDialog, double dlat, double dlon, int distance, String name, List <Tuple <int, string, List <string>, int> > selectedTypes, String email) { try { // we create notifications // No iterate on selected type and create ! String url = "https://www.geocaching.com/notify/edit.aspx"; String post_response = ""; String post_string = ""; int nb = 1; bool error = false; String warning = ""; foreach (var tpl in selectedTypes) { // Is it canceled ? if (_Canceled) { break; // Yes } // Update progress progressDialog.Progress = nb; // Progress message RunOnUiThread(() => progressDialog.SetMessage(this.Resources.GetString(Resource.String.LblCreateInProgress) + " - " + tpl.Item2)); // On demande la page par défaut pour initialiser une nouvelle demande HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.CookieContainer = _gcstuffs._cookieJar; // surtout récupérer le container de cookie qui est maintenant renseigné avec le cookie d'authentification HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream())) { post_response = responseStream.ReadToEnd(); responseStream.Close(); } // On regarde si on a claqué le nombre max warning = GCStuffs.CheckWarningMessage(post_response); if (warning != "") { error = true; break; } // Une mise à jour pour définir le type de cache post_string = GCStuffs.GeneratePostString(post_response, dlat, dlon, distance, name, tpl, email, true); post_response = GCStuffs.GeneratePostRequets(url, post_string, _gcstuffs._cookieJar); // Une mise à jour pour définir le type de notif post_string = GCStuffs.GeneratePostString(post_response, dlat, dlon, distance, name, tpl, email, true); post_response = GCStuffs.GeneratePostRequets(url, post_string, _gcstuffs._cookieJar); // Vérification de la création correcte ! warning = GCStuffs.CheckValidationMessage(post_response); if (warning != "") { error = true; break; } // On décoche le type que l'on vient de poster foreach (var tc in _typecaches) { if (tc.Type == tpl.Item2) { // Found it ! // On le décoche RunOnUiThread(() => tc.Checked = false); } } nb++; } // Kill progressdialog (we are in UI thread already, good) RunOnUiThread(() => progressDialog.Hide()); // All right! if (error) { RunOnUiThread(() => Toast.MakeText(this, warning, ToastLength.Long).Show()); // Don't go to main activity !!! } else if (_Canceled) { RunOnUiThread(() => Toast.MakeText(this, this.Resources.GetString(Resource.String.Canceled), ToastLength.Short).Show()); // Don't go to main activity !!! } else { RunOnUiThread(() => Toast.MakeText(this, this.Resources.GetString(Resource.String.Success), ToastLength.Short).Show()); // Then go back to main activity GoToMainActivity(true); } } catch (Exception ex) { // Kill progressdialog (we are in UI thread already, good) RunOnUiThread(() => progressDialog.Hide()); // Crap RunOnUiThread(() => Toast.MakeText(this, this.Resources.GetString(Resource.String.Error) + "\n" + ex.Message, ToastLength.Long).Show()); } }