예제 #1
0
        public LogManagerView()
        {
            InitializeComponent();
            ILogManager logManager = LogManagerService.GetLogManager();

            // This line will cause a harmless BindingExpression path error because the DataContext is inheirited to the m_logViewer.
            this.DataContext = logManager;
            // 0 is the Global Log
            m_logViewer.Log = logManager.Logs[0];
        }
예제 #2
0
파일: LogTest.cs 프로젝트: mehabadi/HPMS
        public void LogServiceTest()
        {
            //LocatorCreator.Execute();



            var container = new WindsorContainer();

            container.Register(Component.For <ILoggerService>().ImplementedBy <DbLoggerService>().LifeStyle.BoundTo <IService>());
            //container.Register(Component.For<ILogRepository>().ImplementedBy<LogRepository>().LifeStyle.Transient);

            container.Register(Component.For <IConnectionProvider>()
                               .UsingFactoryMethod(c => new ConnectionProvider(() =>
            {
                var s = System.Configuration.ConfigurationManager.
                        ConnectionStrings["PMSDBConnection"].ConnectionString;
                var res = new SqlConnection(s);
                res.Open();
                return(res);
            })).LifestyleBoundTo <IService>());

            DataAccessConfigHelper.ConfigureContainer <UserRepository>(container,
                                                                       () =>
            {
                var session = PMSSecuritySession.GetSession(container.Resolve <IConnectionProvider>().GetConnection());
                return(session);
            }, "PMSSecurity");

            var locator = new WindsorServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() => locator);

            //var userRep = ServiceLocator.Current.GetInstance<UserRepository>();


            var uows = new MITD.Domain.Repository.UnitOfWorkScope(
                new Data.NH.NHUnitOfWorkFactory(() => PMSSecurity.Persistence.NH.PMSSecuritySession.GetSession()));



            using (var uow = new NHUnitOfWork(PMSSession.GetSession()))
                using (var uow2 = uows.CurrentUnitOfWork)
                {
                    var logFactory = new LoggerServiceFactory();
                    var logManager = new LogManagerService(logFactory);
                    var logService = new LogService(logManager);

                    var gid = Guid.NewGuid();
                    Log log = new EventLog(new LogId(gid), "diddd", LogLevel.Information, null, "clll", "mett", "ttttt", "mmmmmmm");

                    logService.AddEventLog(log.Code, log.LogLevel, null, log.ClassName, log.MethodName, log.Title, log.Messages);
                }
        }
예제 #3
0
        /// <summary>
        /// Adds the default services to the parent container.
        /// </summary>
        /// <remarks>
        /// All the services added here are added to the parent container.
        /// This way, if a client class adds a service using the <see cref="Services"/>
        /// property, and this service's type is already present, it will work, the newly
        /// added service will hide the existing one.
        /// </remarks>
        private static void AddDefaultServices()
        {
            LogManagerService logManager = new LogManagerService(new SimpleLogService());

            parentContainer.AddService <ILogService>(logManager);

            // We don't want the log manager to be masked by another implementation.
            childContainer.AddService <ILogManagerService>(logManager);

            // Remark: we pass the child container to the IExceptionHandlerService instance
            // constructor so that it uses the services that may be added by a client class,
            // and not always the default ones (especially for the logging service);
            parentContainer.AddService <IExceptionHandlerService>(
                new BaseExceptionHandlerService(childContainer));
        }