示例#1
0
        // MoveTo
        public CursorGetFlags MoveTo(bool first)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    if (first)
                    {
                        _sourceTable.First();
                    }
                    else
                    {
                        _sourceTable.Last();
                    }
                    return(InternalGetFlags());
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#2
0
        public int RowCount()
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    return(_sourceTable.RowCount());
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#3
0
        public int CompareBookmarks(Guid bookmark1, Guid bookmark2)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    return(InternalCompareBookmarks(bookmark1, bookmark2));
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#4
0
 /// <remarks> Must call SetApplication or SetLibrary before calling Start().  Upon completion, this session will be disposed. </remarks>
 public void Start(string document)
 {
     TimingUtility.PushTimer(String.Format("Windows.Session.Start('{0}')", document));
     try
     {
         // Prepare the root forms host
         _rootFormHost = CreateHost();
         try
         {
             _rootFormHost.NextRequest = new Request(document);
             IWindowsFormInterface rootForm;
             do
             {
                 rootForm = LoadNextForm(_rootFormHost);
                 rootForm.ShowModal(FormMode.None);
             } while (_rootFormHost.NextRequest != null);
         }
         finally
         {
             Dispose();
         }
     }
     finally
     {
         TimingUtility.PopTimer();
     }
 }
示例#5
0
        protected virtual void InternalOpen()
        {
            // get a table object to supply the data
            _plan.SetActiveCursor(this);
            try
            {
                _program.Start(_params);
                _programStarted = true;

                long startTicks = TimingUtility.CurrentTicks;

                CursorNode cursorNode = _plan.CursorNode;
                //LCursorNode.EnsureApplicationTransactionJoined(FPlan.ServerProcess);
                _sourceTable = (ITable)_plan.CursorNode.SourceNode.Execute(_program);
                _sourceTable.Open();
                _sourceRowType = _sourceTable.DataType.RowType;

                _program.Statistics.ExecuteTime = TimingUtility.TimeSpanFromTicks(startTicks);
            }
            catch
            {
                InternalClose();
                throw;
            }
        }
示例#6
0
 /// <remarks> The session should already be prepared before invoking this routine.  Upon completion, this session will be disposed. </remarks>
 public void StartCallback(string document, EventHandler onComplete)
 {
     TimingUtility.PushTimer(String.Format("Windows.Session.StartCallback('{0}')", document));
     try
     {
         // Prepare the root form's host
         _rootFormHost = CreateHost();
         try
         {
             _rootFormHost.NextRequest = new Request(document);
             _onComplete = onComplete;
             RootFormAdvance(null);
         }
         catch
         {
             if (_rootFormHost != null)
             {
                 _rootFormHost.Dispose();
                 _rootFormHost = null;
             }
             throw;
         }
     }
     finally
     {
         TimingUtility.PopTimer();
     }
 }
示例#7
0
        public bool Refresh(IRow row, out CursorGetFlags flags)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    bool success = _sourceTable.Refresh(row);
                    flags = InternalGetFlags();
                    return(success);
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#8
0
        public void FindNearest(IRow key, out CursorGetFlags flags)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    _sourceTable.FindNearest(key);
                    flags = InternalGetFlags();
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#9
0
        public bool GotoBookmark(Guid bookmark, bool forward, out CursorGetFlags flags)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    bool success = InternalGotoBookmark(bookmark, forward);
                    flags = InternalGetFlags();
                    return(success);
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#10
0
        public bool Change(IRow oldRow, IRow newRow, string columnName)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    return(((TableNode)SourceNode).Change(_plan.Program, oldRow, newRow, null, columnName));
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#11
0
        // MoveBy
        public int MoveBy(int delta, out CursorGetFlags flags)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    int localDelta = 0;
                    while (delta != 0)
                    {
                        if (delta > 0)
                        {
                            if (!_sourceTable.Next())
                            {
                                break;
                            }
                            delta--;
                        }
                        else
                        {
                            if (!_sourceTable.Prior())
                            {
                                break;
                            }
                            delta++;
                        }
                        localDelta++;
                    }
                    flags = InternalGetFlags();
                    return(localDelta);
                }
                finally
                {
                    _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#12
0
        public object Execute(DataParams paramsValue)
        {
            object result;

            Start(paramsValue);
            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                result = _code.Execute(this);
                _statistics.ExecuteTime = TimingUtility.TimeSpanFromTicks(startTicks);
            }
            finally
            {
                Stop(paramsValue);
            }
            return(result);
        }
示例#13
0
        public object DeviceExecute(Schema.Device device, PlanNode planNode)
        {
            if (_serverProcess.IsReconciliationEnabled() || (planNode.DataType != null))
            {
                long startTicks = TimingUtility.CurrentTicks;
                try
                {
                    EnsurePrepared(planNode);
                    return(DeviceConnect(device).Execute(this, planNode));
                }
                finally
                {
                    _statistics.DeviceExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
                }
            }

            return(null);
        }
示例#14
0
        /// <summary> Disposes a bookmark. </summary>
        /// <remarks> Does nothing if the bookmark does not exist, or has already been disposed. </remarks>
        public void DisposeBookmark(Guid bookmark)
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                InternalDisposeBookmark(bookmark);
                _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#15
0
        public void Truncate()
        {
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                CheckCapability(CursorCapability.Truncateable);
                _sourceTable.Truncate();
                _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
        }
示例#16
0
        /// <remarks> Must call SetApplication or SetLibrary before calling Start().  Upon completion, the given
        /// callback will be invoked and the session will be disposed.  Note that the session may leave its
        /// control in place and it is up to the caller to replace the content of the given container. </remarks>
        public void Start(string document, ContentControl container)
        {
            TimingUtility.PushTimer(String.Format("Silverlight.Session.Start('{0}')", document));
            try
            {
                // Create the session control
                CreateSessionControl();

                // Prepare the root form's host
                _rootFormHost = CreateHost();
                try
                {
                    _rootFormHost.NextRequest = new Request(document);
                    _container = container;
                    LoadNextForm(_rootFormHost).Show();
                }
                catch
                {
                    if (_rootFormHost != null)
                    {
                        _rootFormHost.Dispose();
                        _rootFormHost = null;
                    }
                    throw;
                }

                // Show the session control as the content of the given container
                DispatchAndWait((System.Action)(() => { if (_sessionControl != null)
                                                        {
                                                            container.Content = _sessionControl;
                                                        }
                                                }));
            }
            finally
            {
                TimingUtility.PopTimer();
            }
        }
示例#17
0
        public bool Next()
        {
            bool      result;
            Exception exception    = null;
            int       nestingLevel = _plan.ServerProcess.BeginTransactionalCall();

            try
            {
                long startTicks = TimingUtility.CurrentTicks;
                result = _sourceTable.Next();
                _program.Statistics.ExecuteTime += TimingUtility.TimeSpanFromTicks(startTicks);
            }
            catch (Exception E)
            {
                exception = E;
                throw WrapException(E);
            }
            finally
            {
                _plan.ServerProcess.EndTransactionalCall(nestingLevel, exception);
            }
            return(result);
        }
示例#18
0
        // BeginTransaction
        public virtual void BeginTransaction(SQLIsolationLevel isolationLevel)
        {
            if (_transactionCount == 0)
            {
                                #if SQLSTORETIMING
                long startTicks = TimingUtility.CurrentTicks;
                                #endif

                DisposeExecuteCommand();
                _connection.BeginTransaction(isolationLevel);

                                #if SQLSTORETIMING
                Store.Counters.Add(new SQLStoreCounter("BeginTransaction", "", "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                                #endif
            }
            _transactionCount++;

            _operationLog.Add(new BeginTransactionOperation());
        }
示例#19
0
        protected internal SQLCursor ExecuteReader(string statement, out SQLCommand readerCommand)
        {
            readerCommand             = GetReaderCommand();
            readerCommand.CommandType = SQLCommandType.Statement;
            readerCommand.Statement   = statement;

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
            try
            {
                        #endif
            return(readerCommand.Open(SQLCursorType.Dynamic, SQLIsolationLevel.Serializable));

                        #if SQLSTORETIMING
        }
        finally
        {
            Store.Counters.Add(new SQLStoreCounter("ExecuteReader", AStatement, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
        }
                        #endif
        }
示例#20
0
        public object ExecuteScalar(string statement)
        {
            ExecuteCommand.CommandType = SQLCommandType.Statement;
            ExecuteCommand.Statement   = statement;

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
            try
            {
                        #endif

            return(ExecuteCommand.Evaluate());

                        #if SQLSTORETIMING
        }
        finally
        {
            Store.Counters.Add(new SQLStoreCounter("ExecuteScalar", AStatement, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
        }
                        #endif
        }
示例#21
0
        public void ExecuteStatement(string statement)
        {
            ExecuteCommand.CommandType = SQLCommandType.Statement;
            ExecuteCommand.Statement   = statement;

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
                        #endif

            ExecuteCommand.Execute();

                        #if SQLSTORETIMING
            Store.Counters.Add(new SQLStoreCounter("ExecuteNonQuery", AStatement, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif
        }
示例#22
0
        public void Delete()
        {
            CheckIsOnRow();

            if ((_currentRow == null) && (_connection.TransactionCount > 1))
            {
                _currentRow = InternalSelect();
            }

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
                        #endif

            _isOnRow = InternalDelete();

                        #if SQLSTORETIMING
            Connection.Store.Counters.Add(new SQLStoreCounter("Delete", FTableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif

            if (_connection.TransactionCount > 1)
            {
                _connection.LogDelete(_tableName, _columns, _key, _currentRow);
            }

            _currentRow = null;
            _editingRow = null;
        }
示例#23
0
        public void Update()
        {
            CheckIsOnRow();

            object[] newRow = null;
            if (_connection.TransactionCount > 1)
            {
                if (_currentRow == null)
                {
                    _currentRow = InternalSelect();
                }

                if (Connection.Store.SupportsUpdatableCursor)
                {
                    newRow = InternalSelect();
                }
                else
                {
                    newRow = _editingRow;
                }
            }

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
                        #endif

            _isOnRow = InternalUpdate();

                        #if SQLSTORETIMING
            Connection.Store.Counters.Add(new SQLStoreCounter("Update", FTableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif

            if (_connection.TransactionCount > 1)
            {
                _connection.LogUpdate(_tableName, _columns, _key, _currentRow, newRow);
            }

            _currentRow = null;
            _editingRow = null;
        }
示例#24
0
        public void Insert(object[] row)
        {
            //EnsureReader();

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
            Connection.Store.Counters.Add(new SQLStoreCounter("CreateRecord", FTableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
            startTicks = TimingUtility.CurrentTicks;
                        #endif

            _isOnRow = InternalInsert(row);

                        #if SQLSTORETIMING
            Connection.Store.Counters.Add(new SQLStoreCounter("Insert", FTableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif

            if (_connection.TransactionCount > 1)
            {
                _connection.LogInsert(_tableName, _columns, _key, row);
            }
        }
示例#25
0
        internal void LogDelete(string tableName, List <string> columns, List <string> key, object[] row)
        {
                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
                        #endif

            _operationLog.Add(new ModifyOperation(GenerateInsertStatement(tableName, columns, key, row)));

                        #if SQLSTORETIMING
            Store.Counters.Add(new SQLStoreCounter("LogDelete", ATableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif
        }
示例#26
0
        public virtual void CommitTransaction()
        {
            _transactionCount--;
            if (_transactionCount <= 0)
            {
                                #if SQLSTORETIMING
                long startTicks = TimingUtility.CurrentTicks;
                                #endif

                if (_connection.InTransaction)
                {
                    _connection.CommitTransaction();
                }

                                #if SQLSTORETIMING
                Store.Counters.Add(new SQLStoreCounter("Disconnect", "", "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                                #endif
            }

            for (int index = _operationLog.Count - 1; index >= 0; index--)
            {
                if (_operationLog[index] is BeginTransactionOperation)
                {
                    _operationLog.RemoveAt(index);
                    break;
                }
            }
        }
示例#27
0
        public virtual void RollbackTransaction()
        {
            _transactionCount--;

            for (int index = _operationLog.Count - 1; index >= 0; index--)
            {
                SQLStoreOperation operation = _operationLog[index];
                _operationLog.RemoveAt(index);
                if (operation is BeginTransactionOperation)
                {
                    break;
                }
                else
                {
                    operation.Undo(this);
                }
            }

            if (_transactionCount <= 0)
            {
                                #if SQLSTORETIMING
                long startTicks = TimingUtility.CurrentTicks;
                                #endif

                if (_connection.InTransaction)
                {
                    _connection.RollbackTransaction();
                }

                                #if SQLSTORETIMING
                Store.Counters.Add(new SQLStoreCounter("Disconnect", "", "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                                #endif
            }
        }
示例#28
0
        public bool Prior()
        {
            _currentRow = null;

                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
            try
            {
                        #endif

            if (_isOnSimulatedCrack)
            {
                _isOnSimulatedCrack = false;
                _isOnRow            = true;
            }
            else
            {
                _isOnRow = InternalPrior();
            }

                        #if SQLSTORETIMING
        }

        finally
        {
            Connection.Store.Counters.Add(new SQLStoreCounter("Prior", FTableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
        }
                        #endif

            if (_isOnRow && (_startValues != null) && ((CompareKeys(_startValues) < 0) || (CompareKeys(_endValues) > 0)))
            {
                _isOnRow = false;
            }

            return(_isOnRow);
        }
示例#29
0
        public void Dispose()
        {
                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
                        #endif

            InternalDispose();

                        #if SQLSTORETIMING
            Store.Counters.Add(new SQLStoreCounter("Disconnect", "", "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif

            if (_store != null)
            {
                _store.ReportDisconnect();
                _store = null;
            }
        }
示例#30
0
        protected virtual bool InternalFirst()
        {
                        #if SQLSTORETIMING
            long startTicks = TimingUtility.CurrentTicks;
                        #endif

            _editingRow = null;
            DisposeReader();
            EnsureReader(null, true, true);
            ClearBuffer();
            return(false);

                        #if SQLSTORETIMING
            Connection.Store.Counters.Add(new SQLStoreCounter("First", FTableName, "", false, false, false, TimingUtility.TimeSpanFromTicks(startTicks)));
                        #endif
        }