/// <summary> /// Initializes a new instance of the <see cref="AbstractScope"/> class. /// </summary> /// <param name="flushAction">The flush action.</param> /// <param name="type">The type.</param> public AbstractScope(FlushAction flushAction, SessionScopeType type) { this.flushAction = flushAction; this.type = type; ThreadScopeAccessor.Instance.RegisterScope(this); }
/// <summary> /// Initializes a new instance of the <see cref="DifferentDatabaseScope"/> class. /// </summary> /// <param name="connection">The connection.</param> /// <param name="flushAction">The flush action.</param> public DifferentDatabaseScope(IDbConnection connection, FlushAction flushAction) : base(flushAction, SessionScopeType.Custom) { if (connection == null) throw new ArgumentNullException("connection"); this.connection = connection; ISessionScope parentScope = ScopeUtil.FindPreviousScope(this, true); if (parentScope != null) { if (parentScope.ScopeType == SessionScopeType.Simple) { parentSimpleScope = (SessionScope) parentScope; } else if (parentScope.ScopeType == SessionScopeType.Transactional) { parentTransactionScope = (TransactionScope) parentScope; parentTransactionScope.OnTransactionCompleted += OnTransactionCompleted; } else { // Not supported? } } }
/// <summary> /// Initializes a new instance of the <see cref="DifferentDatabaseScope"/> class. /// </summary> /// <param name="connection">The connection.</param> /// <param name="flushAction">The flush action.</param> public DifferentDatabaseScope(IDbConnection connection, FlushAction flushAction) : base(flushAction, SessionScopeType.Custom) { if (connection == null) { throw new ArgumentNullException("connection"); } this.connection = connection; ISessionScope parentScope = ScopeUtil.FindPreviousScope(this, true); if (parentScope != null) { if (parentScope.ScopeType == SessionScopeType.Simple) { parentSimpleScope = (SessionScope)parentScope; } else if (parentScope.ScopeType == SessionScopeType.Transactional) { parentTransactionScope = (TransactionScope)parentScope; parentTransactionScope.OnTransactionCompleted += OnTransactionCompleted; } else { // Not supported? } } }
/// <summary> /// Initializes a new instance of the <see cref="AbstractScope"/> class. /// </summary> /// <param name="flushAction">The flush action.</param> /// <param name="type">The type.</param> public AbstractScope(FlushAction flushAction, SessionScopeType type) { this.flushAction = flushAction; this.type = type; ThreadScopeAccessor.Instance.RegisterScope(this); }
//enqueue item public virtual void EnqueueItem(T item, FlushAction action) { _flushQueues[action].Queue.Add(item); if (!IsBatchingEnabled) { FlushQueues(); } }
/// <summary> /// Waits for flush of all pending events to the underlying stream /// </summary> public Task FlushAsync() { // There are event still being processed. Ensure they are all sent // before flushing the underlying stream, by adding a flush event // which will be trigger when current pending events are processed // and the underlying stream has been flushed. var flushAction = new FlushAction(this); QueueAction(flushAction); return(flushAction.Completion); }
/// <summary> /// Initializes a new instance of the <see cref="DifferentDatabaseScope"/> class. /// </summary> public DifferentDatabaseScope( IDbConnection connection, FlushAction flushAction = FlushAction.Auto, ISessionScope parent = null, ISessionFactoryHolder holder = null, IThreadScopeInfo scopeinfo = null ) : base(flushAction, parent: parent, holder: holder, scopeinfo: scopeinfo) { if (connection == null) throw new ArgumentNullException("connection"); _connection = connection; }
/// <summary> /// Initializes a new instance of the <see cref="DifferentDatabaseScope"/> class. /// </summary> public DifferentDatabaseScope( IDbConnection connection, FlushAction flushAction = FlushAction.Auto, ISessionScope parent = null, ISessionFactoryHolder holder = null, IThreadScopeInfo scopeinfo = null ) : base(flushAction, parent: parent, holder: holder, scopeinfo: scopeinfo) { if (connection == null) { throw new ArgumentNullException("connection"); } _connection = connection; }
//perform flush protected virtual Task MakeQuery(List <SignalWrapper <TSignal> > items, FlushAction action) { List <TSignal> signals = items.Select(x => x.Signal).ToList(); if (action == FlushAction.Insert) { return(_queries.Insert(signals)); } if (action == FlushAction.Update) { return(_queries.UpdateSendResults(signals)); } if (action == FlushAction.DeleteOne) { return(_queries.Delete(signals)); } throw new NotImplementedException($"Unknown flush action type {action}"); }
/// <summary> /// /// </summary> /// <param name="flushAction"></param> public EasySession(FlushAction flushAction) { if (dbType == null || dbType == string.Empty || dbType == "SQL") { this.Connection = new SqlConnection(connecString); this.Connection.Open(); this.Transaction = Connection.BeginTransaction(); } else if (dbType == "ORACLE") { this.OConnection = new OracleConnection(connecString); this.OConnection.Open(); this.OTransaction = OConnection.BeginTransaction(); } else if (dbType == "MYSQL") { this.MConnection = new MySqlConnection(connecString); this.MConnection.Open(); this.MTransaction = MConnection.BeginTransaction(); } this.FlushAction = flushAction; }
/// <summary> /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> /// <param name="flushAction">The flush action.</param> public SessionScope(FlushAction flushAction) : base(flushAction, SessionScopeType.Simple) { }
/// <summary> /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> /// <param name="flushAction">The flush action.</param> /// <param name="type">The type.</param> protected SessionScope(FlushAction flushAction, SessionScopeType type) : base(flushAction, type) { }
/// <summary> /// 创建ActionStreamWriter的实例。 /// </summary> /// <param name="writeAction">写入时调用的委托。</param> /// <param name="flushAction">flush调用的委托。</param> public ActionStreamWriter(WriteAction writeAction, FlushAction flushAction = null) { _writeAction = writeAction; _flushAction = flushAction; }
/// <summary> /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> /// <param name="flushAction">The flush action.</param> public SessionScope(FlushAction flushAction) : base(flushAction, SessionScopeType.Simple) { }
/// <summary> /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> /// <param name="flushAction">The flush action.</param> /// <param name="type">The type.</param> protected SessionScope(FlushAction flushAction, SessionScopeType type) : base(flushAction, type) { }