protected AbstractActions(JET_INSTANCE instance, ColumnsInformation columnsInformation, string database, Guid instanceId)
        {
            logger = LogManager.GetLogger(GetType());
            try
            {
                this.instanceId = instanceId;
                ColumnsInformation = columnsInformation;
                session = new Session(instance);

                transaction = new Transaction(session);
                Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);

                queues = new EsentTable(session, new Table(session, dbid, "queues", OpenTableGrbit.None));
                subqueues = new EsentTable(session, new Table(session, dbid, "subqueues", OpenTableGrbit.None));
                txs = new EsentTable(session, new Table(session, dbid, "transactions", OpenTableGrbit.None));
                recovery = new EsentTable(session, new Table(session, dbid, "recovery", OpenTableGrbit.None));
                outgoing = new EsentTable(session, new Table(session, dbid, "outgoing", OpenTableGrbit.None));
                outgoingHistory = new EsentTable(session, new Table(session, dbid, "outgoing_history", OpenTableGrbit.None));
                recveivedMsgs = new EsentTable(session, new Table(session, dbid, "recveived_msgs", OpenTableGrbit.None));
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }
 private void FillTable(EsentTable table)
 {
     Properties.Rows.Add(nameof(table.Name), table.Name);
     Properties.Rows.Add(nameof(table.Opened), table.Opened);
     Properties.Rows.Add(nameof(table.Database), table.Database.Name);
     Properties.Rows.Add("Rows", table.Count);
     Properties.Rows.Add(nameof(table.Columns), table.Columns.Count);
     Properties.Rows.Add(nameof(table.Indexes), table.Indexes.Count);
 }
 public QueueActions(Session session, JET_DBID dbid, string queueName, string[] subqueues, AbstractActions actions, Action<int> changeNumberOfMessages)
 {
     _queueName = queueName;
     _subqueues = subqueues;
     _actions = actions;
     _changeNumberOfMessages = changeNumberOfMessages;
     var msgs = new Table(session, dbid, queueName, OpenTableGrbit.None);
     var msgsHistory = new Table(session, dbid, queueName + "_history", OpenTableGrbit.None);
     _messages = new EsentTable(session, msgs);
     _messageHistory = new EsentTable(session, msgsHistory);
 }
        protected void ClearMultiValue(EsentTable table, JET_COLUMNID columnid)
        {
            var cnt = GetMultiValueCount(table, columnid);
            var si  = new JET_SETINFO()
            {
                itagSequence = 1
            };

            for (var i = 0; i < cnt; i++)
            {
                Api.JetSetColumn(table.Session, table.Table, columnid, null, 0, SetColumnGrbit.None, si);
            }
        }
        /// <summary>
        /// Перечислить значения в столбце со многоими значениями.
        /// </summary>
        /// <param name="table">Таблица.</param>
        /// <param name="columnid">Идентификатор столбца.</param>
        /// <param name="factoryFunc">Фабрика создания значений для получения данных.</param>
        /// <returns>Результат.</returns>
        protected IEnumerable <ColumnValue> EnumMultivalueColumn(EsentTable table, JET_COLUMNID columnid, Func <ColumnValue> factoryFunc)
        {
            var count = GetMultiValueCount(table, columnid);

            if (count == 0)
            {
                yield break;
            }

            var a = new ColumnValue[1];

            for (var i = 1; i <= count; i++)
            {
                var col = factoryFunc();
                col.ItagSequence = i;
                col.Columnid     = columnid;
                a[0]             = col;
                Api.RetrieveColumns(table.Session, table.Table, a);
                yield return(col);
            }
        }
        /// <summary>
        /// Перечислить значения в столбце со многоими значениями.
        /// </summary>
        /// <param name="table">Таблица.</param>
        /// <param name="columnid">Идентификатор столбца.</param>
        /// <param name="grbit">Флаг получения.</param>
        /// <returns>Результат.</returns>
        protected IEnumerable <T> EnumMultivalueColumn <T>(EsentTable table, JET_COLUMNID columnid, RetrieveColumnGrbit grbit = RetrieveColumnGrbit.None) where T : ColumnValue, new()
        {
            var count = GetMultiValueCount(table, columnid);

            if (count == 0)
            {
                yield break;
            }

            var a = new ColumnValue[1];

            for (var i = 1; i <= count; i++)
            {
                var col = new T
                {
                    ItagSequence  = i,
                    Columnid      = columnid,
                    RetrieveGrbit = grbit
                };
                a[0] = col;
                Api.RetrieveColumns(table.Session, table.Table, a);
                yield return(col);
            }
        }
 internal void ClearTable(EsentTable table)
 {
     var enumerator = table.GetEnumerator();
     while (enumerator.MoveNext())
     {
         table.Delete();
     }
 }