diff --git a/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj b/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj index 57cb908..9bab1d8 100644 --- a/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj +++ b/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj @@ -54,6 +54,9 @@ ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + ..\packages\NLog.4.0.1\lib\net45\NLog.dll + diff --git a/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs b/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs index eb4befa..ce06888 100644 --- a/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs +++ b/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs @@ -7,6 +7,7 @@ using System.Windows.Media.Imaging; using Filtration.Common.ViewModels; using Filtration.Interface; using Filtration.ThemeEditor.Providers; +using NLog; using MessageBox = System.Windows.MessageBox; namespace Filtration.ThemeEditor.ViewModels @@ -23,6 +24,8 @@ namespace Filtration.ThemeEditor.ViewModels public class ThemeViewModel : PaneViewModel, IThemeViewModel { + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private readonly IThemeProvider _themeProvider; private bool _filenameIsFake; private string _filePath; @@ -85,6 +88,11 @@ namespace Filtration.ThemeEditor.ViewModels } catch (Exception e) { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } + MessageBox.Show(@"Error saving filter theme - " + e.Message, @"Save Error", MessageBoxButton.OK, MessageBoxImage.Error); } @@ -103,19 +111,24 @@ namespace Filtration.ThemeEditor.ViewModels if (result != DialogResult.OK) return; var previousFilePath = FilePath; - //try - //{ + try + { FilePath = saveDialog.FileName; _themeProvider.SaveTheme(this, FilePath); _filenameIsFake = false; //RemoveDirtyFlag(); - //} - //catch (Exception e) - //{ - // MessageBox.Show(@"Error saving theme file - " + e.Message, @"Save Error", MessageBoxButton.OK, - // MessageBoxImage.Error); - // FilePath = previousFilePath; - //} + } + catch (Exception e) + { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } + + MessageBox.Show(@"Error saving theme file - " + e.Message, @"Save Error", MessageBoxButton.OK, + MessageBoxImage.Error); + FilePath = previousFilePath; + } } public void Close() diff --git a/Filtration.ThemeEditor/packages.config b/Filtration.ThemeEditor/packages.config index 14e5679..c1b45aa 100644 --- a/Filtration.ThemeEditor/packages.config +++ b/Filtration.ThemeEditor/packages.config @@ -6,4 +6,5 @@ + \ No newline at end of file diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index 7c7c9c6..72f4316 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -14,12 +14,14 @@ using Filtration.Properties; using Filtration.ThemeEditor.ViewModels; using Filtration.ViewModels; using Filtration.Views; +using NLog; namespace Filtration { public partial class App { private IWindsorContainer _container; + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private void Application_Startup(object sender, StartupEventArgs e) { @@ -67,6 +69,8 @@ namespace Filtration public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { + _logger.Fatal(e.Exception); + var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace; var innerException = e.Exception.InnerException != null ? e.Exception.InnerException.Message + Environment.NewLine + diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index 5c4307c..b57ba4c 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -64,6 +64,9 @@ False ..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + ..\packages\NLog.4.0.1\lib\net45\NLog.dll + @@ -360,6 +363,12 @@ ResXFileCodeGenerator Resources.Designer.cs + + Always + + + Designer + SettingsSingleFileGenerator diff --git a/Filtration/NLog.config b/Filtration/NLog.config new file mode 100644 index 0000000..9c00a0a --- /dev/null +++ b/Filtration/NLog.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Filtration/NLog.xsd b/Filtration/NLog.xsd new file mode 100644 index 0000000..85019de --- /dev/null +++ b/Filtration/NLog.xsd @@ -0,0 +1,2479 @@ + + + + + + + + + + + + + + + Watch config file for changes and reload automatically. + + + + + Print internal NLog messages to the console. Default value is: false + + + + + Print internal NLog messages to the console error output. Default value is: false + + + + + Write internal NLog messages to the specified file. + + + + + Log level threshold for internal log messages. Default value is: Info. + + + + + Global log level threshold for application log messages. Messages below this level won't be logged.. + + + + + Pass NLog internal exceptions to the application. Default value is: false. + + + + + + + + + + + + + + Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). + + + + + + + + + + + + + + + + + Prefix for targets/layout renderers/filters/conditions loaded from this assembly. + + + + + Load NLog extensions from the specified file (*.dll) + + + + + Load NLog extensions from the specified assembly. Assembly name should be fully qualified. + + + + + + + + + + Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name* + + + + + Comma separated list of levels that this rule matches. + + + + + Minimum level that this rule matches. + + + + + Maximum level that this rule matches. + + + + + Level that this rule matches. + + + + + Comma separated list of target names. + + + + + Ignore further rules if this one matches. + + + + + Enable or disable logging rule. Disabled rules are ignored. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the file to be included. The name is relative to the name of the current config file. + + + + + Ignore any errors in the include file. + + + + + + + Variable name. + + + + + Variable value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to add <!-- --> comments around all written texts. + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events that should be processed in a batch by the lazy writer thread. + + + + + Action to be taken when the lazy writer thread request queue count exceeds the set limit. + + + + + Limit on the number of requests in the lazy writer thread request queue. + + + + + Time in milliseconds to sleep between batches. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events to be buffered. + + + + + Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + + + + + Indicates whether to use sliding timeout. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Network address. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Viewer parameter name. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to use default row highlighting rules. + + + + + The encoding for writing messages to the . + + + + + Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Condition that must be met in order to set the specified foreground and background color. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + Indicates whether to ignore case when comparing texts. + + + + + Regular expression to be matched. You must specify either text or regex. + + + + + Text to be matched. You must specify either text or regex. + + + + + Indicates whether to match whole words only. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send the log messages to the standard error instead of the standard output. + + + + + The encoding for writing messages to the . + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + + + + + Name of the connection string (as specified in <connectionStrings> configuration section. + + + + + Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + + + + + Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + + + + + Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + + + + + Name of the database provider. + + + + + Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + + + + + Indicates whether to keep the database connection open between the log events. + + + + + Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + + + + + Text of the SQL command to be run on each log level. + + + + + Type of the SQL command to be run on each log level. + + + + + + + + + + + + + + + + + + + + + + + Type of the command. + + + + + Connection string to run the command against. If not provided, connection string from the target is used. + + + + + Indicates whether to ignore failures. + + + + + Command text. + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Database parameter name. + + + + + Database parameter precision. + + + + + Database parameter scale. + + + + + Database parameter size. + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Layout that renders event Category. + + + + + Layout that renders event ID. + + + + + Name of the Event Log to write to. This can be System, Application or any user-defined name. + + + + + Name of the machine on which Event Log service is running. + + + + + Value to be used as the event Source. + + + + + Optional entrytype. When not set, or when not convertable to then determined by + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether to return to the first target after any successful write. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + File encoding. + + + + + Line ending mode. + + + + + Maximum number of archive files that should be kept. + + + + + Way file archives are numbered. + + + + + Name of the file to be used for an archive. + + + + + Indicates whether to automatically archive log files every time the specified time passes. + + + + + Size in bytes above which log files will be automatically archived. + + + + + Indicates whether to compress archive files into the zip archive format. + + + + + Gets ors set a value indicating whether a managed file stream is forced, instead of used the native implementation. + + + + + File attributes (Windows only). + + + + + Indicates whether to replace file contents on each write instead of appending log message at the end. + + + + + Name of the file to write to. + + + + + Value specifying the date format to use when archving files. + + + + + Indicates whether to archive old log file on startup. + + + + + Indicates whether to create directories if they do not exist. + + + + + Indicates whether to delete old log file on startup. + + + + + Indicates whether to enable log file(s) to be deleted. + + + + + Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + + + + + Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + + + + + Maximum number of log filenames that should be stored as existing. + + + + + Indicates whether to keep log file open instead of opening and closing it on each logging event. + + + + + Indicates whether concurrent writes to the log file by multiple processes on the same host. + + + + + Number of times the write is appended on the file before NLog discards the log message. + + + + + Delay in milliseconds to wait before attempting to write to the file again. + + + + + Indicates whether to automatically flush the file buffers after each log message. + + + + + Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). + + + + + Log file buffer size in bytes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Condition expression. Log events who meet this condition will be forwarded to the wrapped target. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Windows domain name to change context to. + + + + + Required impersonation level. + + + + + Type of the logon provider. + + + + + Logon Type. + + + + + User account password. + + + + + Indicates whether to revert to the credentials of the process instead of impersonating another user. + + + + + Username to change context to. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Endpoint address. + + + + + Name of the endpoint configuration in WCF configuration file. + + + + + Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + + + + + Client ID. + + + + + Indicates whether to include per-event properties in the payload sent to the server. + + + + + Indicates whether to use binary message encoding. + + + + + + + + + + + + + + Layout that should be use to calculate the value for the parameter. + + + + + Name of the parameter. + + + + + Type of the parameter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send message as HTML instead of plain text. + + + + + Encoding to be used for sending e-mail. + + + + + Indicates whether to add new lines between log entries. + + + + + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Mail message body (repeated for each log message send in one mail). + + + + + Mail subject. + + + + + Sender's email address (e.g. joe@domain.com). + + + + + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Priority used for sending mails. + + + + + Indicates the SMTP client timeout. + + + + + SMTP Server to be used for sending. + + + + + SMTP Authentication mode. + + + + + Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. + + + + + Port number that SMTP Server is listening on. + + + + + Indicates whether the default Settings from System.Net.MailSettings should be used. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used when writing text to the queue. + + + + + Indicates whether to use the XML format when serializing message. This will also disable creating queues. + + + + + Indicates whether to check if a queue exists before writing to it. + + + + + Indicates whether to create the queue if it doesn't exists. + + + + + Label to associate with each message. + + + + + Name of the queue to write to. + + + + + Indicates whether to use recoverable messages (with guaranteed delivery). + + + + + + + + + + + + + + + + + Name of the target. + + + + + Class name. + + + + + Method name. The method must be public and static. + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Network address. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Network address. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to perform layout calculation. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether performance counter should be automatically created. + + + + + Name of the performance counter category. + + + + + Counter help text. + + + + + Name of the performance counter. + + + + + Performance counter type. + + + + + Performance counter instance name. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Default filter to be applied when no specific rule matches. + + + + + + + + + + + + + Condition to be tested. + + + + + Resulting filter to be applied when the condition matches. + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Number of times to repeat each log message. + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of retries that should be attempted on the wrapped target in case of a failure. + + + + + Time to wait between retries in milliseconds. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + + + + Encoding. + + + + + Web service method name. Only used with Soap. + + + + + Web service namespace. Only used with Soap. + + + + + Protocol to be used when calling web service. + + + + + Web service URL. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). + + + + + Column delimiter. + + + + + Quote Character. + + + + + Quoting mode. + + + + + Indicates whether CVS should include header. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout of the column. + + + + + Name of the column. + + + + + + + + + + + + + + + + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + + + + + + + + + + + + + + + + + Layout text. + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Condition expression. + + + + + + + + + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Filtration/Repositories/ItemFilterScriptRepository.cs b/Filtration/Repositories/ItemFilterScriptRepository.cs index 9a25d71..a4106e3 100644 --- a/Filtration/Repositories/ItemFilterScriptRepository.cs +++ b/Filtration/Repositories/ItemFilterScriptRepository.cs @@ -28,15 +28,7 @@ namespace Filtration.Repositories public IItemFilterScriptViewModel LoadScriptFromFile(string path) { - ItemFilterScript loadedScript; - try - { - loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path); - } - catch (Exception e) - { - throw new IOException("Error loading filter script - " + e.Message); - } + var loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path); var newViewModel = _itemFilterScriptViewModelFactory.Create(); newViewModel.Initialise(loadedScript, false); diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index a7295fe..cabfbb8 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -16,6 +16,7 @@ using Filtration.Services; using Filtration.Translators; using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.Messaging; +using NLog; using Clipboard = System.Windows.Clipboard; using MessageBox = System.Windows.MessageBox; @@ -63,6 +64,8 @@ namespace Filtration.ViewModels internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel { + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory; private readonly IItemFilterBlockTranslator _blockTranslator; private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel; @@ -314,7 +317,7 @@ namespace Filtration.ViewModels } Title = Filename; - ContentId = "testcontentid"; + ContentId = "ScriptContentId"; } public void Save() @@ -334,6 +337,11 @@ namespace Filtration.ViewModels } catch (Exception e) { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } + MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK, MessageBoxImage.Error); } @@ -365,6 +373,11 @@ namespace Filtration.ViewModels } catch (Exception e) { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } + MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK, MessageBoxImage.Error); Script.FilePath = previousFilePath; diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index eb99a0f..bc3007a 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -3,13 +3,11 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; -using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Media; using System.Windows.Media.Imaging; using Filtration.Common.ViewModels; using Filtration.Interface; -using Filtration.Models; using Filtration.ObjectModel.ThemeEditor; using Filtration.Properties; using Filtration.Repositories; @@ -21,6 +19,7 @@ using Filtration.Translators; using Filtration.Views; using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.Messaging; +using NLog; using Clipboard = System.Windows.Clipboard; using OpenFileDialog = Microsoft.Win32.OpenFileDialog; @@ -34,6 +33,8 @@ namespace Filtration.ViewModels internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel { + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private readonly IItemFilterScriptRepository _itemFilterScriptRepository; private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator; private readonly IReplaceColorsViewModel _replaceColorsViewModel; @@ -198,8 +199,12 @@ namespace Filtration.ViewModels } } } - catch (Exception) + catch (Exception e) { + if (_logger.IsDebugEnabled) + { + _logger.Debug(e); + } // We don't care if the update check fails, because it could fail for multiple reasons // including the user blocking Filtration in their firewall. } @@ -302,6 +307,10 @@ namespace Filtration.ViewModels } catch(IOException e) { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } MessageBox.Show(@"Error loading filter script - " + e.Message, @"Script Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -328,6 +337,10 @@ namespace Filtration.ViewModels } catch (IOException e) { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -353,6 +366,10 @@ namespace Filtration.ViewModels } catch (IOException e) { + if (_logger.IsErrorEnabled) + { + _logger.Error(e); + } MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/Filtration/ViewModels/StartPageViewModel.cs b/Filtration/ViewModels/StartPageViewModel.cs index 8318082..b5d97df 100644 --- a/Filtration/ViewModels/StartPageViewModel.cs +++ b/Filtration/ViewModels/StartPageViewModel.cs @@ -1,6 +1,5 @@ using Filtration.Common.ViewModels; using Filtration.Interface; -using Filtration.ViewModels.ToolPanes; using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.Messaging; @@ -31,7 +30,6 @@ namespace Filtration.ViewModels throw new System.NotImplementedException(); } - private static void OnOpenScriptCommand() { Messenger.Default.Send(new NotificationMessage("OpenScript")); diff --git a/Filtration/packages.config b/Filtration/packages.config index ebef914..d28bda8 100644 --- a/Filtration/packages.config +++ b/Filtration/packages.config @@ -7,5 +7,8 @@ + + + \ No newline at end of file