void Button2Click(object sender, EventArgs e) { // Supprime la sélection try { _daddy._ThreadProgressBarTitle = _daddy.GetTranslator().GetString("PQBtnDelete"); _daddy.CreateThreadProgressBar(); // On va parcourir chaque PQ, ouvrir sa page et poster la suppression for (int i = 0; i < lvGCNGrid.Items.Count; i++) { EXListViewItem lvi = (EXListViewItem)(lvGCNGrid.Items[i]); EXBoolListViewSubItem svi = lvi.SubItems[1] as EXBoolListViewSubItem; if (svi != null) { if (svi.BoolValue == true) { String guid = lvi.MyValue; guid = "https://www.geocaching.com/pocket/gcquery.aspx?guid=" + guid; PQDownloadHMI.DeletePQ(_daddy, guid); } } } // On rafraichit InitPQs(); _daddy.KillThreadProgressBar(); } catch (Exception ex) { _daddy.ShowException("", _daddy.GetTranslator().GetString("checkPQToolStripMenuItem"), ex); _daddy.KillThreadProgressBar(); } }
private void Diagnostics_Load(object sender, EventArgs e) { try { _daddy._ThreadProgressBarTitle = _daddy.GetTranslator().GetString("LblDownloadInProgress"); _daddy.CreateThreadProgressBarEnh(); // Wait for the creation of the bar while (_daddy._ThreadProgressBar == null) { Thread.Sleep(10); Application.DoEvents(); } _daddy._ThreadProgressBar.progressBar1.Maximum = 31; _daddy._ThreadProgressBar.lblWait.Text = "Performing diagnostics..."; ListViewItem item = null; int nb = 0; // Proxy ? if (_daddy.GetProxy() != null) { CreateEntry("OK", "Proxy status", "Defined"); } else { CreateEntry("OK", "Proxy status", "Undefined"); } // Internet access ? if (_daddy.CheckInternetAccess()) { CreateEntry("OK", "Internet access", "Available"); } else { CreateEntry("KO", "Internet access", "Not available"); } // GC account ? String cryptedpass = ConfigurationManager.AppSettings["ownerpassword"]; String username = ConfigurationManager.AppSettings["owner"]; if (username != "") { CreateEntry("OK", "Geocaching login", "Filled"); } else { CreateEntry("KO", "Geocaching login", "Empty"); } if (cryptedpass != "") { CreateEntry("OK", "Geocaching password", "Filled"); } else { CreateEntry("KO", "Geocaching password", "Empty"); } CookieContainer cookie = null; if ((username != "") && (cryptedpass != "")) { cookie = _daddy.CheckGCAccount(true, true); if (cookie != null) { CreateEntry("OK", "Geocaching authentication", "Success"); } else { CreateEntry("KO", "Geocaching authentication", "Error during authentication"); } } else { CreateEntry("KO", "Geocaching authentication", "Login and/or password empty"); } // MGM websites String urlupdate = ConfigurationManager.AppSettings["urlupdate"]; List <string> urls = urlupdate.Split(';').ToList <string>(); foreach (String url in urls) { try { String rep = MyTools.GetRequest(new Uri(url), _daddy.GetProxy(), 2000); if (rep != "") { CreateEntry("OK", "MGM website", "Available: " + url); } else { CreateEntry("KO", "MGM website", "Not available: " + url); } } catch { item = CreateEntry("KO", "MGM website availability", "Not available: " + url); } } // PQ download ? if (cookie == null) { CreateEntry("KO", "Pocket Queries download", "User not authenticated"); } else { String html = _daddy.GetPQDownloadHTML(cookie); PQDownloadHMI pq = new PQDownloadHMI(_daddy); nb = pq.Populate(html, true); if (nb != 0) { CreateEntry("OK", "Pocket Queries download", "Available PQs: " + nb.ToString()); } else { CreateEntry("KO", "Pocket Queries download", "Available PQs: " + nb.ToString()); } } // Images OfflineCacheData ocd = new OfflineCacheData(); WebClient client = new WebClient(); client.Proxy = _daddy.GetProxy(); string htmlCode = client.DownloadString("http://coord.info/GC2MQGF"); DownloadWorker dwnd = new DownloadWorker(_daddy); dwnd.GetImageFromParsingImpl(ocd, false, htmlCode); String s = ""; nb = 0; List <string> images = new List <string>(); foreach (KeyValuePair <String, OfflineImageWeb> paire in ocd._ImageFilesSpoilers) { OfflineImageWeb oid = paire.Value; s += oid._name + ";"; images.Add(oid._name); nb++; } // ;;; if (nb == 4) { if ( (images[0] == "[SPOILER] Cache") && //(images[1] == "Départ du sentier / Start of the trail") && // les accents peuvent faire chier (images[2] == "Le Saule Pleureur / The Weeping Willow") && (images[3] == "Le Saule Pleureur / The Weeping Willow") ) { CreateEntry("OK", "Image/Spoilers download", "Good count and names"); } else { CreateEntry("KO", "Image/Spoilers download", "Bad names"); } } else { CreateEntry("KO", "Image/Spoilers download", "Bad count"); } // Completion d'une cache if (cookie == null) { CreateEntry("KO", "Cache update", "User not authenticated"); } else { htmlCode = _daddy.GetCacheHTMLFromClientImpl("http://coord.info/GCX076", cookie); Geocache geo = new Geocache(_daddy); DataForStatsRetrieval dataforstats = new DataForStatsRetrieval(); dataforstats.cookieJar = cookie; dataforstats.firstQuestion = false; dataforstats.inbmissed = 0; dataforstats.stopScoreRetrieval = false; nb = _daddy._iNbModifiedCaches; _daddy.CompleteCacheFromHTML(geo, htmlCode, null, dataforstats, true); _daddy._iNbModifiedCaches = nb; if (CheckCacheContent(geo)) { CreateEntry("OK", "Cache update", "General success"); } else { CreateEntry("KO", "Cache update", "General failure"); } } _daddy.KillThreadProgressBarEnh(); } catch (Exception exc) { _daddy.KillThreadProgressBarEnh(); _daddy.ShowException("", _daddy.GetTranslator().GetString("FMenuDiagnostics"), exc); } }