protected void PrepareUpdate(JET_prep mode)
            {
                Contract.ThrowIfFalse(_table != null);

                if (_updater != null)
                {
                    _updater.Dispose();
                }

                _updater = new Update(_session.SessionId, TableId, mode);
            }
            protected void PrepareUpdate(JET_prep mode)
            {
                Contract.ThrowIfFalse(_table != null);

                if (_updater != null)
                {
                    _updater.Dispose();
                }

                _updater = new Update(_session.SessionId, TableId, mode);
            }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the Update class. This automatically
        /// begins an update. The update will be cancelled if
        /// not explicitly saved.
        /// </summary>
        /// <param name="sesid">The session to start the transaction for.</param>
        /// <param name="tableid">The tableid to prepare the update for.</param>
        /// <param name="prep">The type of update.</param>
        public Update(JET_SESID sesid, JET_TABLEID tableid, JET_prep prep)
        {
            if (JET_prep.Cancel == prep)
            {
                throw new ArgumentException("Cannot create an Update for JET_prep.Cancel", "prep");
            }

            this.sesid = sesid;
            this.tableid = tableid;
            Api.JetPrepareUpdate(this.sesid, this.tableid, prep);
            this.ResourceWasAllocated();
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the Update class. This automatically
        /// begins an update. The update will be cancelled if
        /// not explicitly saved.
        /// </summary>
        /// <param name="sesid">The session to start the transaction for.</param>
        /// <param name="tableid">The tableid to prepare the update for.</param>
        /// <param name="prep">The type of update.</param>
        public Update(JET_SESID sesid, JET_TABLEID tableid, JET_prep prep)
        {
            if (JET_prep.Cancel == prep)
            {
                throw new ArgumentException("Cannot create an Update for JET_prep.Cancel", "prep");
            }

            this.sesid   = sesid;
            this.tableid = tableid;
            Api.JetPrepareUpdate(this.sesid, this.tableid, prep);
            this.ResourceWasAllocated();
        }
Exemple #5
0
        /// <summary>
        /// Prepare an update for the current record.
        /// </summary>
        /// <param name="prep">Type of update to prepare.</param>
        public virtual void PrepareUpdate(JET_prep prep)
        {
            this.Tracer.TraceVerbose("PrepareUpdate {0}", prep);
            this.CheckNotDisposed();

            if (JET_prep.Cancel == prep)
            {
                const string Error = "Cannot use JET_prep.Cancel with PrepareUpdate. Use the Cancel method";
                this.Tracer.TraceError(Error);
                throw new ArgumentException(Error);
            }

            Api.JetPrepareUpdate(this.session, this.table, prep);
            this.inUpdate = true;

            this.CheckNotDisposed();
        }
Exemple #6
0
        /// <summary>
        /// Prepare an update for the current record.
        /// </summary>
        /// <param name="prep">Type of update to prepare.</param>
        public virtual void PrepareUpdate(JET_prep prep)
        {
            this.Tracer.TraceVerbose("PrepareUpdate {0}", prep);
            this.CheckNotDisposed();

            if (JET_prep.Cancel == prep)
            {
                const string Error = "Cannot use JET_prep.Cancel with PrepareUpdate. Use the Cancel method";
                this.Tracer.TraceError(Error);
                throw new ArgumentException(Error);
            }

            Api.JetPrepareUpdate(this.session, this.table, prep);
            this.inUpdate = true;

            this.CheckNotDisposed();
        }
Exemple #7
0
 public static Update BeginUpdate(this Session session, JET_TABLEID tableid, JET_prep prep)
 {
     return(new Update(session, tableid, prep));
 }
Exemple #8
0
 /// <summary>
 /// Prepare a cursor for update.
 /// </summary>
 /// <param name="sesid">The session which is starting the update.</param>
 /// <param name="tableid">The cursor to start the update for.</param>
 /// <param name="prep">The type of update to prepare.</param>
 public static void JetPrepareUpdate(JET_SESID sesid, JET_TABLEID tableid, JET_prep prep)
 {
     Api.Check(Impl.JetPrepareUpdate(sesid, tableid, prep));
 }
        private void SetEntry(CacheEntry entry, JET_prep updateType)
        {
            Api.JetPrepareUpdate(_sesid, _table, updateType);
            try
            {
                // The easy part set the key
                Api.SetColumn(
                    _sesid,
                    _table,
                    _keyColumn,
                    entry.Key,
                    Encoding.Unicode
                    );

                Api.SetColumn(
                    _sesid,
                    _table,
                    _dataColumn,
                    entry.Data
                    );

                Api.SetColumn(
                    _sesid,
                    _table,
                    _callbacksColumn,
                    entry.PostEvicationCallbacks
                    );

                // Avoid race conditions on update by making sure the record
                // is clear
                if (updateType == JET_prep.Replace)
                {
                    // Get the existing channels
                    var column = new JET_RETRIEVECOLUMN
                    {
                        columnid = _dependencyColumn,
                        grbit    = RetrieveColumnGrbit.RetrieveTag
                    };
                    Api.JetRetrieveColumns(_sesid, _table, new[] { column }, 1);

                    // This is a bit tricky, note that when an item is removed all the
                    // itag sequences update to be one lower
                    int count = column.itagSequence;
                    for (int i = 0; i < count; i++)
                    {
                        JET_SETINFO setInfo = new JET_SETINFO {
                            itagSequence = 1
                        };
                        Api.JetSetColumn(
                            _sesid,
                            _table,
                            _dependencyColumn,
                            null,
                            0,
                            SetColumnGrbit.UniqueMultiValues,
                            setInfo
                            );
                    }

                    Api.SetColumn(_sesid, _table, _absoluteExpirationColumn, null);
                    Api.SetColumn(_sesid, _table, _lastAccessedColumn, null);
                    Api.SetColumn(_sesid, _table, _slidingExpirationColumn, null);
                }


                if (entry.AbsoluteExpiration > 0)
                {
                    Api.SetColumn(
                        _sesid,
                        _table,
                        _absoluteExpirationColumn,
                        entry.AbsoluteExpiration
                        );
                }
                else if (entry.SlidingExpiration > 0)
                {
                    Api.SetColumn(
                        _sesid,
                        _table,
                        _lastAccessedColumn,
                        Convert.ToInt64(entry.LastAccessed)
                        );

                    Api.SetColumn(
                        _sesid,
                        _table,
                        _slidingExpirationColumn,
                        entry.SlidingExpiration
                        );
                }

                // Loop through all the channels and create them,
                // as this is a new record there is no need for checks
                foreach (var dependency in entry.Dependencies)
                {
                    // Using tag sequence 0 wil mean the items are
                    // automatically pushed into the mv-column
                    JET_SETINFO setInfo = new JET_SETINFO();
                    setInfo.itagSequence = 0;

                    // Note the use of ASCII to take up half the space
                    // there is no reason either subscriber or channel
                    // will have more than this
                    byte[] data = Encoding.ASCII.GetBytes(dependency);
                    Api.JetSetColumn(
                        _sesid,
                        _table,
                        _dependencyColumn,
                        data,
                        data.Length,
                        SetColumnGrbit.UniqueMultiValues,
                        setInfo
                        );
                }

                Api.JetUpdate(_sesid, _table);
            }
            catch (Exception exp)
            {
                Api.JetPrepareUpdate(_sesid, _table, JET_prep.Cancel);
                throw exp;
            }
        }
Exemple #10
0
 public static Update BeginUpdate(this Session session, JET_TABLEID tableid, JET_prep prep)
 {
     return new Update(session, tableid, prep);
 }
        /// <summary>
        /// Обновить данные в текущей строке таблицы.
        /// </summary>
        /// <param name="table">Таблица.</param>
        /// <param name="reference">Ссылка на доску.</param>
        /// <param name="prep">Тип обновления.</param>
        protected virtual void UpdateFullRowInfo(BoardReferenceTable table, IBoardReference reference, JET_prep prep)
        {
            var row = new BoardReferenceTable.ViewValues.FullRowView()
            {
                Id           = GetId(reference),
                Category     = reference.Category ?? "",
                Pages        = reference.Pages,
                IsAdult      = reference.IsAdult,
                DefaultName  = reference.DefaultName,
                ShortName    = reference.ShortName,
                DisplayName  = reference.DisplayName,
                ExtendedData = SerializeDataContract(BoardExtendedInfo.ToContract(reference, LinkSerialization)),
                BumpLimit    = reference.BumpLimit
            };

            if (prep == JET_prep.Replace)
            {
                table.Update.UpdateAsFullRowView(ref row);
            }
            else if (prep == JET_prep.Insert)
            {
                table.Insert.InsertAsFullRowView(ref row);
            }
        }
Exemple #12
0
 /// <summary> Prepares insertion </summary>
 internal RowModification(Table table, HasJetHandleBase<JET_TABLEID> cursor, JET_prep preparationType)
 {
     Table = table;
     Cursor = cursor;
     Api.JetPrepareUpdate(CurrentSession, cursor, preparationType);
 }
Exemple #13
0
 /// <summary>
 /// Создать обновление.
 /// </summary>
 /// <param name="prep">Тип обновления.</param>
 /// <returns>Обновление.</returns>
 public Update Update(JET_prep prep)
 {
     return(new Update(Session, Table, prep));
 }