示例#1
0
        private void commitDataStore(IGxDataStore ds, String auditObjectName)
        {
            GXLogging.Debug(log, "DataStoreProvider commit auditObjectName:" + auditObjectName);
            GxCommand cmd = new GxCommand(ds.Db, "commit", ds, 0, false, true, _errorHandler);

            cmd.ErrorMask = GxErrorMask.GX_NOMASK;
            try
            {
                ds.Commit();
            }
            catch (Exception dbEx)
            {
                //If commit fails it should not retry, it makes no sense because it will no longer be possible. just close the existing connection.
                int status           = 0;
                GxADODataException e = new GxADODataException(dbEx);
                bool retry           = false;
                int  retryCount      = 0;
                bool pe = ds.Connection.DataRecord.ProcessError(e.DBMSErrorCode, e.ErrorInfo, cmd.ErrorMask, ds.Connection, ref status, ref retry, retryCount);
                GXLogging.Error(log, "Commit Transaction Error", e);
                retryCount++;
                cmd.processErrorHandler(status, e.DBMSErrorCode, e.SqlState, e.ErrorInfo, cmd.ErrorMask, "FETCH", ref pe, ref retry);
                if (!pe)
                {
                    try
                    {
                        ds.Connection.Close();
                        if (retry)
                        {
                            ds.Connection.Open();
                        }
                    }
                    catch (Exception ex)
                    {
                        GXLogging.Error(log, "beginTransaction in commit transaction failed", ex);
                        throw (new GxADODataException(e.ToString(), e));
                    }
                }
            }
            cmd.Dispose();
        }
示例#2
0
        private void rollbackDataStore(IGxDataStore ds, String auditObjectName)
        {
            GxCommand cmd = new GxCommand(ds.Db, "rollback", ds, 0, false, true, _errorHandler);

            cmd.ErrorMask = GxErrorMask.GX_NOMASK;
            try
            {
                ds.Rollback();
            }
            catch (Exception dbEx)
            {
                int status           = 0;
                GxADODataException e = new GxADODataException(dbEx);
                bool retry           = false;
                int  retryCount      = 0;
                bool pe = ds.Connection.DataRecord.ProcessError(e.DBMSErrorCode, e.ErrorInfo, cmd.ErrorMask, ds.Connection, ref status, ref retry, retryCount);
                GXLogging.Error(log, "Rollback Transaction Error", e);
                retryCount++;
                cmd.processErrorHandler(status, e.DBMSErrorCode, e.SqlState, e.ErrorInfo, cmd.ErrorMask, "FETCH", ref pe, ref retry);
                if (!pe)
                {
                    try
                    {
                        ds.Connection.Close();
                        if (retry)
                        {
                            ds.Connection.Open();
                        }
                    }
                    catch (Exception ex)
                    {
                        GXLogging.Error(log, "beginTransaction in Rollback transaction failed", ex);
                        throw (new GxADODataException(e.ToString(), e));
                    }
                }
            }
            cmd.Dispose();
        }