Пример #1
0
        public SiteSessionContext()
        {
            var injectorService = DependencyInversionService.GetServiceInstance();

            _databaseContext = injectorService.GetInstance <DatabaseContext>();
            _logger          = LogManager.GetLogger("SessionServiceLogger");
        }
Пример #2
0
        public BaseController()
        {
            ControlPanelControllerLogger = LogManager.GetCurrentClassLogger();

            var injectorService = DependencyInversionService.GetServiceInstance();

            DatabaseContext = injectorService.GetInstance <DatabaseContext>();

            //SessionContext = injectorService.GetInstance<ControlPanelSessionContext>();
        }
Пример #3
0
        protected void Application_Start()
        {
            _logger = LogManager.GetLogger("ApplicationAndSessionLogger");
            _logger.Info("-----------------------------------------------------------------------------------------");
            _logger.Info("Application started.");

            //AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            #region IoC (Simple Injector) Configuration

            var stopWatchLog = new StopWatchLogHelper();
            stopWatchLog.Start("WebApplication", " - IOC Configuration started.");

            try
            {
                var injectorService = DependencyInversionService.GetServiceInstance();

                injectorService.Container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

                injectorService.Container.Register <ISessional, SiteSessionContext>();
                injectorService.Container.Register <DatabaseContext>(Lifestyle.Scoped);

                //injectorService.Container.Register<ISessional, SiteSessionContext>(Lifestyle.Scoped);
                //injectorService.Container.Register<ISessional, SiteSessionContext>(Lifestyle.Scoped);

                injectorService.Container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

                injectorService.Container.RegisterMvcIntegratedFilterProvider();

                injectorService.Container.Verify();

                DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(injectorService.Container));
            }
            catch (Exception ex)
            {
                var exceptionId = Guid.NewGuid();

                _logger.Error(exceptionId + " - " + "Unable register container. " + ex.ToString());
                throw new AppException(exceptionId + " - " + "Unable register container. ", ex);
            }

            stopWatchLog.Stop(" - IOC Configuration finished. Elapsed time : ");

            #endregion
        }
Пример #4
0
        protected void Session_End(object sender, EventArgs args)
        {
            _logger = LogManager.GetLogger("ApplicationAndSessionLogger");

            var injectorService = DependencyInversionService.GetServiceInstance();

            var sessionContext = injectorService.GetInstance <SiteSessionContext>();

            try
            {
                _logger.Info("Session is terminated. Session Key : " + sessionContext.DomainUserSession.SessionId == null ? "" : sessionContext.DomainUserSession.SessionId + " Ip : " + sessionContext.ClientIp == null ? "" : sessionContext.ClientIp + " Domain User Name : " + sessionContext.DomainUser.NameAndSurname);
                _logger.Info("-----------------------------------------------------------------------------------------");
            }
            catch (Exception ex)
            {
                _logger.Error("Session cannot be created!. Exception : " + ex);
            }
        }