Minor improvements
This commit is contained in:
+19
-10
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace Swarmops.Database
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Database optimizations
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Database-Constructors.cs" />
|
||||
<Compile Include="Database-Newsletters.cs" />
|
||||
<Compile Include="RecordLimit.cs" />
|
||||
<None Include="app.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -574,7 +574,9 @@ namespace Swarmops.Logic.Resources {
|
||||
/// <summary>
|
||||
/// 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]..
|
||||
/// </summary>
|
||||
internal static string OutboundComm_Sent_Body {
|
||||
get {
|
||||
|
||||
@@ -328,7 +328,9 @@ This mail was sent to [Addressee] from [OrganizationName]. If you do not desire
|
||||
<data name="OutboundComm_Sent_Body" xml:space="preserve">
|
||||
<value>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].</value>
|
||||
Time spent resolving: [ResolvingTime].
|
||||
Time spent transmitting: [TransmissionTime].
|
||||
Total time from comm creation to completion: [TotalTime].</value>
|
||||
</data>
|
||||
<data name="OutboundComm_Sent_Subject" xml:space="preserve">
|
||||
<value>[[OrganizationName]] Comms transmitted: [GeographyName]</value>
|
||||
|
||||
Reference in New Issue
Block a user