Minor improvements

This commit is contained in:
Rick Falkvinge
2017-01-04 01:50:26 +01:00
parent 5fa0f8548c
commit 2001df5853
2 changed files with 12 additions and 11 deletions
+9 -5
View File
@@ -42,7 +42,7 @@ namespace Swarmops.Backend
customStrings["RecipientCount"] = comm.Recipients.Count.ToString("N0");
if (resolver is IHasGeography)
{
customStrings["GeographyName"] = ((IHasGeography) resolver).Geography.Name;
customStrings["GeographyName"] = ((IHasGeography) resolver).Geography.Localized;
}
OutboundComm.CreateNotification(Organization.FromIdentity(comm.OrganizationId),
NotificationResource.OutboundComm_Resolved, notifyStrings, customStrings,
@@ -66,6 +66,8 @@ namespace Swarmops.Backend
BotLog.Write(2, "CommsTx", "--transmitting to " + recipients.Count.ToString("N0") + " recipients");
comm.StartTransmission();
int success = 0;
int fail = 0;
foreach (OutboundCommRecipient recipient in recipients)
{
@@ -73,10 +75,12 @@ namespace Swarmops.Backend
{
transmitter.Transmit (envelope, recipient.Person);
recipient.CloseSuccess();
success++;
}
catch (OutboundCommTransmitException e)
{
recipient.CloseFailed (e.Description);
fail++;
}
}
@@ -84,7 +88,7 @@ namespace Swarmops.Backend
BotLog.Write(2, "CommsTx", "--closing");
if (comm.RecipientsFail + comm.RecipientsSuccess > 1)
if (success + fail > 1)
{
BotLog.Write(2, "CommsTx", "--notifying");
@@ -97,13 +101,13 @@ namespace Swarmops.Backend
NotificationStrings notifyStrings = new NotificationStrings();
NotificationCustomStrings customStrings = new NotificationCustomStrings();
notifyStrings[NotificationString.OrganizationName] = Organization.FromIdentity(comm.OrganizationId).Name;
customStrings["RecipientCount"] = comm.Recipients.Count.ToString("N0");
customStrings["RecipientsSuccess"] = comm.RecipientsSuccess.ToString("N0");
customStrings["RecipientCount"] = recipients.Count.ToString("N0");
customStrings["RecipientsSuccess"] = success.ToString("N0");
customStrings["TransmissionTime"] =
(comm.ClosedDateTime - comm.StartTransmitDateTime).ToString("m min ss.ff sec");
if (resolver is IHasGeography)
{
customStrings["GeographyName"] = ((IHasGeography)resolver).Geography.Name;
customStrings["GeographyName"] = ((IHasGeography)resolver).Geography.Localized;
}
OutboundComm.CreateNotification(Organization.FromIdentity(comm.OrganizationId),
NotificationResource.OutboundComm_Sent, notifyStrings, customStrings,
+3 -6
View File
@@ -111,13 +111,10 @@ namespace Swarmops.Frontend.Pages.Comms
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox))
if (PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox) && authData.CurrentUser.Identity == 1 && !live)
{
if (authData.CurrentUser.Identity == 1)
{
OutboundComm.CreateSandboxMail(subject, body, dummyMail);
return new AjaxCallResult {Success = true};
}
OutboundComm.CreateSandboxMail(subject, body, dummyMail);
return new AjaxCallResult {Success = true};
return new AjaxCallResult {Success = false}; // wtf, this shouldn't happen
}