Skip to content

Commit

Permalink
Merge branch 'master' into public
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Carlson committed Sep 26, 2017
2 parents b98ddfb + 5e0b519 commit 9e44eb2
Show file tree
Hide file tree
Showing 353 changed files with 587,738 additions and 3,509 deletions.
145 changes: 121 additions & 24 deletions Source/Deployment/Monahrq-Installer.ism

Large diffs are not rendered by default.

Binary file modified Source/Deployment/welcome.bmp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Monahrq.Default.Views;
using Monahrq.Sdk.Events;
using System.Diagnostics;
using Monahrq.Infrastructure;


namespace Monahrq.Default.Controllers
Expand Down Expand Up @@ -37,14 +38,17 @@ public abstract class DefaultCompositeUIEventHandler<T>
public class SimpleImportCompleteHandler : DefaultCompositeUIEventHandler<ISimpleImportCompletedPayload>,
ISimpleImportCompleteHandler
{
[Import(LogNames.Session)]
public ILogWriter Logger { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="SimpleImportCompleteHandler"/> class.
/// </summary>
/// <param name="events">The events.</param>
[ImportingConstructor]
public SimpleImportCompleteHandler(IEventAggregator events)
{
events.GetEvent<SimpleImportCompletedEvent>().Subscribe(payload => Handle(payload));
events.GetEvent<SimpleImportCompletedEvent>().Subscribe(Handle);
}

/// <summary>
Expand All @@ -53,6 +57,8 @@ public SimpleImportCompleteHandler(IEventAggregator events)
/// <param name="result">The result.</param>
public override void Handle(ISimpleImportCompletedPayload result)
{
this.Logger.Information($@"Simple import completed for {result.Description}; {result.CountInserted} rows inserted, {result.NumberOfErrors} errors encountered");

if (result.NumberOfErrors == 0 && result.CountInserted > 0)
{
MessageBox.Show(Application.Current.MainWindow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Practices.Prism.Events;
using Microsoft.Practices.Prism.Regions;
using Monahrq.Default.Views;
using Monahrq.Infrastructure;
using Monahrq.Sdk.Events;
using Monahrq.Sdk.Regions;

Expand Down Expand Up @@ -39,6 +40,9 @@ public class PleaseStandByHandler : DefaultCompositeUIEventHandler<PleaseStandBy
[Import]
IEventAggregator Events { get; set; }

[Import(LogNames.Session)]
public ILogWriter Logger { get; set; }

/// <summary>
/// Handles the specified result.
/// </summary>
Expand All @@ -49,10 +53,13 @@ public override void Handle(PleaseStandByEventPayload result)
ctrl.Model = result;
Events.GetEvent<PleaseStandByMessageUpdateEvent>().Subscribe(msg =>
{
this.Logger.Debug($"Processing update: {msg}");
ctrl.Model.Message = msg;
ctrl.Refresh();
});


this.Logger.Debug("Pausing normal processing");

IRegion region = RegionManager.Regions[RegionNames.Modal];
if (!region.Views.Contains(ctrl))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Microsoft.Practices.Prism.Regions;
using Monahrq.Default.Views;
using Monahrq.Infrastructure;
using Monahrq.Sdk.Events;
using Monahrq.Sdk.Regions;

Expand All @@ -14,7 +15,7 @@ namespace Monahrq.Default.Controllers
/// <summary>
/// class to resume the processing
/// </summary>
/// <seealso cref="Monahrq.Default.Controllers.DefaultCompositeUIEventHandler{Monahrq.Sdk.Events.Empty}" />
/// <seealso cref="Empty" />
[Export]
public class ResumeNormalProcessingHandler : DefaultCompositeUIEventHandler<Empty>
{
Expand All @@ -27,6 +28,10 @@ public class ResumeNormalProcessingHandler : DefaultCompositeUIEventHandler<Empt
/// </value>
[Import]
IRegionManager RegionManager { get; set; }

[Import(LogNames.Session)]
public ILogWriter Logger { get; set; }

/// <summary>
/// Handles the specified payload.
/// </summary>
Expand All @@ -36,6 +41,7 @@ public override void Handle(Empty payload)
var deactivateThese = RegionManager.Regions[RegionNames.Modal].Views.OfType<PleaseStandBy>();
foreach (var ctrl in deactivateThese)
{
this.Logger.Debug("Resuming normal processing");
RegionManager.Regions[RegionNames.Modal].Deactivate(ctrl);
RegionManager.Regions[RegionNames.Modal].Remove(ctrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.Practices.Prism.Events;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using Monahrq.Infrastructure;
using Monahrq.Sdk.DataProvider.Builder;
using Monahrq.Sdk.Regions;

Expand Down Expand Up @@ -45,21 +46,11 @@ IDataProviderAdministratorController Controller
}


IEventAggregator Events
{
get
{
return ServiceLocator.Current.GetInstance<IEventAggregator>();
}
}
private IEventAggregator Events => ServiceLocator.Current.GetInstance<IEventAggregator>();
private IRegion DialogRegion => ServiceLocator.Current.GetInstance<IRegionManager>().Regions[RegionNames.Modal];

IRegion DialogRegion
{
get
{
return ServiceLocator.Current.GetInstance<IRegionManager>().Regions[RegionNames.Modal];
}
}
[Import]
public ILogWriter Logger { get; set; }

[ImportingConstructor]
public DataProviderAdministratorView(IServiceLocator serviceLocator,
Expand All @@ -71,17 +62,21 @@ public DataProviderAdministratorView(IServiceLocator serviceLocator,
.Subscribe(evnt => LoadBuilderDialog(evnt.Configuration));

Events.GetEvent<DataProviderAdministratorController.DeletingEvent>()
.Subscribe(evnt => PromptForDelete(evnt));
.Subscribe(PromptForDelete);
}

private void PromptForDelete(DeletingConnectionEventArgs evnt)
{
evnt.Cancel =
MessageBox.Show(Application.Current.MainWindow,
var result = MessageBox.Show(
Application.Current.MainWindow,
string.Format(@"Delete ""{0}"" ?", evnt.Connection.Name),
"Delete Connection?",
MessageBoxButton.YesNo,
MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No;
MessageBoxImage.Question, MessageBoxResult.No);

this.Logger.Debug($"User responded '{result}' to prompt \"Delete {evnt.Connection.Name}\"");

evnt.Cancel = result == MessageBoxResult.No;
}

private void LoadBuilderDialog(Infrastructure.Configuration.NamedConnectionElement connection)
Expand Down
8 changes: 5 additions & 3 deletions Source/Framework/Monahrq.Default/DefaultModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Microsoft.Practices.ServiceLocation;
using Monahrq.Default.Controllers;
using Monahrq.Default.Views;
using Monahrq.Infrastructure;
using Monahrq.Infrastructure.Services;
using Monahrq.Sdk.Attributes.Wings;
using Monahrq.Sdk.Events;
using Monahrq.Sdk.Modules;
Expand Down Expand Up @@ -59,7 +61,7 @@ IRegion PopupRegion
/// <summary>
/// The logger
/// </summary>
private readonly ILoggerFacade _logger;
private readonly ILogWriter _logger;
/// <summary>
/// The plugin tracker
/// </summary>
Expand All @@ -84,7 +86,7 @@ IRegion PopupRegion
/// or
/// moduleTracker</exception>
[ImportingConstructor]
public DefaultModule(ILoggerFacade logger, IRegionManager regionManager, IPluginModuleTracker pluginTracker, IEventAggregator events)
public DefaultModule(ILogWriter logger, IRegionManager regionManager, IPluginModuleTracker pluginTracker, IEventAggregator events)
{
Events = events;
if (logger == null)
Expand Down Expand Up @@ -148,7 +150,7 @@ public DefaultModule(ILoggerFacade logger, IRegionManager regionManager, IPlugin
/// </summary>
public void Initialize()
{
_logger.Log("Monahrq.Default demonstrates logging during Initialize().", Category.Info, Priority.Medium);
_logger.Write("Monahrq.Default demonstrates logging during Initialize().");

//_regionManager.RegisterViewWithRegion(Sdk.Regions.RegionNames.Modal, typeof(DataProvider.Administration.DataProviderAdministratorView));

Expand Down
5 changes: 5 additions & 0 deletions Source/Framework/Monahrq.Default/ViewModels/BaseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Threading.Tasks;
using Monahrq.Infrastructure;
using Monahrq.Infrastructure.Extensions;
using Monahrq.Sdk.Logging;

namespace Monahrq.Default.ViewModels
{
Expand Down Expand Up @@ -76,6 +77,8 @@ protected BaseViewModel()
ViewImportSampleCommand = new DelegateCommand<string>(OnViewSample);
}

private readonly Lazy<ILogWriter> logger = new Lazy<ILogWriter>(() => new SessionLogger(new CallbackLogger()));

/// <summary>
/// Initializes a new instance of the <see cref="BaseViewModel"/> class.
/// </summary>
Expand Down Expand Up @@ -130,6 +133,8 @@ public bool Committed

public DelegateCommand<string> ViewImportSampleCommand { get; set; }

protected ILogWriter Logger => this.logger.Value;

/// <summary>
/// Internal list of errors
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.Practices.Prism.Logging;
using Monahrq.Infrastructure.Domain;
using Monahrq.Infrastructure.Entities.Domain;


Expand Down Expand Up @@ -52,11 +53,13 @@ public override void LoadData()
(ImportType == BaseDataImportStrategyType.Append || VersionStrategy.IsNewest()))
{
// start transaction
Logger.Write($"Processing base data update for type {typeof(TEntity).Name} from file {file}");
var rows = 0;

// Verify data file exists.
if (!File.Exists(Path.Combine(baseDataDir, file)))
{
Logger.Log(string.Format("Import file \"{0}\" missing from the base data resources directory.", file), Category.Warn, Priority.Medium);
Logger.Warning("Import file \"{0}\" missing from the base data resources directory.", file);
return;
}

Expand Down Expand Up @@ -102,9 +105,9 @@ public override void LoadData()

if (reader == null)
{
Logger.Log(string.Format(
"A problem occurred while trying to read CSV file \"{0}\". Please make sure that the file is properly formated and has data.",
file), Category.Exception, Priority.High);
Logger.Warning(
"A problem occurred while trying to read CSV file \"{0}\". Please make sure that the file is properly formated and has data.",
file);
return;
}

Expand All @@ -115,21 +118,25 @@ public override void LoadData()
var temp = LoadFromReader(reader);
if (temp != null)
bulkImporter.Insert(temp);
rows++;
}
}
}
}
}
}

SchemaVersion version;
using (var session = DataProvider.SessionFactory.OpenSession())
{
var version = VersionStrategy.GetVersion(session);

version = VersionStrategy.GetVersion(session);
session.SaveOrUpdate(version);
session.Flush();
}

// commit transaction
Logger.Information(
$"Base data update completed for type {typeof(TEntity).Name}: {rows} rows inserted or updated; now at schema version {version}");
}
}

Expand All @@ -139,7 +146,7 @@ public override void LoadData()
}
catch (Exception ex)
{
Logger.Log(ex.ToString(), Category.Warn, Priority.Medium);
Logger.Write(ex, "Error loading base data for entity {0}", typeof(TEntity).Name);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.Prism.Logging;
using Monahrq.Infrastructure.Domain;
using Monahrq.Infrastructure.Entities.Domain;

namespace Monahrq.Infrastructure.BaseDataLoader
Expand Down Expand Up @@ -32,6 +33,9 @@ public override void LoadData()
{
if (!VersionStrategy.IsLoaded() && VersionStrategy.IsNewest())
{
Logger.Information($"Processing base data update for type {typeof(TEntity).Name}");

var rows = 0;
// start transaction
using (var session = DataProvider.SessionFactory.OpenStatelessSession())
{
Expand Down Expand Up @@ -62,23 +66,27 @@ public override void LoadData()
if (temp != null)
{
bulkImporter.Insert(temp);
rows++;
}
}
}
}

SchemaVersion version;
using (var session = DataProvider.SessionFactory.OpenSession())
{
var version = VersionStrategy.GetVersion(session);

version = VersionStrategy.GetVersion(session);
session.SaveOrUpdate(version);
session.Flush();
}

Logger.Information($"Base data update completed for type {typeof(TEntity).Name}: {rows} rows inserted or updated; now at schema version {version}");
}
}
catch (Exception ex)
{
Logger.Log(ex.ToString(), Category.Warn, Priority.Medium);
Logger.Write(ex, "Error importing {0} enumeration values for data type {1}", typeof(TEnum).Name,
typeof(TEntity).Name);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class BaseDataImporter<TEntity, TKey> : IBaseDataImporter<TEntit
/// The logger.
/// </value>
[Import(LogNames.Session)]
public ILoggerFacade Logger { get; set; }
public ILogWriter Logger { get; set; }

/// <summary>
/// Gets the loader priority.
Expand Down
Loading

0 comments on commit 9e44eb2

Please sign in to comment.