private void CheckUpdate() { Trace.WriteLine("Entered CheckUpdate()."); LoadCatalog(); try { bool hasUpdate = false; Trace.WriteLine(" Downloading messages."); FoeClientMessage.DownloadMessages(); Trace.WriteLine(" Downloaded messages."); // Check if there is any update that's newer than what are currently displayed List <FoeClientCatalogItem> catalog = FoeClientCatalog.GetAll(); foreach (FoeClientCatalogItem item in catalog) { Trace.WriteLine(" Checking updated news."); Trace.WriteLine(" " + item.Code + " updated at " + item.DtLastUpdated.ToString("yyyy-MM-dd HH:mm:ss")); Trace.WriteLine(" _lastUpdated = " + _lastUpdated.ToString("yyyy-MM-dd HH:mm:ss")); if (item.DtLastUpdated > _lastUpdated) { Trace.WriteLine(" Updated news is available."); // Set timer to normal interval timerCheckUpdate.Interval = _checkInterval; // Redisplay feed DisplayFeeds(); Trace.WriteLine(" Displayed feed."); // record keeping hasUpdate = true; tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " updated feeds."; _lastUpdated = DateTime.Now; Trace.WriteLine(" Updated _lastUpdated."); break; } } if (!hasUpdate) { tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " no new feeds."; Trace.WriteLine(" No update available."); } } catch (Exception except) { tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error ."; Trace.WriteLine(" Error occured:\r\n" + except.ToString()); } Trace.WriteLine("Exiting CheckUpdate()."); }
private void timerCheckRegistration_Tick(object sender, EventArgs e) { try { // Stop timer timerCheckRegistration.Stop(); // Check messages lblStatus.Text = "Checking registration status..."; FoeClientMessage.DownloadMessages(); // Check if user ID is now set FoeClientRegistryEntry userId = FoeClientRegistry.GetEntry("userid"); if ((userId == null) || (userId.Value.Trim().Length == 0)) { lblStatus.Text = "[" + DateTime.Now.ToString("HH:mm:ss") + "] registration still processing. Wait 15 seconds."; timerCheckRegistration.Start(); return; } // Registration is completed lblStatus.Text = "Registration completed."; _result = DialogResult.OK; Close(); } catch (Exception) { MessageBox.Show("Error checking registration request. Make sure your computer is connected to the Internet and the POP3 servers " + "settings are correct. You can click the Email Settings button to reconfigure SMTP and POP3 settings.", "Foe", MessageBoxButtons.OK, MessageBoxIcon.Error); // re-enable buttons btnRegister.Enabled = true; btnEmailSettings.Enabled = true; // Update status lblStatus.Text = "Error checking registration request."; } }
private void CheckUpdate() { try { bool hasUpdate = false; FoeClientMessage.DownloadMessages(); // Check if there is any update that's newer than what are currently displayed List <FoeClientCatalogItem> catalog = FoeClientCatalog.GetAll(); foreach (FoeClientCatalogItem item in catalog) { if (item.DtLastUpdated > _lastUpdated) { // Set timer to normal interval timerCheckUpdate.Interval = _checkInterval; // Redisplay feed DisplayFeeds(); // record keeping hasUpdate = true; tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " updated feeds."; _lastUpdated = DateTime.Now; break; } } if (!hasUpdate) { tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " no new feeds."; } } catch (Exception) { tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error ."; } }