public ViewModel(IExrinContainer exrinContainer, IVisualState visualState, [CallerFilePath] string caller = nameof(ViewModel)) { if (exrinContainer == null) { throw new ArgumentNullException(nameof(IExrinContainer)); } _applicationInsights = exrinContainer.ApplicationInsights; _displayService = exrinContainer.DisplayService; _navigationService = exrinContainer.NavigationService; _errorHandlingService = exrinContainer.ErrorHandlingService; VisualState = visualState; if (VisualState != null) { Task.Run(() => visualState.Init()) .ContinueWith((task) => { if (task.Exception != null) { _applicationInsights.TrackException(task.Exception); } }); } Execution = new Execution() { HandleTimeout = TimeoutHandle, NotifyOfActivity = NotifyActivity, NotifyActivityFinished = NotifyActivityFinished, HandleResult = HandleResult }; }
public ViewModel(IExrinContainer exrinContainer, IVisualState visualState, [CallerFilePath] string caller = nameof(ViewModel)) { if (exrinContainer == null) throw new ArgumentNullException(nameof(IExrinContainer)); _applicationInsights = exrinContainer.ApplicationInsights; _displayService = exrinContainer.DisplayService; _navigationService = exrinContainer.NavigationService; _errorHandlingService = exrinContainer.ErrorHandlingService; VisualState = visualState; if (VisualState != null) Task.Run(() => visualState.Init()) .ContinueWith((task) => { if (task.Exception != null) _applicationInsights.TrackException(task.Exception); }); Execution = new Execution() { HandleTimeout = TimeoutHandle, NotifyOfActivity = NotifyActivity, NotifyActivityFinished = NotifyActivityFinished, HandleResult = HandleResult }; }
public void Log <TState>( LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter ) { SeverityLevel severityLevel = SeverityLevel.Verbose; var msg = formatter(state, exception); var properties = GetProperties(state); switch (logLevel) { case LogLevel.Trace: case LogLevel.Debug: severityLevel = SeverityLevel.Verbose; break; case LogLevel.Information: severityLevel = SeverityLevel.Information; break; case LogLevel.Warning: severityLevel = SeverityLevel.Warning; break; case LogLevel.Error: severityLevel = SeverityLevel.Error; break; case LogLevel.Critical: case LogLevel.None: severityLevel = SeverityLevel.Critical; break; } if (exception != null) { ApplicationInsights.TrackException(new Error() { Name = exception.GetType().Name, Message = exception.ToString() }, null, severityLevel, properties); } else { ApplicationInsights.TrackTrace(msg, severityLevel, properties); } }