ILock ApiLock And Check Method
Execute the lock context and verify the query. If the query result is not found, throw an exception and release the lock context.
Definition
Namespace: Casewhere.Runtime.DSL.Api
Assembly: Casewhere.Runtime (in Casewhere.Runtime.dll) Version: 2.9.8.6
Assembly: Casewhere.Runtime (in Casewhere.Runtime.dll) Version: 2.9.8.6
C#
void LockAndCheck(
string lockId,
DataSourceApiQuery query,
TimeSpan waitingTime,
TimeSpan expiredTime
)Parameters
- lockId String
- id of lock context
- query DataSourceApiQuery
- The search query
- waitingTime TimeSpan
- The timeout of waiting for lock context
- expiredTime TimeSpan
- The timeout of lock context
Return Value
Example
C#
var lockApi = ctx.Use<ILockApi>();
var objectId = "data object id";
var lockId = "key of lock context";
var expiredTime = TimeSpan.FromSeconds(30);
var waitingTime = TimeSpan.Zero;
var filter = FilterBuilder.Create().Eq("DepartmentId", ctx.Input.Id).Eq("Active", true).Build();
var query = DataSourceApiQuery.For("Employee")
.FilterBy(filter)
.ProjectOn("FirstName", "LastName")
.OrderBy("FirstName", true);
// lock and check
lockApi.LockAndCheck(lockId, query, waitingTime, expiredTime);
// do lock logic
// release
lockApi.Release(lockId);