/// <exclude /> public static void CancelFlowsByConsoleId(string consoleId) { List <string> serializedFlowTokens = (from f in DataFacade.GetData <IFlowInformation>() where f.ConsoleId == consoleId select f.SerializedFlowToken).ToList(); foreach (string serializedFlowToken in serializedFlowTokens) { FlowToken flowToken = FlowTokenSerializer.Deserialize(serializedFlowToken); CancelFlow(flowToken); } }
internal static void RegisterNewFlowInformation(FlowToken flowToken, EntityToken entityToken, ActionToken actionToken, string consoleId) { IFlowInformation flowInformation = DataFacade.BuildNew <IFlowInformation>(); flowInformation.Id = Guid.NewGuid(); flowInformation.Username = UserSettings.Username; flowInformation.ConsoleId = consoleId; flowInformation.SerializedFlowToken = FlowTokenSerializer.Serialize(flowToken); flowInformation.SerializedEntityToken = EntityTokenSerializer.Serialize(entityToken); flowInformation.SerializedActionToken = ActionTokenSerializer.Serialize(actionToken); flowInformation.TimeStamp = DateTime.Now; DataFacade.AddNew <IFlowInformation>(flowInformation); }
/// <exclude /> public static IEnumerable <FlowToken> GetFlowTokensByUsername(string username) { List <string> serializedFlowTokens = (from f in DataFacade.GetData <IFlowInformation>() where f.Username == username select f.SerializedFlowToken).ToList(); foreach (string serializedFlowToken in serializedFlowTokens) { FlowToken flowToken = FlowTokenSerializer.Deserialize(serializedFlowToken); yield return(flowToken); } }
/// <exclude /> public static void Scavenge() { Log.LogVerbose(LogTitle, "Starting scavenger run"); List <IFlowInformation> flowInformations = DataFacade.GetData <IFlowInformation>().ToList(); // NOTE: Low performance implementation foreach (IFlowInformation flowInformation in flowInformations) { TimeSpan timeSpan = DateTime.Now - flowInformation.TimeStamp; if (timeSpan > Timeout) { FlowToken flowToken = null; string flowTokenStr; try { flowToken = FlowTokenSerializer.Deserialize(flowInformation.SerializedFlowToken); flowTokenStr = flowToken.ToString(); } catch (Exception) { flowTokenStr = flowInformation.SerializedFlowToken ?? string.Empty; if (flowTokenStr.Length > 200) { flowTokenStr = flowTokenStr.Substring(0, 200); } } Log.LogVerbose(LogTitle, "Scavenging flow started by username '{0}', flow = '{1}'".FormatWith(flowInformation.Username, flowTokenStr)); DataFacade.Delete <IFlowInformation>(flowInformation); if (flowToken != null) { FlowControllerFacade.CancelFlow(flowToken); } } } }
internal static void UnregisterFlowInformation(FlowToken flowToken) { string serializedFlowToken = FlowTokenSerializer.Serialize(flowToken); DataFacade.Delete <IFlowInformation>(f => f.SerializedFlowToken == serializedFlowToken); }