/// <summary> /// Routine that attempts to resend emails that previously failed. /// </summary> /// <returns>List of emails that were successfully resent.</returns> /// <remarks>Uses internally maintained queue of emails that failed to send.</remarks> public PFListEx <stEmailArchiveEntry> ResendEmails() { PFListEx <stEmailArchiveEntry> successfulResends = new PFListEx <stEmailArchiveEntry>(); PFListEx <stEmailArchiveEntry> failedResends = new PFListEx <stEmailArchiveEntry>(); _emailResendQueue = PFListEx <stEmailArchiveEntry> .LoadFromXmlFile(_emailResendQueueFile); _emailLastResendList.Clear(); foreach (stEmailArchiveEntry emailEntry in _emailResendQueue) { stEmailSendResult res = this.SendEmail(emailEntry.emailMessage, false); if (res.emailSendResult == enEmailSendResult.Success) { stEmailArchiveEntry successEntry = new stEmailArchiveEntry(res, emailEntry.emailMessage); successEntry.numRetries = emailEntry.numRetries + 1; successEntry.firstSendAttempt = emailEntry.firstSendAttempt; successEntry.lastSendAttempt = DateTime.Now; successfulResends.Add(successEntry); } else { stEmailArchiveEntry failedEntry = new stEmailArchiveEntry(res, emailEntry.emailMessage); failedEntry.firstSendAttempt = emailEntry.firstSendAttempt; failedEntry.lastSendAttempt = DateTime.Now; failedEntry.numRetries = emailEntry.numRetries + 1; failedResends.Add(failedEntry); } } _emailResendQueue.Clear(); if (failedResends.Count > 0) { foreach (stEmailArchiveEntry entry in failedResends) { if (entry.numRetries < _maxNumResendAttempts) { stEmailArchiveEntry newEntry = new stEmailArchiveEntry(entry.sendResult, entry.emailMessage); newEntry.firstSendAttempt = entry.firstSendAttempt; newEntry.lastSendAttempt = entry.lastSendAttempt; newEntry.numRetries = entry.numRetries; _emailResendQueue.Add(newEntry); } else { stEmailArchiveEntry lastEntry = new stEmailArchiveEntry(entry.sendResult, entry.emailMessage); lastEntry.firstSendAttempt = entry.firstSendAttempt; lastEntry.lastSendAttempt = entry.lastSendAttempt; lastEntry.numRetries = entry.numRetries; _emailLastResendList.Add(lastEntry); } } } _emailResendQueue.SaveToXmlFile(_emailResendQueueFile); return(successfulResends); }
public static void ListMergeTest() { PFListEx <string> list1 = new PFListEx <string>(); PFListEx <string> list2 = new PFListEx <string>(); PFListEx <string> list3 = new PFListEx <string>(); try { _msg.Length = 0; _msg.Append("ListMergeTest started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); list1.Add("First"); list1.Add("Second"); list1.Add("Third"); list2.Add("fourth"); list2.Add("fifth"); list2.Add("sixth"); list3.Add("Seventh"); list3.Add("Eighth"); list3.Add("Ninth"); list3.Add("Tenth"); PFListEx <string>[] listArray = { list1, list2, list3 }; PFListEx <PFListEx <string> > listOfLists = new PFListEx <PFListEx <string> >(); listOfLists.Add(list1); listOfLists.Add(list2); listOfLists.Add(list3); PFListEx <string> concatListFromArray = PFListEx <string> .ConcatenateLists(listArray); _msg.Length = 0; _msg.Append(Environment.NewLine); _msg.Append("Concatenated list from Array"); _msg.Append(Environment.NewLine); _msg.Append(concatListFromArray.ToXmlString()); Program._messageLog.WriteLine(_msg.ToString()); PFListEx <string> concatListFromList = PFListEx <string> .ConcatenateLists(listOfLists); _msg.Length = 0; _msg.Append(Environment.NewLine); _msg.Append("Concatenated list from List"); _msg.Append(Environment.NewLine); _msg.Append(concatListFromList.ToXmlString()); Program._messageLog.WriteLine(_msg.ToString()); PFListEx <string> mergedList = list1.Merge(list2); _msg.Length = 0; _msg.Append(Environment.NewLine); _msg.Append("Merged list"); _msg.Append(Environment.NewLine); _msg.Append(mergedList.ToXmlString()); Program._messageLog.WriteLine(_msg.ToString()); mergedList.Clear(); mergedList = list3.Merge(new PFListEx <string>[2] { list1, list2 }); _msg.Length = 0; _msg.Append(Environment.NewLine); _msg.Append("Merged list from Array"); _msg.Append(Environment.NewLine); _msg.Append(mergedList.ToXmlString()); Program._messageLog.WriteLine(_msg.ToString()); mergedList.Clear(); mergedList = list3.Merge(new PFListEx <PFListEx <string> > { list2, list1 }); _msg.Length = 0; _msg.Append(Environment.NewLine); _msg.Append("Merged list from List"); _msg.Append(Environment.NewLine); _msg.Append(mergedList.ToXmlString()); Program._messageLog.WriteLine(_msg.ToString()); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... ListMergeTest finished."); Program._messageLog.WriteLine(_msg.ToString()); } }