diff --git a/Backend/Program.cs b/Backend/Program.cs index a1bde388..0fb46f36 100644 --- a/Backend/Program.cs +++ b/Backend/Program.cs @@ -82,6 +82,29 @@ namespace Swarmops.Backend OutboundComm.CreateNotification(null, NotificationResource.System_Startup); + Console.WriteLine("Transmitting..."); + + OutboundComms comms = OutboundComms.GetOpen(); + + foreach (OutboundComm comm in comms) + { + if (comm.TransmitterClass != "Swarmops.Utility.Communications.CommsTransmitterMail") + { + throw new NotImplementedException(); + } + + ICommsTransmitter transmitter = new Swarmops.Utility.Communications.CommsTransmitterMail(); + + OutboundCommRecipients recipients = comm.Recipients; + PayloadEnvelope envelope = PayloadEnvelope.FromXml(comm.PayloadXml); + + foreach (OutboundCommRecipient recipient in recipients) + { + transmitter.Transmit(envelope, recipient.Person); + } + } + + Console.Write("\r\nAll tests run. Waiting for mail queue to flush... "); while (!MailTransmitter.CanExit) { diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs index 5ac4e901..5a736a57 100644 --- a/Logic/Communications/OutboundComm.cs +++ b/Logic/Communications/OutboundComm.cs @@ -123,6 +123,11 @@ namespace Swarmops.Logic.Communications SwarmDb.GetDatabaseForWriting().CreateOutboundCommRecipient(this.Identity, person.Identity); } + public OutboundCommRecipients Recipients + { + get { return OutboundCommRecipients.ForOutboundComm(this); } + } + } public enum CommResolverClass diff --git a/Logic/Communications/OutboundCommRecipient.cs b/Logic/Communications/OutboundCommRecipient.cs index 94d92d61..1b313ef3 100644 --- a/Logic/Communications/OutboundCommRecipient.cs +++ b/Logic/Communications/OutboundCommRecipient.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Swarmops.Basic.Types.Communications; +using Swarmops.Logic.Swarm; namespace Swarmops.Logic.Communications { @@ -12,5 +13,17 @@ namespace Swarmops.Logic.Communications { // private ctor } + + public static OutboundCommRecipient FromBasic (BasicOutboundCommRecipient basic) + { + return new OutboundCommRecipient(basic); + } + + public Person Person + { + get { return Person.FromIdentity(base.PersonId); } + } + + // TODO: CloseSuccess, CloseFail } } diff --git a/Logic/Communications/OutboundCommRecipients.cs b/Logic/Communications/OutboundCommRecipients.cs index 4f654935..434db6c6 100644 --- a/Logic/Communications/OutboundCommRecipients.cs +++ b/Logic/Communications/OutboundCommRecipients.cs @@ -3,12 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Swarmops.Basic.Types.Communications; +using Swarmops.Database; using Swarmops.Logic.Support; namespace Swarmops.Logic.Communications { public class OutboundCommRecipients: PluralBase { - + public static OutboundCommRecipients ForOutboundComm (OutboundComm comm) + { + return FromArray(SwarmDb.GetDatabaseForReading().GetOutboundCommRecipients(comm)); + } } } diff --git a/Logic/Communications/OutboundComms.cs b/Logic/Communications/OutboundComms.cs index a1dde520..afd6273e 100644 --- a/Logic/Communications/OutboundComms.cs +++ b/Logic/Communications/OutboundComms.cs @@ -3,11 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Swarmops.Basic.Types.Communications; +using Swarmops.Database; using Swarmops.Logic.Support; namespace Swarmops.Logic.Communications { public class OutboundComms: PluralBase { + public static OutboundComms GetOpen() + { + return FromArray(SwarmDb.GetDatabaseForReading().GetOutboundComms(DatabaseCondition.OpenTrue)); + } } } diff --git a/Logic/Communications/Transmission/PayloadBase.cs b/Logic/Communications/Transmission/PayloadBase.cs index cfc0cc54..aa1fa74f 100644 --- a/Logic/Communications/Transmission/PayloadBase.cs +++ b/Logic/Communications/Transmission/PayloadBase.cs @@ -18,7 +18,7 @@ namespace Swarmops.Logic.Communications.Transmission serializer.Serialize(stream, this); byte[] xmlBytes = stream.GetBuffer(); - return Encoding.Default.GetString(xmlBytes); + return Encoding.UTF8.GetString(xmlBytes); } public static T FromXml (string xml) @@ -26,7 +26,7 @@ namespace Swarmops.Logic.Communications.Transmission var serializer = new XmlSerializer(typeof(T)); var stream = new MemoryStream(); - byte[] xmlBytes = Encoding.Default.GetBytes(xml); + byte[] xmlBytes = Encoding.UTF8.GetBytes(xml); stream.Write(xmlBytes, 0, xmlBytes.Length); stream.Position = 0; diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 267908e9..a8e7f271 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -234,11 +234,6 @@ True Swarmops.Logic.Localizations.resx - - True - True - SwarmopsLogicLoc.resx - @@ -308,10 +303,6 @@ ResXFileCodeGenerator Swarmops.Logic.Localizations.Designer.cs - - ResXFileCodeGenerator - SwarmopsLogicLoc.Designer.cs - \ No newline at end of file diff --git a/Logic/Support/SerializableDictionary.cs b/Logic/Support/SerializableDictionary.cs index 75ec2cc1..ff064af9 100644 --- a/Logic/Support/SerializableDictionary.cs +++ b/Logic/Support/SerializableDictionary.cs @@ -6,7 +6,7 @@ using System.Xml.Serialization; namespace Swarmops.Logic.Support { - // Code from Paul Welter's Weblog at http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx -- assumed by style, writing and tone to be in public domain + // Code from Paul Welter's Weblog at http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx -- assumed by style, writing and tone of Q&A to be in public domain [XmlRoot("dictionary")] public class SerializableDictionary diff --git a/Logic/Support/SingularFactory.cs b/Logic/Support/SingularFactory.cs index 62bbe8c3..764730fe 100644 --- a/Logic/Support/SingularFactory.cs +++ b/Logic/Support/SingularFactory.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using Swarmops.Basic.Types.Communications; using Swarmops.Basic.Types.Financial; using Swarmops.Logic.Communications; using Swarmops.Logic.Financial; @@ -34,6 +35,12 @@ namespace Swarmops.Logic.Support case "Swarmops.Basic.Types.BasicCommunicationTurnaround": return CommunicationTurnaround.FromBasic((BasicCommunicationTurnaround)basic); + case "Swarmops.Basic.Types.Communications.BasicOutboundComm": + return OutboundComm.FromBasic((BasicOutboundComm)basic); + + case "Swarmops.Basic.Types.Communications.BasicOutboundCommRecipient": + return OutboundCommRecipient.FromBasic((BasicOutboundCommRecipient)basic); + // ----------- FINANCIAL CLASSES ---------- diff --git a/Logic/SwarmopsLogicLoc.Designer.cs b/Logic/SwarmopsLogicLoc.Designer.cs deleted file mode 100644 index 63d0ee60..00000000 --- a/Logic/SwarmopsLogicLoc.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.296 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Swarmops.Logic { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SwarmopsLogicLoc { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SwarmopsLogicLoc() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.SwarmopsLogicLoc", typeof(SwarmopsLogicLoc).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Test2. - /// - internal static string Test { - get { - return ResourceManager.GetString("Test", resourceCulture); - } - } - } -} diff --git a/Logic/SwarmopsLogicLoc.resx b/Logic/SwarmopsLogicLoc.resx deleted file mode 100644 index df7a81ea..00000000 --- a/Logic/SwarmopsLogicLoc.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Test2 - - \ No newline at end of file diff --git a/Site5-Deployment/Site5-Deployment.wdproj b/Site5-Deployment/Site5-Deployment.wdproj index 18b8bb20..081c2d01 100644 --- a/Site5-Deployment/Site5-Deployment.wdproj +++ b/Site5-Deployment/Site5-Deployment.wdproj @@ -49,6 +49,10 @@ {13E59551-34AC-43DC-9A03-EF5E4721DC61} Logic + + {C540570C-20E0-4979-84EB-8833810DDDF6} + Utility +