From 7d46e59222a274e55f8247d04c81eb5e6d5e2711 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 6 Jul 2013 14:10:59 +0000 Subject: [PATCH] Added Resolved=true to OutboundComm.CreateNotification --- Database/Database-OutboundComms.cs | 22 +++++++++++++++++++--- Logic/Communications/OutboundComm.cs | 17 +++++++++++++++++ Site5/Master-v5.master.cs | 1 - 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Database/Database-OutboundComms.cs b/Database/Database-OutboundComms.cs index f86a3246..e8d0d2d6 100644 --- a/Database/Database-OutboundComms.cs +++ b/Database/Database-OutboundComms.cs @@ -214,17 +214,33 @@ namespace Swarmops.Database AddParameterWithName(command, "senderPersonId", senderPersonId); AddParameterWithName(command, "fromPersonId", fromPersonId); AddParameterWithName(command, "organizationId", organizationId); - AddParameterWithName(command, "resolverClass", String.IsNullOrEmpty(resolverClass)? "0": resolverClass); // Will be turned into ID by stored procedure - AddParameterWithName(command, "recipientDataXml", String.IsNullOrEmpty(recipientDataXml)? string.Empty: recipientDataXml); + AddParameterWithName(command, "resolverClass", String.IsNullOrEmpty(resolverClass) ? "0" : resolverClass); // Will be turned into ID by stored procedure + AddParameterWithName(command, "recipientDataXml", String.IsNullOrEmpty(recipientDataXml) ? string.Empty : recipientDataXml); AddParameterWithName(command, "transmitterClass", transmitterClass); // Will be turned into ID by stored procedure AddParameterWithName(command, "payloadXml", payloadXml); - AddParameterWithName(command, "priority", (int) priority); // convert enum to integerized priority; convert back on field read + AddParameterWithName(command, "priority", (int)priority); // convert enum to integerized priority; convert back on field read AddParameterWithName(command, "createdDateTime", DateTime.UtcNow); return Convert.ToInt32(command.ExecuteScalar()); } } + public void SetOutboundCommResolved(int outboundCommId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetOutboundCommResolved", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "outboundCommId", outboundCommId); + AddParameterWithName(command, "dateTime", DateTime.UtcNow); + + command.ExecuteNonQuery(); + } + } + #endregion diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs index ac259aef..e6ca0085 100644 --- a/Logic/Communications/OutboundComm.cs +++ b/Logic/Communications/OutboundComm.cs @@ -95,6 +95,23 @@ namespace Swarmops.Logic.Communications // public static OutboundComm CreateNotification (FinancialAccount budget, string notificationResource) + public new bool Resolved + { + get { return base.Resolved; } + set + { + if (!base.Resolved && value == true) + { + SwarmDb.GetDatabaseForWriting().SetOutboundCommResolved(this.Identity); + base.Resolved = true; + } + else + { + throw new InvalidOperationException("Can only set OutboundComms.Resolved from false to true"); + } + } + } + public void AddRecipient (Person person) { diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs index 27cafca9..3d66691f 100644 --- a/Site5/Master-v5.master.cs +++ b/Site5/Master-v5.master.cs @@ -37,7 +37,6 @@ namespace Swarmops _authority = _currentUser.GetAuthority(); _currentOrganization = Organization.FromIdentity(currentOrganizationId); - // OutboundComm.CreateNotification(null, NotificationResource.System_Startup); } protected void Page_Load(object sender, EventArgs e)