Summary#
<Wf>.Version answers "which version of this process is running?" with an int: the app version the
code is running in. It is the number a workflow migration names — migration OrderFlow v6 -> v7 moves runs from the
sixth version of the app to the seventh — and the version every run started now is pinned to.
int v = OrderFlow.Version; // 7
string? file = OrderFlow.Graph.SourceFile; // "workflows/order-flow.osy"Signature#
<Wf>.Version -> int // the app version the code runs in; 1 for an app on its first version
<Wf>.Graph.SourceFile -> string? // the file that declares the workflow, its path from the app rootDescription#
Why the app's version, and not the workflow's own#
A workflow has no version of its own that moves: every app version is compiled fresh, so the workflow's revision
row says 1 in every version. The platform's one idiom for "which version of a workflow" is therefore the app
version — the number migrations are written against (Migrating runs that are still in flight). Two workflows in the same app answer
the same number; the number changes when the app is published, whether or not that workflow changed.
It is a server read#
The version is a fact about where the code runs, not about the declaration, so <Wf>.Version is answered on the
server (it costs no database statement). Read it in a function, or in a live var, like any other server value. The
workflow name is checked at compile time: NoSuchFlow.Version is an error, not a zero.
Code running a run that was started on an earlier version still executes in that version, and reads that version's number.
SourceFile#
<Wf>.Graph.SourceFile is set when the compiler builds the graph, like the rest of Graph — every state and every transition of a workflow, so it names
the file of the version that is running and costs nothing. It is the path from the app root
(workflows/order-flow.osy), not just the file name — see Graph — every state and every transition of a workflow. It is null for a workflow that has no file.
Examples#
using Osysharp.Workflow;
enum JobStatus { Working, Done }
entity Job {
[Required, MaxLength(80)] string Title;
JobStatus Status = JobStatus.Working;
}
workflow JobFlow {
Tracks = Job.Status;
Autostart = false;
Initial = Working;
event Finish();
state Working { on Finish { goto Done; } }
terminal success Done { }
}
[Test]
void a_new_app_is_on_its_first_version_and_the_workflow_names_its_file() {
Assert.Equal(1, JobFlow.Version);
Assert.True(JobFlow.Graph.SourceFile != null);
}See also#
- Migrating runs that are still in flight —
migration Wf vN -> vM, the numbers this one is - Graph — every state and every transition of a workflow — the rest of the declaration as a value
- Workflow.Current (which run is this code in?) — facts about one run