TrackException() public static method

Tracks any exception.
public static TrackException ( Exception ex ) : void
ex Exception
return void
        private WorkItemCollection GetWorkItemsFromQuery(WorkItemMigrationClient wiClient)
        {
            var startTime = DateTime.UtcNow;
            var timer     = System.Diagnostics.Stopwatch.StartNew();
            WorkItemCollection results;

            try
            {
                results = wiClient.Store.Query(Query);
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.Collection.ToString(), "GetWorkItemsFromQuery", null, startTime, timer.Elapsed, "200", true));
            }
            catch (Exception ex)
            {
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.Collection.ToString(), "GetWorkItemsFromQuery", null, startTime, timer.Elapsed, "500", false));
                Telemetry.TrackException(ex,
                                         new Dictionary <string, string> {
                    { "CollectionUrl", wiClient.Store.TeamProjectCollection.Uri.ToString() }
                },
                                         new Dictionary <string, double> {
                    { "QueryTime", timer.ElapsedMilliseconds }
                });
                Log.Error(ex, " Error running query");
                throw;
            }
            return(results);
        }
Beispiel #2
0
 public static void LogException(Exception value)
 {
     if (value != null)
     {
         Telemetry.TrackException(value);
     }
 }
Beispiel #3
0
        public static void LogEvent(string message, LogLevel level)
        {
            try
            {
                switch (level)
                {
                case LogLevel.Operation:
                    LogToOutputWindow(message);
                    break;

                case LogLevel.Error:
                    LogToActivityLog(message, __ACTIVITYLOG_ENTRYTYPE.ALE_ERROR);
                    break;

                case LogLevel.Task:
                    LogToStatusBar(message);
                    LogToOutputWindow(message);
                    break;

                case LogLevel.Status:
                    LogToStatusBar(message);
                    break;
                }
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(nameof(LogEvent), ex);
                System.Diagnostics.Debug.Write(ex);
            }
        }
        public Dictionary <string, DatabaseInfo> GetAllServerUserDatabases()
        {
            var result = new Dictionary <string, DatabaseInfo>();

            try
            {
                var servers = new List <SqlConnectionInfo>();

                foreach (var srvHerarchy in GetExplorerHierarchies())
                {
                    // ReSharper disable once SuspiciousTypeConversion.Global
                    var provider = srvHerarchy.Root as IServiceProvider;

                    if (provider == null)
                    {
                        continue;
                    }
                    if (provider.GetService(typeof(INodeInformation)) is INodeInformation containedItem)
                    {
                        servers.Add(containedItem.Connection as SqlConnectionInfo);
                    }
                }

                foreach (var sqlConnectionInfo in servers)
                {
                    var builder = new SqlConnectionStringBuilder(sqlConnectionInfo.ConnectionString);
                    AddToList(result, builder);
                }
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(ex);
            }
            return(result);
        }
        async virtual public Task BeginCreateTable(Action successCallback, Action <Exception> failureCallback)
        {
            await Task.Run(() =>
            {
                try
                {
                    if (IsReadOnly)
                    {
                        return;
                    }

                    using (var statement = ((ISQLiteConnection)_vesselDB.Connection).Prepare(GetCreateTableSql()))
                    {
                        statement.Step();
                    }

                    const string enableForeighKeys = "PRAGMA foreign_keys = ON;";
                    using (var statement = ((ISQLiteConnection)_vesselDB.Connection).Prepare(enableForeighKeys))
                    {
                        statement.Step();
                    }
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    failureCallback(ex);
                }

                successCallback();
            });
        }
        public override ProjectData GetProject()
        {
            var     startTime = DateTime.UtcNow;
            var     timer     = System.Diagnostics.Stopwatch.StartNew();
            Project y;

            try
            {
                y = (from Project x in Store.Projects where x.Name.ToUpper() == MigrationClient.Config.AsTeamProjectConfig().Project.ToUpper() select x).SingleOrDefault();
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetProject", null, startTime, timer.Elapsed, "200", true));
            }
            catch (Exception ex)
            {
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetProject", null, startTime, timer.Elapsed, "500", false));
                Telemetry.TrackException(ex,
                                         new Dictionary <string, string> {
                    { "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() }
                },
                                         new Dictionary <string, double> {
                    { "Time", timer.ElapsedMilliseconds }
                });
                Log.Error(ex, "Unable to configure store");
                throw;
            }
            return(y.ToProjectData());
        }
        public override WorkItemData GetWorkItem(int id)
        {
            var      startTime = DateTime.UtcNow;
            var      timer     = System.Diagnostics.Stopwatch.StartNew();
            WorkItem y;

            try
            {
                y = Store.GetWorkItem(id);
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "200", true));
            }
            catch (Exception ex)
            {
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "500", false));
                Telemetry.TrackException(ex,
                                         new Dictionary <string, string> {
                    { "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() }
                },
                                         new Dictionary <string, double> {
                    { "Time", timer.ElapsedMilliseconds }
                });
                Log.Error(ex, "Unable to configure store");
                throw;
            }
            return(y?.AsWorkItemData());
        }
        public override ProjectData GetProject()
        {
            var     startTime = DateTime.UtcNow;
            var     timer     = System.Diagnostics.Stopwatch.StartNew();
            Project y;

            try
            {
                y = (from Project x in Store.Projects where string.Equals(x.Name, MigrationClient.Config.AsTeamProjectConfig().Project, StringComparison.OrdinalIgnoreCase) select x).Single(); // Use Single instead of SingleOrDefault to force an exception here
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetProject", null, startTime, timer.Elapsed, "200", true));
            }
            catch (Exception ex)
            {
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetProject", null, startTime, timer.Elapsed, "500", false));
                Telemetry.TrackException(ex,
                                         new Dictionary <string, string> {
                    { "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() }
                },
                                         new Dictionary <string, double> {
                    { "Time", timer.ElapsedMilliseconds }
                });
                Log.Error(ex, "Unable to get project with name {ConfiguredProjectName}", MigrationClient.Config.AsTeamProjectConfig().Project);
                throw;
            }
            return(y.ToProjectData()); // With SingleOrDefault earlier this would result in a NullReferenceException which is hard to debug
        }
        private void OnFileSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            var textDocument = sender as ITextDocument;

            if (e.FileActionType == FileActionTypes.ContentSavedToDisk && textDocument != null)
            {
                Task.Run(async() =>
                {
                    try
                    {
                        Manifest newManifest = Manifest.FromJson(textDocument.TextBuffer.CurrentSnapshot.GetText(), _dependencies);
                        await RemoveFilesAsync(newManifest).ConfigureAwait(false);

                        _manifest = newManifest;

                        await LibraryHelpers.RestoreAsync(textDocument.FilePath, _manifest, CancellationToken.None).ConfigureAwait(false);
                        Telemetry.TrackOperation("restoresave");
                    }
                    catch (Exception ex)
                    {
                        string textMessage = string.Concat(Environment.NewLine, LibraryManager.Resources.Text.RestoreHasErrors, Environment.NewLine);

                        Logger.LogEvent(textMessage, LogLevel.Task);
                        Logger.LogEvent(ex.ToString(), LogLevel.Error);
                        Telemetry.TrackException("restoresavefailed", ex);
                    }
                });
            }
        }
 async private void DatabaseMetadataTimerTic(object stateInfo)
 {
     try
     {
         if (null != App.BuildDBTables.VesselDB)
         {
             this.DatabaseSize = App.BuildDBTables.VesselDB.Size();
         }
         if (null != App.BuildDBTables.SensorTable)
         {
             this.TotalSensors = await App.BuildDBTables.SensorTable.TotalSensors();
         }
         if (null != App.BuildDBTables.DeviceTable)
         {
             this.TotalSensors = await App.BuildDBTables.DeviceTable.TotalDevices();
         }
         if (null != App.BuildDBTables.AISTable)
         {
             this.TotalAISTargets = await App.BuildDBTables.AISTable.TotalAISTargets();
         }
     }
     catch (Exception ex)
     {
         Telemetry.TrackException(ex);
     }
 }
        protected override async Task OnInitializedAsync()
        {
            var auth      = await AuthenticationStateTask;
            var stockUser = UserRepository.GetByEmail(auth.User.Identity.Name);

            if (stockUser == null || stockUser.StockRole != StockRole.ADMIN)
            {
                Telemetry.TrackEvent("AccessDenied");
                NavigationManager.NavigateTo("/accessdenied");
                return;
            }

            try
            {
                _categories = await Repository.GetAllAsync <Category>();

                _sortedCategories = new List <Category>(_categories);
                _suppliers        = await Repository.GetAllAsync <Supplier>();

                _sortedSuppliers = new List <Supplier>(_suppliers);
            } catch (Exception e)
            {
                Telemetry.TrackException(e);
                ToastService.ShowWarning("Probleem bij het inladen van data, herlaad de pagina.");
            }
        }
Beispiel #12
0
        /// <summary>
        /// Ambient Light Sensor adjusts the brightness of the display. Less ambient light equates to a dimmer display.
        /// </summary>
        /// <param name="lightSensor"></param>
        /// <param name="e"></param>
        private async void LightSensor_ReadingChanged(LightSensor lightSensor, LightSensorReadingChangedEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                try
                {
                    LightSensorReading lightSensorReading = lightSensor.GetCurrentReading();

                    if (BrightnessOverrideSetting != null && BrightnessOverrideSetting.IsSupported)
                    {
                        const double maximumAllowedBrightness            = 0.15;
                        const double highestLuxValueBeforeFullBrightness = 25.0;

                        double brightness = Math.Min(lightSensorReading.IlluminanceInLux, highestLuxValueBeforeFullBrightness) / highestLuxValueBeforeFullBrightness *maximumAllowedBrightness;

                        if (PreviousDisplayBrightness != brightness)
                        {
                            BrightnessOverrideSetting.SetBrightnessLevel(brightness, DisplayBrightnessOverrideOptions.None);

                            PreviousDisplayBrightness = brightness;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(nameof(LightSensor_ReadingChanged), ex);
                }
            });
        }
Beispiel #13
0
        public void Configure(IMigrationClient migrationClient, bool bypassRules = true)
        {
            if (migrationClient is null)
            {
                throw new ArgumentNullException(nameof(migrationClient));
            }
            _migrationClient = migrationClient;

            var startTime = DateTime.UtcNow;
            var timer     = System.Diagnostics.Stopwatch.StartNew();

            try
            {
                InnerConfigure(migrationClient, bypassRules);
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TeamService", "GetWorkItemStore", startTime, timer.Elapsed, true));
            }
            catch (Exception ex)
            {
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TeamService", "GetWorkItemStore", startTime, timer.Elapsed, false));
                Telemetry.TrackException(ex,
                                         new Dictionary <string, string> {
                    { "CollectionUrl", MigrationClient.Config.Collection.ToString() }
                },
                                         new Dictionary <string, double> {
                    { "Time", timer.ElapsedMilliseconds }
                });
                Log.Error(ex, "Unable to configure store");
                throw;
            }
        }
Beispiel #14
0
        protected override async Task OnInitializedAsync()
        {
            Telemetry.TrackPageView(new PageViewTelemetry("Updater page")
            {
                Url = new Uri("/Updater/Manage", UriKind.Relative)
            });

            await base.OnInitializedAsync().ConfigureAwait(false);

            UpdaterService.OnDownloadProgress += UpdaterService_OnDownloadProgressAsync;

            UpdaterService.OnDownloadStart += UpdaterService_OnDownloadStart;

            UpdaterService.OndownloadComplete += UpdaterService_OndownloadComplete;

            UpdaterService.OnReleasesDownloadCompleted += UpdaterService_OnReleasesDownloadCompleted;

            try
            {
                UpdaterService.LoadReleases();
            }
            catch (Exception e)
            {
                Logger.LogError("Impossible de charger la liste des releases.", e);
                Telemetry.TrackException(e);

                await ShowErrorToastAsync("Release", $"Impossible d'obtenir la liste des release.");
            }
        }
Beispiel #15
0
        /// <summary>
        /// Verifies whether or not the <see cref="ODataQueryOptions(TEntity)"/> are allowed or not.
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="odataOptions">The odata options from the request.</param>
        /// <param name="allowedQueryStructure">Each web api will have their individual allowed set of query strutures.</param>
        /// <param name="isFeatureEnabled">The configuration state for the feature.</param>
        /// <param name="telemetryContext">Information to be used by the telemetry events.</param>
        /// <returns>True if the options are allowed.</returns>
        public static bool AreODataOptionsAllowed <TEntity>(ODataQueryOptions <TEntity> odataOptions,
                                                            ODataQueryFilter allowedQueryStructure,
                                                            bool isFeatureEnabled,
                                                            string telemetryContext)
        {
            // If validation of the ODataQueryOptions fails, we will not reject the request.
            var isAllowed = true;

            try
            {
                isAllowed = allowedQueryStructure.IsAllowed(odataOptions);
            }
            catch (Exception ex)
            {
                var telemetryProperties = new Dictionary <string, string>();
                telemetryProperties.Add(TelemetryService.CallContext, $"{telemetryContext}:{nameof(AreODataOptionsAllowed)}");
                telemetryProperties.Add(TelemetryService.IsEnabled, $"{isFeatureEnabled}");

                // Log and do not throw
                Telemetry.TrackException(ex, telemetryProperties);
            }

            _telemetryService.TrackODataQueryFilterEvent(
                callContext: $"{telemetryContext}:{nameof(AreODataOptionsAllowed)}",
                isEnabled: isFeatureEnabled,
                isAllowed: isAllowed,
                queryPattern: ODataQueryFilter.ODataOptionsMap(odataOptions).ToString());

            return(isFeatureEnabled ? isAllowed : true);
        }
        /// <summary>
        /// Log unhandled exceptions from the dispatcher.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void ApplicationUnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
        {
            Telemetry.TrackException(e.Exception);
            Telemetry.Flush(); // only for desktop apps

            e.Handled = true;
        }
Beispiel #17
0
        public static string GetFilePath(this ITextBuffer buffer)
        {
            IVsTextBuffer bufferAdapter;

            if (!buffer.Properties.TryGetProperty(typeof(IVsTextBuffer), out bufferAdapter))
            {
                return(null);
            }

            if (bufferAdapter == null)
            {
                return(null);
            }

            var persistFileFormat = bufferAdapter as IPersistFileFormat;

            if (persistFileFormat == null)
            {
                return(null);
            }

            string ppzsFilename = null;
            uint   iii;

            try
            {
                persistFileFormat.GetCurFile(out ppzsFilename, out iii);
                return(ppzsFilename);
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                return(null);
            }
        }
 protected void Submit()
 {
     if (_editContext.Validate())
     {
         _product.ProductNumber = Regex.Replace(_product.ProductNumber, @"\s+", "");
         if (!Repository.ProductDuplicateExists(_product.Id, _product.ProductNumber))
         {
             try
             {
                 Repository.Save(_product);
                 _product.Category.Products.Add(_product);
                 ToastService.ShowSuccess("Product: " + _product.Description + " werd toegevoegd in categorie: " + _product.Category.CategoryName);
                 Telemetry.TrackEvent("NonUniqueProductNumber");
                 NavigationManager.NavigateTo("/beheer");
             }
             catch (Exception ex)
             {
                 Telemetry.TrackException(ex);
                 ToastService.ShowError("Kon product niet opslaan.");
             }
         }
         else
         {
             Telemetry.TrackEvent("NonUniqueProductNumber");
             ToastService.ShowError("Product met identiek productnummer bestaat al.");
         }
     }
 }
        private WorkItemStore GetWorkItemStore(WorkItemStoreFlags bypassRules)
        {
            var           startTime = DateTime.UtcNow;
            var           timer     = System.Diagnostics.Stopwatch.StartNew();
            WorkItemStore store;

            try
            {
                store = new WorkItemStore(MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), bypassRules);
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItemStore", null, startTime, timer.Elapsed, "200", true));
            }
            catch (Exception ex)
            {
                timer.Stop();
                Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItemStore", null, startTime, timer.Elapsed, "500", false));
                Telemetry.TrackException(ex,
                                         new Dictionary <string, string> {
                    { "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() }
                },
                                         new Dictionary <string, double> {
                    { "Time", timer.ElapsedMilliseconds }
                });
                Log.Error(ex, "Unable to configure store");
                throw;
            }
            return(store);
        }
        async public Task BeginDropTable(string myTableName, Action sucessCallback, Action <Exception> failureCallback)
        {
            await Task.Run(() =>
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(myTableName))
                    {
                        throw new ArgumentException("TableName", "Tablename was not specified");
                    }

                    this.ItemSet.Tables.Remove(myTableName);

                    string str = "DROP TABLE " + myTableName;
                    using (var statement = ((ISQLiteConnection)(this.Connection)).Prepare(str))
                    {
                        statement.Step();
                    }

                    sucessCallback();
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    failureCallback(ex);
                }
            });
        }
        internal void LogError(List <string> statusMessages, Exception exception)
        {
            ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                // Switch to main thread
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                if (exception != null)
                {
                    Telemetry.TrackException(exception);
                }

                await VS.StatusBar.ShowMessageAsync(SharedLocale.AnErrorOccurred);

                var messageBuilder = new StringBuilder();

                foreach (var error in statusMessages)
                {
                    messageBuilder.AppendLine(error);
                }

                if (exception != null)
                {
                    await exception.Demystify().LogAsync(messageBuilder.ToString());
                }
                else
                {
                    await exception.LogAsync(messageBuilder.ToString());
                }
            });
        }
        public async Task BeginDropDatabase(Action sucessCallback, Action <Exception> failureCallback)
        {
            await Task.Run(() =>
            {
                try
                {
                    FileInfo fileInfo = new FileInfo(this.DatabaseFileName);

                    ISQLiteConnection con = this.Connection as ISQLiteConnection;
                    if (null != con)
                    {
                        con.Dispose();
                        GC.Collect();
                    }

                    fileInfo.Delete();

                    this.Connection = null;

                    sucessCallback();
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    failureCallback(ex);
                }
            });
        }
        private async Task ApiCall(string url)
        {
            try
            {
                IConfidentialClientApplication confidentialClientApplication =
                    ConfidentialClientApplicationBuilder
                    .Create(Configuration["AzureAd:ClientId"])
                    .WithTenantId(Configuration["AzureAd:TenantId"])
                    .WithClientSecret(Configuration["AzureAd:ClientSecret"])
                    .Build();
                string[]             scopes = new string[] { "https://graph.microsoft.com/.default" };
                AuthenticationResult result = null;
                result = await confidentialClientApplication.AcquireTokenForClient(scopes)
                         .ExecuteAsync();

                var httpClient = new HttpClient();
                var apiCaller  = new ProtectedApiCallHelper(httpClient);
                var res        = await apiCaller
                                 .CallWebApiAndProcessResultASync(
                    url,
                    result.AccessToken
                    );

                ProcessGraphUsers(res);
                if (res.Properties().FirstOrDefault(p => p.Name == "@odata.nextLink") != null)
                {
                    await ApiCall(res.Properties().First(p => p.Name == "@odata.nextLink").Value.ToString());
                }
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het ophalen van de gebruikers.");
            }
        }
        public async Task <bool> Upload(string filename)
        {
            var files = (await FileReaderService.CreateReference(inputElement).EnumerateFilesAsync()).ToList();

            foreach (var file in files)
            {
                try
                {
                    var fi = await file.ReadFileInfoAsync();

                    if (fi.Size < 20 * 1024 * 1024)
                    {
                        await _service.SetContainer(Container);

                        await _service.UploadBlobToContainer(file, filename);
                    }
                } catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                }
            }
            await ClearFile();

            return(true);
        }
        protected void DeleteCategory(int id)
        {
            Category cat = _categories.FirstOrDefault(p => p.Id == id);

            if (cat.Products == null || cat.Products.Count == 0)
            {
                try
                {
                    Repository.Delete(cat);
                    _categories.Remove(cat);
                    _sortedCategories.Remove(cat);
                    Telemetry.TrackEvent("CategoryDelete");
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    ToastService.ShowError("Kon categorie niet verwijderen.");
                }
            }
            else
            {
                Telemetry.TrackEvent("CategoryDeleteFail");
                ToastService.ShowError("Categorie heeft producten.");
            }
        }
Beispiel #26
0
        virtual async public Task BeginFindByGaugePageId(Int64 gaugePageId, Action <ItemTable> sucessCallback, Action <Exception> failureCallback)
        {
            ItemTable results = null;

            await Task.Run(() =>
            {
                try
                {
                    results = new ItemTable();
                    this.CreateTableSchema(results);

                    string query = "SELECT * FROM " + TableName +
                                   " WHERE PageId = " + gaugePageId.ToString();

                    using (var statement = sqlConnection.Prepare(query))
                    {
                        while (statement.Step() == SQLiteResult.ROW)
                        {
                            this.LoadTableRow(statement, results);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    failureCallback(ex);
                }

                sucessCallback(results);
            });
        }
Beispiel #27
0
 public static void Log(Exception ex)
 {
     if (ex != null)
     {
         Log(ex.ToString());
         Telemetry.TrackException(ex);
     }
 }
Beispiel #28
0
        /// <summary>
        /// Load all of the devices from the device table
        /// </summary>
        async public Task BeginLoad()
        {
            try
            {
                bool        isVirtualDeviceFound = false;   // HJave we found the required virtual device
                IDeviceItem device = null;
                using (var releaser = await _lock.ReaderLockAsync())
                {
                    foreach (ItemRow row in App.BuildDBTables.DeviceTable.Rows)
                    {
                        switch (row.Field <DeviceType>("DeviceType"))
                        {
                        case DeviceType.IPCamera:
                            break;

                        case DeviceType.NMEA2000:
                            break;

                        case DeviceType.Virtual:
                            device            = new DeviceItem(row);
                            device.IsVirtual  = true;
                            device.DeviceType = DeviceType.Virtual;
                            this.Add(device);
                            isVirtualDeviceFound = true;
                            break;

                        default:
                            device = new DeviceItem(row);
                            this.Add(device);
                            break;
                        }
                    }

                    // We need at least one virtual device to contain virtual sensors
                    if (!isVirtualDeviceFound)
                    {
                        device              = new DeviceItem();
                        device.IsVirtual    = true;
                        device.DeviceType   = DeviceType.Virtual;
                        device.SerialNumber = typeof(App).ToString();

                        Package        package        = Package.Current;
                        PackageId      packageId      = package.Id;
                        PackageVersion packageVersion = packageId.Version;
                        device.FirmwareVersion = string.Format("{0}.{1}.{2}",
                                                               packageVersion.Major,
                                                               packageVersion.Minor,
                                                               packageVersion.Revision);

                        this.Add(device);
                    }
                }
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(ex);
            }
        }
        /// <summary>
        /// Write exception to ApplicationInsights.
        ///
        /// Note that Source.Error (DiagnosticsSourceExtensions) currently uses TraceEvent instead.
        /// </summary>
        public virtual void ExceptionEvent(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

            Telemetry.TrackException(exception);
        }
Beispiel #30
0
        public void Call_TrackException_Propagates_The_Same_Exception()
        {
            var telemetry = new Telemetry(_client);

            var exception = new Exception("Test Exception");

            telemetry.TrackException(exception);

            _client.Received().TrackException(Arg.Is <Exception>(ex => ex.Equals(exception)), null, null);
        }