示例#1
0
        public DbContextScope(DataContextScopeOption joiningOption, bool readOnly, IsolationLevel? isolationLevel, IDataContextFactory dbContextFactory = null)
        {
            if (isolationLevel.HasValue && joiningOption == DataContextScopeOption.JoinExisting)
                throw new ArgumentException("Cannot join an ambient DbContextScope when an explicit database transaction is required. When requiring explicit database transactions to be used (i.e. when the 'isolationLevel' parameter is set), you must not also ask to join the ambient context (i.e. the 'joinAmbient' parameter must be set to false).");

            _disposed = false;
            _completed = false;
            _readOnly = readOnly;

            _parentScope = GetAmbientScope();
            if (_parentScope != null && joiningOption == DataContextScopeOption.JoinExisting)
            {
                if (_parentScope._readOnly && !this._readOnly)
                {
                    throw new InvalidOperationException("Cannot nest a read/write DbContextScope within a read-only DbContextScope.");
                }

                _nested = true;
                _dataContexts = _parentScope._dataContexts;
            }
            else
            {
                _nested = false;
                _dataContexts = new DbContextCollection(readOnly, isolationLevel, dbContextFactory);
            }

            SetAmbientScope(this);
        }
示例#2
0
        /// <summary>
        /// Start a new basket
        /// </summary>
        /// <param name="dataContextFactory">Data context factory</param>
        /// <returns>An instance of a basketwrapper serving a new transaction</returns>
        public static BasketWrapper CreateNewByIdentity(IDataContextFactory dataContextFactory)
        {
            var basket = new BasketWrapper(dataContextFactory.CreateByUser());
            basket.Transaction = new Transaction {CreatedDateTime = DateTime.Now};

            return basket;
        }
 public DataContextScopeFactory(Func<DataContext> dataContextFactory)
 {
     if (dataContextFactory != null)
       {
     _dataContextFactory = new DataContextFactory(dataContextFactory);
       }
 }
示例#4
0
    public UnitOfWork(IDataContextFactory dataContextFactory)
    {
      _dataContextFactory = dataContextFactory;

      DataContext = _dataContextFactory.CreateDataContext();
      _transaction = DataContext.BeginTransaction();
    }
示例#5
0
 /// <summary>
 /// Constructor. It creates a dbContext Factory and initializes the database.
 /// </summary>
 public UnitOfWorkFixture()
 {
     _contextFactory = new DataContextFactory();
     _contextFactory.Get().Database.Initialize(false);
     IRepositoryProvider provider = new RepositoryProvider(new RepositoryFactories());
     provider.DataContextFactory = _contextFactory;
     _unitOfWork = new UnitOfWork(provider);
 }
 public AccountController(ICookieHelper cookieHelper, ILogger logger, 
     IDataContextFactory dataContextFactory, IEmailService emailService)
 {
     _cookieHelper = cookieHelper;
     _logger = logger;
     _dataContextFactory = dataContextFactory;
     _emailService = emailService;
 }
示例#7
0
        /// <summary>
        /// Get a basketwrapper based on a provided transactionId
        /// </summary>
        /// <param name="dataContextFactory">Data context factory</param>
        /// <param name="transactionId">Id of the transaction to load in the basket</param>
        /// <returns>An instance of a basketwrapper serving the transaction</returns>
        /// <remarks>
        /// At first attempt the a datacontext based on userIdentity is applied.
        /// If userIdentity datacontext does not contain requested transaction, user does not yet
        /// have access to transaction (new user or new vendor). Use datacontext based on 
        /// transactionId instead.
        /// </remarks>
        public static BasketWrapper CreateByTransaction(IDataContextFactory dataContextFactory, Guid transactionId)
        {
            var basket = new BasketWrapper(dataContextFactory.CreateByTransaction(transactionId));
            var transactionLoaded = basket.LoadTransaction(transactionId);

            if (!transactionLoaded)
            {
                throw new Exception();
            }

            return basket;
        }
示例#8
0
        public static VendorCredentialModel ForCreate(IDataContextFactory contextFactory, Guid vendorId)
        {
            VendorCredentialModel result;

            using (var context = contextFactory.CreateByUser())
            {
                var vendor = (from x in context.Vendors where x.ObjectId == vendorId select x).FirstOrDefault();

                result = new VendorCredentialModel()
                {
                    VendorId = vendor.ObjectId,
                    VendorName = vendor.Name,
                };
            }
            return result;
        }
示例#9
0
        public static VendorCredentialModel ForEdit(IDataContextFactory dataContextFactory, Guid key)
        {
            VendorCredentialModel result;

            using (var dataContext = dataContextFactory.CreateByUser())
            {
                var vendorCredential =
                    dataContext.VendorCredentials.Where(vs => vs.VendorCredentialId == key).Include(x => x.Vendor).Single();

                result = new VendorCredentialModel()
                {
                    VendorId = vendorCredential.Vendor.ObjectId,
                    VendorName = vendorCredential.Vendor.Name,
                    VendorCredentialId = vendorCredential.VendorCredentialId,
                    CredentialName = vendorCredential.CredentialName,
                    CredentialValue = Encoding.UTF8.GetString(SymmetricEncryption.DecryptForDatabase(vendorCredential.CredentialValue))
                };
            }
            return result;
        }
示例#10
0
 public SKUController(IDataContextFactory dataContextFactory)
     : base(dataContextFactory)
 {
     this.dataContextFactory = dataContextFactory;
 }
 public ManagerService(IDataContextFactory dataContextFactory)
 {
     this.context = dataContextFactory.Create(ConnectionType.Ip);
 }
 public DataContextScopeFactory()
 {
     _dataContextFactory = null;
 }
示例#13
0
 public DeliveryNoteListService(IDataContextFactory contextFactory)
 {
     _contextFactory = contextFactory;
 }
 public EmployeeService(IDataContextFactory dataContextFactory)
 {
     this.context = dataContextFactory.Create(ConnectionType.Ip);
 }
 public CustomerAppIssueController(IDataContextFactory dataContextFactory, ILoggingService loggingService)
 {
     this.dataContextFactory = dataContextFactory;
     this.loggingService = loggingService;
 }
示例#16
0
 public WsseDotShipRepository(IDataContextFactory contextFactory)
     : base(contextFactory)
 {
 }
 public ProductTitleRepository(IDataContextFactory factory)
     : base(factory)
 {
 }
示例#18
0
 public ProjectService(IDataContextFactory dataContextFactory, IGenericService genericService)
 {
     this.context    = dataContextFactory.Create(ConnectionType.Ip);
     _genericService = genericService;
 }
示例#19
0
 public AttachmentRepository(IDataContextFactory dataContextFactory) : base(dataContextFactory)
 {
     this.context = dataContextFactory.Context as BlueHrDataContext;
 }
示例#20
0
 public LocationInventoryListService(IDataContextFactory contextFactory)
 {
     _contextFactory = contextFactory;
 }
 public SelfCommitEntityRepository(IDataContextFactory <TContext> databaseFactory)
     : base(databaseFactory)
 {
     _dbset = DataContext.Set <T>();
 }
示例#22
0
 public DomainLicenseController(IDataContextFactory dataContextFactory)
 {
     this.dataContextFactory = dataContextFactory;
 }
示例#23
0
 public OfferRepository(IDataContextFactory dbFactory)
     : base(dbFactory)
 {
 }
示例#24
0
 public WsseTMSProductsRepository(IDataContextFactory contextFactory)
     : base(contextFactory)
 {
 }
示例#25
0
 /// <summary>
 /// Constructor. It creates a dbContext Factory and initializes the database.
 /// </summary>
 public DataContextFixture()
 {
     _contextFactory = new DataContextFactory();
     _contextFactory.Get().Database.Initialize(false);
 }
 public DataContextReadOnlyScope(IsolationLevel isolationLevel, IDataContextFactory dataContextFactory = null)
     : this(joiningOption: DataContextScopeOption.ForceCreateNew, isolationLevel: isolationLevel, dataContextFactory: dataContextFactory)
 {
 }
示例#27
0
        /// <summary>
        /// Parameterized Constructor.
        /// </summary>
        public SnapshotStore(IDataContextFactory dbContextFactory)
        {
            this._dbContextFactory = dbContextFactory;

            this._persistent = ConfigurationManager.AppSettings["thinkcfg.snapshot_storage"].To(false);
        }
示例#28
0
 public CustomerAppController(IDataContextFactory dataContextFactory)
 {
     this.dataContextFactory = dataContextFactory;
 }
示例#29
0
 /// <summary>
 /// Default Constructor.
 /// </summary>
 public HandlerRecordStore(IDataContextFactory contextFactory)
 {
     this._contextFactory = contextFactory;
 }
示例#30
0
 public AccountController(IDataContextFactory dataContextFactory)
 {
     this.dataContextFactory = dataContextFactory;
 }
 public ProjectService(IDataContextFactory dataContextFactory)
 {
     _context = dataContextFactory.Create(ConnectionType.Ip);
 }
 public DataContextScopeFactory(IDataContextFactory dataContextFactory = null)
 {
     _dataContextFactory = dataContextFactory;
 }
 public DataContextScopeFactory(IDataContextFactory dataContextFactory = null)
 {
     _dataContextFactory = dataContextFactory;
 }
示例#34
0
 public UserSessionsRepository(IDataContextFactory dataContextFactory)
     : base(dataContextFactory)
 {
 }
 public DataContextReadOnlyScope(IDataContextFactory dataContextFactory = null)
     : this(joiningOption: DataContextScopeOption.JoinExisting, isolationLevel: null, dataContextFactory: dataContextFactory)
 {
 }
 public EntityFrameworkSessionScopeFactory(IDataContextFactory dbContextFactory)
 {
     Requires.NotNull(dbContextFactory, "dbContextFactory");
     _dbContextFactory = dbContextFactory;
 }
 public DataContextReadOnlyScope(DataContextScopeOption joiningOption, IsolationLevel? isolationLevel, IDataContextFactory dataContextFactory = null)
 {
     _internalScope = new DataContextScope(joiningOption: joiningOption, readOnly: true, isolationLevel: isolationLevel, dataContextFactory: dataContextFactory);
 }
示例#38
0
 public LicenseValidator(IDataContextFactory dataContextFactory, ILoggingService loggingService, IApplicationIssueUnitOfWork applicationIssueUnitOfWork)
 {
     this.dataContextFactory = dataContextFactory;
     this.loggingService = loggingService;
     this.applicationIssueUnitOfWork = applicationIssueUnitOfWork;
 }
 public FeedProcessor(ILogger logger, IDataContextFactory dataContextFactory)
 {
     _logger = logger;
     _dataContextFactory = dataContextFactory;
 }
示例#40
0
 protected RepositoryBase(IDataContextFactory dbFactory)
 {
     _dbFactory = dbFactory;
 }
示例#41
0
 /// <summary>
 /// Parameterized Constructor.
 /// </summary>
 public EventStore(IDataContextFactory dbContextFactory)
 {
     this._dbContextFactory = dbContextFactory;
 }
 public DataContextScopeFactory()
 {
     _dataContextFactory = null;
 }