Files
DP44/Common/DTS.Common/Events/PageErrorEvent.cs
2026-04-17 14:55:32 -04:00

47 lines
1.3 KiB
C#

using DTS.Common.Utilities.Logging;
using Prism.Events;
using Prism.Ioc;
using System;
namespace DTS.Common.Events
{
/// <summary>
/// Event to inform app that it should mark itself busy or available
/// </summary>
/// <remarks>
///
/// </remarks>
public class PageErrorEvent : PubSubEvent<PageErrorArg>
{
/// <summary>
/// surfaces an error to the application, if applicable
/// http://manuscript.dts.local/f/cases/28312/Surface-Read-does-not-match-write-to-user
/// </summary>
/// <param name="msg"></param>
public static void SurfaceApplicationError(string msg)
{
try
{
var eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new[] { msg }, null));
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
}
public class PageErrorArg
{
public string[] Errors { get; }
public object Page { get; }
public bool Handled { get; set; }
public PageErrorArg(string[] errors, object page)
{
Errors = errors;
Page = page;
}
}
}