diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs
index 6eab6392..58f4312f 100644
--- a/Backend/CommsTransmitter.cs
+++ b/Backend/CommsTransmitter.cs
@@ -60,14 +60,12 @@ namespace Swarmops.Backend
ICommsTransmitter transmitter = new CommsTransmitterMail();
- OutboundCommRecipients recipients = comm.Recipients;
+ OutboundCommRecipients recipients = comm.GetRecipientBatch(100);
PayloadEnvelope envelope = PayloadEnvelope.FromXml (comm.PayloadXml);
BotLog.Write(2, "CommsTx", "--transmitting to " + recipients.Count.ToString("N0") + " recipients");
comm.StartTransmission();
- int success = 0;
- int fail = 0;
foreach (OutboundCommRecipient recipient in recipients)
{
@@ -75,12 +73,10 @@ namespace Swarmops.Backend
{
transmitter.Transmit (envelope, recipient.Person);
recipient.CloseSuccess();
- success++;
}
catch (OutboundCommTransmitException e)
{
recipient.CloseFailed (e.Description);
- fail++;
}
}
@@ -88,7 +84,9 @@ namespace Swarmops.Backend
BotLog.Write(2, "CommsTx", "--closing");
- if (success + fail > 1)
+ OutboundComm reloadedComm = OutboundComm.FromIdentity(comm.Identity); // object doesn't update as we get results
+
+ if (comm.RecipientCount > 1)
{
BotLog.Write(2, "CommsTx", "--notifying");
@@ -101,10 +99,16 @@ namespace Swarmops.Backend
NotificationStrings notifyStrings = new NotificationStrings();
NotificationCustomStrings customStrings = new NotificationCustomStrings();
notifyStrings[NotificationString.OrganizationName] = Organization.FromIdentity(comm.OrganizationId).Name;
- customStrings["RecipientCount"] = recipients.Count.ToString("N0");
- customStrings["RecipientsSuccess"] = success.ToString("N0");
- customStrings["TransmissionTime"] =
- (comm.ClosedDateTime - comm.StartTransmitDateTime).ToString("m min ss.ff sec");
+ customStrings["RecipientCount"] = reloadedComm.RecipientCount.ToString("N0");
+ customStrings["RecipientsSuccess"] = reloadedComm.RecipientsSuccess.ToString("N0");
+
+ TimeSpan resolveTime = comm.StartTransmitDateTime - comm.CreatedDateTime;
+ TimeSpan transmitTime = comm.ClosedDateTime - comm.StartTransmitDateTime;
+ TimeSpan totalTime = resolveTime + transmitTime;
+
+ customStrings["TransmissionTime"] = FormatTimespan(transmitTime);
+ customStrings["ResolveTime"] = FormatTimespan(resolveTime);
+ customStrings["TotalTime"] = FormatTimespan(totalTime);
if (resolver is IHasGeography)
{
customStrings["GeographyName"] = ((IHasGeography)resolver).Geography.Localized;
@@ -116,6 +120,11 @@ namespace Swarmops.Backend
}
}
+ internal static string FormatTimespan(TimeSpan span)
+ {
+ return String.Format("{0} min {1}.{2:D3} sec", span.TotalMinutes, span.Seconds, span.Milliseconds);
+ }
+
internal static ICommsResolver FindResolver(OutboundComm comm)
{
// Resolve recipients
diff --git a/Database/Database-Conditions.cs b/Database/Database-Conditions.cs
index 64b27119..7f4260a7 100644
--- a/Database/Database-Conditions.cs
+++ b/Database/Database-Conditions.cs
@@ -71,7 +71,7 @@ namespace Swarmops.Database
result = result.Concat (ConstructWhereClauseRecurse (tableName, partialCondition)).ToList();
}
}
- else // iterate through attributes to find final hope of clue
+ else if (!(condition is RecordLimit)) // iterate through attributes to find final hope of clue
{
foreach (object attribute in condition.GetType().GetCustomAttributes (typeof (DbEnumField), true))
{
@@ -81,6 +81,10 @@ namespace Swarmops.Database
}
}
}
+ else if (condition is RecordLimit)
+ {
+ result.Add(" LIMIT " + (condition as RecordLimit).Limit);
+ }
}
return result;
@@ -197,7 +201,14 @@ namespace Swarmops.Database
{
if (!String.IsNullOrEmpty (clause))
{
- result += "AND " + clause;
+ if (!clause.StartsWith("LIMIT"))
+ {
+ result += "AND " + clause;
+ }
+ else
+ {
+ result += clause;
+ }
}
}
diff --git a/Database/Database-OutboundCommRecipients.cs b/Database/Database-OutboundCommRecipients.cs
index 3e92545f..1f1826c8 100644
--- a/Database/Database-OutboundCommRecipients.cs
+++ b/Database/Database-OutboundCommRecipients.cs
@@ -84,6 +84,7 @@ namespace Swarmops.Database
}
}
+
#endregion
#region Database optimizations
diff --git a/Database/Database.csproj b/Database/Database.csproj
index b670dcd8..14b19aa7 100644
--- a/Database/Database.csproj
+++ b/Database/Database.csproj
@@ -137,6 +137,7 @@
+
Designer
diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs
index 76d79062..1bbe4246 100644
--- a/Logic/Communications/OutboundComm.cs
+++ b/Logic/Communications/OutboundComm.cs
@@ -41,6 +41,11 @@ namespace Swarmops.Logic.Communications
get { return OutboundCommRecipients.ForOutboundComm (this); }
}
+ public OutboundCommRecipients GetRecipientBatch(int limit)
+ {
+ return OutboundCommRecipients.ForOutboundCommLimited(this, limit);
+ }
+
public new bool Open
{
get { return base.Open; }
diff --git a/Logic/Communications/OutboundCommRecipients.cs b/Logic/Communications/OutboundCommRecipients.cs
index 4c954c9d..69c1749a 100644
--- a/Logic/Communications/OutboundCommRecipients.cs
+++ b/Logic/Communications/OutboundCommRecipients.cs
@@ -11,5 +11,10 @@ namespace Swarmops.Logic.Communications
{
return FromArray (SwarmDb.GetDatabaseForReading().GetOutboundCommRecipients (comm));
}
+
+ public static OutboundCommRecipients ForOutboundCommLimited (OutboundComm comm, int limit)
+ {
+ return FromArray(SwarmDb.GetDatabaseForReading().GetOutboundCommRecipients(comm, new RecordLimit(limit)));
+ }
}
}
\ No newline at end of file
diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
index 7cb6b65e..1ec94b2c 100644
--- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
+++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
@@ -574,7 +574,9 @@ namespace Swarmops.Logic.Resources {
///
/// Looks up a localized string similar to Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients, [RecipientsSuccess] succeeded from Swarmops' horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.)
///
- ///Time spent transmitting: [TransmissionTime]..
+ ///Time spent resolving: [ResolvingTime].
+ ///Time spent transmitting: [TransmissionTime].
+ ///Total time from comm creation to completion: [TotalTime]..
///
internal static string OutboundComm_Sent_Body {
get {
diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
index e0573f5e..0ddc2208 100644
--- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
+++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
@@ -328,7 +328,9 @@ This mail was sent to [Addressee] from [OrganizationName]. If you do not desire
Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients, [RecipientsSuccess] succeeded from Swarmops' horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.)
-Time spent transmitting: [TransmissionTime].
+Time spent resolving: [ResolvingTime].
+Time spent transmitting: [TransmissionTime].
+Total time from comm creation to completion: [TotalTime].
[[OrganizationName]] Comms transmitted: [GeographyName]