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;
                }
            }
        }
Exemple #2
0
        protected void EnsureOperators(ServerProcess process)
        {
            // no access
            var deviceSession = (SQLDeviceSession)Connect(process, process.ServerSession.SessionInfo);

            try
            {
                SQLConnection connection = deviceSession.Connection;
                if (!connection.InTransaction)
                {
                    connection.BeginTransaction(SQLIsolationLevel.Serializable);
                }
                try
                {
                    using (SQLCommand command = connection.CreateCommand(false))
                    {
                        using (Stream stream = GetType().Assembly.GetManifestResourceStream("SystemCatalog.sql"))
                        {
                            if (stream != null)
                            {
                                var systemCatalog = new StreamReader(stream).ReadToEnd();
                                if (systemCatalog.Length > 0)
                                {
                                    var batches = SQLUtility.ProcessBatches(systemCatalog, @"\");
                                    foreach (string batch in batches)
                                    {
                                        command.Statement = batch;
                                        command.Execute();
                                    }
                                }
                            }
                        }
                    }
                    connection.CommitTransaction();
                }
                catch
                {
                    connection.RollbackTransaction();
                    throw;
                }
            }
            finally
            {
                Disconnect(deviceSession);
            }
        }