当前位置: 首页>>代码示例>>C#>>正文


C# ILogger.ErrorException方法代码示例

本文整理汇总了C#中ILogger.ErrorException方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.ErrorException方法的具体用法?C# ILogger.ErrorException怎么用?C# ILogger.ErrorException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILogger的用法示例。


在下文中一共展示了ILogger.ErrorException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveImageInfo

        public static void SaveImageInfo(IApplicationPaths appPaths, ILogger logger, string musicBrainzId, string url, string size)
        {
            if (appPaths == null)
            {
                throw new ArgumentNullException("appPaths");
            }
            if (string.IsNullOrEmpty(musicBrainzId))
            {
                throw new ArgumentNullException("musicBrainzId");
            }
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }

            var cachePath = Path.Combine(appPaths.CachePath, "lastfm", musicBrainzId, "image.txt");

            try
            {
                if (string.IsNullOrEmpty(url))
                {
                    File.Delete(cachePath);
                }
                else
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(cachePath));
                    File.WriteAllText(cachePath, url + "|" + size);
                }
            }
            catch (IOException ex)
            {
                // Don't fail if this is unable to write
                logger.ErrorException("Error saving to {0}", ex, cachePath);
            }
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:35,代码来源:LastfmHelper.cs

示例2: OpenUrl

        /// <summary>
        /// Opens the URL.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="logger">The logger.</param>
        private static void OpenUrl(string url, ILogger logger)
        {
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = url
                },

                EnableRaisingEvents = true,
            };

            process.Exited += ProcessExited;

            try
            {
                process.Start();
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error launching url: {0}", ex, url);

                Console.WriteLine("Error launching url: {0}", ex.Message);
                Console.WriteLine(ex.Message);

//#if !__MonoCS__
//                System.Windows.Forms.MessageBox.Show("There was an error launching your web browser. Please check your default browser settings.");
//#endif
            }
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:35,代码来源:BrowserLauncher.cs

示例3: ImageProcessor

        public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
        {
            _logger = logger;
            _fileSystem = fileSystem;
            _jsonSerializer = jsonSerializer;
            _appPaths = appPaths;

            _saveImageSizeTimer = new Timer(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);

            Dictionary<Guid, ImageSize> sizeDictionary;

            try
            {
                sizeDictionary = jsonSerializer.DeserializeFromFile<Dictionary<Guid, ImageSize>>(ImageSizeFile) ?? 
                    new Dictionary<Guid, ImageSize>();
            }
            catch (FileNotFoundException)
            {
                // No biggie
                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error parsing image size cache file", ex);

                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }

            _cachedImagedSizes = new ConcurrentDictionary<Guid, ImageSize>(sizeDictionary);
        }
开发者ID:Tensre,项目名称:MediaBrowser,代码行数:30,代码来源:ImageProcessor.cs

示例4: Migrate

        /// <summary>
        /// Migrates the specified old file.
        /// </summary>
        /// <param name="oldFile">The old file.</param>
        /// <param name="newDatabase">The new database.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="json">The json.</param>
        /// <returns>Task.</returns>
        public static async Task Migrate(string oldFile, IDbConnection newDatabase, ILogger logger, IJsonSerializer json)
        {
            var oldDb = await SqliteExtensions.ConnectToDb(oldFile).ConfigureAwait(false);

            using (oldDb)
            {
                IDbTransaction transaction = null;

                var data = GetAllUserData(oldDb, json).ToList();

                try
                {
                    transaction = newDatabase.BeginTransaction();

                    foreach (var userdata in data)
                    {
                        PersistUserData(userdata, newDatabase, transaction);
                    }

                    transaction.Commit();
                }
                catch (OperationCanceledException)
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }

                    throw;
                }
                catch (Exception e)
                {
                    logger.ErrorException("Failed to save user data:", e);

                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }

                    throw;
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Dispose();
                    }
                }
            }

            var backupFile = Path.Combine(Path.GetDirectoryName(oldFile), "userdata_v1.db.bak");

            if (File.Exists(backupFile))
            {
                File.Delete(backupFile);
            }

            File.Move(oldFile, backupFile);
        }
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:67,代码来源:UserDataMigration.cs

示例5: CloseOutputStream

 public static void CloseOutputStream(this HttpListenerResponse response, ILogger logger)
 {
     try
     {
         response.OutputStream.Flush();
         response.OutputStream.Close();
         response.Close();
     }
     catch (Exception ex)
     {
         logger.ErrorException("Error in HttpListenerResponseWrapper: " + ex.Message, ex);
     }
 }
开发者ID:jabbera,项目名称:MediaBrowser,代码行数:13,代码来源:Extensions.cs

示例6: GetCreationTimeUtc

        /// <summary>
        /// Gets the creation time UTC.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>DateTime.</returns>
        public static DateTime GetCreationTimeUtc(FileSystemInfo info, ILogger logger)
        {
            // This could throw an error on some file systems that have dates out of range

            try
            {
                return info.CreationTimeUtc;
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error determining CreationTimeUtc for {0}", ex, info.FullName);
                return DateTime.MinValue;
            }
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:20,代码来源:FileSystem.cs

示例7: UninstallService

        /// <summary>
        /// Uninstalls the service.
        /// </summary>
        private static void UninstallService(ILogger logger)
        {
            var runningPath = Process.GetCurrentProcess().MainModule.FileName;

            try
            {
                ManagedInstallerClass.InstallHelper(new[] { "/u", runningPath });

                logger.Info("Service uninstallation succeeded");
            }
            catch (Exception ex)
            {
                logger.ErrorException("Uninstall failed", ex);
            }
        }
开发者ID:kreeturez,项目名称:MediaBrowser,代码行数:18,代码来源:MainStartup.cs

示例8: UninstallService

        /// <summary>
        /// Uninstalls the service.
        /// </summary>
        private static void UninstallService(string applicationPath, ILogger logger)
        {
            try
            {
                ManagedInstallerClass.InstallHelper(new[] { "/u", applicationPath });

                logger.Info("Service uninstallation succeeded");
            }
            catch (Exception ex)
            {
                logger.ErrorException("Uninstall failed", ex);
            }
        }
开发者ID:Sile626,项目名称:MediaBrowser,代码行数:16,代码来源:MainStartup.cs

示例9: AttachPrimaryImageAspectRatio

        /// <summary>
        /// Attaches the primary image aspect ratio.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <param name="item">The item.</param>
        /// <param name="logger">The _logger.</param>
        /// <returns>Task.</returns>
        internal static async Task AttachPrimaryImageAspectRatio(IItemDto dto, BaseItem item, ILogger logger)
        {
            var path = item.PrimaryImagePath;

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var metaFileEntry = item.ResolveArgs.GetMetaFileByPath(path);

            // See if we can avoid a file system lookup by looking for the file in ResolveArgs
            var dateModified = metaFileEntry == null ? File.GetLastWriteTimeUtc(path) : metaFileEntry.LastWriteTimeUtc;

            ImageSize size;

            try
            {
                size = await Kernel.Instance.ImageManager.GetImageSize(path, dateModified).ConfigureAwait(false);
            }
            catch (FileNotFoundException)
            {
                logger.Error("Image file does not exist: {0}", path);
                return;
            }
            catch (Exception ex)
            {
                logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
                return;
            }

            dto.OriginalPrimaryImageAspectRatio = size.Width / size.Height;

            var supportedEnhancers = Kernel.Instance.ImageManager.ImageEnhancers.Where(i =>
            {
                try
                {
                    return i.Supports(item, ImageType.Primary);
                }
                catch (Exception ex)
                {
                    logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);

                    return false;
                }

            }).ToList();


            foreach (var enhancer in supportedEnhancers)
            {
                try
                {
                    size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size);
                }
                catch (Exception ex)
                {
                    logger.ErrorException("Error in image enhancer: {0}", ex, enhancer.GetType().Name);
                }
            }

            dto.PrimaryImageAspectRatio = size.Width / size.Height;
        }
开发者ID:jordy1955,项目名称:MediaBrowser,代码行数:70,代码来源:DtoBuilder.cs

示例10: InstallFrameworkV46IfNeeded

        private static async Task InstallFrameworkV46IfNeeded(ILogger logger)
        {
            bool installFrameworkV46 = false;

            try
            {
                using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)
                    .OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\"))
                {
                    if (ndpKey != null && ndpKey.GetValue("Release") != null)
                    {
                        if ((int)ndpKey.GetValue("Release") <= 393295)
                        {
                            //Found framework V4, but not yet V4.6
                            installFrameworkV46 = true;
                        }
                    }
                    else
                    {
                        //Nothing found in the registry for V4
                        installFrameworkV46 = true;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error getting .NET Framework version", ex);
            }

            _logger.Info(".NET Framework 4.6 found: {0}", !installFrameworkV46);

            if (installFrameworkV46)
            {
                try
                {
                    await InstallFrameworkV46().ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    logger.ErrorException("Error installing .NET Framework version 4.6", ex);
                }
            }
        }
开发者ID:ChubbyArse,项目名称:Emby,代码行数:43,代码来源:MainStartup.cs

示例11: InstallVcredist2013IfNeeded

        private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger)
        {
            // Reference 
            // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed

            try
            {
                var subkey = Environment.Is64BitProcess
                    ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64"
                    : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86";

                using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default)
                    .OpenSubKey(subkey))
                {
                    if (ndpKey != null && ndpKey.GetValue("Version") != null)
                    {
                        var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v');
                        if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase))
                        {
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error getting .NET Framework version", ex);
                return;
            }

            try
            {
                await InstallVcredist2013().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error installing Visual Studio C++ runtime", ex);
            }
        }
开发者ID:t-andre,项目名称:Emby,代码行数:39,代码来源:MainStartup.cs

示例12: RunQueries

        /// <summary>
        /// Runs the queries.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="queries">The queries.</param>
        /// <param name="logger">The logger.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        /// <exception cref="System.ArgumentNullException">queries</exception>
        public static void RunQueries(this IDbConnection connection, string[] queries, ILogger logger)
        {
            if (queries == null)
            {
                throw new ArgumentNullException("queries");
            }

            using (var tran = connection.BeginTransaction())
            {
                try
                {
                    using (var cmd = connection.CreateCommand())
                    {
                        foreach (var query in queries)
                        {
                            cmd.Transaction = tran;
                            cmd.CommandText = query;
                            cmd.ExecuteNonQuery();
                        }
                    }

                    tran.Commit();
                }
                catch (Exception e)
                {
                    logger.ErrorException("Error running queries", e);
                    tran.Rollback();
                    throw;
                }
            }
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:39,代码来源:SqliteExtensions.cs

示例13: InstallService

        /// <summary>
        /// Installs the service.
        /// </summary>
        private static void InstallService(string applicationPath, ILogger logger)
        {
            try
            {
                ManagedInstallerClass.InstallHelper(new[] { applicationPath });

                // Change security permissions on the service to allow the service user to start/stop the service
                string sd;

                var serviceName = BackgroundService.GetExistingServiceName();

                var startInfo = new ProcessStartInfo()
                {
                    CreateNoWindow = true,
                    UseShellExecute = false,

                    FileName = "sc.exe",
                    Arguments = "sdshow " + serviceName,

                    RedirectStandardOutput = true
                };

                using (var sc = Process.Start(startInfo))
                    sd = sc.StandardOutput.ReadToEnd().Trim();

                // Description of the SDDL strings can be found here:
                // http://blogs.msmvps.com/erikr/2007/09/26/set-permissions-on-a-specific-service-windows/
                if (sd.Contains("A;;CCLCSWLOCRRC;;;SU"))    // default permissions for service user
                {
                    sd = sd.Replace("A;;CCLCSWLOCRRC;;;SU", "A;;CCLCSWRPWPDTLOCRRC;;;SU")   // Allow the service to be started/stopped by the service user account
                           .Replace("A;;CCLCSWLOCRRC;;;IU", "A;;CCLCSWRPWPDTLOCRRC;;;IU");  // Allow the service to be started/stopped by the interactive user

                    startInfo.Arguments = string.Format("sdset {0} {1}", serviceName, sd);
                    startInfo.RedirectStandardOutput = false;

                    using (var sc = Process.Start(startInfo))
                        sc.WaitForExit();
                }

                logger.Info("Service installation succeeded");
            }
            catch (Exception ex)
            {
                logger.ErrorException("Uninstall failed", ex);
            }
        }
开发者ID:mford1,项目名称:Emby,代码行数:49,代码来源:MainStartup.cs

示例14: PerformUpdateIfNeeded

        /// <summary>
        /// Performs the update if needed.
        /// </summary>
        /// <param name="appPaths">The app paths.</param>
        /// <param name="logger">The logger.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
        {
            // Look for the existence of an update archive
            var updateArchive = Path.Combine(appPaths.TempUpdatePath, Constants.MbServerPkgName + ".zip");
            if (File.Exists(updateArchive))
            {
                logger.Info("An update is available from {0}", updateArchive);

                // Update is there - execute update
                try
                {
                    var serviceName = _isRunningAsService ? BackgroundService.Name : string.Empty;
                    new ApplicationUpdater().UpdateApplication(MBApplication.MBServer, appPaths, updateArchive, logger, serviceName);

                    // And just let the app exit so it can update
                    return true;
                }
                catch (Exception e)
                {
                    logger.ErrorException("Error starting updater.", e);

                    MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message));
                }
            }

            return false;
        }
开发者ID:kreeturez,项目名称:MediaBrowser,代码行数:33,代码来源:MainStartup.cs

示例15: GetFilteredFileSystemEntries

        /// <summary>
        /// Gets the filtered file system entries.
        /// </summary>
        /// <param name="directoryService">The directory service.</param>
        /// <param name="path">The path.</param>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="args">The args.</param>
        /// <param name="flattenFolderDepth">The flatten folder depth.</param>
        /// <param name="resolveShortcuts">if set to <c>true</c> [resolve shortcuts].</param>
        /// <returns>Dictionary{System.StringFileSystemInfo}.</returns>
        /// <exception cref="System.ArgumentNullException">path</exception>
        public static Dictionary<string, FileSystemMetadata> GetFilteredFileSystemEntries(IDirectoryService directoryService,
            string path,
            IFileSystem fileSystem,
            ILogger logger,
            ItemResolveArgs args,
            int flattenFolderDepth = 0,
            bool resolveShortcuts = true)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (!resolveShortcuts && flattenFolderDepth == 0)
            {
                return directoryService.GetFileSystemDictionary(path);
            }

            var entries = directoryService.GetFileSystemEntries(path);

            var dict = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);

            foreach (var entry in entries)
            {
                var isDirectory = entry.IsDirectory;

                var fullName = entry.FullName;

                if (resolveShortcuts && fileSystem.IsShortcut(fullName))
                {
                    try
                    {
                        var newPath = fileSystem.ResolveShortcut(fullName);

                        if (string.IsNullOrWhiteSpace(newPath))
                        {
                            //invalid shortcut - could be old or target could just be unavailable
                            logger.Warn("Encountered invalid shortcut: " + fullName);
                            continue;
                        }

                        // Don't check if it exists here because that could return false for network shares.
                        var data = fileSystem.GetDirectoryInfo(newPath);

                        // add to our physical locations
                        args.AddAdditionalLocation(newPath);

                        dict[newPath] = data;
                    }
                    catch (Exception ex)
                    {
                        logger.ErrorException("Error resolving shortcut from {0}", ex, fullName);
                    }
                }
                else if (flattenFolderDepth > 0 && isDirectory)
                {
                    foreach (var child in GetFilteredFileSystemEntries(directoryService, fullName, fileSystem, logger, args, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts))
                    {
                        dict[child.Key] = child.Value;
                    }
                }
                else
                {
                    dict[fullName] = entry;
                }
            }

            return dict;
        }
开发者ID:paul-777,项目名称:Emby,代码行数:85,代码来源:FileData.cs


注:本文中的ILogger.ErrorException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。