Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit 6063b80e572486256f4c1d64b3f04ac31e803870 @gnschenker committed Jul 7, 2012
Showing with 27,492 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +158 −0 Audit/Audit.csproj
  3. +64 −0 Audit/DomainAwareAnalysis.cs
  4. +65 −0 Audit/Program.cs
  5. +70 −0 Audit/Properties/Resources.Designer.cs
  6. +124 −0 Audit/Properties/Resources.resx
  7. +26 −0 Audit/Properties/Settings.Designer.cs
  8. +7 −0 Audit/Properties/Settings.settings
  9. +13 −0 Audit/ReadMe.markdown
  10. +35 −0 Audit/Util/CommonColors.cs
  11. +75 −0 Audit/Util/DomainLogDisplayItem.cs
  12. +96 −0 Audit/Util/DomainQueryManager.cs
  13. +134 −0 Audit/Util/LocalEventStore.cs
  14. +31 −0 Audit/Util/NodeExtensions.cs
  15. +88 −0 Audit/Util/ShellServices.cs
  16. +367 −0 Audit/Views/DomainLogView.Designer.cs
  17. +319 −0 Audit/Views/DomainLogView.cs
  18. +123 −0 Audit/Views/DomainLogView.resx
  19. +74 −0 Audit/Views/DomainScanner.cs
  20. +144 −0 Audit/Views/LoadSettingsForm.Designer.cs
  21. +127 −0 Audit/Views/LoadSettingsForm.cs
  22. +570 −0 Audit/Views/LoadSettingsForm.resx
  23. +77 −0 Audit/Views/ModifyMessage.Designer.cs
  24. +27 −0 Audit/Views/ModifyMessage.cs
  25. +120 −0 Audit/Views/ModifyMessage.resx
  26. +176 −0 Audit/Views/RepopulateView.Designer.cs
  27. +228 −0 Audit/Views/RepopulateView.cs
  28. +248 −0 Audit/Views/RepopulateView.resx
  29. +21 −0 Audit/Views/ViewMapInfo.cs
  30. +4 −0 Audit/Views/ViewsNode.cs
  31. +4 −0 README.md
  32. +7 −0 Recipe.Client/App.xaml
  33. +17 −0 Recipe.Client/App.xaml.cs
  34. +46 −0 Recipe.Client/Bootstrap.cs
  35. +71 −0 Recipe.Client/DelegateCommand.cs
  36. +35 −0 Recipe.Client/ExtendSimpleExpression.cs
  37. +50 −0 Recipe.Client/MainViewModel.cs
  38. +33 −0 Recipe.Client/MainWindow.xaml
  39. +22 −0 Recipe.Client/MainWindow.xaml.cs
  40. +55 −0 Recipe.Client/Properties/AssemblyInfo.cs
  41. +63 −0 Recipe.Client/Properties/Resources.Designer.cs
  42. +117 −0 Recipe.Client/Properties/Resources.resx
  43. +26 −0 Recipe.Client/Properties/Settings.Designer.cs
  44. +7 −0 Recipe.Client/Properties/Settings.settings
  45. +30 −0 Recipe.Client/RecipeView.xaml
  46. +28 −0 Recipe.Client/RecipeView.xaml.cs
  47. +63 −0 Recipe.Client/RecipeViewModel.cs
  48. +68 −0 Recipe.Client/RecipeViewModelState.cs
  49. +134 −0 Recipe.Client/Recipes.Client.csproj
  50. +6 −0 Recipe.Client/Recipes.Client.csproj.user
  51. +94 −0 Recipe.Contracts/AbstractIdentity.cs
  52. +18 −0 Recipe.Contracts/Commands.cs
  53. +32 −0 Recipe.Contracts/ConcreteIdentity.cs
  54. +35 −0 Recipe.Contracts/Current.cs
  55. +78 −0 Recipe.Contracts/Describe.cs
  56. +19 −0 Recipe.Contracts/Events.cs
  57. +120 −0 Recipe.Contracts/FormatUtil.cs
  58. +10 −0 Recipe.Contracts/IBus.cs
  59. +64 −0 Recipe.Contracts/Interfaces.cs
  60. +15 −0 Recipe.Contracts/Projections/RecipeByNameIndex.cs
  61. +12 −0 Recipe.Contracts/Projections/RecipeView.cs
  62. +36 −0 Recipe.Contracts/Properties/AssemblyInfo.cs
  63. +10 −0 Recipe.Contracts/Providers/IRecipeProvider.cs
  64. +10 −0 Recipe.Contracts/RecipeStatus.cs
  65. +63 −0 Recipe.Contracts/Recipes.Contracts.csproj
  66. +29 −0 Recipe.Contracts/Source.cs
  67. +17 −0 Recipe.Projections/BootstrapProjections.cs
  68. +36 −0 Recipe.Projections/Properties/AssemblyInfo.cs
  69. +30 −0 Recipe.Projections/RecipeByNameIndexProjection.cs
  70. +33 −0 Recipe.Projections/RecipeProjection.cs
  71. +60 −0 Recipe.Projections/Recipes.Projections.csproj
  72. +36 −0 Recipes.Domain/Properties/AssemblyInfo.cs
  73. +55 −0 Recipes.Domain/RecipeAggregate.cs
  74. +34 −0 Recipes.Domain/RecipeAggregateState.cs
  75. +60 −0 Recipes.Domain/Recipes.Domain.csproj
  76. +68 −0 Recipes.Domain/RedirectToWhen.cs
  77. +36 −0 Recipes.ReadModel/Properties/AssemblyInfo.cs
  78. +25 −0 Recipes.ReadModel/ProviderFactory.cs
  79. +37 −0 Recipes.ReadModel/RecipeProvider.cs
  80. +64 −0 Recipes.ReadModel/Recipes.ReadModel.csproj
  81. +138 −0 Recipes.Wires/AggregateFactory.cs
  82. +22 −0 Recipes.Wires/Bus.cs
  83. +51 −0 Recipes.Wires/Context.cs
  84. +40 −0 Recipes.Wires/DocumentStrategy.cs
  85. +62 −0 Recipes.Wires/EnvelopeSerializer.cs
  86. +26 −0 Recipes.Wires/MessageSender.cs
  87. +40 −0 Recipes.Wires/ProjectionStrategy.cs
  88. +36 −0 Recipes.Wires/Properties/AssemblyInfo.cs
  89. +87 −0 Recipes.Wires/Recipes.Wires.csproj
  90. +129 −0 Recipes.Wires/RedirectToDynamicEvent.cs
  91. +102 −0 Recipes.Wires/SetupClassThatReplacesIoCContainerFramework.cs
  92. +29 −0 Recipes.Wires/SimpleBus.cs
  93. +35 −0 Recipes.Wires/SimpleDispatcher.cs
  94. +81 −0 Recipes.Wires/Topology.cs
  95. +5 −0 Recipes.Wires/packages.config
  96. +11 −0 RecipesWithCqrsAndEs.7.0.TeamCity.user
  97. +102 −0 RecipesWithCqrsAndEs.sln
  98. +2 −0 RecipesWithCqrsAndEs.sln.DotSettings.user
  99. BIN RecipesWithCqrsAndEs.suo
  100. BIN lib/Lokad.Cqrs.Portable.dll
  101. BIN lib/Lokad.Cqrs.Portable.pdb
  102. BIN packages/ServiceStack.Text.3.8.3/ServiceStack.Text.3.8.3.nupkg
  103. +464 −0 packages/ServiceStack.Text.3.8.3/lib/net35/ServiceStack.Text.XML
  104. BIN packages/ServiceStack.Text.3.8.3/lib/net35/ServiceStack.Text.dll
  105. BIN packages/ServiceStack.Text.3.8.3/lib/net35/ServiceStack.Text.pdb
  106. +409 −0 packages/ServiceStack.Text.3.8.3/lib/sl4-windowsphone71/ServiceStack.Text.WP.XML
  107. BIN packages/ServiceStack.Text.3.8.3/lib/sl4-windowsphone71/ServiceStack.Text.WP.dll
  108. BIN packages/ServiceStack.Text.3.8.3/lib/sl4/ServiceStack.Text.dll
  109. +385 −0 packages/ServiceStack.Text.3.8.3/lib/sl4/ServiceStack.Text.xml
  110. BIN packages/ServiceStack.Text.3.8.3/lib/sl5/ServiceStack.Text.dll
  111. +385 −0 packages/ServiceStack.Text.3.8.3/lib/sl5/ServiceStack.Text.xml
  112. BIN packages/protobuf-net.2.0.0.480/lib/ios/protobuf-net.dll
  113. BIN packages/protobuf-net.2.0.0.480/lib/ios/protobuf-net.pdb
  114. +1,474 −0 packages/protobuf-net.2.0.0.480/lib/ios/protobuf-net.xml
  115. BIN packages/protobuf-net.2.0.0.480/lib/mono/protobuf-net.dll
  116. +2,434 −0 packages/protobuf-net.2.0.0.480/lib/mono/protobuf-net.xml
  117. BIN packages/protobuf-net.2.0.0.480/lib/net20/protobuf-net.dll
  118. BIN packages/protobuf-net.2.0.0.480/lib/net20/protobuf-net.pdb
  119. +2,519 −0 packages/protobuf-net.2.0.0.480/lib/net20/protobuf-net.xml
  120. BIN packages/protobuf-net.2.0.0.480/lib/net30/protobuf-net.dll
  121. BIN packages/protobuf-net.2.0.0.480/lib/net30/protobuf-net.pdb
  122. +2,640 −0 packages/protobuf-net.2.0.0.480/lib/net30/protobuf-net.xml
  123. BIN packages/protobuf-net.2.0.0.480/lib/net35/protobuf-net.dll
  124. BIN packages/protobuf-net.2.0.0.480/lib/net35/protobuf-net.pdb
  125. +2,640 −0 packages/protobuf-net.2.0.0.480/lib/net35/protobuf-net.xml
  126. BIN packages/protobuf-net.2.0.0.480/lib/net40/protobuf-net.dll
  127. BIN packages/protobuf-net.2.0.0.480/lib/net40/protobuf-net.pdb
  128. +2,640 −0 packages/protobuf-net.2.0.0.480/lib/net40/protobuf-net.xml
  129. +2,362 −0 packages/protobuf-net.2.0.0.480/lib/sl3-wp/protobuf-net.XML
  130. BIN packages/protobuf-net.2.0.0.480/lib/sl3-wp/protobuf-net.dll
  131. BIN packages/protobuf-net.2.0.0.480/lib/sl3-wp/protobuf-net.pdb
  132. BIN packages/protobuf-net.2.0.0.480/lib/sl4/protobuf-net.dll
  133. BIN packages/protobuf-net.2.0.0.480/lib/sl4/protobuf-net.pdb
  134. +2,403 −0 packages/protobuf-net.2.0.0.480/lib/sl4/protobuf-net.xml
  135. BIN packages/protobuf-net.2.0.0.480/protobuf-net.2.0.0.480.nupkg
  136. +4 −0 packages/repositories.config
6 .gitignore
@@ -0,0 +1,6 @@
+# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
+bin
+obj
+
+# mstest test results
+TestResults
158 Audit/Audit.csproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{BC973EC1-80D2-4F06-A078-0A7E44E3AE8C}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Audit</RootNamespace>
+ <AssemblyName>Sample.Audit</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Debug\Shelfcheck.Audit.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\Shelfcheck.Audit.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Lokad.Cqrs.Portable, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\lib\Lokad.Cqrs.Portable.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Text">
+ <HintPath>..\..\..\Library\ServiceStack\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Xml.Linq" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Util\NodeExtensions.cs" />
+ <Compile Include="Util\DomainQueryManager.cs" />
+ <Compile Include="Views\DomainScanner.cs" />
+ <Compile Include="Views\ModifyMessage.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Views\ModifyMessage.Designer.cs">
+ <DependentUpon>ModifyMessage.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Util\CommonColors.cs" />
+ <Compile Include="Views\DomainLogView.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Views\DomainLogView.Designer.cs">
+ <DependentUpon>DomainLogView.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Views\LoadSettingsForm.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Views\LoadSettingsForm.Designer.cs">
+ <DependentUpon>LoadSettingsForm.cs</DependentUpon>
+ </Compile>
+ <Compile Include="DomainAwareAnalysis.cs" />
+ <Compile Include="Util\DomainLogDisplayItem.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Util\LocalEventStore.cs" />
+ <Compile Include="Util\ShellServices.cs" />
+ <Compile Include="Views\RepopulateView.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="Views\RepopulateView.Designer.cs">
+ <DependentUpon>RepopulateView.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Views\ViewMapInfo.cs" />
+ <Compile Include="Views\ViewsNode.cs" />
+ <EmbeddedResource Include="Views\DomainLogView.resx">
+ <DependentUpon>DomainLogView.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Views\LoadSettingsForm.resx">
+ <DependentUpon>LoadSettingsForm.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Views\ModifyMessage.resx">
+ <DependentUpon>ModifyMessage.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
+ </Compile>
+ <EmbeddedResource Include="Views\RepopulateView.resx">
+ <DependentUpon>RepopulateView.cs</DependentUpon>
+ </EmbeddedResource>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ReadMe.markdown" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Recipe.Contracts\Recipes.Contracts.csproj">
+ <Project>{93F0421A-97A1-42D2-A219-D8A113E7C97D}</Project>
+ <Name>Recipes.Contracts</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Recipe.Projections\Recipes.Projections.csproj">
+ <Project>{8C63C3C5-06EA-48CE-805B-5F6519792C11}</Project>
+ <Name>Recipes.Projections</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Recipes.Wires\Recipes.Wires.csproj">
+ <Project>{693B3505-63B7-4D73-9A52-50F62BCA0B72}</Project>
+ <Name>Recipes.Wires</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>
64 Audit/DomainAwareAnalysis.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Drawing;
+using Audit.Util;
+using Lokad.Cqrs;
+using Recipes.Contracts;
+
+namespace Audit
+{
+ static class DomainAwareAnalysis
+ {
+ public static Color GetBackgroundColorForContract(ImmutableMessage message)
+ {
+ var commad = message.Content as IRecipeCommand;
+
+ if (commad != null)
+ {
+ return CommonColors.Green;
+ }
+
+ var @event = message.Content as IRecipeEvent;
+
+ if (@event != null)
+ {
+ return CommonColors.Blue;
+ }
+ return CommonColors.Gray;
+ }
+
+ public static Color GetBackgroundColorForCategory(string category)
+ {
+ if (String.IsNullOrEmpty(category))
+ return Color.LightGray;
+
+ var hashCode = category.GetHashCode();
+ var b = BitConverter.GetBytes(hashCode);
+ return Color.FromArgb(b[0] ^ b[1] | 128, b[2] ^ b[1] | 128, b[2] ^ b[3] | 128);
+ }
+
+ public static string GetCategoryNames(ImmutableMessage messages)
+ {
+ var item = messages.Content;
+
+ if (item is IFunctionalCommand || item is IFunctionalEvent)
+ return "system";
+
+ var @event = item as IEvent<IIdentity>;
+
+ if (@event != null)
+ {
+ return @event.Id.ToString();
+ }
+
+ var command = item as ICommand<IIdentity>;
+
+ if (command != null)
+ {
+ return command.Id.ToString();
+ }
+
+
+ throw new InvalidOperationException("Unknown envelope category name.");
+ }
+ }
+}
65 Audit/Program.cs
@@ -0,0 +1,65 @@
+using System;
+using System.IO;
+using System.Windows.Forms;
+using Audit.Util;
+using Audit.Views;
+using Recipes.Wires;
+using Lokad.Cqrs;
+using Lokad.Cqrs.TapeStorage;
+
+namespace Audit
+{
+ static class Program
+ {
+ static readonly IEnvelopeStreamer EnvelopeStreamer;
+
+ static Program()
+ {
+ EnvelopeStreamer = Contracts.CreateStreamer();
+ }
+
+ [STAThread]
+ static void Main(string[] args)
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+
+ using (var form = new LoadSettingsForm())
+ {
+ form.BindArgs(args);
+ if (form.ShowDialog() != DialogResult.OK)
+ {
+ return;
+ }
+
+ var conf = form.GetAzureConfig();
+ if (form.ConfigFileSelected)
+ {
+ AttachToRemoteLog(conf);
+ }
+ else
+ {
+ AttachToLocalLog(conf);
+ }
+ }
+ }
+
+ static void AttachToLocalLog(string filePath)
+ {
+ var config = FileStorage.CreateConfig(Path.GetDirectoryName(filePath) ?? "");
+
+ var cache = new FileTapeStream(filePath);
+
+ var store = new LocalEventStore(null, cache);
+ var send = config.CreateQueueWriter(Topology.RouterQueue);
+ var endpoint = new SimpleMessageSender(EnvelopeStreamer, send);
+
+ Application.Run(new DomainLogView(store, endpoint, EnvelopeStreamer));
+ }
+
+ static void AttachToRemoteLog(string azureConfig)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
70 Audit/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.239
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Audit.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // 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 Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [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("Audit.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ internal static byte[] ReadMe {
+ get {
+ object obj = ResourceManager.GetObject("ReadMe", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+ }
+}
124 Audit/Properties/Resources.resx
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="ReadMe" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\readme.markdown;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+</root>
26 Audit/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.239
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Audit.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
7 Audit/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
13 Audit/ReadMe.markdown
@@ -0,0 +1,13 @@
+Lokad Audit Tool
+================
+
+> document revision 2011-12-16 by Rinat Abdullin
+
+This is local (via Ctrl-C + Ctrl-V) port of Salescast Maintenance
+Utility for the purposes of this specific project. It allows
+to load Domain log and audit individual entries (synchronizing to
+the local cache, if needed).
+
+Tool can operate either with local streams or remote streams.
+
+TODO: support for rebuilding views
35 Audit/Util/CommonColors.cs
@@ -0,0 +1,35 @@
+using System.Drawing;
+
+namespace Audit.Util
+{
+ public static class CommonColors
+ {
+ public static readonly Color Green = Color.FromArgb(204, 255, 204);
+ public static readonly Color Blue = Color.FromArgb(204, 255, 255);
+ public static readonly Color Red = Color.FromArgb(255, 204, 204);
+ public static readonly Color Gray = Color.FromArgb(204, 204, 204);
+
+ /// <summary>
+ /// Courtesy of http://ethanschoonover.com/solarized#usage-development
+ /// </summary>
+ public static class Solarized
+ {
+ public static readonly Color Base03 = Color.FromArgb(0, 43, 54);
+ public static readonly Color Base02 = Color.FromArgb(7, 54, 66);
+ public static readonly Color Base01 = Color.FromArgb(88, 110, 117);
+ public static readonly Color Base00 = Color.FromArgb(101, 123, 131);
+ public static readonly Color Base0 = Color.FromArgb(131, 148, 150);
+ public static readonly Color Base1 = Color.FromArgb(147, 161, 161);
+ public static readonly Color Base2 = Color.FromArgb(238, 232, 213);
+ public static readonly Color Base3 = Color.FromArgb(253, 246, 227);
+ public static readonly Color Yellow = Color.FromArgb(181, 137, 0);
+ public static readonly Color Orange = Color.FromArgb(203, 75, 22);
+ public static readonly Color Red = Color.FromArgb(220, 50, 47);
+ public static readonly Color Magenta = Color.FromArgb(211, 54, 130);
+ public static readonly Color Violet = Color.FromArgb(108, 113, 196);
+ public static readonly Color Blue = Color.FromArgb(38, 139, 210);
+ public static readonly Color Cyan = Color.FromArgb(42, 161, 152);
+ public static readonly Color Green = Color.FromArgb(133, 153, 0);
+ }
+ }
+}
75 Audit/Util/DomainLogDisplayItem.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Linq;
+using System.Windows.Forms;
+using Lokad.Cqrs;
+using Lokad.Cqrs.Envelope;
+using Recipes.Contracts;
+using ServiceStack.Text;
+
+namespace Audit.Util
+{
+ public sealed class DomainLogDisplayItem
+ {
+ public readonly ImmutableEnvelope Item;
+ public readonly string RecordId;
+ public readonly long StoreIndex;
+ public Action<DataGridViewCell> Style = style => { };
+
+ public DomainLogDisplayItem(ImmutableEnvelope item, string session, long storeIndex)
+ {
+ Class = string.Join(",", item.Items.Select(s => s.MappedType.Name).ToArray());
+ Recorded = FormatUtil.TimeOffsetUtc(DateTime.SpecifyKind(item.CreatedOnUtc, DateTimeKind.Utc));
+ RecordId = item.EnvelopeId;
+ Item = item;
+ Session = session;
+ AssignStyle(item, session);
+ StoreIndex = storeIndex;
+
+ Type = ' ';
+ }
+
+ public string Class { get; set; }
+ public string Recorded { get; set; }
+ public string Session { get; set; }
+ public char Type { get; set; }
+
+ void AssignStyle(ImmutableEnvelope item, string session)
+ {
+ Style += cell =>
+ {
+ if (session == (cell.Value as string))
+ {
+ cell.Style.BackColor = DomainAwareAnalysis.GetBackgroundColorForCategory(session);
+ }
+ else if (cell.Value is char)
+ {
+ cell.Style.BackColor = DomainAwareAnalysis.GetBackgroundColorForCategory(Class);
+ }
+ else
+ {
+ cell.Style.BackColor = DomainAwareAnalysis.GetBackgroundColorForContract(item.Items[0]);
+ }
+ };
+ }
+
+ string Indent(string source)
+ {
+ return string.Join("\r\n",
+ source.Split(new[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries).Select(s => "> " + s));
+ }
+
+ public override string ToString()
+ {
+ return Item.PrintToString(o =>
+ {
+ string details = JsvFormatter.Format(JsonSerializer.SerializeToString(o));
+ string description;
+ if (Describe.TryDescribe(o, out description))
+ {
+ return "\r\n" + Indent(description) + "\r\n\r\n" + details;
+ }
+ return details;
+ });
+ }
+ }
+}
96 Audit/Util/DomainQueryManager.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Diagnostics;
+using System.Threading.Tasks;
+using Lokad.Cqrs;
+
+namespace Audit.Util
+{
+ public sealed class DomainQueryManager
+ {
+ readonly IEnvelopeStreamer _serializer;
+ readonly LocalEventStore _store;
+ readonly ShellServices _services;
+
+ public DomainQueryManager(IEnvelopeStreamer serializer, LocalEventStore store, ShellServices services)
+ {
+ _serializer = serializer;
+ _store = store;
+ _services = services;
+ }
+
+ public DomainQueryManager CloneFor(LocalEventStore store)
+ {
+ return new DomainQueryManager(_serializer, store, _services);
+ }
+
+ public bool IsSyncAvailable
+ {
+ get { return _store.IsSyncAvailable; }
+ }
+
+ public void Log(string text, params object[] args)
+ {
+ _services.Log("DomainAudit", text, args);
+ }
+
+ public Task<unit> SyncLog()
+ {
+ Log("Sync log");
+ return _store.SyncLog(s => Log(s));
+ }
+
+ public void QueryConsumer(Action<ImmutableEnvelope> redirects)
+ {
+ Log("Loading infrastructure");
+
+ var boundary = DateTime.MinValue;
+
+ var watch = Stopwatch.StartNew();
+ var count = 0;
+
+ _store.ObserveAll(data =>
+ {
+ var message = _serializer.ReadAsEnvelopeData(data.Data);
+
+ count += 1;
+ var date = message.CreatedOnUtc;
+
+ if (date.Month != boundary.Month)
+ {
+ Log("Scanned to {0:yyyy-MM}", date);
+ boundary = date;
+ }
+ redirects(message);
+ });
+
+ var seconds = watch.Elapsed.TotalSeconds;
+ var speed = count / seconds;
+ Log("Scanned {0} events in {1} sec ({2} per second)", count, Math.Round(seconds, 0), Math.Round(speed, 0));
+ }
+
+ public sealed class Stat
+ {
+ public readonly Type ConsumerType;
+ public readonly Type MessageType;
+ public readonly TimeSpan TimeSpent;
+ public readonly int Messages;
+
+ public long AverageTicks
+ {
+ get
+ {
+ if (Messages == 0) return 0;
+ return TimeSpent.Ticks / Messages;
+ }
+ }
+
+ public Stat(Type consumerType, Type messageType, TimeSpan timeSpent, int messages)
+ {
+ ConsumerType = consumerType;
+ MessageType = messageType;
+ TimeSpent = timeSpent;
+ Messages = messages;
+ }
+ }
+ }
+}
134 Audit/Util/LocalEventStore.cs
@@ -0,0 +1,134 @@
+using System;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+using Lokad.Cqrs;
+using Lokad.Cqrs.TapeStorage;
+
+namespace Audit.Util
+{
+ public sealed class LocalEventStore
+ {
+ const int BatchSize = 5000;
+
+ readonly ITapeStream _remote;
+ readonly FileTapeStream _cache;
+
+ public bool IsSyncAvailable { get; private set; }
+
+ public LocalEventStore(ITapeStream remote, FileTapeStream cache)
+ {
+ IsSyncAvailable = remote != null;
+ _remote = remote;
+ _cache = cache;
+ }
+
+ public Task<unit> SyncLog(Action<string> logger)
+ {
+ return new Task<unit>(() =>
+ {
+ SyncInternal(logger);
+ return unit.it;
+ });
+ }
+
+ public void ObserveAll(Action<TapeRecord> observer)
+ {
+ foreach (var record in _cache.ReadRecords(0, int.MaxValue))
+ {
+ observer(record);
+ }
+ }
+
+ /// <summary>
+ /// Observes first <see cref="count"/> records from reversed list
+ /// where version is less or equal to <see cref="max"/>.
+ /// </summary>
+ /// <param name="max">Max version observed.</param>
+ /// <param name="count">Max count of observed records.</param>
+ /// <param name="observer">Observer action.</param>
+ public void ObserveTill(long max, int count, Action<TapeRecord> observer)
+ {
+ // It's assumed that FileTapeStream uses Versions as index
+ // and Version will increase by one without gaps.
+
+ // Read backward
+ var start = Math.Min(max, _cache.GetCurrentVersion());
+ var end = Math.Max(start - count, 0);
+ var totalCount = (int) (start - end);
+
+ var index = 0;
+ while (true)
+ {
+ var readCount = Math.Min(BatchSize, totalCount - index);
+ if (readCount == 0)
+ break;
+
+ var records = _cache.ReadRecords(start - readCount - index, readCount).ToArray();
+ if (records.Length == 0)
+ break;
+
+ foreach (var record in records.Reverse())
+ observer(record);
+
+ index += records.Length;
+ }
+ }
+
+ T Retry<T>(Func<T> producer, Action<string> message)
+ {
+ Exception e = new NullReferenceException();
+ for (int i = 0; i < 4; i++)
+ {
+ try
+ {
+ return producer();
+ }
+ catch (Exception ex)
+ {
+ message("Retrying from: " + ex.Message);
+ e = ex;
+ }
+ }
+ throw e;
+ }
+
+ void SyncInternal(Action<string> logger)
+ {
+ try
+ {
+ var next = _cache.GetCurrentVersion();
+
+ while (true)
+ {
+ long next1 = next;
+ var items = Retry(() => _remote.ReadRecords(next1, BatchSize).ToArray(), logger);
+ if (items.Length == 0)
+ break;
+
+ // Check that versions are contiguous
+ var nextCopy = next;
+ var versions = items
+ .Select((r, i) => new {Actual = r.Version, Expected = nextCopy + 1 + i})
+ .ToArray();
+
+ if (!versions.All(v => v.Actual == v.Expected))
+ throw new InvalidOperationException("Versions are not contiguous.");
+
+ next = items.Max(m => m.Version);
+
+ _cache.AppendNonAtomic(items);
+ logger(string.Format("Downloaded {0} records", items.Length));
+
+ if (items.Length <= 4)
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ logger(ex.Message);
+ Trace.WriteLine(ex);
+ }
+ }
+ }
+}
31 Audit/Util/NodeExtensions.cs
@@ -0,0 +1,31 @@
+using System.Windows.Forms;
+
+namespace Audit.Util
+{
+ public static class NodeExtensions
+ {
+ public static TreeNode AddNode(this TreeNode node, string name, object tag = null, string image = "")
+ {
+ var child = node.Nodes.Add(name, name);
+ if (!string.IsNullOrEmpty(image))
+ {
+ child.SelectedImageKey = child.ImageKey = image;
+ }
+
+ child.Tag = tag;
+ return child;
+ }
+
+ public static TreeNode AddNode(this TreeView view, string name, object tag = null, string image = "")
+ {
+ var child = view.Nodes.Add(name, name);
+ if (!string.IsNullOrEmpty(image))
+ {
+ child.SelectedImageKey = child.ImageKey = image;
+ }
+
+ child.Tag = tag;
+ return child;
+ }
+ }
+}
88 Audit/Util/ShellServices.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Concurrent;
+using System.Diagnostics;
+using System.Globalization;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Lokad.Cqrs;
+using Recipes.Contracts;
+using ServiceStack.Text;
+
+namespace Audit.Util
+{
+ public sealed class ShellServices
+ {
+ readonly ConcurrentQueue<string> _log = new ConcurrentQueue<string>();
+
+ readonly SimpleMessageSender _client;
+ readonly Stopwatch _watch = Stopwatch.StartNew();
+
+ readonly CancellationTokenSource _source = new CancellationTokenSource();
+
+ public ShellServices(SimpleMessageSender client)
+ {
+ _client = client;
+ }
+
+ public Task ConnectLogger(RichTextBox box)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ while (!_source.Token.IsCancellationRequested)
+ {
+ string result;
+ var builder = new StringBuilder();
+ while (_log.TryDequeue(out result))
+ {
+ builder.AppendLine(result);
+ }
+ if (builder.Length > 0)
+ {
+ box.Invoke(new Action(() =>
+ {
+ box.AppendText(builder.ToString());
+ box.ScrollToCaret();
+ }));
+ }
+ _source.Token.WaitHandle.WaitOne(TimeSpan.FromMilliseconds(250));
+ }
+ }, _source.Token);
+ }
+
+ public SimpleMessageSender Client
+ {
+ get { return _client; }
+ }
+
+ public void SendCommand(IRecipeCommand message)
+ {
+ Log("BUS", "Sending '{0}'\r\n{1}", message.GetType().Name, JsonSerializer.SerializeToString(message));
+
+ _client.SendOne(message);
+ }
+
+
+ public void Schedule(Action action, TimeSpan span)
+ {
+ Task.Factory
+ .StartNew(() => _source.Token.WaitHandle.WaitOne(span))
+ .ContinueWith(t => action(), _source.Token,
+ TaskContinuationOptions.OnlyOnRanToCompletion,
+ TaskScheduler.FromCurrentSynchronizationContext());
+ }
+
+
+ public void Disconnect()
+ {
+ _source.Cancel();
+ }
+
+ public void Log(string sender, string format, params object[] args)
+ {
+ var prefix = string.Format("[{0}: {1:0000000}] ", sender, _watch.ElapsedMilliseconds);
+ _log.Enqueue(prefix + string.Format(CultureInfo.InvariantCulture, format, args));
+ }
+ }
+}
367 Audit/Views/DomainLogView.Designer.cs
@@ -0,0 +1,367 @@
+namespace Audit.Views
+{
+ partial class DomainLogView
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this._log = new System.Windows.Forms.RichTextBox();
+ this.splitter1 = new System.Windows.Forms.Splitter();
+ this._display = new System.Windows.Forms.RichTextBox();
+ this.toolStrip1 = new System.Windows.Forms.ToolStrip();
+ this._beginningEvents = new System.Windows.Forms.ToolStripButton();
+ this._nextEvents = new System.Windows.Forms.ToolStripButton();
+ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.resendDropDownButton = new System.Windows.Forms.ToolStripDropDownButton();
+ this.modifySendMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
+ this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel();
+ this.txtCount = new System.Windows.Forms.ToolStripTextBox();
+ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
+ this._detailsLabel = new System.Windows.Forms.Label();
+ this._domainGrid = new System.Windows.Forms.DataGridView();
+ this.panel2 = new System.Windows.Forms.Panel();
+ this.splitter2 = new System.Windows.Forms.Splitter();
+ this.panel3 = new System.Windows.Forms.Panel();
+ this._domainLogTab = new System.Windows.Forms.TabPage();
+ this.panel4 = new System.Windows.Forms.Panel();
+ this.tabControl1 = new System.Windows.Forms.TabControl();
+ this.viewsTab = new System.Windows.Forms.TabPage();
+ this.panel1.SuspendLayout();
+ this.toolStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this._domainGrid)).BeginInit();
+ this.panel2.SuspendLayout();
+ this.panel3.SuspendLayout();
+ this._domainLogTab.SuspendLayout();
+ this.panel4.SuspendLayout();
+ this.tabControl1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.Controls.Add(this._log);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.panel1.Location = new System.Drawing.Point(0, 319);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(836, 100);
+ this.panel1.TabIndex = 0;
+ //
+ // _log
+ //
+ this._log.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this._log.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._log.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
+ this._log.Location = new System.Drawing.Point(0, 0);
+ this._log.Name = "_log";
+ this._log.ReadOnly = true;
+ this._log.Size = new System.Drawing.Size(836, 100);
+ this._log.TabIndex = 0;
+ this._log.Text = "";
+ this._log.WordWrap = false;
+ //
+ // splitter1
+ //
+ this.splitter1.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.splitter1.Location = new System.Drawing.Point(0, 316);
+ this.splitter1.Name = "splitter1";
+ this.splitter1.Size = new System.Drawing.Size(836, 3);
+ this.splitter1.TabIndex = 1;
+ this.splitter1.TabStop = false;
+ //
+ // _display
+ //
+ this._display.BackColor = System.Drawing.SystemColors.Window;
+ this._display.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this._display.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._display.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this._display.Location = new System.Drawing.Point(0, 24);
+ this._display.Name = "_display";
+ this._display.ReadOnly = true;
+ this._display.Size = new System.Drawing.Size(417, 258);
+ this._display.TabIndex = 1;
+ this._display.Text = "";
+ //
+ // toolStrip1
+ //
+ this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this._beginningEvents,
+ this._nextEvents,
+ this.toolStripSeparator1,
+ this.resendDropDownButton,
+ this.toolStripSeparator3,
+ this.toolStripLabel2,
+ this.txtCount,
+ this.toolStripSeparator2});
+ this.toolStrip1.Location = new System.Drawing.Point(0, 0);
+ this.toolStrip1.Name = "toolStrip1";
+ this.toolStrip1.Size = new System.Drawing.Size(400, 25);
+ this.toolStrip1.TabIndex = 3;
+ this.toolStrip1.Text = "toolStrip1";
+ //
+ // _beginningEvents
+ //
+ this._beginningEvents.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this._beginningEvents.Name = "_beginningEvents";
+ this._beginningEvents.Size = new System.Drawing.Size(77, 22);
+ this._beginningEvents.Text = "Load Last";
+ this._beginningEvents.Click += new System.EventHandler(this.BeginningEventsClick);
+ //
+ // _nextEvents
+ //
+ this._nextEvents.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this._nextEvents.Name = "_nextEvents";
+ this._nextEvents.Size = new System.Drawing.Size(56, 22);
+ this._nextEvents.Text = "Older";
+ this._nextEvents.Click += new System.EventHandler(this.NextEventsClick);
+ //
+ // toolStripSeparator1
+ //
+ this.toolStripSeparator1.Name = "toolStripSeparator1";
+ this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
+ //
+ // resendDropDownButton
+ //
+ this.resendDropDownButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.modifySendMenuItem});
+ this.resendDropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this.resendDropDownButton.Name = "resendDropDownButton";
+ this.resendDropDownButton.Size = new System.Drawing.Size(121, 22);
+ this.resendDropDownButton.Text = "Resend Selected";
+ this.resendDropDownButton.Click += new System.EventHandler(this.ResendClick);
+ //
+ // modifySendMenuItem
+ //
+ this.modifySendMenuItem.Name = "modifySendMenuItem";
+ this.modifySendMenuItem.Size = new System.Drawing.Size(154, 22);
+ this.modifySendMenuItem.Text = "Modify && Send";
+ this.modifySendMenuItem.Click += new System.EventHandler(this.ModifySendMenuItemClick);
+ //
+ // toolStripSeparator3
+ //
+ this.toolStripSeparator3.Name = "toolStripSeparator3";
+ this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
+ //
+ // toolStripLabel2
+ //
+ this.toolStripLabel2.Name = "toolStripLabel2";
+ this.toolStripLabel2.Size = new System.Drawing.Size(40, 22);
+ this.toolStripLabel2.Text = "Count";
+ //
+ // txtCount
+ //
+ this.txtCount.Name = "txtCount";
+ this.txtCount.Size = new System.Drawing.Size(50, 25);
+ this.txtCount.Text = "500";
+ //
+ // toolStripSeparator2
+ //
+ this.toolStripSeparator2.Name = "toolStripSeparator2";
+ this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
+ //
+ // _detailsLabel
+ //
+ this._detailsLabel.BackColor = System.Drawing.Color.DimGray;
+ this._detailsLabel.Dock = System.Windows.Forms.DockStyle.Top;
+ this._detailsLabel.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this._detailsLabel.Location = new System.Drawing.Point(0, 0);
+ this._detailsLabel.Name = "_detailsLabel";
+ this._detailsLabel.Size = new System.Drawing.Size(417, 24);
+ this._detailsLabel.TabIndex = 1;
+ this._detailsLabel.Text = "Details";
+ //
+ // _domainGrid
+ //
+ this._domainGrid.AllowUserToAddRows = false;
+ this._domainGrid.AllowUserToDeleteRows = false;
+ this._domainGrid.AllowUserToOrderColumns = true;
+ this._domainGrid.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this._domainGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+ this._domainGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
+ dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+ this._domainGrid.DefaultCellStyle = dataGridViewCellStyle2;
+ this._domainGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._domainGrid.Location = new System.Drawing.Point(0, 0);
+ this._domainGrid.Name = "_domainGrid";
+ this._domainGrid.ReadOnly = true;
+ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this._domainGrid.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+ this._domainGrid.RowHeadersVisible = false;
+ this._domainGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this._domainGrid.Size = new System.Drawing.Size(398, 257);
+ this._domainGrid.TabIndex = 0;
+ this._domainGrid.SelectionChanged += new System.EventHandler(this.DataGridView1SelectionChanged);
+ //
+ // panel2
+ //
+ this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.panel2.Controls.Add(this._display);
+ this.panel2.Controls.Add(this._detailsLabel);
+ this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel2.Location = new System.Drawing.Point(406, 3);
+ this.panel2.Name = "panel2";
+ this.panel2.Size = new System.Drawing.Size(419, 284);
+ this.panel2.TabIndex = 2;
+ //
+ // splitter2
+ //
+ this.splitter2.Location = new System.Drawing.Point(403, 3);
+ this.splitter2.Name = "splitter2";
+ this.splitter2.Size = new System.Drawing.Size(3, 284);
+ this.splitter2.TabIndex = 1;
+ this.splitter2.TabStop = false;
+ //
+ // panel3
+ //
+ this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.panel3.Controls.Add(this._domainGrid);
+ this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel3.Location = new System.Drawing.Point(0, 25);
+ this.panel3.Name = "panel3";
+ this.panel3.Size = new System.Drawing.Size(400, 259);
+ this.panel3.TabIndex = 4;
+ //
+ // _domainLogTab
+ //
+ this._domainLogTab.Controls.Add(this.panel2);
+ this._domainLogTab.Controls.Add(this.splitter2);
+ this._domainLogTab.Controls.Add(this.panel4);
+ this._domainLogTab.Location = new System.Drawing.Point(4, 22);
+ this._domainLogTab.Name = "_domainLogTab";
+ this._domainLogTab.Padding = new System.Windows.Forms.Padding(3);
+ this._domainLogTab.Size = new System.Drawing.Size(828, 290);
+ this._domainLogTab.TabIndex = 0;
+ this._domainLogTab.Text = "Domain Log";
+ this._domainLogTab.UseVisualStyleBackColor = true;
+ //
+ // panel4
+ //
+ this.panel4.Controls.Add(this.panel3);
+ this.panel4.Controls.Add(this.toolStrip1);
+ this.panel4.Dock = System.Windows.Forms.DockStyle.Left;
+ this.panel4.Location = new System.Drawing.Point(3, 3);
+ this.panel4.Name = "panel4";
+ this.panel4.Size = new System.Drawing.Size(400, 284);
+ this.panel4.TabIndex = 0;
+ //
+ // tabControl1
+ //
+ this.tabControl1.Controls.Add(this._domainLogTab);
+ this.tabControl1.Controls.Add(this.viewsTab);
+ this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControl1.Location = new System.Drawing.Point(0, 0);
+ this.tabControl1.Name = "tabControl1";
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new System.Drawing.Size(836, 316);
+ this.tabControl1.TabIndex = 2;
+ //
+ // viewsTab
+ //
+ this.viewsTab.Location = new System.Drawing.Point(4, 22);
+ this.viewsTab.Name = "viewsTab";
+ this.viewsTab.Padding = new System.Windows.Forms.Padding(3);
+ this.viewsTab.Size = new System.Drawing.Size(828, 290);
+ this.viewsTab.TabIndex = 1;
+ this.viewsTab.Text = "Views";
+ this.viewsTab.UseVisualStyleBackColor = true;
+ //
+ // DomainLogView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(836, 419);
+ this.Controls.Add(this.tabControl1);
+ this.Controls.Add(this.splitter1);
+ this.Controls.Add(this.panel1);
+ this.Name = "DomainLogView";
+ this.Text = "Hub.Audit";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DomainLogView_FormClosing);
+ this.Load += new System.EventHandler(this.DomainLogView_Load);
+ this.panel1.ResumeLayout(false);
+ this.toolStrip1.ResumeLayout(false);
+ this.toolStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this._domainGrid)).EndInit();
+ this.panel2.ResumeLayout(false);
+ this.panel3.ResumeLayout(false);
+ this._domainLogTab.ResumeLayout(false);
+ this.panel4.ResumeLayout(false);
+ this.panel4.PerformLayout();
+ this.tabControl1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.RichTextBox _log;
+ private System.Windows.Forms.Splitter splitter1;
+ private System.Windows.Forms.RichTextBox _display;
+ private System.Windows.Forms.ToolStrip toolStrip1;
+ private System.Windows.Forms.ToolStripButton _beginningEvents;
+ private System.Windows.Forms.ToolStripButton _nextEvents;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
+ private System.Windows.Forms.Label _detailsLabel;
+ private System.Windows.Forms.DataGridView _domainGrid;
+ private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Splitter splitter2;
+ private System.Windows.Forms.Panel panel3;
+ private System.Windows.Forms.TabPage _domainLogTab;
+ private System.Windows.Forms.Panel panel4;
+ private System.Windows.Forms.TabControl tabControl1;
+ private System.Windows.Forms.ToolStripLabel toolStripLabel2;
+ private System.Windows.Forms.ToolStripTextBox txtCount;
+ private System.Windows.Forms.ToolStripDropDownButton resendDropDownButton;
+ private System.Windows.Forms.ToolStripMenuItem modifySendMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
+ private System.Windows.Forms.TabPage viewsTab;
+
+ }
+}
+
319 Audit/Views/DomainLogView.cs
@@ -0,0 +1,319 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Audit.Util;
+using Lokad.Cqrs;
+using Lokad.Cqrs.Envelope;
+using Recipes.Contracts;
+
+namespace Audit.Views
+{
+ public partial class DomainLogView : Form
+ {
+ int _maxCount = 500;
+
+ int MaxCount
+ {
+ get { return _maxCount; }
+ set { _maxCount = value; }
+ }
+
+ readonly LocalEventStore _client;
+
+ readonly IEnvelopeStreamer _serializer;
+ readonly ShellServices _services;
+
+ Int64 _currentId;
+
+ public DomainLogView(LocalEventStore eventStore, SimpleMessageSender endpoint, IEnvelopeStreamer serializer)
+ {
+ InitializeComponent();
+
+ _client = eventStore;
+
+ _services = new ShellServices(endpoint);
+ _serializer = serializer;
+
+ _log.BackColor = CommonColors.Solarized.Base03;
+ _log.ForeColor = CommonColors.Solarized.Base0;
+
+ _display.BackColor = CommonColors.Solarized.Base3;
+ _display.ForeColor = CommonColors.Solarized.Base00;
+
+ _detailsLabel.BackColor = CommonColors.Solarized.Base2;
+ _detailsLabel.ForeColor = CommonColors.Solarized.Base01;
+
+ var control = new RepopulateView(serializer, eventStore, _services) {Dock = DockStyle.Fill};
+ viewsTab.Controls.Add(control);
+ }
+
+ public void Log(string text, params object[] args)
+ {
+ _services.Log("DLV", text, args);
+ }
+
+ void LoadEventsTill(long maxVersion, bool sync, ToolStripItem sender)
+ {
+ var context = TaskScheduler.FromCurrentSynchronizationContext();
+ _domainGrid.DataSource = new[] {new {Message = "Loading..."}};
+
+ var start = sync ? _client.SyncLog(s => Log(s)) : Task.Factory.StartNew(() => { });
+
+ start.ContinueWith(t =>
+ {
+ var list = new List<DomainLogDisplayItem>();
+
+ long maxCount;
+ if (!Int64.TryParse(txtCount.Text, out maxCount))
+ {
+ maxCount = MaxCount;
+ }
+
+ MaxCount = (int) maxCount;
+
+ _client.ObserveTill(maxVersion, (int) maxCount, s =>
+ {
+ var envelope = _serializer.ReadAsEnvelopeData(s.Data);
+
+
+ for (int i = 0; i < envelope.Items.Length; i++)
+ {
+ var item = envelope.Items[i];
+ var session = DomainAwareAnalysis.GetCategoryNames(item);
+ // clone batch envelopes into separate ones
+ var clone = EnvelopeBuilder.CloneProperties(envelope.EnvelopeId + "-" + i, envelope);
+ clone.AddItem(item.Content);
+ list.Add(new DomainLogDisplayItem(clone.Build(), session, s.Version));
+ }
+ });
+ return list;
+ }).ContinueWith(x =>
+ {
+ if (x.Exception != null)
+ {
+ Log("Exception: {0}", x.Exception.Message);
+ Trace.WriteLine(x.Exception);
+ return;
+ }
+ var items = x.Result;
+ if (items.Count > 0)
+ {
+ var min = items.Min(i => i.StoreIndex) - 1;
+ _currentId = min;
+ }
+
+ _domainGrid.DataSource = items;
+ tabControl1.SelectedTab = _domainLogTab;
+
+ // paint
+
+ foreach (DataGridViewRow dataGridViewRow in _domainGrid.Rows)
+ {
+ var disp = (DomainLogDisplayItem) dataGridViewRow.DataBoundItem;
+ foreach (DataGridViewCell cell in dataGridViewRow.Cells)
+ {
+ disp.Style(cell);
+ }
+ }
+
+ _domainGrid.Columns[0].Width = 200;
+ _domainGrid.Columns[1].Width = 80;
+ _domainGrid.Columns[2].Width = 90;
+ _domainGrid.Columns[3].Width = 40;
+
+ Log("Displayed {0} records starting from version {1}.", items.Count, _currentId);
+ }, context)
+ .ContinueWith(_ =>
+ {
+ if (sender != null)
+ {
+ Invoke(new MethodInvoker(() => sender.Enabled = true));
+ }
+ });
+
+ if (start.Status == TaskStatus.Created)
+ start.Start();
+ }
+
+ void DataGridView1SelectionChanged(object sender, EventArgs e)
+ {
+ _display.Text = "";
+
+ var builder = new StringBuilder();
+
+
+ var rows = _domainGrid.SelectedRows;
+
+ if (rows.Count < 10)
+ {
+ foreach (DataGridViewRow row in rows)
+ {
+ var display = row.DataBoundItem as DomainLogDisplayItem;
+ if (null != display)
+ {
+ builder.AppendLine(display.ToString()).AppendLine();
+ }
+ }
+ }
+ else
+ {
+ builder.AppendLine(string.Format("There are {0} messages selected", rows.Count));
+ }
+ _display.Text = builder.ToString();
+ }
+
+ void NextEventsClick(object sender, EventArgs e)
+ {
+ _nextEvents.Enabled = false;
+ LoadEventsTill(_currentId, false, _nextEvents);
+ }
+
+ void BeginningEventsClick(object sender, EventArgs e)
+ {
+ _beginningEvents.Enabled = false;
+ LoadEventsTill(int.MaxValue, _client.IsSyncAvailable, _beginningEvents);
+ }
+
+ void ResendClick(object sender, EventArgs e)
+ {
+ if (_domainGrid.SelectedRows.Count == 0)
+ return;
+
+ var envelopes = _domainGrid.SelectedRows.Cast<DataGridViewRow>()
+ .Select(v => v.DataBoundItem)
+ .Cast<DomainLogDisplayItem>()
+ .Select(d => d).ToArray();
+ var all = envelopes
+ .SelectMany(d => d.Item.Items.Select(i => i.Content)).ToArray();
+
+
+ // don`t resend set of commands
+ if (_domainGrid.SelectedRows.Count > 1)
+ {
+ Log("Selected too many commands. Please, select only one!");
+
+ return;
+ }
+
+
+ if (Debugger.IsAttached)
+ {
+ foreach (var o in envelopes)
+ {
+ var saveEnvelopeData = _serializer.SaveEnvelopeData(o.Item);
+ Trace.WriteLine(Convert.ToBase64String(saveEnvelopeData));
+ }
+ }
+ var items = all
+ .OfType<IRecipeCommand>()
+ .ToArray();
+
+ // don`t resend set of commands
+ if (items.Length > 1)
+ {
+ Log("Too many commands in selected envelope. Please, select only one!");
+
+ //_services.Client.Put(all.ToArray());
+ return;
+ }
+
+ if (items.Length == 0)
+ {
+ Log(@"No commands to send.");
+ return;
+ }
+
+ var text = new StringBuilder();
+
+ text
+ .AppendFormat("Do you want to send message? You will have to live with the consequences!")
+ .AppendLine()
+ .Append(string.Join(";", items.Select(c => c.GetType().Name)));
+ if (
+ MessageBox.Show(this, text.ToString(), @"Send confirmation", MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2) == DialogResult.Yes)
+ {
+ foreach (var shelfCommand in items)
+ {
+ _services.SendCommand(shelfCommand);
+ }
+ }
+ }
+
+ void ModifySendMenuItemClick(object sender, EventArgs e)
+ {
+ if (_domainGrid.SelectedRows.Count == 0)
+ {
+ Log(@"No commands to send.");
+ return;
+ }
+
+ // don`t resend set of commands
+ if (_domainGrid.SelectedRows.Count > 1)
+ {
+ Log("Selected too many commands. Please, select only one!");
+ return;
+ }
+
+ try
+ {
+ var items = _domainGrid.SelectedRows
+ .Cast<DataGridViewRow>()
+ .Select(i => (DomainLogDisplayItem) i.DataBoundItem)
+ .SelectMany(d => d.Item.Items)
+ .ToList();
+
+ // don`t resend set of commands
+ if (items.Count > 1)
+ {
+ Log("Too many commands in selected envelope. Please, select only one!");
+ return;
+ }
+
+ var envelope = items.Single();
+ using (var m = new ModifyMessage())
+ {
+ m.BindMessage(envelope.MappedType, envelope.Content);
+ if (m.ShowDialog(this) != DialogResult.OK)
+ {
+ return;
+ }
+
+ var result = m.GetMessage();
+
+ if (
+ MessageBox.Show(this, @"Do you really want to send this message?", @"Sending confirmation",
+ MessageBoxButtons.YesNo) ==
+ DialogResult.No)
+ return;
+
+ _services.SendCommand((IRecipeCommand) result);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, ex.ToString(), @"Error");
+ }
+ }
+
+ void DomainLogView_Load(object sender, EventArgs e)
+ {
+ _services.ConnectLogger(_log);
+ _domainGrid.Focus();
+
+ Log("Starting sync...");
+
+ LoadEventsTill(int.MaxValue, _client.IsSyncAvailable, null);
+ }
+
+ void DomainLogView_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ _services.Disconnect();
+ }
+ }
+}
123 Audit/Views/DomainLogView.resx
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+</root>
74 Audit/Views/DomainScanner.cs
@@ -0,0 +1,74 @@
+#region (c) 2010-2011 Lokad CQRS - New BSD License
+
+// Copyright (c) Lokad SAS 2010-2012 (http://www.lokad.com)
+// This code is released as Open Source under the terms of the New BSD License
+// Homepage: http://lokad.github.com/lokad-cqrs/
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Lokad.Cqrs.AtomicStorage;
+using Recipes.Projections;
+using Recipes.Wires;
+
+namespace Audit.Views
+{
+ public static class DomainScanner
+ {
+ sealed class AtomicDetector : IAtomicContainer
+ {
+ public readonly List<Tuple<Type, Type>> List = new List<Tuple<Type, Type>>();
+
+ public IAtomicWriter<TKey, TEntity> GetEntityWriter<TKey, TEntity>()
+ {
+ List.Add(Tuple.Create(typeof(TKey), typeof(TEntity)));
+ return null;
+ }
+
+ public IAtomicReader<TKey, TEntity> GetEntityReader<TKey, TEntity>()
+ {
+ throw new NotImplementedException();
+ }
+
+ public IAtomicStorageStrategy Strategy
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public IEnumerable<AtomicRecord> EnumerateContents()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void WriteContents(IEnumerable<AtomicRecord> records)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public static IEnumerable<ViewMapInfo> GetActiveViewMaps()
+ {
+ var marker = new AtomicDetector();
+ var projections = BootstrapProjections.BuildProjectionsWithWhenConvention(marker)
+ .ToArray();
+
+ int idx = 0;
+ foreach (var projection in projections)
+ {
+ var redirect = new RedirectToDynamicEvent();
+ redirect.WireToWhen(projection);
+ var mark = marker.List[idx];
+ yield return new ViewMapInfo(mark.Item2, mark.Item1, projection.GetType(), redirect.Dict.Keys.ToArray())
+ ;
+ idx += 1;
+ }
+ }
+ }
+}
144 Audit/Views/LoadSettingsForm.Designer.cs
@@ -0,0 +1,144 @@
+namespace Audit.Views
+{
+ partial class LoadSettingsForm
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoadSettingsForm));
+ this._ok = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this._file = new System.Windows.Forms.TextBox();
+ this._browse = new System.Windows.Forms.Button();
+ this.label3 = new System.Windows.Forms.Label();
+ this._storage = new System.Windows.Forms.TextBox();
+ this._help = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // _ok
+ //
+ this._ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this._ok.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this._ok.Location = new System.Drawing.Point(383, 118);
+ this._ok.Name = "_ok";
+ this._ok.Size = new System.Drawing.Size(75, 23);
+ this._ok.TabIndex = 1;
+ this._ok.Text = "OK";
+ this._ok.UseVisualStyleBackColor = true;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 24);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(64, 13);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Settings File";
+ //
+ // _file
+ //
+ this._file.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this._file.Enabled = false;
+ this._file.Location = new System.Drawing.Point(12, 40);
+ this._file.Name = "_file";
+ this._file.Size = new System.Drawing.Size(412, 20);
+ this._file.TabIndex = 3;
+ //
+ // _browse
+ //
+ this._browse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this._browse.Location = new System.Drawing.Point(430, 38);
+ this._browse.Name = "_browse";
+ this._browse.Size = new System.Drawing.Size(28, 23);
+ this._browse.TabIndex = 4;
+ this._browse.Text = "...";
+ this._browse.UseVisualStyleBackColor = true;
+ this._browse.Click += new System.EventHandler(this.BrowseClick);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(12, 68);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(87, 13);
+ this.label3.TabIndex = 5;
+ this.label3.Text = "Storage Account";
+ //
+ // _storage
+ //
+ this._storage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this._storage.Enabled = false;
+ this._storage.Location = new System.Drawing.Point(12, 84);
+ this._storage.Name = "_storage";
+ this._storage.Size = new System.Drawing.Size(446, 20);
+ this._storage.TabIndex = 3;
+ //
+ // _help
+ //
+ this._help.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this._help.Location = new System.Drawing.Point(12, 118);
+ this._help.Name = "_help";
+ this._help.Size = new System.Drawing.Size(75, 23);
+ this._help.TabIndex = 6;
+ this._help.Text = "Help...";
+ this._help.UseVisualStyleBackColor = true;
+ this._help.Click += new System.EventHandler(this._help_Click);
+ //
+ // LoadSettingsForm
+ //
+ this.AcceptButton = this._ok;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(470, 153);
+ this.Controls.Add(this._help);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this._browse);
+ this.Controls.Add(this._storage);
+ this.Controls.Add(this._file);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this._ok);
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.Name = "LoadSettingsForm";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Starting Maintenance...";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button _ok;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox _file;
+ private System.Windows.Forms.Button _browse;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.TextBox _storage;
+ private System.Windows.Forms.Button _help;
+ }
+}
127 Audit/Views/LoadSettingsForm.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Windows.Forms;
+using System.Xml.Linq;
+using Audit.Properties;
+
+namespace Audit.Views
+{
+ public partial class LoadSettingsForm : Form
+ {
+ IDictionary<string, string> _settings = new Dictionary<string, string>();
+
+ public bool ConfigFileSelected { get; private set; }
+
+ public LoadSettingsForm()
+ {
+ InitializeComponent();
+
+ Shown += OnLoad;
+ }
+
+
+ void OnLoad(object sender, EventArgs eventArgs)
+ {
+ if (