Commit 10f503c

mo <email@solidware.ca>
2011-03-20 03:48:53
hooked up the DB4O startup.
1 parent 1d6aa4f
product/desktop.ui/bootstrappers/Bootstrapper.cs
@@ -8,6 +8,7 @@ using gorilla.utility;
 using solidware.financials.infrastructure;
 using solidware.financials.infrastructure.eventing;
 using solidware.financials.messages;
+using solidware.financials.service;
 using solidware.financials.service.handlers;
 using solidware.financials.service.orm;
 using solidware.financials.windows.ui.handlers;
@@ -55,6 +56,7 @@ namespace solidware.financials.windows.ui.bootstrappers
             builder.RegisterType<ComposeShell>().As<NeedStartup>();
             builder.RegisterType<ConfigureMappings>().As<NeedStartup>();
             builder.RegisterType<WireUpSubscribers>().As<NeedStartup>();
+            new DB4OBootstrapper().run();
         }
 
         static void register_presentation_infrastructure(ContainerBuilder builder)
product/desktop.ui/Properties/AssemblyInfo.cs
@@ -49,5 +49,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2011.3.18.1348")]
-[assembly: AssemblyFileVersion("2011.3.18.1348")]
+[assembly: AssemblyVersion("2011.3.19.2146")]
+[assembly: AssemblyFileVersion("2011.3.19.2146")]
product/desktop.ui/app.config.template
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <appSettings>
+    <add key="reset.db" value="false"/>
+  </appSettings>
+</configuration>
\ No newline at end of file
product/desktop.ui/solidware.financials.csproj
@@ -15,6 +15,7 @@
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
     <PublishUrl>publish\</PublishUrl>
     <Install>true</Install>
     <InstallFrom>Disk</InstallFrom>
@@ -27,7 +28,6 @@
     <MapFileExtensions>true</MapFileExtensions>
     <ApplicationRevision>0</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
@@ -176,6 +176,8 @@
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
+    <None Include="app.config" />
+    <None Include="app.config.template" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
product/service/orm/DB4ODatabase.cs
@@ -13,7 +13,6 @@ namespace solidware.financials.service.orm
         public DB4ODatabase(IObjectContainer session)
         {
             this.session = session;
-            using (var embeddedObjectContainer = Db4oEmbedded.OpenFile("c:/tmp")) { }
         }
 
         public void save(Person person)
product/service/orm/LastOpened.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace solidware.financials.service.orm
+{
+    public class LastOpened
+    {
+        public DateTime Now { get; private set; }
+
+        public LastOpened(DateTime now)
+        {
+            Now = now;
+        }
+    }
+}
\ No newline at end of file
product/service/DB4OBootstrapper.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Configuration;
+using System.IO;
+using Db4objects.Db4o;
+using gorilla.utility;
+using solidware.financials.service.orm;
+
+namespace solidware.financials.service
+{
+    public class DB4OBootstrapper : Command
+    {
+        string database_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
+                                            @"mokhan.ca\momoney\default.db4o");
+
+        Settings settings = new Settings(ConfigurationManager.AppSettings);
+
+        public void run()
+        {
+            if (settings.named<bool>("reset.db"))
+                if (File.Exists(database_path)) File.Delete(database_path);
+
+            ensure_directories_exist();
+
+            using (var database = Db4oEmbedded.OpenFile(database_path))
+            {
+                database.Store(new LastOpened(Clock.now()));
+            }
+        }
+
+        void ensure_directories_exist()
+        {
+            var company_dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"mokhan.ca");
+            if (!Directory.Exists(company_dir))
+                Directory.CreateDirectory(company_dir);
+
+            var application_dir = Path.Combine(company_dir, "momoney");
+            if (!Directory.Exists(application_dir))
+                Directory.CreateDirectory(application_dir);
+        }
+    }
+}
\ No newline at end of file
product/service/service.csproj
@@ -41,6 +41,7 @@
       <HintPath>..\..\thirdparty\commons\gorilla.utility.dll</HintPath>
     </Reference>
     <Reference Include="System" />
+    <Reference Include="System.configuration" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
@@ -49,6 +50,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="DB4OBootstrapper.cs" />
     <Compile Include="handlers\AddIncomeCommandMessageHandler.cs" />
     <Compile Include="handlers\AddNewFamilyMemberHandler.cs" />
     <Compile Include="domain\Entity.cs" />
@@ -56,6 +58,7 @@
     <Compile Include="handlers\FindAllFamilyHandler.cs" />
     <Compile Include="orm\DB4ODatabase.cs" />
     <Compile Include="orm\InMemoryDatabase.cs" />
+    <Compile Include="orm\LastOpened.cs" />
     <Compile Include="orm\PersonRepository.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
product/specs/specs.csproj
@@ -33,7 +33,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="gorilla.utility, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
+    <Reference Include="gorilla.utility, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\thirdparty\commons\gorilla.utility.dll</HintPath>
+    </Reference>
     <Reference Include="Machine.Specifications">
       <HintPath>..\..\thirdparty\mspec\Machine.Specifications.dll</HintPath>
     </Reference>
support/default.build
@@ -86,6 +86,8 @@
   <target name="create.configs">
     <property name="target" value="${src.dir}/desktop.ui/Properties/AssemblyInfo.cs" />
     <call target="expand.template.file" />
+    <property name="target" value="${src.dir}/desktop.ui/app.config" />
+    <call target="expand.template.file" />
   </target>
 
   <target name="run" depends="compile">
thirdparty/commons/gorilla.infrastructure.dll
Binary file
thirdparty/commons/gorilla.utility.dll
Binary file
.gitignore
@@ -8,3 +8,5 @@ _build.log
 tmp
 local.properties.xml
 %APPDATA%
+app.config
+*.stackdump