/// <summary> /// DELETE /// </summary> //public static void Delete<T>(T proxy) //{ // try // { // using (ConnectionContext connection = new ConnectionContext()) // { // switch (typeof(T).Name) // { // case "ActionProxy": // ActionProxy actionProxy = proxy as ActionProxy; // Data_API.Delete(new ActionModel(connection, actionProxy.ActionID)); // break; // case "AttachmentProxy": // AttachmentProxy attachmentProxy = proxy as AttachmentProxy; // Data_API.Delete(new AttachmentModel(connection, attachmentProxy.AttachmentID)); // break; // } // } // } // catch (AuthenticationException ex) // { // // TODO - tell user they don't have permission // Data_API.LogMessage(ActionLogType.Delete, ReferenceType.None, 0, "choke", ex); // } // catch (System.Data.ConstraintException ex) // { // // TODO - data integrity failure // Data_API.LogMessage(ActionLogType.Delete, ReferenceType.None, 0, "choke", ex); // } // catch (Exception ex) // { // //int logid = DataAPI.Data_API.LogException(new Proxy.AuthenticationModel(authenticationTicket), ex, "Ticket Merge Exception:" + ex.Source); // //return $"Error merging tickets. Exception #{logid}. Please report this to TeamSupport by either emailing [email protected], or clicking Help/Support Hub in the upper right of your account."; // } //} #region Tickets public static string MergeTickets(int destinationTicketID, int sourceTicketID) { try { using (ConnectionContext connection = new ConnectionContext(true)) // use transaction { try { TicketMerge merge = new TicketMerge(connection, connection.Ticket(destinationTicketID), connection.Ticket(sourceTicketID)); merge.Merge1(); connection.Commit(); return(String.Empty); } catch (Exception ex) { connection.Rollback(); int logid = Data_API.LogException(connection.Authentication, ex, "Ticket Merge Exception:" + ex.Source); return($"Error merging tickets. Exception #{logid}. Please report this to TeamSupport by either emailing [email protected], or clicking Help/Support Hub in the upper right of your account."); } } } catch (Exception ex) { int logid = Data_API.LogException(new IDTree.AuthenticationModel(), ex, "Ticket Merge Exception:" + ex.Source); return($"Error merging tickets. Exception #{logid}. Please report this to TeamSupport by either emailing [email protected], or clicking Help/Support Hub in the upper right of your account."); } }
public void Execute_create_and_drop_schema_table(string connectionString, DatabaseProvider provider) { //Arrange const string schema = "minimigtest2"; const string table = "minimigtabletest"; var options = new Options() { ConnectionString = connectionString, Provider = provider, MigrationsTableSchema = schema, MigrationsTable = table }; //Act using var context = new ConnectionContext(options); context.Open(); context.BeginTransaction(); context.ExecuteCommand($"Create schema {schema}"); context.Commit(); bool existsSchema = context.SchemaMigrationExists(); context.CreateMigrationsTable(); bool existsTable = context.SchemaMigrationExists(); //Clean Up context.DropMigrationsTable(); context.ExecuteCommand($"Drop schema {schema}"); context.Dispose(); //Assert Assert.Equal(ConnectionState.Closed, context.Connection.State); Assert.True(existsSchema); Assert.True(existsTable); }
public void Connection_commit_without_begin_invalid_operation_exception(string connectionString, DatabaseProvider provider) { //Arrange var options = new Options() { ConnectionString = connectionString, Provider = provider }; //Act using var context = new ConnectionContext(options); context.Open(); void action() => context.Commit(); //Assert Assert.Throws <InvalidOperationException>(action); }
public void Connection_has_completed_transactions_on_preview(string connectionString, DatabaseProvider provider) { //Arrange var options = new Options() { ConnectionString = connectionString, Provider = provider, IsPreview = true }; //Act var context = new ConnectionContext(options); context.Open(); context.BeginTransaction(); context.Commit(); //Assert Assert.Equal(ConnectionState.Open, context.Connection.State); Assert.False(context.HasPendingTransaction); }