From 4fc87c97834ac499a25e211ae9d6f707bfd5071c Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 15 Jun 2013 23:20:04 +0000 Subject: [PATCH] Committing work at EOD --- Basic/Basic.csproj | 4 +-- Console/Console.cs | 14 +++++--- Console/Console.csproj | 7 ++-- Database/Configuration.cs | 30 +++++++++++----- Database/Database.csproj | 4 +-- Interface/Interface.csproj | 4 +-- .../Transmission/NotificationPayload.cs | 35 +++++++++++++++++-- Logic/Logic.csproj | 4 +-- Site5-Deployment/Site5-Deployment.wdproj | 4 +-- Site5/Master-v5.master.cs | 5 +++ Site5/Pages/v5/Init/Default.aspx | 2 +- Swarmops.sln | 2 +- Utility/Utility.csproj | 4 +-- 13 files changed, 88 insertions(+), 31 deletions(-) diff --git a/Basic/Basic.csproj b/Basic/Basic.csproj index 0e5f686d..7ccd3123 100644 --- a/Basic/Basic.csproj +++ b/Basic/Basic.csproj @@ -29,7 +29,7 @@ 4 prompt Library - Activizr.Basic + Swarmops.Basic ../Site/bin/ @@ -42,7 +42,7 @@ 4 prompt Library - Activizr.Basic + Swarmops.Basic diff --git a/Console/Console.cs b/Console/Console.cs index 863396c6..96726aa4 100644 --- a/Console/Console.cs +++ b/Console/Console.cs @@ -10,6 +10,8 @@ using System.Web; using System.Web.Mail; using Swarmops.Basic.Enums; using Swarmops.Basic; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Communications.Transmission; using Swarmops.Logic.Financial; using Swarmops.Logic.Swarm; using Swarmops.Logic.Structure; @@ -53,6 +55,8 @@ namespace Swarmops // Utility.BotCode.EventProcessor.Run(); + OutboundComm.CreateNotification(null, NotificationResource.System_Startup); + Console.WriteLine(string.Empty); Console.Write("Waiting for mail queue to flush... "); @@ -1174,6 +1178,7 @@ namespace Swarmops static void PopulateCountries() { + /* SwarmDb database = SwarmDb.GetDatabase(); using (StreamReader reader = new StreamReader("C:\\Countries.txt")) @@ -1190,7 +1195,7 @@ namespace Swarmops line = reader.ReadLine(); } - } + }*/ } static void InviteManyNodesToUP(int[] nodeIds, int organizationId) @@ -1285,6 +1290,7 @@ namespace Swarmops static void SendNewsletter() { + /* SwarmDb database = SwarmDb.GetDatabase(); int[] subscriberIds = database.GetSubscribersForNewsletterFeed(2); @@ -1296,11 +1302,11 @@ namespace Swarmops @"H:\Data\Piratpartiet\MailTemplates\PP-Newsletter\Template.txt", subscribers). Send(); - return; + return;*/ } static void ImportReporters() - { + {/* string fileName = @"C:\Documents and Settings\rick\Desktop\reportrar.txt"; SwarmDb database = SwarmDb.GetDatabase(); @@ -1330,7 +1336,7 @@ namespace Swarmops } } } - + */ } /* diff --git a/Console/Console.csproj b/Console/Console.csproj index a17456a7..eab07f9f 100644 --- a/Console/Console.csproj +++ b/Console/Console.csproj @@ -31,7 +31,7 @@ 4 prompt Exe - Activizr.Console + Swarmops.Console ./App.ico @@ -45,9 +45,12 @@ 4 prompt Exe - Activizr.Console + Swarmops.Console ./App.ico + + Swarmops.BotConsole + diff --git a/Database/Configuration.cs b/Database/Configuration.cs index 28d8b0a8..be3405a0 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -82,7 +82,9 @@ namespace Swarmops.Database { XmlSerializer serializer = new XmlSerializer(typeof(Configuration)); - using (FileStream readFileStream = new FileStream(GetConfigurationFileName(), FileMode.Open, FileAccess.Read, FileShare.Read)) + string configFileName = GetConfigurationFileName(); + + using (FileStream readFileStream = new FileStream(configFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { _configuration = (Configuration) serializer.Deserialize(readFileStream); @@ -103,21 +105,31 @@ namespace Swarmops.Database public static string GetConfigurationFileName() { - // If we're running in a HTTP context on Windows, use the path mapper, as we're in a web process. - // Otherwise, use a relative path from the binary. + // Four possibilities here. Debug environment on Windows (dev), Console environment on Windows (dev), + // Console/daemon production environment and web production environment. - if (HttpContext.Current != null && Path.DirectorySeparatorChar != '/') - { - // Web process, so use MapPath + // In both production environments, we should use /etc/swarmops/database.config. + // In dev Web, we should use ~/database.config. + // In dev console, we should use database.config. - return HttpContext.Current.Server.MapPath("~/database.config"); - } - else + if (Path.DirectorySeparatorChar == '/') { // Production process - just use the simple filename return "/etc/swarmops/database.config"; } + else if (HttpContext.Current != null) + { + // Dev web process + + return HttpContext.Current.Server.MapPath ("~/database.config"); + } + else + { + // Dev console process + + return "database.config"; // Each dev needs to set the working directory to the Console directory when debugging + } } } diff --git a/Database/Database.csproj b/Database/Database.csproj index 77ebca8b..6731fe25 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -29,7 +29,7 @@ 4 prompt Library - Activizr.Database + Swarmops.Database ../Site/bin/ @@ -42,7 +42,7 @@ 4 prompt Library - Activizr.Database + Swarmops.Database diff --git a/Interface/Interface.csproj b/Interface/Interface.csproj index e3172e75..5ee3f5e7 100644 --- a/Interface/Interface.csproj +++ b/Interface/Interface.csproj @@ -29,7 +29,7 @@ 4 prompt Library - Activizr.Interface + Swarmops.Interface ../Site/bin/ @@ -42,7 +42,7 @@ 4 prompt Library - Activizr.Interface + Swarmops.Interface diff --git a/Logic/Communications/Transmission/NotificationPayload.cs b/Logic/Communications/Transmission/NotificationPayload.cs index a3612006..284acc8d 100644 --- a/Logic/Communications/Transmission/NotificationPayload.cs +++ b/Logic/Communications/Transmission/NotificationPayload.cs @@ -11,19 +11,27 @@ namespace Swarmops.Logic.Communications.Transmission [Serializable] public class NotificationPayload: PayloadBase, ICommsRenderer { + [Obsolete("Do not use this direct constructor. It is intended for XML serialization only. Therefore, you're getting a compile-time error.", true)] public NotificationPayload() { - // empty ctor, for XML reflection + // empty ctor, for XML reflection. Do not use. } - public NotificationPayload (string notificationResource) + public NotificationPayload(string notificationResource): this (notificationResource, new NotificationStrings()) + { + // redirect to main ctor + } + + public NotificationPayload (string notificationResource, NotificationStrings strings) { this.SubjectResource = "Notifications_" + notificationResource + "_Subject"; this.BodyResource = "Notifications_" + notificationResource + "_Body"; + this.Strings = strings; } public string SubjectResource { get; set; } public string BodyResource { get; set; } + public NotificationStrings Strings { get; set; } public string GetSubject() { @@ -73,4 +81,27 @@ namespace Swarmops.Logic.Communications.Transmission } // ReSharper restore InconsistentNaming + + public enum NotificationString + { + Unknown=0, + ConcernedPersonName, + ActingPersonName, + TertiaryPersonName, + OrganizationName, + DateTime, + DateTimeExpiry, + BudgetName, + BudgetAmountFloat, + EmbeddedPreformattedList, + HostName, + SwarmopsVersion + } + + [Serializable] + public class NotificationStrings: Dictionary + { + // typeset + } + } diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 732a8573..18cfffbd 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -29,7 +29,7 @@ 4 prompt Library - Activizr.Logic + Swarmops.Logic ../Site/bin/ @@ -42,7 +42,7 @@ 4 prompt Library - Activizr.Logic + Swarmops.Logic diff --git a/Site5-Deployment/Site5-Deployment.wdproj b/Site5-Deployment/Site5-Deployment.wdproj index 28c5519f..18b8bb20 100644 --- a/Site5-Deployment/Site5-Deployment.wdproj +++ b/Site5-Deployment/Site5-Deployment.wdproj @@ -21,14 +21,14 @@ .\Debug true true - Site5-Deployment + Swarmops.Site false .\Release true true - Activizr.Site + Swarmops.Site true true diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs index 79713fc8..26365e8a 100644 --- a/Site5/Master-v5.master.cs +++ b/Site5/Master-v5.master.cs @@ -12,6 +12,8 @@ using Swarmops.Logic.Security; using Swarmops.Logic.Structure; using Telerik.Web.UI; using Membership = Swarmops.Logic.Swarm.Membership; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Communications.Transmission; namespace Swarmops { @@ -34,6 +36,9 @@ namespace Swarmops _currentUser = Person.FromIdentity(currentUserId); _authority = _currentUser.GetAuthority(); _currentOrganization = Organization.FromIdentity(currentOrganizationId); + + OutboundComm.CreateNotification(null, NotificationResource.System_Startup); + } protected void Page_Load(object sender, EventArgs e) diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index a41b1327..34d0cbfe 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -380,7 +380,7 @@ - + diff --git a/Swarmops.sln b/Swarmops.sln index 99a968b5..05da7243 100644 --- a/Swarmops.sln +++ b/Swarmops.sln @@ -17,7 +17,7 @@ EndProject Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Site5", "Site5\", "{367F36EA-AE1C-4E15-BAF9-BA75B18B3807}" ProjectSection(WebsiteProperties) = preProject TargetFrameworkMoniker = ".NETFramework,Version%3Dv3.5" - ProjectReferences = "{3A5B5F19-51A5-48CE-A82E-97D5C189E5CB}|Activizr.Database.dll;{6608C2E6-F841-4CD1-8AB2-28DC3B1DDDD1}|Activizr.Basic.dll;{13E59551-34AC-43DC-9A03-EF5E4721DC61}|Activizr.Logic.dll;{BA24FAF7-D518-49E8-952A-45595682877E}|Activizr.Interface.dll;" + ProjectReferences = "{3A5B5F19-51A5-48CE-A82E-97D5C189E5CB}|Swarmops.Database.dll;{6608C2E6-F841-4CD1-8AB2-28DC3B1DDDD1}|Swarmops.Basic.dll;{13E59551-34AC-43DC-9A03-EF5E4721DC61}|Swarmops.Logic.dll;{BA24FAF7-D518-49E8-952A-45595682877E}|Swarmops.Interface.dll;" Debug.AspNetCompiler.VirtualPath = "/Site5" Debug.AspNetCompiler.PhysicalPath = "Site5\" Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\Site5\" diff --git a/Utility/Utility.csproj b/Utility/Utility.csproj index 1d4fa86c..4ff1691b 100644 --- a/Utility/Utility.csproj +++ b/Utility/Utility.csproj @@ -29,7 +29,7 @@ 4 prompt Library - Activizr.Utility + Swarmops.Utility ../Site/bin/ @@ -42,7 +42,7 @@ 4 prompt Library - Activizr.Utility + Swarmops.Utility