private async Task SaveComponentToExecutionThreadAsync(Component component, ExecutionThread executionThread) { var executingComponent = executionThread.ExecutingComponents.FirstOrDefault(e => e.ExecutingID == component.TXID.xid); executingComponent.State = component.State; executionThread = await AppExecution.SaveExecutionThreadAsync(executionThread); }
/// <summary> /// Returns URL of component instance after initiating a new execution thread. /// </summary> /// <param name="componentInterface"></param> /// <returns></returns> public async Task <string> RedirectLaunchAppAsync(string componentInterfaceFullname, string returnUrl) // Potentially more params to come inc. returnTaskId, forceContextSearch, etc { // Get info about the registered component. var registeredComponent = await AppRegister.GetComponentByInterfaceFullName(componentInterfaceFullname); // TODO: What if requested component interface is not registered? var componentInterfaceName = componentInterfaceFullname.Split('.').LastOrDefault(); var componentUrl = $"{registeredComponent.DomainName}/{registeredComponent.PrimaryAppRoute}"; var launcher = new LuLauncher() { ClientRef = componentInterfaceFullname, ReturnUrl = returnUrl }; var thread = new ExecutionThread() { ExecutingComponents = new List <ExecutingComponent>() { new ExecutingComponent() { ExecutingID = 1, // Starts at 1 and will later be incremented for each additional component instance executing within the thread. InterfaceFullname = typeof(LuLauncher).FullName, // a system Launcher Component is always the entry point to a thread //URL = "?", // Relevant for LuLauncher?? Breadcrumb = "LuLauncher(1)", // Includes ExecutingID. ParentExecutingID = 0, // No parent for entry point launcher ClientRef = launcher.ClientRef, State = launcher.State, Title = registeredComponent.Title }, new ExecutingComponent() // The root component (i.e. the component launched for execution). { ExecutingID = 2, // Starts at 1 and is incremented for each component executed within the thread. InterfaceFullname = componentInterfaceFullname, URL = componentUrl, Breadcrumb = $"LuLauncher(1)/{componentInterfaceName}(2)", ClientRef = "LuLauncher(1)", ParentExecutingID = 1, // LuLauncher acts as parent to root component. State = null, Title = registeredComponent.Title } }, ComponentExecutingID = 2, // Execution starts at the root component. ExecutingComponentTitle = registeredComponent.Title, ExecutionStatus = LogicalUnitStatusEnum.Initialised, LaunchInputs = null, LockDateTime = DateTime.Now, LockUserID = Guid.NewGuid().ToString(), // TODO: Determine user ID LockUserName = "******", RootComponentTitle = registeredComponent.Title, PendingOutcome = null }; var persistedThread = await AppExecution.SaveNewExecutionThreadAsync(thread); return(await RedirectResumeExecutionThreadAsync(persistedThread.ID)); }
public async Task <string> RedirectResumeExecutionThreadAsync(ExecutionThread executionThread) { var componentExecuting = executionThread.ExecutingComponents.FirstOrDefault(e => e.ExecutingID == executionThread.ComponentExecutingID); componentExecuting.URL = $"{componentExecuting.URL}/{executionThread.ID}.{executionThread.ComponentExecutingID}/"; executionThread.ExecutionStatus = LogicalUnitStatusEnum.Started; executionThread = await AppExecution.SaveExecutionThreadAsync(executionThread); return(componentExecuting.URL); }
private T LoadComponentFromExecutionThread <T>(ExecutionThread executionThread, int xid) where T : Component, new() { var t = new T(); var component = t as LogicalUnit; var executingComponent = executionThread.ExecutingComponents.FirstOrDefault(e => e.ExecutingID == xid); component.TXID = new TXID(executionThread.ID, xid); component.ClientRef = executingComponent.ClientRef; component.State = executingComponent.State; return(t); }