Exemplo n.º 1
0
        private Logger()
        {
            TraceManager traceMgr;

            DatabaseProviderFactory factory = new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection);
            DatabaseFactory.SetDatabaseProviderFactory(factory, false);

            LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
            defaultWriter = new LogWriter(loggingConfiguration);

            // Create a TraceManager object for use in activity tracing example.
            traceMgr = new TraceManager(defaultWriter);
            try
            {
                if (!Directory.Exists(@"C:\Temp"))
                {
                    Directory.CreateDirectory(@"C:\Temp");
                }
            }
            catch
            {
                //Console.WriteLine(@"WARNING: Folder C:\Temp cannot be created for disk log files");
                //Console.WriteLine();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LcboInventoryServiceAgent"/> class.
 /// </summary>
 /// <param name="pageRetrieverFactory">The page retriever factory.</param>
 public LcboInventoryServiceAgent(
     [ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
     )
 {
     this.pageRetriever = pageRetrieverFactory.InventoryPageRetriever;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
 }
 public LcboProductServiceAgent(
     [ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
     )
 {
     this.productDetailsPageRetriever = pageRetrieverFactory.ProductDetailsPageRetriever;
     this.productListPageRetriever = pageRetrieverFactory.ProductListPageRetriever;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
 }
 //private readonly IGeoLocationServiceAgent geolocationService;
 /// <summary>
 /// Initializes a new instance of the LcboStoresServiceAgent class.
 /// </summary>
 public LcboStoresServiceAgent(
     [ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
     //,
     //[ServiceDependency]IGeoLocationServiceAgent geolocationService
     )
 {
     this.storeDetailsPageRetriever = pageRetrieverFactory.StoreDetailsPageRetriever;
     this.storeListPageRetriever = pageRetrieverFactory.StoreListPageRetriever;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     //this.geolocationService = geolocationService;
 }
Exemplo n.º 5
0
 public InventoryController(
     [ServiceDependency] ILcboInventoryService lcboService,
     [ServiceDependency] ILcboStoresService lcboStoresService,
     [CreateNew] IDomainContext domainContext
     )
 {
     this.lcboService = lcboService;
     this.lcboStoresService = lcboStoresService;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     this.domainContext = domainContext;
 }
Exemplo n.º 6
0
 public AdminController(
     [CreateNew] IUnitOfWork unitOfWork,
     [ServiceDependency] ILcboProductsService lcboProductsService,
     [ServiceDependency] ILcboStoresService lcboStoresService,
     [CreateNew] IFastDomainContext domainContext
     )
 {
     this.unitOfWork = unitOfWork;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     this.lcboProductsService = lcboProductsService;
     this.lcboStoresService = lcboStoresService;
     this.domainContext = domainContext;
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            #region Create the required objects

            DatabaseProviderFactory factory = new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection);
            DatabaseFactory.SetDatabaseProviderFactory(factory, false);

            LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
            defaultWriter = new LogWriter(loggingConfiguration);

            // Create a TraceManager object for use in activity tracing example.
            traceMgr = new TraceManager(defaultWriter);

            // Create a folder named Temp on drive C: for disk log files if it does not exist
            try
            {
                if (!Directory.Exists(@"C:\Temp"))
                {
                    Directory.CreateDirectory(@"C:\Temp");
                }
            }
            catch
            {
                Console.WriteLine(@"WARNING: Folder C:\Temp cannot be created for disk log files");
                Console.WriteLine();
            }

            #endregion

            new MenuDrivenApplication("Logging Block Developer's Guide Examples",
                SimpleLogWriterWrite,
                SimpleLogWriterWriteDecalarative,
                MultipleCategoriesLogWriterWrite,
                SimpleLogEntryWrite,
                SpecialSources,
                LogToDatabase,
                DynamicReconfiguration,
                CheckStatusAndAddContextInfo,
                UseAsyncWrapper,
                TraceActivities).Run();

            defaultWriter.Dispose();
 

        }
Exemplo n.º 8
0
        static void Main()
        {
            var loggingConfig = new LoggingConfiguration();
            var customizedWriter = new LogWriter(loggingConfig);

            var logWriterFactory = new LogWriterFactory();
            var defaultWriter = logWriterFactory.Create();

            var logEntry = new LogEntry
                {
                    EventId = 100,
                    Priority = 2,
                    Message = "Informational message",
                    Categories = { "Trace", "UI Events" }
                };

            new ManagedSecurityContextInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);
            new DebugInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);
            new ComPlusInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);
            new UnmanagedSecurityContextInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);

            defaultWriter.Write(logEntry);

            var traceManager = new TraceManager(defaultWriter);
            using (traceManager.StartTrace("Trace"))
            {
                defaultWriter.Write("Operation 1");
            }

            using (traceManager.StartTrace("UI Events", Guid.NewGuid()))
            {
                defaultWriter.Write("Operation 2", "Trace");
            }

            using (traceManager.StartTrace("Trace"))
            {
                using (traceManager.StartTrace("UI Events"))
                {
                    defaultWriter.Write("Operation 3");
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogManager"/> class.
 /// </summary>
 public LogManager()
 {
     defaultWriter = new LogWriterFactory().Create(); defaultTrace = new TraceManager(defaultWriter); try { if (!Directory.Exists(@"C:\Temp")) { Directory.CreateDirectory(@"C:\Temp"); } } catch { Trace.WriteLine(@"WARNING: Folder C:\Temp cannot be created for disk log files"); }
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            #region Resolve the required objects

            // Resolve the default LogWriter object from the container.
            // The actual concrete type is determined by the configuration settings.
            defaultWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

            // Resolve a TraceManager object from the container to use in activity tracing example.
            traceMgr = EnterpriseLibraryContainer.Current.GetInstance<TraceManager>();

            // Create a folder named Temp on drive C: for disk log files if it does not exist
            try
            {
                if (!Directory.Exists(@"C:\Temp"))
                {
                    Directory.CreateDirectory(@"C:\Temp");
                }
            }
            catch
            {
                Console.WriteLine(@"WARNING: Folder C:\Temp cannot be created for disk log files");
                Console.WriteLine();
            }

            #endregion

            new MenuDrivenApplication("Ejemplo del Logging Block",
                SimpleLogWriterWrite,
                MultipleCategoriesLogWriterWrite,
                SimpleLogEntryWrite,
                SpecialSources
                //LogToDatabase,
                //CheckStatusAndAddContextInfo,
                //TraceActivities
                ).Run();
        }
Exemplo n.º 11
0
 protected PageRetriever()
 {
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
 }