skipcheck

TM1 client · Docs · Reading and writing data

ChangeSetService

using Skipcheck.Tm1.Client.Services;

Change sets: groups of cell writes that can be undone together.

A write joins a change set through TM1's !ChangeSet query option, which a session view from Tm1Session.WithChangeSet adds to every request ($metadata doesn't say how; TM1 11.8 does it this way). WithinAsync does it all: begins a change set, gives the work a session that records into it, and ends it however the work finishes.

Make some writes in a change set, keeping its ID:

// Record some writes in a change set, and keep its ID to undo them later
var cell = new Dictionary<string, string>
{
    ["Version"] = "Forecast",
    ["Region"] = "North",
    ["Month"] = "Jan",
    ["Measure"] = "Revenue",
};
return await tm1.ChangeSets.WithinAsync(async session =>
{
    await Tm1Client.Of(session).Cells.UpdateAsync("Sales", cell, 1500);
    return session.ChangeSet()!;
});

Undo them later:

// Revert every write recorded in the change set; writes outside it stay
await tm1.ChangeSets.UndoAsync(changeSet);

Members

ChangeSetService constructorA service that sends its requests through session.
BeginAsyncStarts a change set, and returns its ID, for Tm1Session.WithChangeSet.
EndAsyncStops recording into a change set; it can still be undone.
UndoAsyncReverts every write recorded in a change set.
WithinAsyncRuns work in a new change set.
WithinAsyncWithinAsync{R} for work that gives nothing.
WithinAsyncJava's within for work that streams (a Flux).

ChangeSetService

constructor
ChangeSetService(Tm1Session session)

A service that sends its requests through session.

BeginAsync

Task<string> BeginAsync(CancellationToken cancellationToken = default)

BeginChangeSet: starts a change set, and returns its ID, for Tm1Session.WithChangeSet. Needs schema 10.2.2.6.

TM1 REST ActionImport BeginChangeSet

EndAsync

Task<long> EndAsync(string id, CancellationToken cancellationToken = default)

EndChangeSet: stops recording into a change set; it can still be undone. Returns TM1's return code. Needs schema 10.2.2.6.

TM1 REST ActionImport EndChangeSet

UndoAsync

Task UndoAsync(string id, CancellationToken cancellationToken = default)

UndoChangeSet: reverts every write recorded in a change set. Needs schema 10.2.2.6.

TM1 REST ActionImport UndoChangeSet

WithinAsync

Task<R> WithinAsync<R>(Func<Tm1Session, Task<R>> work, CancellationToken cancellationToken = default)

Runs work in a new change set: begins it, gives the work a view of the session that records into it (session.ChangeSet() has the ID, for a later UndoAsync), and ends it when the work completes, fails or is cancelled.

// Record some writes in a change set, and keep its ID to undo them later
var cell = new Dictionary<string, string>
{
    ["Version"] = "Forecast",
    ["Region"] = "North",
    ["Month"] = "Jan",
    ["Measure"] = "Revenue",
};
return await tm1.ChangeSets.WithinAsync(async session =>
{
    await Tm1Client.Of(session).Cells.UpdateAsync("Sales", cell, 1500);
    return session.ChangeSet()!;
});

TM1 REST ActionImport BeginChangeSet ActionImport EndChangeSet

WithinAsync

Task WithinAsync(Func<Tm1Session, Task> work, CancellationToken cancellationToken = default)

WithinAsync{R} for work that gives nothing.

TM1 REST ActionImport BeginChangeSet ActionImport EndChangeSet

WithinAsync

IAsyncEnumerable<R> WithinAsync<R>( Func<Tm1Session, IAsyncEnumerable<R>> work, [EnumeratorCancellation] CancellationToken cancellationToken = default )

Java's within for work that streams (a Flux): the change set ends when the enumeration ends, however it ends.

TM1 REST ActionImport BeginChangeSet ActionImport EndChangeSet