Пример #1
0
        private void ProcessLogOn()
        {
            if (_lockLogOn)
            {
                return;
            }

            _lockLogOn = true;

            User savedUser = null;
            bool isLogOnOk = false;

            using (IWorkContextScope scope = _workEnvironment.GetWorkContextScope())
            {
                if ((isLogOnOk = _userService.LogOn(UserName, Password)))
                {
                    savedUser = _userService.GetUser(UserName);
                }
            }

            if (isLogOnOk)
            {
                GoBack(savedUser);
            }
            else
            {
                HasError     = true;
                ErrorMessage = _userService.ErrorString;
            }

            _lockLogOn = false;
        }
Пример #2
0
        public ISession For(Type entityType)
        {
            Logger.Debug("Acquiring session for {0}", entityType);

            IWorkContextScope currentScope = _workEnvironment.GetWorkContextScope();
            object            session      = null;

            if (!currentScope.Items.TryGetValue(ContextKey, out session))
            {
                currentScope.Disposing += WorkUnitScope_Disposing;

                var sessionFactory = _sessionFactoryHolder.GetSessionFactory();

                ITransactionManager txManager = ServiceLocator.Current.GetInstance <ITransactionManager>();
                txManager.Demand();

                currentScope.Items.Add(TransactionKey, txManager);

                Logger.Debug("Openning database session");
                session = sessionFactory.OpenSession();

                currentScope.Items.Add(ContextKey, session);
            }

            return(session as ISession);
        }
Пример #3
0
 public void LoadCategoryData()
 {
     using (IWorkContextScope scope = _workEnviroment.GetWorkContextScope())
     {
         foreach (var category in _dataSource.Categories)
         {
             _foodService.CategoryProvider.Create(category);
         }
     }
 }