public static void ExecuteElementAction(ElementHandle elementHandle, ActionHandle actionHandle, string consoleId) { FlowControllerServicesContainer flowServicesContainer = new FlowControllerServicesContainer(); flowServicesContainer.AddService(new ManagementConsoleMessageService(consoleId)); flowServicesContainer.AddService(new ElementDataExchangeService(elementHandle.ProviderName)); flowServicesContainer.AddService(new ActionExecutionService(elementHandle.ProviderName, consoleId)); flowServicesContainer.AddService(new ElementInformationService(elementHandle)); FlowToken flowToken = ActionExecutorFacade.Execute(elementHandle.EntityToken, actionHandle.ActionToken, flowServicesContainer); IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer); if (typeof(FlowUiDefinitionBase).IsAssignableFrom(uiDefinition.GetType())) { string serializedEntityToken = EntityTokenSerializer.Serialize(elementHandle.EntityToken, true); ViewTransitionHelper.HandleNew(consoleId, elementHandle.ProviderName, serializedEntityToken, flowToken, (FlowUiDefinitionBase)uiDefinition); } }
public void Execute(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent) { FlowControllerServicesContainer flowServicesContainer = new FlowControllerServicesContainer(); flowServicesContainer.AddService(new ManagementConsoleMessageService(this.ConsoleId)); flowServicesContainer.AddService(new ElementDataExchangeService(this.ElementProviderName)); flowServicesContainer.AddService(this); FlowToken flowToken = ActionExecutorFacade.Execute(entityToken, actionToken, flowServicesContainer, taskManagerEvent); IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer); ActionResult result = new ActionResult(); if (typeof(FlowUiDefinitionBase).IsAssignableFrom(uiDefinition.GetType())) { string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true); ViewTransitionHelper.HandleNew(this.ConsoleId, this.ElementProviderName, serializedEntityToken, flowToken, (FlowUiDefinitionBase)uiDefinition); } }
private static void BaseEventHandler(string consoleId, string elementProviderName, FlowToken flowToken, FormFlowUiDefinition formFlowUiCommand, FlowControllerServicesContainer servicesContainer, Dictionary <IFormEventIdentifier, FormFlowEventHandler> eventHandlers, IFormEventIdentifier localScopeEventIdentifier, FlowControllerServicesContainer formServicesContainer) { FormTreeCompiler activeFormTreeCompiler = CurrentFormTreeCompiler; Dictionary <string, object> activeInnerFormBindings = CurrentInnerFormBindings; FormFlowEventHandler handler = eventHandlers[localScopeEventIdentifier]; Dictionary <string, Exception> bindingErrors = activeFormTreeCompiler.SaveAndValidateControlProperties(); FormTreeCompiler activeCustomToolbarFormTreeCompiler = CurrentCustomToolbarFormTreeCompiler; if (activeCustomToolbarFormTreeCompiler != null) { var toolbarBindingErrors = activeCustomToolbarFormTreeCompiler.SaveAndValidateControlProperties(); foreach (var pair in toolbarBindingErrors) { bindingErrors.Add(pair.Key, pair.Value); } } formServicesContainer.AddService(new BindingValidationService(bindingErrors)); handler.Invoke(flowToken, activeInnerFormBindings, formServicesContainer); if (formServicesContainer.GetService <IManagementConsoleMessageService>().CloseCurrentViewRequested) { ViewTransitionHelper.HandleCloseCurrentView(formFlowUiCommand.UiContainerType); return; } var formFlowService = formServicesContainer.GetService <IFormFlowRenderingService>(); bool replacePageOutput = (formServicesContainer.GetService <IFormFlowWebRenderingService>().NewPageOutput != null); bool rerenderView = formFlowService.RerenderViewRequested; if (formFlowService.BindingPathedMessages != null) { ShowFieldMessages(CurrentControlTreeRoot, formFlowService.BindingPathedMessages, CurrentControlContainer, servicesContainer); } List <bool> boolCounterList = new List <bool> { replacePageOutput, rerenderView }; if (boolCounterList.Count(f => f) > 1) { StringBuilder sb = new StringBuilder("Flow returned conflicting directives for post handling:\n"); if (replacePageOutput) { sb.AppendLine(" - Replace page output with new web control."); } if (rerenderView) { sb.AppendLine(" - Rerender view."); } throw new InvalidOperationException(sb.ToString()); } if (rerenderView) { Log.LogVerbose("FormFlowRendering", "Re-render requested"); IFlowUiDefinition newFlowUiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, servicesContainer); if (!(newFlowUiDefinition is FlowUiDefinitionBase)) { throw new NotImplementedException("Unable to handle transitions to ui definition of type " + newFlowUiDefinition.GetType()); } ViewTransitionHelper.HandleRerender(consoleId, elementProviderName, flowToken, formFlowUiCommand, (FlowUiDefinitionBase)newFlowUiDefinition, servicesContainer); } if (replacePageOutput) { Log.LogVerbose("FormFlowRendering", "Replace pageoutput requested"); IFormFlowWebRenderingService webRenderingService = formServicesContainer.GetService <IFormFlowWebRenderingService>(); Control newPageOutput = webRenderingService.NewPageOutput; foreach (Control control in GetNestedControls(newPageOutput).Where(f => f is ScriptManager).ToList()) { control.Parent.Controls.Remove(control); } Page currentPage = HttpContext.Current.Handler as Page; HtmlHead newHeadControl = GetNestedControls(newPageOutput).FirstOrDefault(f => f is HtmlHead) as HtmlHead; HtmlHead oldHeadControl = currentPage.Header; ControlCollection headContainer = null; bool headersHasToBeSwitched = newHeadControl != null && oldHeadControl != null; if (headersHasToBeSwitched) { headContainer = newHeadControl.Parent.Controls; headContainer.Remove(newHeadControl); } currentPage.Controls.Clear(); if (string.IsNullOrEmpty(webRenderingService.NewPageMimeType)) { currentPage.Response.ContentType = "text/html"; } else { currentPage.Response.ContentType = webRenderingService.NewPageMimeType; } currentPage.Controls.Add(newPageOutput); if (headersHasToBeSwitched) { oldHeadControl.Controls.Clear(); oldHeadControl.InnerHtml = ""; oldHeadControl.InnerText = ""; if (newHeadControl.ID != null) { oldHeadControl.ID = newHeadControl.ID; } oldHeadControl.Title = newHeadControl.Title; headContainer.AddAt(0, oldHeadControl); foreach (Control c in newHeadControl.Controls.Cast <Control>().ToList()) { oldHeadControl.Controls.Add(c); } } } }