@napernik,
Found the solution from digging through the code. The following code works in every situation from workflows at least (until now ;).
JamBo
Found the solution from digging through the code. The following code works in every situation from workflows at least (until now ;).
public static void CloseView(EntityToken token, string consoleId)
{
// We need the formatter for deserialization
IFormatter formatter = new BinaryFormatter();
// We need the serialized token
string serializedEntityToken = EntityTokenSerializer.Serialize(token);
// Get the locking info
ILockingInformation lockingInformation = DataFacade.GetData<ILockingInformation>().Where(t => t.SerializedEntityToken == serializedEntityToken).SingleOrDefault();
// Did we find any locking info
if (lockingInformation != null)
{
// Return var
object ownerId;
// Deserialize the ownerid
byte[] bytes = Convert.FromBase64String(lockingInformation.SerializedOwnerId);
using (MemoryStream ms = new MemoryStream(bytes))
{
ownerId = formatter.Deserialize(ms);
}
// It's a workflowtoken that created the lock
WorkflowFlowToken flowtoken = new WorkflowFlowToken((Guid)ownerId);
// Get a flowhandle
FlowHandle flowHandle = new FlowHandle(flowtoken);
// Serialize it
string serializedFlowHandle = flowHandle.Serialize();
// Get the ViewId that belongs to this hanlde
string viewId = "view" + serializedFlowHandle.GetHashCode();
// Fire the close message
ConsoleMessageQueueFacade.Enqueue(new CloseViewMessageQueueItem { ViewId = viewId }, consoleId);
}
}
thnx,JamBo