Commit dd4aa5d
Changed files (66)
product
client
presentation.windows
bootstrappers
commands
orm
mappings
presenters
service
views
presentation.windows.common
presentation.windows.server
domain
orm
product/client/presentation.windows/bootstrappers/Bootstrapper.cs
@@ -1,34 +1,20 @@
using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
using System.Threading;
using System.Windows.Threading;
using Autofac.Builder;
-using FluentNHibernate.Cfg;
-using FluentNHibernate.Cfg.Db;
using Gorilla.Commons.Infrastructure.Container;
using Gorilla.Commons.Infrastructure.Logging;
using gorilla.commons.infrastructure.thirdparty.Autofac;
using gorilla.commons.infrastructure.thirdparty.Log4Net;
using gorilla.commons.utility;
-using momoney.database.transactions;
using MoMoney.Service.Infrastructure.Eventing;
using MoMoney.Service.Infrastructure.Threading;
-using momoney.service.infrastructure.transactions;
-using NHibernate.ByteCode.Castle;
-using NHibernate.Cfg;
-using NHibernate.Tool.hbm2ddl;
-using presentation.windows.commands;
-using presentation.windows.infrastructure;
-using presentation.windows.orm;
-using presentation.windows.orm.mappings;
-using presentation.windows.orm.nhibernate;
+using presentation.windows.common;
+using presentation.windows.common.messages;
using presentation.windows.presenters;
using presentation.windows.queries;
+using presentation.windows.service.infrastructure;
using presentation.windows.views;
-using Environment = System.Environment;
-using ISession = NHibernate.ISession;
-using ISessionFactory = NHibernate.ISessionFactory;
namespace presentation.windows.bootstrappers
{
@@ -50,12 +36,6 @@ namespace presentation.windows.bootstrappers
builder.Register<Log4NetLogFactory>().As<LogFactory>().SingletonScoped();
builder.Register<DefaultMapper>().As<Mapper>().SingletonScoped();
- var session_factory = bootstrap_nhibernate();
- builder.Register(x => session_factory).SingletonScoped();
- builder.Register(x => current_session(x));
- builder.Register<NHibernateUnitOfWorkFactory>().As<IUnitOfWorkFactory>();
- builder.Register(x => create_application_context()).SingletonScoped();
-
// presentation infrastructure
SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());
builder.Register<WpfApplicationController>().As<ApplicationController>().SingletonScoped();
@@ -69,72 +49,24 @@ namespace presentation.windows.bootstrappers
builder.Register<CompensationPresenter>().SingletonScoped();
builder.Register<SelectedFamilyMemberPresenter>().SingletonScoped();
builder.Register<AddFamilyMemberPresenter>();
+ builder.Register<AccountPresenter>();
builder.Register<SaveCommand>();
builder.Register<CancelCommand>();
// commanding
builder.Register<ContainerCommandBuilder>().As<CommandBuilder>().SingletonScoped();
builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
- builder.Register<AddFamilyMemberCommand>();
builder.Register<WpfCommandBuilder>().As<UICommandBuilder>();
// queries
- builder.Register<FindMemberIdentifiedBy>();
builder.Register<FindAllFamily>();
builder.Register<ContainerAwareQueryBuilder>().As<QueryBuilder>();
- // repositories
- builder.Register<NHibernatePersonRepository>().As<PersonRepository>().FactoryScoped();
-
Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
Resolve.the<CommandProcessor>().run();
- shell_window.Closed += (sender, args) => Resolve.the<CommandProcessor>().stop();
+ shell_window.Closed += (o, e) => Resolve.the<CommandProcessor>().stop();
return shell_window;
}
-
- static IContext create_application_context()
- {
- return new ContextFactory().create_for(new PerThreadScopedStorage(new CurrentThread()));
- }
-
- static ISession current_session(Autofac.IContext x)
- {
- var session = x.Resolve<IContext>().value_for(new TypedKey<ISession>());
- if (null == session) Debugger.Break();
- return session;
- }
-
- static ISessionFactory bootstrap_nhibernate()
- {
- var configuration = new Configuration();
- var database_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"mokhan.ca\momoney\default.db");
- var fluent_configuration = Fluently
- .Configure(configuration)
- .Database(SQLiteConfiguration.Standard
- .UsingFile(database_path)
- .AdoNetBatchSize(500)
- .ConnectionString(x => x.Is("Data Source={0};Version=3;New=True;".formatted_using(database_path)))
- .ShowSql()
- .ProxyFactoryFactory<ProxyFactoryFactory>()
- )
- .Mappings(x =>
- {
- x.FluentMappings.AddFromAssemblyOf<MappingAssembly>();
- })
- .ExposeConfiguration(x => export(x))
- ;
- return fluent_configuration.BuildSessionFactory();
- }
-
- static void export(Configuration configuration)
- {
- var database_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"mokhan.ca\momoney\default.db");
- if (File.Exists(database_path))
- {
- File.Delete(database_path);
- }
- new SchemaExport(configuration).Execute(true, true, false);
- }
}
}
\ No newline at end of file
product/client/presentation.windows/bootstrappers/ComposeShell.cs
@@ -1,4 +1,5 @@
using System.Windows.Controls;
+using presentation.windows.common;
using presentation.windows.presenters;
using presentation.windows.views;
@@ -18,6 +19,7 @@ namespace presentation.windows.bootstrappers
public void run()
{
controller.add_tab<CompensationPresenter, CompensationTab>();
+ controller.add_tab<AccountPresenter, AccountTab>();
region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Expenses"}));
region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "RRSP"}));
region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Party"}));
product/client/presentation.windows/bootstrappers/ConfigureMappings.cs
@@ -1,5 +1,6 @@
using AutoMapper;
-using presentation.windows.domain;
+using presentation.windows.common;
+using presentation.windows.common.messages;
using presentation.windows.queries;
namespace presentation.windows.bootstrappers
@@ -8,14 +9,16 @@ namespace presentation.windows.bootstrappers
{
public void run()
{
- Mapper
- .CreateMap<Person, PersonDetails>()
- .ConvertUsing(x => new PersonDetails
- {
- id = x.id,
- first_name = x.first_name,
- last_name = x.last_name,
- });
+ Mapper.CreateMap<AddedNewFamilyMember, PersonDetails>()
+ .ConvertUsing(x =>
+ {
+ return new PersonDetails
+ {
+ id = x.id,
+ first_name = x.first_name,
+ last_name = x.last_name,
+ };
+ });
}
}
}
\ No newline at end of file
product/client/presentation.windows/commands/AddFamilyMemberCommand.cs
@@ -1,37 +0,0 @@
-using gorilla.commons.utility;
-using MoMoney.Service.Infrastructure.Eventing;
-using presentation.windows.commands.dto;
-using presentation.windows.domain;
-using presentation.windows.events;
-using presentation.windows.orm;
-
-namespace presentation.windows.commands
-{
- public class AddFamilyMemberCommand : Command<FamilyMemberToAdd>
- {
- PersonRepository people;
- EventAggregator event_aggregator;
-
- public AddFamilyMemberCommand(PersonRepository people, EventAggregator event_aggregator)
- {
- this.people = people;
- this.event_aggregator = event_aggregator;
- }
-
- public void run_against(FamilyMemberToAdd item)
- {
- var person = Person.New(item.first_name, item.last_name, item.date_of_birth);
- people.save(person);
- event_aggregator.publish(new AddedNewFamilyMember
- {
- id = person.id,
- first_name = person.first_name,
- });
- }
-
- public override string ToString()
- {
- return "Adding Family Member";
- }
- }
-}
\ No newline at end of file
product/client/presentation.windows/orm/mappings/MappingAssembly.cs
@@ -1,4 +0,0 @@
-namespace presentation.windows.orm.mappings
-{
- public class MappingAssembly {}
-}
\ No newline at end of file
product/client/presentation.windows/presenters/AccountPresenter.cs
@@ -0,0 +1,41 @@
+using presentation.windows.views;
+
+namespace presentation.windows.presenters
+{
+ public class AccountPresenter : TabPresenter
+ {
+ UICommandBuilder ui_builder;
+
+ public AccountPresenter(UICommandBuilder ui_builder)
+ {
+ this.ui_builder = ui_builder;
+ }
+
+ public void present()
+ {
+ AddAccount = ui_builder.build<AddNewAccountCommand>(this);
+ }
+
+ public string Header
+ {
+ get { return "Accounts"; }
+ }
+
+ IObservableCommand AddAccount { get; set; }
+
+ public class AddNewAccountCommand : UICommand<AccountPresenter>
+ {
+ ApplicationController controller;
+
+ public AddNewAccountCommand(ApplicationController controller)
+ {
+ this.controller = controller;
+ }
+
+ protected override void run(AccountPresenter presenter)
+ {
+ controller.launch_dialog<AddNewAccountPresenter, AddNewAccountDialog>();
+ }
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/presenters/AddNewAccountPresenter.cs
@@ -0,0 +1,47 @@
+using System;
+using presentation.windows.common;
+
+namespace presentation.windows.presenters
+{
+ public class AddNewAccountPresenter : DialogPresenter
+ {
+ UICommandBuilder builder;
+
+ public AddNewAccountPresenter(UICommandBuilder builder)
+ {
+ this.builder = builder;
+ }
+
+ public void present()
+ {
+ Accept = builder.build<CreateNewAccount>(this);
+ Cancel = builder.build<CancelCommand>(this);
+ }
+
+ public string account_name { get; set; }
+ public string currency { get; set; }
+ public Action close { get; set; }
+ public IObservableCommand Accept { get; set; }
+ public IObservableCommand Cancel { get; set; }
+
+ public class CreateNewAccount : UICommand<AddNewAccountPresenter>
+ {
+ ServiceBus bus;
+
+ public CreateNewAccount(ServiceBus bus)
+ {
+ this.bus = bus;
+ }
+
+ protected override void run(AddNewAccountPresenter presenter)
+ {
+ bus.publish<common.messages.CreateNewAccount>(x =>
+ {
+ x.account_name = presenter.account_name;
+ x.currency = presenter.currency;
+ });
+ presenter.close();
+ }
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/presenters/SaveCommand.cs
@@ -1,31 +1,26 @@
-using MoMoney.Service.Infrastructure.Threading;
-using presentation.windows.commands;
-using presentation.windows.commands.dto;
+using presentation.windows.common;
+using presentation.windows.common.messages;
+using presentation.windows.service.infrastructure;
namespace presentation.windows.presenters
{
public class SaveCommand : UICommand<AddFamilyMemberPresenter>
{
- CommandBuilder command_builder;
- CommandProcessor processor;
+ ServiceBus bus;
- public SaveCommand(CommandBuilder command_builder, CommandProcessor processor)
+ public SaveCommand(ServiceBus bus)
{
- this.command_builder = command_builder;
- this.processor = processor;
+ this.bus = bus;
}
protected override void run(AddFamilyMemberPresenter presenter)
{
- processor.add(command_builder
- .prepare(new FamilyMemberToAdd
- {
- first_name = presenter.first_name,
- last_name = presenter.last_name,
- date_of_birth = presenter.date_of_birth
- })
- .build<AddFamilyMemberCommand>("Adding Family Member")
- );
+ bus.publish<FamilyMemberToAdd>(x =>
+ {
+ x.first_name = presenter.first_name;
+ x.last_name = presenter.last_name;
+ x.date_of_birth = presenter.date_of_birth;
+ });
presenter.close();
}
}
product/client/presentation.windows/presenters/SelectedFamilyMemberPresenter.cs
@@ -1,5 +1,9 @@
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using gorilla.commons.utility;
using MoMoney.Service.Infrastructure.Eventing;
+using presentation.windows.common;
+using presentation.windows.common.messages;
using presentation.windows.events;
using presentation.windows.queries;
@@ -8,13 +12,16 @@ namespace presentation.windows.presenters
public class SelectedFamilyMemberPresenter : Observable<SelectedFamilyMemberPresenter>, Presenter, EventSubscriber<AddedNewFamilyMember>
{
PersonDetails selected_member;
- QueryBuilder builder;
EventAggregator event_aggregator;
+ Mapper mapper;
+ ServiceBus bus;
- public SelectedFamilyMemberPresenter(QueryBuilder builder, EventAggregator event_aggregator)
+ public SelectedFamilyMemberPresenter(EventAggregator event_aggregator, Mapper mapper, ServiceBus bus)
{
- this.builder = builder;
+ this.bus = bus;
+ this.mapper = mapper;
this.event_aggregator = event_aggregator;
+ family_members = new ObservableCollection<PersonDetails>();
}
public ICollection<PersonDetails> family_members { get; set; }
@@ -32,13 +39,12 @@ namespace presentation.windows.presenters
public void present()
{
- builder.build<FindAllFamily>(x => family_members = x.fetch().to_observable());
- update(x => x.family_members);
+ bus.publish<FindAllFamily>();
}
public void notify(AddedNewFamilyMember message)
{
- builder.build<FindMemberIdentifiedBy>(x => family_members.Add(x.fetch(message.id)));
+ family_members.Add(mapper.map_from<AddedNewFamilyMember, PersonDetails>(message));
update(x => x.family_members);
}
}
product/client/presentation.windows/presenters/StatusBarPresenter.cs
@@ -1,6 +1,6 @@
using System.Threading;
using MoMoney.Service.Infrastructure.Eventing;
-using presentation.windows.commands;
+using presentation.windows.service.infrastructure;
namespace presentation.windows.presenters
{
product/client/presentation.windows/queries/FindAllFamily.cs
@@ -1,24 +0,0 @@
-using System.Collections.Generic;
-using gorilla.commons.utility;
-using presentation.windows.domain;
-using presentation.windows.orm;
-
-namespace presentation.windows.queries
-{
- public class FindAllFamily : Query<IEnumerable<PersonDetails>>
- {
- PersonRepository people;
- Mapper mapper;
-
- public FindAllFamily(PersonRepository people, Mapper mapper)
- {
- this.people = people;
- this.mapper = mapper;
- }
-
- public IEnumerable<PersonDetails> fetch()
- {
- return people.find_all().map_all_using<Person, PersonDetails>(mapper);
- }
- }
-}
\ No newline at end of file
product/client/presentation.windows/queries/FindMemberIdentifiedBy.cs
@@ -1,24 +0,0 @@
-using System;
-using gorilla.commons.utility;
-using presentation.windows.domain;
-using presentation.windows.orm;
-
-namespace presentation.windows.queries
-{
- public class FindMemberIdentifiedBy : Query<Guid, PersonDetails>
- {
- PersonRepository people;
- Mapper mapper;
-
- public FindMemberIdentifiedBy(PersonRepository people, Mapper mapper)
- {
- this.people = people;
- this.mapper = mapper;
- }
-
- public PersonDetails fetch(Guid item)
- {
- return people.find_by(item).map_using<Person, PersonDetails>(mapper);
- }
- }
-}
\ No newline at end of file
product/client/presentation.windows/commands/CommandBuilder.cs → product/client/presentation.windows/service/infrastructure/CommandBuilder.cs
@@ -1,6 +1,6 @@
using gorilla.commons.utility;
-namespace presentation.windows.commands
+namespace presentation.windows.service.infrastructure
{
public interface CommandBuilder
{
product/client/presentation.windows/commands/ContainerAwareCommandBuilder.cs → product/client/presentation.windows/service/infrastructure/ContainerAwareCommandBuilder.cs
@@ -4,7 +4,7 @@ using gorilla.commons.utility;
using MoMoney.Service.Infrastructure.Eventing;
using momoney.service.infrastructure.transactions;
-namespace presentation.windows.commands
+namespace presentation.windows.service.infrastructure
{
public class ContainerAwareCommandBuilder<T> : CommandBuilder<T>, Command
{
product/client/presentation.windows/commands/ContainerCommandBuilder.cs → product/client/presentation.windows/service/infrastructure/ContainerCommandBuilder.cs
@@ -3,7 +3,7 @@ using gorilla.commons.utility;
using MoMoney.Service.Infrastructure.Eventing;
using momoney.service.infrastructure.transactions;
-namespace presentation.windows.commands
+namespace presentation.windows.service.infrastructure
{
public class ContainerCommandBuilder : CommandBuilder
{
product/client/presentation.windows/commands/NamedCommand.cs → product/client/presentation.windows/service/infrastructure/NamedCommand.cs
@@ -1,6 +1,6 @@
using gorilla.commons.utility;
-namespace presentation.windows.commands
+namespace presentation.windows.service.infrastructure
{
public class NamedCommand<T> : Command where T : Command
{
product/client/presentation.windows/service/infrastructure/ServiceBus.cs
@@ -1,9 +0,0 @@
-using gorilla.commons.utility;
-
-namespace presentation.windows.service.infrastructure
-{
- public interface ServiceBus
- {
- void run<T>(Command<T> command, T item);
- }
-}
\ No newline at end of file
product/client/presentation.windows/commands/UpdateOnLongRunningProcess.cs → product/client/presentation.windows/service/infrastructure/UpdateOnLongRunningProcess.cs
@@ -1,6 +1,6 @@
using MoMoney.Service.Infrastructure.Eventing;
-namespace presentation.windows.commands
+namespace presentation.windows.service.infrastructure
{
public class UpdateOnLongRunningProcess : IEvent
{
product/client/presentation.windows/views/AccountTab.xaml
@@ -0,0 +1,9 @@
+<UserControl x:Class="presentation.windows.views.AccountTab"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+ <StackPanel>
+ <Button Command="{Binding AddAccount}">Add New Account</Button>
+ <TreeView>
+ </TreeView>
+ </StackPanel>
+</UserControl>
product/client/presentation.windows/views/AccountTab.xaml.cs
@@ -0,0 +1,12 @@
+using presentation.windows.presenters;
+
+namespace presentation.windows.views
+{
+ public partial class AccountTab : Tab<AccountPresenter>
+ {
+ public AccountTab()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/views/AddFamilyMemberDialog.xaml.cs
@@ -10,9 +10,9 @@ namespace presentation.windows.views
InitializeComponent();
}
- public void show_dialog(Window parent)
+ public void open()
{
- Owner = parent;
+ Owner = Application.Current.MainWindow;
ShowDialog();
}
}
product/client/presentation.windows/views/AddNewAccountDialog.xaml
@@ -0,0 +1,8 @@
+<Window x:Class="presentation.windows.views.AddNewAccountDialog"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="AddNewAccountDialog" Height="300" Width="300">
+ <Grid>
+
+ </Grid>
+</Window>
product/client/presentation.windows/views/AddNewAccountDialog.xaml.cs
@@ -0,0 +1,19 @@
+using System.Windows;
+using presentation.windows.presenters;
+
+namespace presentation.windows.views
+{
+ public partial class AddNewAccountDialog : Dialog<AddNewAccountPresenter>
+ {
+ public AddNewAccountDialog()
+ {
+ InitializeComponent();
+ }
+
+ public void open()
+ {
+ Owner = Application.Current.MainWindow;
+ ShowDialog();
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/Dialog.cs
@@ -1,10 +1,8 @@
-using System.Windows;
-
namespace presentation.windows
{
public interface Dialog<TPresenter> : View<TPresenter> where TPresenter : DialogPresenter
{
- void show_dialog(Window parent);
+ void open();
void Close();
}
}
\ No newline at end of file
product/client/presentation.windows/presentation.windows.csproj
@@ -42,22 +42,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\build\lib\app\automapper\AutoMapper.dll</HintPath>
</Reference>
- <Reference Include="FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\lib\app\nhibernate\FluentNHibernate.dll</HintPath>
- </Reference>
- <Reference Include="NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\lib\app\nhibernate\NHibernate.dll</HintPath>
- </Reference>
- <Reference Include="NHibernate.ByteCode.Castle, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\lib\app\nhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
- </Reference>
- <Reference Include="NHibernate.Linq, Version=1.0.0.4000, Culture=neutral, PublicKeyToken=444cf6a87fdab271, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\build\lib\app\nhibernate\NHibernate.Linq.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -89,10 +73,18 @@
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
+ <Page Include="views\AccountTab.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="views\AddFamilyMemberDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="views\AddNewAccountDialog.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="views\CompensationTab.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -122,61 +114,44 @@
<Compile Include="ApplicationController.cs" />
<Compile Include="bootstrappers\Bootstrapper.cs" />
<Compile Include="bootstrappers\ConfigureMappings.cs" />
- <Compile Include="domain\payroll\Calendar.cs" />
- <Compile Include="domain\payroll\Compensation.cs" />
- <Compile Include="domain\payroll\Date.cs" />
- <Compile Include="domain\payroll\Grant.cs" />
- <Compile Include="domain\payroll\History.cs" />
- <Compile Include="domain\payroll\Money.cs" />
- <Compile Include="domain\payroll\Unit.cs" />
- <Compile Include="domain\payroll\UnitPrice.cs" />
<Compile Include="events\SelectedFamilyMember.cs" />
- <Compile Include="orm\nhibernate\NHibernateUnitOfWorkFactory.cs" />
- <Compile Include="orm\nhibernate\NHibernateUnitOfWork.cs" />
- <Compile Include="infrastructure\DefaultMapper.cs" />
- <Compile Include="domain\Entity.cs" />
- <Compile Include="events\AddedNewFamilyMember.cs" />
- <Compile Include="commands\UpdateOnLongRunningProcess.cs" />
+ <Compile Include="service\infrastructure\UpdateOnLongRunningProcess.cs" />
<Compile Include="Dialog.cs" />
<Compile Include="DialogPresenter.cs" />
- <Compile Include="domain\Person.cs" />
- <Compile Include="orm\mappings\DateUserType.cs" />
- <Compile Include="orm\mappings\MappingAssembly.cs" />
- <Compile Include="orm\mappings\PersonMapping.cs" />
- <Compile Include="orm\nhibernate\NHibernatePersonRepository.cs" />
- <Compile Include="orm\PersonRepository.cs" />
+ <Compile Include="presenters\AccountPresenter.cs" />
<Compile Include="presenters\AddFamilyMemberPresenter.cs" />
- <Compile Include="commands\CommandBuilder.cs" />
- <Compile Include="commands\AddFamilyMemberCommand.cs" />
+ <Compile Include="service\infrastructure\CommandBuilder.cs" />
+ <Compile Include="presenters\AddNewAccountPresenter.cs" />
<Compile Include="presenters\CancelCommand.cs" />
<Compile Include="presenters\CompensationPresenter.cs" />
- <Compile Include="commands\dto\FamilyMemberToAdd.cs" />
- <Compile Include="commands\ContainerCommandBuilder.cs" />
- <Compile Include="commands\NamedCommand.cs" />
- <Compile Include="commands\ContainerAwareCommandBuilder.cs" />
+ <Compile Include="service\infrastructure\ContainerCommandBuilder.cs" />
+ <Compile Include="service\infrastructure\NamedCommand.cs" />
+ <Compile Include="service\infrastructure\ContainerAwareCommandBuilder.cs" />
<Compile Include="presenters\SaveCommand.cs" />
<Compile Include="presenters\UICommand.cs" />
<Compile Include="presenters\UICommandBuilder.cs" />
<Compile Include="presenters\WpfBindingExtensinos.cs" />
<Compile Include="presenters\WpfCommandBuilder.cs" />
<Compile Include="queries\ContainerAwareQueryBuilder.cs" />
- <Compile Include="queries\FindAllFamily.cs" />
- <Compile Include="queries\FindMemberIdentifiedBy.cs" />
<Compile Include="presenters\SelectedFamilyMemberPresenter.cs" />
<Compile Include="presenters\StatusBarPresenter.cs" />
<Compile Include="presenters\Observable.cs" />
<Compile Include="queries\PersonDetails.cs" />
<Compile Include="queries\QueryBuilder.cs" />
- <Compile Include="service\infrastructure\ServiceBus.cs" />
<Compile Include="View.cs" />
+ <Compile Include="views\AccountTab.xaml.cs">
+ <DependentUpon>AccountTab.xaml</DependentUpon>
+ </Compile>
<Compile Include="views\AddFamilyMemberDialog.xaml.cs">
<DependentUpon>AddFamilyMemberDialog.xaml</DependentUpon>
</Compile>
+ <Compile Include="views\AddNewAccountDialog.xaml.cs">
+ <DependentUpon>AddNewAccountDialog.xaml</DependentUpon>
+ </Compile>
<Compile Include="views\CompensationTab.xaml.cs">
<DependentUpon>CompensationTab.xaml</DependentUpon>
</Compile>
<Compile Include="bootstrappers\ComposeShell.cs" />
- <Compile Include="NeedStartup.cs" />
<Compile Include="Presenter.cs" />
<Compile Include="PresenterFactory.cs" />
<Compile Include="RegionManager.cs" />
@@ -238,6 +213,10 @@
<Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
<Name>utility</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\presentation.windows.common\presentation.windows.common.csproj">
+ <Project>{72B22B1E-1B62-41A6-9392-BD5283D17F79}</Project>
+ <Name>presentation.windows.common</Name>
+ </ProjectReference>
<ProjectReference Include="..\boot\boot.csproj">
<Project>{2DB82691-BF15-4538-8C5E-6BF8F4F875A9}</Project>
<Name>boot</Name>
@@ -259,6 +238,7 @@
<Resource Include="log4net.config.xml" />
</ItemGroup>
<ItemGroup>
+ <Folder Include="infrastructure\" />
<Folder Include="service\application\" />
<Folder Include="service\domain\" />
</ItemGroup>
product/client/presentation.windows/Program.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Security.Principal;
using System.Windows;
using System.Windows.Threading;
@@ -12,6 +13,7 @@ namespace presentation.windows
[STAThread]
static public void Main()
{
+ Process.Start("presentation.windows.server.exe");
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
Dispatcher.CurrentDispatcher.UnhandledException += (o, e) =>
{
product/client/presentation.windows/WpfApplicationController.cs
@@ -1,7 +1,6 @@
using System.Windows;
using System.Windows.Controls;
using MoMoney.Service.Infrastructure.Eventing;
-using presentation.windows.views;
namespace presentation.windows
{
@@ -39,10 +38,7 @@ namespace presentation.windows
dialog.Close();
};
presenter.present();
- region_manager.region<ShellWindow>(x =>
- {
- dialog.show_dialog(x);
- });
+ dialog.open();
}
public void load_region<Presenter, Region>() where Presenter : windows.Presenter where Region : FrameworkElement, View<Presenter>, new()
product/client/presentation.windows/events/AddedNewFamilyMember.cs → product/presentation.windows.common/messages/AddedNewFamilyMember.cs
@@ -1,12 +1,12 @@
using System;
using MoMoney.Service.Infrastructure.Eventing;
-namespace presentation.windows.events
+namespace presentation.windows.common.messages
{
public class AddedNewFamilyMember : IEvent
{
public Guid id { get; set; }
-
public string first_name { get; set; }
+ public string last_name { get; set; }
}
}
\ No newline at end of file
product/presentation.windows.common/messages/CreateNewAccount.cs
@@ -0,0 +1,8 @@
+namespace presentation.windows.common.messages
+{
+ public class CreateNewAccount
+ {
+ public string account_name { get; set; }
+ public string currency { get; set; }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/commands/dto/FamilyMemberToAdd.cs → product/presentation.windows.common/messages/FamilyMemberToAdd.cs
@@ -1,6 +1,6 @@
using System;
-namespace presentation.windows.commands.dto
+namespace presentation.windows.common.messages
{
public class FamilyMemberToAdd
{
product/presentation.windows.common/messages/FindAllFamily.cs
@@ -0,0 +1,4 @@
+namespace presentation.windows.common.messages
+{
+ public class FindAllFamily {}
+}
\ No newline at end of file
product/presentation.windows.common/messages/NewAccountCreated.cs
@@ -0,0 +1,7 @@
+namespace presentation.windows.common.messages
+{
+ public class NewAccountCreated
+ {
+ public string name { get; set; }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/infrastructure/DefaultMapper.cs → product/presentation.windows.common/DefaultMapper.cs
@@ -1,6 +1,6 @@
using gorilla.commons.utility;
-namespace presentation.windows.infrastructure
+namespace presentation.windows.common
{
public class DefaultMapper : Mapper
{
product/client/presentation.windows/NeedStartup.cs → product/presentation.windows.common/NeedStartup.cs
@@ -1,6 +1,6 @@
using gorilla.commons.utility;
-namespace presentation.windows
+namespace presentation.windows.common
{
public interface NeedStartup : Command {}
}
\ No newline at end of file
product/presentation.windows.common/presentation.windows.common.csproj
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{72B22B1E-1B62-41A6-9392-BD5283D17F79}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>presentation.windows.common</RootNamespace>
+ <AssemblyName>presentation.windows.common</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="AutoMapper, Version=0.3.1.71, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\automapper\AutoMapper.dll</HintPath>
+ </Reference>
+ <Reference Include="FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\nhibernate\FluentNHibernate.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DefaultMapper.cs" />
+ <Compile Include="messages\AddedNewFamilyMember.cs" />
+ <Compile Include="messages\CreateNewAccount.cs" />
+ <Compile Include="messages\FamilyMemberToAdd.cs" />
+ <Compile Include="messages\FindAllFamily.cs" />
+ <Compile Include="messages\NewAccountCreated.cs" />
+ <Compile Include="NeedStartup.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ServiceBus.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\client\service.infrastructure\service.infrastructure.csproj">
+ <Project>{81412692-F3EE-4FBF-A7C7-69454DD1BD46}</Project>
+ <Name>service.infrastructure</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\commons\utility\utility.csproj">
+ <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
+ <Name>utility</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
product/presentation.windows.common/ServiceBus.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace presentation.windows.common
+{
+ public interface ServiceBus
+ {
+ void publish<T>();
+ void publish<T>(T item);
+ void publish<T>(Action<T> configure);
+ }
+}
\ No newline at end of file
product/presentation.windows.server/domain/accounting/Account.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace presentation.windows.server.domain.accounting
+{
+ public class Account
+ {
+ static public Account New(string account_name, UnitOfMeasure units)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
product/presentation.windows.server/domain/accounting/Currency.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace presentation.windows.server.domain.accounting
+{
+ public class Currency : UnitOfMeasure
+ {
+ static public Currency named(string currency)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
product/presentation.windows.server/domain/accounting/UnitOfMeasure.cs
@@ -0,0 +1,4 @@
+namespace presentation.windows.server.domain.accounting
+{
+ public interface UnitOfMeasure {}
+}
\ No newline at end of file
product/client/presentation.windows/domain/payroll/Calendar.cs → product/presentation.windows.server/domain/payroll/Calendar.cs
@@ -1,6 +1,6 @@
using System;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
static public class Calendar
{
product/client/presentation.windows/domain/payroll/Compensation.cs → product/presentation.windows.server/domain/payroll/Compensation.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using gorilla.commons.utility;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class Compensation
{
product/client/presentation.windows/domain/payroll/Date.cs → product/presentation.windows.server/domain/payroll/Date.cs
@@ -1,6 +1,6 @@
using System;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class Date
{
product/client/presentation.windows/domain/payroll/Grant.cs → product/presentation.windows.server/domain/payroll/Grant.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using gorilla.commons.utility;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class Grant
{
product/client/presentation.windows/domain/payroll/History.cs → product/presentation.windows.server/domain/payroll/History.cs
@@ -1,4 +1,4 @@
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class History
{
product/client/presentation.windows/domain/payroll/Money.cs → product/presentation.windows.server/domain/payroll/Money.cs
@@ -1,6 +1,6 @@
using System;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class Money : IEquatable<Money>
{
product/client/presentation.windows/domain/payroll/Unit.cs → product/presentation.windows.server/domain/payroll/Unit.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class Unit
{
product/client/presentation.windows/domain/payroll/UnitPrice.cs → product/presentation.windows.server/domain/payroll/UnitPrice.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace presentation.windows.domain.payroll
+namespace presentation.windows.server.domain.payroll
{
public class UnitPrice
{
product/client/presentation.windows/domain/Entity.cs → product/presentation.windows.server/domain/Entity.cs
@@ -1,7 +1,7 @@
using System;
using gorilla.commons.utility;
-namespace presentation.windows.domain
+namespace presentation.windows.server.domain
{
public class Entity : IEquatable<Entity>
{
product/client/presentation.windows/domain/Person.cs → product/presentation.windows.server/domain/Person.cs
@@ -1,6 +1,6 @@
-using Gorilla.Commons.Utility;
+using presentation.windows.server.domain.payroll;
-namespace presentation.windows.domain
+namespace presentation.windows.server.domain
{
public class Person : Entity
{
product/presentation.windows.server/handlers/AddNewFamilyMemberHandler.cs
@@ -0,0 +1,30 @@
+using presentation.windows.common;
+using presentation.windows.common.messages;
+using presentation.windows.server.domain;
+using presentation.windows.server.orm;
+
+namespace presentation.windows.server.handlers
+{
+ public class AddNewFamilyMemberHandler : Handler<FamilyMemberToAdd>
+ {
+ PersonRepository people;
+ ServiceBus bus;
+
+ public AddNewFamilyMemberHandler(PersonRepository people, ServiceBus bus)
+ {
+ this.people = people;
+ this.bus = bus;
+ }
+
+ public void handle(FamilyMemberToAdd item)
+ {
+ var person = Person.New(item.first_name, item.last_name, item.date_of_birth);
+ people.save(person);
+ bus.publish<AddedNewFamilyMember>(x =>
+ {
+ x.id = person.id;
+ x.first_name = person.first_name;
+ });
+ }
+ }
+}
\ No newline at end of file
product/presentation.windows.server/handlers/FindAllFamilyHandler.cs
@@ -0,0 +1,30 @@
+using gorilla.commons.utility;
+using presentation.windows.common;
+using presentation.windows.common.messages;
+using presentation.windows.server.domain;
+using presentation.windows.server.orm;
+
+namespace presentation.windows.server.handlers
+{
+ public class FindAllFamilyHandler : Handler<FindAllFamily>
+ {
+ PersonRepository people;
+ Mapper mapper;
+ ServiceBus bus;
+
+ public FindAllFamilyHandler(PersonRepository people, Mapper mapper, ServiceBus bus)
+ {
+ this.people = people;
+ this.bus = bus;
+ this.mapper = mapper;
+ }
+
+ public void handle(FindAllFamily item)
+ {
+ people
+ .find_all()
+ .map_all_using<Person, AddedNewFamilyMember>(mapper)
+ .each(x => bus.publish(x));
+ }
+ }
+}
\ No newline at end of file
product/presentation.windows.server/handlers/Handler.cs
@@ -0,0 +1,7 @@
+namespace presentation.windows.server.handlers
+{
+ public interface Handler<T>
+ {
+ void handle(T item);
+ }
+}
\ No newline at end of file
product/presentation.windows.server/handlers/SaveNewAccountCommand.cs
@@ -0,0 +1,25 @@
+using presentation.windows.common;
+using presentation.windows.common.messages;
+using presentation.windows.server.domain.accounting;
+using presentation.windows.server.orm;
+
+namespace presentation.windows.server.handlers
+{
+ public class SaveNewAccountCommand : Handler<CreateNewAccount>
+ {
+ AccountRepository accounts;
+ ServiceBus bus;
+
+ public SaveNewAccountCommand(AccountRepository accounts, ServiceBus bus)
+ {
+ this.accounts = accounts;
+ this.bus = bus;
+ }
+
+ public void handle(CreateNewAccount item)
+ {
+ accounts.save(Account.New(item.account_name, Currency.named(item.currency)));
+ bus.publish<NewAccountCreated>(x => x.name = item.account_name);
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/orm/mappings/DateUserType.cs → product/presentation.windows.server/orm/mappings/DateUserType.cs
@@ -5,7 +5,7 @@ using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
-namespace presentation.windows.orm.mappings
+namespace presentation.windows.server.orm.mappings
{
public class DateUserType : IUserType
{
product/presentation.windows.server/orm/mappings/MappingAssembly.cs
@@ -0,0 +1,4 @@
+namespace presentation.windows.server.orm.mappings
+{
+ public class MappingAssembly {}
+}
\ No newline at end of file
product/client/presentation.windows/orm/mappings/PersonMapping.cs → product/presentation.windows.server/orm/mappings/PersonMapping.cs
@@ -1,7 +1,7 @@
using FluentNHibernate.Mapping;
-using presentation.windows.domain;
+using presentation.windows.server.domain;
-namespace presentation.windows.orm.mappings
+namespace presentation.windows.server.orm.mappings
{
public class PersonMapping : ClassMap<Person>
{
product/client/presentation.windows/orm/nhibernate/NHibernatePersonRepository.cs → product/presentation.windows.server/orm/nhibernate/NHibernatePersonRepository.cs
@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using NHibernate;
using NHibernate.Linq;
-using presentation.windows.domain;
+using presentation.windows.server.domain;
-namespace presentation.windows.orm.nhibernate
+namespace presentation.windows.server.orm.nhibernate
{
public class NHibernatePersonRepository : PersonRepository
{
product/client/presentation.windows/orm/nhibernate/NHibernateUnitOfWork.cs → product/presentation.windows.server/orm/nhibernate/NHibernateUnitOfWork.cs
@@ -3,7 +3,7 @@ using momoney.service.infrastructure.transactions;
using ISession = NHibernate.ISession;
using ITransaction = NHibernate.ITransaction;
-namespace presentation.windows.orm.nhibernate
+namespace presentation.windows.server.orm.nhibernate
{
public class NHibernateUnitOfWork : IUnitOfWork
{
product/client/presentation.windows/orm/nhibernate/NHibernateUnitOfWorkFactory.cs → product/presentation.windows.server/orm/nhibernate/NHibernateUnitOfWorkFactory.cs
@@ -4,7 +4,7 @@ using MoMoney.Service.Infrastructure.Transactions;
using ISession = NHibernate.ISession;
using ISessionFactory = NHibernate.ISessionFactory;
-namespace presentation.windows.orm.nhibernate
+namespace presentation.windows.server.orm.nhibernate
{
public class NHibernateUnitOfWorkFactory : IUnitOfWorkFactory
{
product/presentation.windows.server/orm/AccountRepository.cs
@@ -0,0 +1,9 @@
+using presentation.windows.server.domain.accounting;
+
+namespace presentation.windows.server.orm
+{
+ public interface AccountRepository
+ {
+ void save(Account account);
+ }
+}
\ No newline at end of file
product/client/presentation.windows/orm/PersonRepository.cs → product/presentation.windows.server/orm/PersonRepository.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
-using presentation.windows.domain;
+using presentation.windows.server.domain;
-namespace presentation.windows.orm
+namespace presentation.windows.server.orm
{
public interface PersonRepository
{
product/presentation.windows.server/Bootstrapper.cs
@@ -0,0 +1,105 @@
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using Autofac.Builder;
+using FluentNHibernate.Cfg;
+using FluentNHibernate.Cfg.Db;
+using Gorilla.Commons.Infrastructure.Container;
+using Gorilla.Commons.Infrastructure.Logging;
+using gorilla.commons.infrastructure.thirdparty.Autofac;
+using gorilla.commons.infrastructure.thirdparty.Log4Net;
+using gorilla.commons.utility;
+using momoney.database.transactions;
+using MoMoney.Service.Infrastructure.Threading;
+using momoney.service.infrastructure.transactions;
+using NHibernate.ByteCode.Castle;
+using NHibernate.Cfg;
+using NHibernate.Tool.hbm2ddl;
+using presentation.windows.common;
+using presentation.windows.server.orm;
+using presentation.windows.server.orm.mappings;
+using presentation.windows.server.orm.nhibernate;
+using Environment = System.Environment;
+using ISessionFactory = NHibernate.ISessionFactory;
+
+namespace presentation.windows.server
+{
+ public class Bootstrapper
+ {
+ static public void run()
+ {
+ var builder = new ContainerBuilder();
+ Resolve.initialize_with(new AutofacDependencyRegistryBuilder(builder).build());
+
+ //needs startups
+ builder.Register<ConfigureMappings>().As<NeedStartup>();
+
+ // infrastructure
+ builder.Register<Log4NetLogFactory>().As<LogFactory>().SingletonScoped();
+ builder.Register<DefaultMapper>().As<Mapper>().SingletonScoped();
+
+ var session_factory = bootstrap_nhibernate();
+ builder.Register(x => session_factory).SingletonScoped();
+ builder.Register(x => current_session(x));
+ builder.Register<NHibernateUnitOfWorkFactory>().As<IUnitOfWorkFactory>();
+ builder.Register(x => create_application_context()).SingletonScoped();
+
+ // commanding
+ //builder.Register<ContainerCommandBuilder>().As<CommandBuilder>().SingletonScoped();
+ builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
+ //builder.Register<AddFamilyMemberCommand>();
+
+ // queries
+
+ // repositories
+ builder.Register<NHibernatePersonRepository>().As<PersonRepository>().FactoryScoped();
+
+ Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
+ Resolve.the<CommandProcessor>().run();
+ }
+
+ static IContext create_application_context()
+ {
+ return new ContextFactory().create_for(new PerThreadScopedStorage(new CurrentThread()));
+ }
+
+ static ISession current_session(Autofac.IContext x)
+ {
+ var session = x.Resolve<IContext>().value_for(new TypedKey<ISession>());
+ if (null == session) Debugger.Break();
+ return session;
+ }
+
+ static ISessionFactory bootstrap_nhibernate()
+ {
+ var configuration = new Configuration();
+ var database_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"mokhan.ca\momoney\default.db");
+ var fluent_configuration = Fluently
+ .Configure(configuration)
+ .Database(SQLiteConfiguration.Standard
+ .UsingFile(database_path)
+ .AdoNetBatchSize(500)
+ .ConnectionString(x => x.Is("Data Source={0};Version=3;New=True;".formatted_using(database_path)))
+ .ShowSql()
+ .ProxyFactoryFactory<ProxyFactoryFactory>()
+ )
+ .Mappings(x =>
+ {
+ x.FluentMappings.AddFromAssemblyOf<MappingAssembly>();
+ })
+ .ExposeConfiguration(x => export(x))
+ ;
+ return fluent_configuration.BuildSessionFactory();
+ }
+
+ static void export(Configuration configuration)
+ {
+ var database_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"mokhan.ca\momoney\default.db");
+ if (File.Exists(database_path))
+ {
+ File.Delete(database_path);
+ }
+ new SchemaExport(configuration).Execute(true, true, false);
+ }
+ }
+}
\ No newline at end of file
product/presentation.windows.server/ConfigureMappings.cs
@@ -0,0 +1,22 @@
+using AutoMapper;
+using presentation.windows.common;
+using presentation.windows.common.messages;
+using presentation.windows.server.domain;
+
+namespace presentation.windows.server
+{
+ public class ConfigureMappings : NeedStartup
+ {
+ public void run()
+ {
+ Mapper
+ .CreateMap<Person, AddedNewFamilyMember>()
+ .ConvertUsing(x => new AddedNewFamilyMember
+ {
+ id = x.id,
+ first_name = x.first_name,
+ last_name = x.last_name,
+ });
+ }
+ }
+}
\ No newline at end of file
product/presentation.windows.server/presentation.windows.server.csproj
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4E60988E-1A43-4807-8CEC-4E13F63DE363}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>presentation.windows.server</RootNamespace>
+ <AssemblyName>presentation.windows.server</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\auto.fac\Autofac.dll</HintPath>
+ </Reference>
+ <Reference Include="AutoMapper, Version=0.3.1.71, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\automapper\AutoMapper.dll</HintPath>
+ </Reference>
+ <Reference Include="FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\nhibernate\FluentNHibernate.dll</HintPath>
+ </Reference>
+ <Reference Include="NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\nhibernate\NHibernate.dll</HintPath>
+ </Reference>
+ <Reference Include="NHibernate.ByteCode.Castle, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\nhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
+ </Reference>
+ <Reference Include="NHibernate.Linq, Version=1.0.0.4000, Culture=neutral, PublicKeyToken=444cf6a87fdab271, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\build\lib\app\nhibernate\NHibernate.Linq.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="handlers\AddNewFamilyMemberHandler.cs" />
+ <Compile Include="Bootstrapper.cs" />
+ <Compile Include="ConfigureMappings.cs" />
+ <Compile Include="domain\accounting\Account.cs" />
+ <Compile Include="domain\accounting\Currency.cs" />
+ <Compile Include="domain\accounting\UnitOfMeasure.cs" />
+ <Compile Include="domain\Entity.cs" />
+ <Compile Include="domain\payroll\Calendar.cs" />
+ <Compile Include="domain\payroll\Compensation.cs" />
+ <Compile Include="domain\payroll\Date.cs" />
+ <Compile Include="domain\payroll\Grant.cs" />
+ <Compile Include="domain\payroll\History.cs" />
+ <Compile Include="domain\payroll\Money.cs" />
+ <Compile Include="domain\payroll\Unit.cs" />
+ <Compile Include="domain\payroll\UnitPrice.cs" />
+ <Compile Include="domain\Person.cs" />
+ <Compile Include="handlers\FindAllFamilyHandler.cs" />
+ <Compile Include="handlers\Handler.cs" />
+ <Compile Include="handlers\SaveNewAccountCommand.cs" />
+ <Compile Include="orm\AccountRepository.cs" />
+ <Compile Include="orm\mappings\DateUserType.cs" />
+ <Compile Include="orm\mappings\MappingAssembly.cs" />
+ <Compile Include="orm\mappings\PersonMapping.cs" />
+ <Compile Include="orm\nhibernate\NHibernatePersonRepository.cs" />
+ <Compile Include="orm\nhibernate\NHibernateUnitOfWork.cs" />
+ <Compile Include="orm\nhibernate\NHibernateUnitOfWorkFactory.cs" />
+ <Compile Include="orm\PersonRepository.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\client\database\database.csproj">
+ <Project>{580E68A8-EDEE-4350-8BBE-A053645B0F83}</Project>
+ <Name>database</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\client\service.infrastructure\service.infrastructure.csproj">
+ <Project>{81412692-F3EE-4FBF-A7C7-69454DD1BD46}</Project>
+ <Name>service.infrastructure</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\commons\infrastructure.thirdparty.log4net\infrastructure.thirdparty.log4net.csproj">
+ <Project>{6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}</Project>
+ <Name>infrastructure.thirdparty.log4net</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\commons\infrastructure.thirdparty\infrastructure.thirdparty.csproj">
+ <Project>{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}</Project>
+ <Name>infrastructure.thirdparty</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\commons\infrastructure\infrastructure.csproj">
+ <Project>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</Project>
+ <Name>infrastructure</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\commons\utility\utility.csproj">
+ <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
+ <Name>utility</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\presentation.windows.common\presentation.windows.common.csproj">
+ <Project>{72B22B1E-1B62-41A6-9392-BD5283D17F79}</Project>
+ <Name>presentation.windows.common</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
product/presentation.windows.server/Program.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace presentation.windows.server
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Bootstrapper.run();
+ Console.ReadLine();
+ }
+ }
+}
\ No newline at end of file
solution.sln
@@ -41,6 +41,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presentation.winforms", "pr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presentation.windows", "product\client\presentation.windows\presentation.windows.csproj", "{81E2CF6C-4D61-442E-8086-BF1E017C7041}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presentation.windows.server", "product\presentation.windows.server\presentation.windows.server.csproj", "{4E60988E-1A43-4807-8CEC-4E13F63DE363}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presentation.windows.common", "product\presentation.windows.common\presentation.windows.common.csproj", "{72B22B1E-1B62-41A6-9392-BD5283D17F79}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -114,6 +118,14 @@ Global
{81E2CF6C-4D61-442E-8086-BF1E017C7041}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81E2CF6C-4D61-442E-8086-BF1E017C7041}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81E2CF6C-4D61-442E-8086-BF1E017C7041}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4E60988E-1A43-4807-8CEC-4E13F63DE363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4E60988E-1A43-4807-8CEC-4E13F63DE363}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4E60988E-1A43-4807-8CEC-4E13F63DE363}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4E60988E-1A43-4807-8CEC-4E13F63DE363}.Release|Any CPU.Build.0 = Release|Any CPU
+ {72B22B1E-1B62-41A6-9392-BD5283D17F79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {72B22B1E-1B62-41A6-9392-BD5283D17F79}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {72B22B1E-1B62-41A6-9392-BD5283D17F79}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {72B22B1E-1B62-41A6-9392-BD5283D17F79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -130,6 +142,8 @@ Global
{81412692-F3EE-4FBF-A7C7-69454DD1BD46} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
{F3E06696-0CD2-46EE-B117-A05C1E7E8CD8} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
{81E2CF6C-4D61-442E-8086-BF1E017C7041} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {4E60988E-1A43-4807-8CEC-4E13F63DE363} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {72B22B1E-1B62-41A6-9392-BD5283D17F79} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
{AA5EEED9-4531-45F7-AFCD-AD9717D2E405} = {099D479D-7BFC-428E-A897-9189C294C9C8}
{04DC09B4-5DF9-44A6-8DD1-05941F0D0228} = {099D479D-7BFC-428E-A897-9189C294C9C8}
{6BDCB0C1-51E1-435A-93D8-CA02BF8E409C} = {099D479D-7BFC-428E-A897-9189C294C9C8}