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


C# ILoggingService.LogError方法代码示例

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


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

示例1: GenerateCode

        /// <summary>
        /// Generates client proxy source code using the generator specified by <paramref name="codeGeneratorName"/>.
        /// </summary>
        /// <param name="options">The options to use for code generation.</param>
        /// <param name="parameters">The parameters required to create the <see cref="ISharedCodeService"/>.</param>
        /// <param name="loggingService">The service to use for logging.</param>
        /// <param name="codeGeneratorName">Optional generator name.  A <c>null</c> or empty value will select the default generator.</param>
        /// <returns>The generated source code or <c>null</c> if none was generated.</returns>
        internal string GenerateCode(ClientCodeGenerationOptions options, SharedCodeServiceParameters parameters, ILoggingService loggingService, string codeGeneratorName)
        {
            Debug.Assert(options != null, "options cannot be null");
            Debug.Assert(parameters != null, "parameters cannot be null");
            Debug.Assert(loggingService != null, "loggingService cannot be null");

            try
            {
                AppDomainUtilities.ConfigureAppDomain(options);
                LoadOpenRiaServicesServerAssembly(parameters, loggingService);

                using (SharedCodeService sharedCodeService = new SharedCodeService(parameters, loggingService))
                {
                    CodeGenerationHost host = new CodeGenerationHost(loggingService, sharedCodeService);
                    return this.GenerateCode(host, options, parameters.ServerAssemblies, codeGeneratorName);
                }
            }
            catch (Exception ex)
            {
                // Fatal exceptions are never swallowed or processed
                if (ex.IsFatal())
                {
                    throw;
                }

                // Any exception from the code generator is caught and reported, otherwise it will
                // hit the MSBuild backstop and report failure of the custom build task.
                // It is acceptable to report this exception and "ignore" it because we
                // are running in a separate AppDomain which will be torn down immediately
                // after our return.
                loggingService.LogError(string.Format(CultureInfo.CurrentCulture,
                                                Resource.ClientCodeGenDispatecher_Threw_Exception_Before_Generate,
                                                ex.Message));
                loggingService.LogException(ex);
                return null;
            }
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:45,代码来源:ClientCodeGenerationDispatcher.cs

示例2: Main

        static void Main(string[] args)
        {
            try
            {
                // The configurationRepository is intended to abstract the configurationManager type and allow
                // for different configuration options to be applied. For example, a DatabaseConfigurationRepository could be provided
                // if the requirement is to take reference values from a database.
                configurationRepository = new ConfigFileConfigurationRepository();
                loggingService = new Log4NetLoggingService(configurationRepository, new ThreadContextService());

                GovernmentGatewayEnvironment gatewayEnv = GovernmentGatewayEnvironment.localtestservice;

                //GovTalkMessageHelper helper = new GovTalkMessageHelper(configurationRepository, loggingService);

                //////// Optionally, set this to a valid filepath for a CSV that contains GiftAid data in an acceptable format.
                string csvFile = configurationRepository.GetConfigurationValue<string>("TempFolder") + "testdata.csv";

                #region Testing
                //TestGovTalkMessageCreation(csvFile, outputFilename);

                //XmlDocument LiveXml = new XmlDocument();
                //LiveXml.PreserveWhitespace = true;
                //LiveXml.Load(outputFilename);
                //XmlDocument LocalTestXml = new XmlDocument();
                //LocalTestXml.PreserveWhitespace = true;
                //LocalTestXml = helper.UpdateMessageForLocalTest(LiveXml);
                //LocalTestXml.Save(@"C:\Temp\Localsend.xml");
                #endregion Testing

                //// Create a GovTalkMessage and save the Xml to disk

                string outputFilename = DemonstrateCreateSubmitRequest(loggingService, configurationRepository, csvFile);

                XmlDocument submitMessageXml = new XmlDocument();

                ////// It is important if the XML message is being loaded from disk to preserve whitespace, otherwise the IRmark will be out for non-compressed files
                submitMessageXml.PreserveWhitespace = true;
                submitMessageXml.Load(outputFilename);

                XmlDocument submitMessageReply = DemonstrateSendMessage(loggingService, submitMessageXml, gatewayEnv);
                //XmlDocument submitMessageReply = new XmlDocument();
                //pollMessageReply.Load(@"C:\Temp\20151020110837.xml");

                DemonstrateReadMessage(loggingService, submitMessageReply);
            }
            catch (System.Net.WebException wex)
            {
                loggingService.LogError(wex.Source, "Exception occured in connecting to remote machine", wex);

                //Console.WriteLine("Exception occured in connecting to remote machine");
                //Console.WriteLine(wex.InnerException.Message);
                //Console.WriteLine(wex.Message);
            }
            catch (Exception ex)
            {
                loggingService.LogError(ex.Source, ex.Message, ex);
                //Console.WriteLine(ex);
            }
            finally
            {
                Console.ReadKey();
            }
        }
开发者ID:LalithaSharma,项目名称:gail,代码行数:63,代码来源:DemoConsole.cs

示例3: LoadOpenRiaServicesServerAssembly

        /// <summary>
        /// Tries to loads the OpenRiaServices.DomainServices.Server assembly from the server projects references.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="loggingService">The logging service.</param>
        private static void LoadOpenRiaServicesServerAssembly(SharedCodeServiceParameters parameters, ILoggingService loggingService)
        {
            // Try to load the OpenRiaServices.DomainServies.Server assembly using the one used by the server project
            // This way we can be sure that codegen works with both signed and unsigned server assembly while
            // making sure that only a single version is loaded
            var filename = OpenRiaServices_DomainServices_Server_Assembly;
            var serverAssemblyPath = parameters.ServerAssemblies.FirstOrDefault(sa => sa.EndsWith(filename));
            if (serverAssemblyPath != null)
            {
                var serverAssembly = AssemblyUtilities.LoadAssembly(serverAssemblyPath, loggingService);
                if (serverAssembly != null)
                {
                    // Since this assembly (OpenRiaServices.DomainServices.Tools) requires the Server assembly to be loaded
                    // before the final call to AssemblyUtilities.SetAssemblyResolver (when the DomainServiceCatalog is instanciated)
                    // we need to setup our assembly resolver with the server assembly in case the server version is signed
                    // but this version is unsigned
#if SIGNED
                    if (!serverAssembly.GetName().IsSigned())
                    {
                        loggingService.LogWarning(Resource.ClientCodeGen_SignedTools_UnsignedServer);
                    }
#else
                    AssemblyUtilities.SetAssemblyResolver(new[] { serverAssembly });
#endif
                }
                else
                {
                    loggingService.LogError(string.Format(CultureInfo.CurrentCulture,
                        Resource.ClientCodeGen_Failed_Loading_OpenRiaServices_Assembly, filename, serverAssemblyPath));
                }

            }
            else
            {
                loggingService.LogError(string.Format(CultureInfo.CurrentCulture, Resource.ClientCodeGen_Missing_OpenRiaServices_Reference, filename));
            }
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:42,代码来源:ClientCodeGenerationDispatcher.cs


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