Explorar o código

添加项目文件。

旭 王 hai 1 semana
pai
achega
3a15f6e6e8

+ 25 - 0
SK-Test.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32630.194
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApp1", "WpfApp1\WpfApp1.csproj", "{06E0F80B-2D66-4D50-BFDD-CC9129568895}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{06E0F80B-2D66-4D50-BFDD-CC9129568895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{06E0F80B-2D66-4D50-BFDD-CC9129568895}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{06E0F80B-2D66-4D50-BFDD-CC9129568895}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{06E0F80B-2D66-4D50-BFDD-CC9129568895}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {A4275A8D-E534-4A27-B323-CADB67027EBB}
+	EndGlobalSection
+EndGlobal

+ 6 - 0
WpfApp1/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+    </startup>
+</configuration>

+ 9 - 0
WpfApp1/App.xaml

@@ -0,0 +1,9 @@
+<Application x:Class="WpfApp1.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:WpfApp1"
+             StartupUri="MainWindow.xaml">
+    <Application.Resources>
+         
+    </Application.Resources>
+</Application>

+ 21 - 0
WpfApp1/App.xaml.cs

@@ -0,0 +1,21 @@
+using NLog;
+using NLog.Config;
+using NLog.Targets;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace WpfApp1
+{
+    /// <summary>
+    /// App.xaml 的交互逻辑
+    /// </summary>
+    public partial class App : Application
+    {
+
+    }
+}

+ 30 - 0
WpfApp1/ILogger.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfApp1
+{
+    /// <summary>
+    /// 通用的日志接口
+    /// </summary>
+    public interface ILogger
+    {
+        /// <summary>
+        /// 调试跟踪(预留)
+        /// </summary>
+        /// <param name="message"></param>
+        void Trace(string message);
+
+        void Debug(string message);
+
+        void Info(string message);
+
+        void Warn(string message);
+
+        void Error(string message, Exception ex = null);
+
+        void Fatal(string message, Exception ex = null);
+    }
+}

+ 29 - 0
WpfApp1/LogDataService.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace WpfApp1
+{
+    public class LogDataService
+    {
+        private static LogDataService instance;
+
+        private readonly object lockObject = new object();
+        public ObservableCollection<LoggingEventModel> LogEventModels { get; set; } = new ObservableCollection<LoggingEventModel>();
+
+        public static LogDataService Instance()
+        {
+            if (instance == null) instance = new LogDataService();
+            return instance;
+        }
+
+        private LogDataService()
+        {
+            BindingOperations.EnableCollectionSynchronization(LogEventModels, lockObject);
+        }
+    }
+}

+ 24 - 0
WpfApp1/LogFactory.cs

@@ -0,0 +1,24 @@
+using NLog;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfApp1
+{
+    public class LogFactory
+    {
+        public enum LogCategory
+        {
+            ProductionLogger,
+            ParameterLogger,
+            ProcessLogger,
+            ActionLogger
+        }
+        public static ILogger Get(string category)
+        {
+            return new NLogLogger(category);
+        }
+    }
+}

+ 30 - 0
WpfApp1/LoggingEventModel.cs

@@ -0,0 +1,30 @@
+using NLog;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfApp1
+{
+    public class LoggingEventModel
+    {
+        public string Logger { get; set; }
+        public string Timestamp { get; set; }
+        public string Level { get; set; }
+        public string Thread { get; set; }
+        public string Message { get; set; }
+        public string Exception { get; set; }
+
+
+        public LoggingEventModel(LogEventInfo loggingEvent)
+        {
+            Logger = loggingEvent.LoggerName;
+            Timestamp = loggingEvent.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss,fff");
+            Level = loggingEvent.Level.Name;
+            Thread = Convert.ToString(System.Threading.Thread.CurrentThread.ManagedThreadId);
+            Message = loggingEvent.Message;
+            Exception = loggingEvent.Exception?.Message;
+        }
+    }
+}

+ 30 - 0
WpfApp1/LoggingEventTarget.cs

@@ -0,0 +1,30 @@
+using NLog;
+using NLog.Targets;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfApp1
+{
+    /// <summary>
+    /// NLog 扩展
+    /// </summary>
+    public class LoggingEventTarget : TargetWithLayout
+    {
+        static readonly int LOGVIEW_MAXLINE = 1000;
+
+        private readonly LogDataService logDataService = LogDataService.Instance();
+
+        protected override void Write(LogEventInfo loggingEvent)
+        {
+            logDataService.LogEventModels.Insert(0, new LoggingEventModel(loggingEvent));
+
+            if (logDataService.LogEventModels.Count == LOGVIEW_MAXLINE)
+            {
+                logDataService.LogEventModels.RemoveAt(LOGVIEW_MAXLINE - 1);
+            }
+        }
+    }
+}

+ 13 - 0
WpfApp1/MainViewModel.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfApp1
+{
+    public class MainViewModel
+    {
+        public LogDataService LogDataService { get; set; } = LogDataService.Instance();
+    }
+}

+ 53 - 0
WpfApp1/MainWindow.xaml

@@ -0,0 +1,53 @@
+<Window x:Class="WpfApp1.MainWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:WpfApp1"
+        mc:Ignorable="d"
+        Title="MainWindow" Height="450" Width="800"
+        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase">
+    <Window.Resources>
+        <CollectionViewSource x:Key="SortedLogs" Source="{Binding LogDataService.LogEventModels}">
+            <CollectionViewSource.SortDescriptions>
+                <scm:SortDescription Direction="Descending" PropertyName="Timestamp" />
+            </CollectionViewSource.SortDescriptions>
+        </CollectionViewSource>
+    </Window.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <WrapPanel>
+            <Button Content="运行生产/机台操作/MES通讯" Height="50" Width="200" Margin="10" Click="Button_Click"/>
+            <Button Content="参数修改" Height="50" Width="200" Margin="10" Click="Button_Click_1"/>
+            <Button Content="流程步骤及状态" Height="50" Width="200" Margin="10" Click="Button_Click_2"/>
+            <Button Content="动作执行/视觉通讯" Height="50" Width="200" Margin="10" Click="Button_Click_3"/>
+        </WrapPanel>
+        <ListView
+                Margin="10,0,10,0"
+                ItemsSource="{Binding Source={StaticResource SortedLogs}}" Grid.Row="1">
+            <ListView.View>
+                <GridView>
+                    <GridViewColumn
+                            Width="160"
+                            DisplayMemberBinding="{Binding Timestamp}"
+                            Header="时间" />
+                    <GridViewColumn
+                            Width="60"
+                            DisplayMemberBinding="{Binding Level}"
+                            Header="级别" />
+                    <GridViewColumn
+                            Width="60"
+                            DisplayMemberBinding="{Binding Thread}"
+                            Header="线程" />
+                    <GridViewColumn
+                            Width="600"
+                            DisplayMemberBinding="{Binding Message}"
+                            Header="消息" />
+                </GridView>
+            </ListView.View>
+        </ListView>
+    </Grid>
+</Window>

+ 54 - 0
WpfApp1/MainWindow.xaml.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace WpfApp1
+{
+    /// <summary>
+    /// MainWindow.xaml 的交互逻辑
+    /// </summary>
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+            this.DataContext = new MainViewModel();
+
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            ILogger logger = LogFactory.Get(LogFactory.LogCategory.ProductionLogger.ToString());
+            logger.Debug("这是一条生产数据");
+        }
+
+        private void Button_Click_1(object sender, RoutedEventArgs e)
+        {
+            ILogger logger = LogFactory.Get(LogFactory.LogCategory.ParameterLogger.ToString());
+            logger.Debug("这是一条参数数据");
+        }
+
+        private void Button_Click_2(object sender, RoutedEventArgs e)
+        {
+            ILogger logger = LogFactory.Get(LogFactory.LogCategory.ProcessLogger.ToString());
+            logger.Debug("这是一条流程数据");
+        }
+
+        private void Button_Click_3(object sender, RoutedEventArgs e)
+        {
+            ILogger logger = LogFactory.Get(LogFactory.LogCategory.ActionLogger.ToString());
+            logger.Debug("这是一条动作数据");
+        }
+    }
+}

+ 86 - 0
WpfApp1/NLog.config

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+	<!-- 定义日志输出格式模板 -->
+	<variable name="myLayout" value="[${longdate}] ${level:uppercase=true} ${threadid}[${callsite:className=true:methodName=false}] - ${message}${exception:format=toString}" />
+
+	<!-- 全局设置:定义四个不同的异步文件目标 -->
+	<targets>
+		<!-- 1. 生产日志 (运行生产、机台操作、MES通讯) -->
+		<target name="ProductionFile" xsi:type="AsyncWrapper" queueLimit="10000" overflowAction="Discard">
+			<target xsi:type="File"
+                    fileName="D:/SkyUnion/Test/logs/生产/${shortdate}.log"
+                    layout="${myLayout}"
+                    archiveEvery="Day"
+                    archiveAboveSize="1024"
+                    archiveNumbering="Rolling"
+                    maxArchiveFiles="30"
+                    concurrentWrites="true"
+                    keepFileOpen="false"
+                    encoding="utf-8"/>
+		</target>
+
+		<!-- 2. 参数日志 (参数修改) -->
+		<target name="ParameterFile" xsi:type="AsyncWrapper" queueLimit="10000" overflowAction="Discard">
+			<target xsi:type="File"
+                    fileName="D:/SkyUnion/Test/logs/参数/${shortdate}.log"
+                    layout="${myLayout}"
+                    archiveEvery="Day"
+                    archiveAboveSize="104857600"
+                    archiveNumbering="Rolling"
+                    maxArchiveFiles="30"
+                    concurrentWrites="true"
+                    keepFileOpen="false"
+                    encoding="utf-8"/>
+		</target>
+
+		<!-- 3. 流程日志 (流程步骤及状态) -->
+		<target name="ProcessFile" xsi:type="AsyncWrapper" queueLimit="10000" overflowAction="Discard">
+			<target xsi:type="File"
+                    fileName="D:/SkyUnion/Test/logs/流程/${shortdate}.log"
+                    layout="${myLayout}"
+                    archiveEvery="Day"
+                    archiveAboveSize="104857600"
+                    archiveNumbering="Rolling"
+                    maxArchiveFiles="30"
+                    concurrentWrites="true"
+                    keepFileOpen="false"
+                    encoding="utf-8"/>
+		</target>
+
+		<!-- 4. 动作日志 (动作执行、视觉通讯) -->
+		<target name="ActionFile" xsi:type="AsyncWrapper" queueLimit="10000" overflowAction="Discard">
+			<target xsi:type="File"
+                    fileName="D:/SkyUnion/Test/logs/动作/${shortdate}.log"
+                    layout="${myLayout}"
+                    archiveEvery="Day"
+                    archiveAboveSize="104857600"
+                    archiveNumbering="Rolling"
+                    maxArchiveFiles="30"
+                    concurrentWrites="true"
+                    keepFileOpen="false"
+                    encoding="utf-8"/>
+		</target>
+
+		<target name="LoggingEventTarget" xsi:type="WpfApp1.LoggingEventTarget"/>
+	</targets>
+
+	<!-- 规则设置:将不同名称的 logger 映射到对应的目标文件 -->
+	<rules>
+		<!-- 所有名为 "ProductionLogger" 的日志写入 生产.log -->
+		<logger name="ProductionLogger" minlevel="Trace" writeTo="ProductionFile" />
+
+		<!-- 所有名为 "ParameterLogger" 的日志写入 参数.log -->
+		<logger name="ParameterLogger" minlevel="Trace" writeTo="ParameterFile" />
+
+		<!-- 所有名为 "ProcessLogger" 的日志写入 流程.log -->
+		<logger name="ProcessLogger" minlevel="Trace" writeTo="ProcessFile" />
+
+		<!-- 所有名为 "ActionLogger" 的日志写入 动作.log -->
+		<logger name="ActionLogger" minlevel="Trace" writeTo="ActionFile" />
+
+		<!-- 所有日志 >= Tarce 写到LoggingEventTarget类 -->
+		<logger name="*" minlevel="Trace" writeTo="LoggingEventTarget" />
+	</rules>
+</nlog>

+ 49 - 0
WpfApp1/NLogLogger.cs

@@ -0,0 +1,49 @@
+using NLog;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfApp1
+{
+    public class NLogLogger : ILogger
+    {
+
+        private readonly Logger log;
+
+        public NLogLogger(string category)
+        {
+            log = LogManager.GetLogger(category);
+        }
+
+        public void Debug(string message)
+        {
+            log.Debug(message);
+        }
+        public void Info(string message)
+        {
+            log.Info(message);
+        }
+
+        public void Trace(string message)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Warn(string message)
+        {
+            log.Warn(message);
+        }
+
+        public void Error(string message, Exception ex = null)
+        {
+            log.Error(message, ex);
+        }
+
+        public void Fatal(string message, Exception ex = null)
+        {
+            log.Fatal(message, ex);
+        }
+    }
+}

+ 55 - 0
WpfApp1/Properties/AssemblyInfo.cs

@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("WpfApp1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WpfApp1")]
+[assembly: AssemblyCopyright("Copyright ©  2026")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
+//例如,如果您在源文件中使用的是美国英语,
+//使用的是美国英语,请将 <UICulture> 设置为 en-US。  然后取消
+//对以下 NeutralResourceLanguage 特性的注释。  更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+                                     //(未在页面中找到资源时使用,
+                                     //或应用程序资源字典中找到时使用)
+    ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+                                              //(未在页面中找到资源时使用,
+                                              //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 70 - 0
WpfApp1/Properties/Resources.Designer.cs

@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+
+namespace WpfApp1.Properties
+{
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [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>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WpfApp1.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   重写当前线程的 CurrentUICulture 属性,对
+        ///   使用此强类型资源类的所有资源查找执行重写。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
WpfApp1/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?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.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: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" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </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" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 29 - 0
WpfApp1/Properties/Settings.Designer.cs

@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+
+namespace WpfApp1.Properties
+{
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.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 - 0
WpfApp1/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 114 - 0
WpfApp1/WpfApp1.csproj

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{06E0F80B-2D66-4D50-BFDD-CC9129568895}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>WpfApp1</RootNamespace>
+    <AssemblyName>WpfApp1</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <WarningLevel>4</WarningLevel>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <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' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+      <HintPath>..\packages\NLog.5.0.0\lib\net46\NLog.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.IO.Compression" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xaml">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase" />
+    <Reference Include="PresentationCore" />
+    <Reference Include="PresentationFramework" />
+  </ItemGroup>
+  <ItemGroup>
+    <ApplicationDefinition Include="App.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </ApplicationDefinition>
+    <Compile Include="ILogger.cs" />
+    <Compile Include="LogFactory.cs" />
+    <Compile Include="MainViewModel.cs" />
+    <Compile Include="NLogLogger.cs" />
+    <Page Include="MainWindow.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Compile Include="App.xaml.cs">
+      <DependentUpon>App.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="LogDataService.cs" />
+    <Compile Include="LoggingEventModel.cs" />
+    <Compile Include="LoggingEventTarget.cs" />
+    <Compile Include="MainWindow.xaml.cs">
+      <DependentUpon>MainWindow.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <None Include="NLog.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Include="packages.config" />
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 4 - 0
WpfApp1/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="NLog" version="5.0.0" targetFramework="net472" />
+</packages>