//******************************************************************************************************
// App.xaml.cs - Gbtc
//
// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 04/01/2011 - Mehulbhai P Thakkar
// Generated original version of source code.
// 12/20/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
using System;
using System.Security.Principal;
using System.Windows;
using GSF.Windows.ErrorManagement;
using GSF.Reflection;
using GSF.TimeSeries.UI;
namespace TsfManager
{
///
/// Interaction logic for App.xaml
///
public partial class App : Application
{
#region [ Members ]
// Fields
private Guid m_nodeID;
private readonly ErrorLogger m_errorLogger;
private readonly Func m_defaultErrorText;
private readonly string m_title;
#endregion
#region [ Constructors ]
///
/// Creates an instance of class.
///
public App()
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
m_errorLogger = new ErrorLogger();
m_defaultErrorText = m_errorLogger.ErrorTextMethod;
m_errorLogger.ErrorTextMethod = ErrorText;
m_errorLogger.ExitOnUnhandledException = false;
m_errorLogger.HandleUnhandledException = true;
m_errorLogger.LogToEmail = false;
m_errorLogger.LogToEventLog = true;
m_errorLogger.LogToFile = true;
m_errorLogger.LogToScreenshot = true;
m_errorLogger.LogToUI = true;
m_errorLogger.Initialize();
Version appVersion = AssemblyInfo.EntryAssembly.Version;
m_title = AssemblyInfo.EntryAssembly.Title + " (v" + appVersion.Major + "." + appVersion.Minor + "." + appVersion.Build + ") ";
}
#endregion
#region [ Properties ]
///
/// Gets or sets the ID of the node user is currently connected to.
///
public Guid NodeID
{
get
{
return m_nodeID;
}
set
{
m_nodeID = value;
m_nodeID.SetAsCurrentNodeID();
}
}
public string Title
{
get
{
return m_title;
}
}
#endregion
#region [ Methods ]
private string ErrorText()
{
string errorMessage = m_defaultErrorText();
Exception ex = m_errorLogger.LastException;
if (ex != null)
{
if (string.Compare(ex.Message, "UnhandledException", true) == 0 && ex.InnerException != null)
ex = ex.InnerException;
errorMessage = string.Format("{0}\r\n\r\nError details: {1}", errorMessage, ex.Message);
}
return errorMessage;
}
#endregion
}
}