private void SendCatalogRequest() { try { // Delete all previous content requests FoeClientRequest.DeleteOldRequest(_requestInterval); // Create Foe Message string requestId = FoeClientRequest.GenerateId(); FoeClientMessage.SendMessage( FoeClientMessage.GetSmtpServer(), FoeClientRegistry.GetEntry("useremail").Value, FoeClientRegistry.GetEntry("processoremail").Value, SubjectGenerator.RequestSubject(RequestType.Catalog, requestId, FoeClientRegistry.GetEntry("userid").Value), ""); // save requestid to DB FoeClientRequestItem reqItem = new FoeClientRequestItem(); reqItem.Id = requestId; reqItem.Type = "catalog"; reqItem.DtRequested = DateTime.Now; FoeClientRequest.Add(reqItem); // remember when the request was sent _lastRequestSent = DateTime.Now; // Set status tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " requested catalog."; } catch (Exception) { tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error sending request."; } }
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()."); }
static bool IsEmailConfigured() { SmtpServer smtp = FoeClientMessage.GetSmtpServer(); PopServer pop = FoeClientMessage.GetPopServer(); if ((smtp == null) || (pop == null)) { return(false); } return(true); }
private void SendSubscriptionRequest() { try { // Delete all previous content requests FoeClientRequest.DeleteOldRequest(_requestInterval); // Create Foe Message string catalogs = ""; List <FoeClientCatalogItem> catalog = FoeClientCatalog.GetAll(); if (catalog.Count == 0) { return; } foreach (FoeClientCatalogItem item in catalog) { if (item.IsSubscribed) { catalogs += item.Code + ","; } } string requestId = FoeClientRequest.GenerateId(); FoeClientMessage.SendMessage( FoeClientMessage.GetSmtpServer(), FoeClientRegistry.GetEntry("useremail").Value, FoeClientRegistry.GetEntry("processoremail").Value, SubjectGenerator.RequestSubject(RequestType.Content, requestId, FoeClientRegistry.GetEntry("userid").Value), catalogs); // save requestid to DB FoeClientRequestItem reqItem = new FoeClientRequestItem(); reqItem.Id = requestId; reqItem.Type = "content"; reqItem.DtRequested = DateTime.Now; FoeClientRequest.Add(reqItem); // remember when the request was sent _lastRequestSent = DateTime.Now; // Set status tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " requested update."; } catch (Exception) { tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error sending request."; } }
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 ."; } }