Commit 3e9321c

mo khan <mo@mokhan.ca>
2010-07-09 23:05:05
created startup command to ensure application data directory exisits.
1 parent 4712931
product/client/presentation.windows/bootstrappers/StartServiceBus.cs
@@ -1,6 +1,7 @@
 using Gorilla.Commons.Infrastructure.Container;
 using MoMoney.Service.Infrastructure.Threading;
 using presentation.windows.common;
+using presentation.windows.common.messages;
 
 namespace presentation.windows.bootstrappers
 {
@@ -16,7 +17,7 @@ namespace presentation.windows.bootstrappers
                 handler.handler(x);
             });
             Resolve.the<CommandProcessor>().add(receiver);
-            //Resolve.the<ServiceBus>().publish<StartedApplication>(x => x.message = "client");
+            Resolve.the<ServiceBus>().publish<StartedApplication>(x => x.message = "client");
         }
     }
 }
\ No newline at end of file
product/client/presentation.windows/Program.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Diagnostics;
+using System.IO;
 using System.Security.Principal;
 using System.Windows;
 using System.Windows.Threading;
@@ -13,7 +14,7 @@ namespace presentation.windows
         [STAThread]
         static public void Main()
         {
-            Process.Start(@"D:\development\mokhan\git\mo.money\product\presentation.windows.server\bin\Debug\presentation.windows.server.exe");
+            Process.Start(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\..\presentation.windows.server\bin\Debug\presentation.windows.server.exe")));
             AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
             Dispatcher.CurrentDispatcher.UnhandledException += (o, e) =>
             {
product/presentation.windows.server/Bootstrapper.cs
@@ -26,6 +26,8 @@ namespace presentation.windows.server
     {
         static public void run()
         {
+            new ConfigureApplicationDirectory().run();
+
             var builder = new ContainerBuilder();
             var registry = new AutofacDependencyRegistryBuilder(builder).build();
             Resolve.initialize_with(registry);
@@ -52,7 +54,8 @@ namespace presentation.windows.server
 
             // commanding
             //builder.Register<ContainerCommandBuilder>().As<CommandBuilder>().SingletonScoped();
-            builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
+            //builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
+            builder.Register<SynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
             builder.Register<AddNewFamilyMemberHandler>().As<Handler>();
             builder.Register<FindAllFamilyHandler>().As<Handler>();
             builder.Register<SaveNewAccountCommand>().As<Handler>();
product/presentation.windows.server/ConfigureApplicationDirectory.cs
@@ -0,0 +1,21 @@
+using System;
+using System.IO;
+using gorilla.commons.utility;
+
+namespace presentation.windows.server
+{
+    public class ConfigureApplicationDirectory : Command
+    {
+        public void run()
+        {
+            var company_directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"mokhan.ca");
+            ensure_exisits(company_directory);
+            ensure_exisits(Path.Combine(company_directory, "momoney"));
+        }
+
+        void ensure_exisits(string directory)
+        {
+            if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
+        }
+    }
+}
\ No newline at end of file
product/presentation.windows.server/presentation.windows.server.csproj
@@ -110,6 +110,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ConfigureApplicationDirectory.cs" />
     <Compile Include="handlers\AddNewFamilyMemberHandler.cs" />
     <Compile Include="Bootstrapper.cs" />
     <Compile Include="ConfigureMappings.cs" />
product/presentation.windows.server/StartServiceBus.cs
@@ -22,7 +22,7 @@ namespace presentation.windows.server
             });
             Resolve.the<CommandProcessor>().add(receiver);
             //ThreadPool.QueueUserWorkItem(x => receiver.run());
-            Resolve.the<ServiceBus>().publish<StartedApplication>(x => x.message = "server");
+            //Resolve.the<ServiceBus>().publish<StartedApplication>(x => x.message = "server");
         }
     }
 }
\ No newline at end of file