private void OnWorkflowInstanceTerminatedCleanup(Guid instanceId) { AbortedWorkflows.Remove(instanceId); WorkflowFlowToken flowToken = new WorkflowFlowToken(instanceId); TaskManagerFacade.CompleteTasks(flowToken); ReleaseAllLocks(instanceId); SetWorkflowInstanceStatus(instanceId, WorkflowInstanceStatus.Terminated, false); RemoveFlowControllerServicesContainer(instanceId); RemoveIfExistFormData(instanceId); RemovePersistingType(instanceId); DeletePersistedWorkflow(instanceId); DeletePersistedFormData(instanceId); using (ThreadDataManager.EnsureInitialize()) { FlowControllerFacade.FlowComplete(new WorkflowFlowToken(instanceId)); } }
public void AuthorizeRequest(object sender, EventArgs e) { if (!SystemSetupFacade.IsSystemFirstTimeInitialized) { return; } HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; bool adminRootRequest = UrlUtils.IsAdminConsoleRequest(context); if (adminRootRequest && UserValidationFacade.IsLoggedIn()) { _dataScope = new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo); if (!_consoleArtifactsInitialized) { lock (_consoleArtifactsInitializeLock) { if (!_consoleArtifactsInitialized && !SystemSetupFacade.SetupIsRunning) { HookingFacade.EnsureInitialization(); FlowControllerFacade.Initialize(); ConsoleFacade.Initialize(); ElementProviderLoader.LoadAllProviders(); _consoleArtifactsInitialized = true; } } } } }
/// <exclude /> public static Control GetFlowUi(FlowHandle flowHandle, string elementProviderName, string consoleId, out string uiContainerName) { uiContainerName = null; try { Control webControl = null; string viewId = ViewTransitionHelper.MakeViewId(flowHandle.Serialize()); FlowControllerServicesContainer flowServicesContainer = new FlowControllerServicesContainer(); flowServicesContainer.AddService(new ActionExecutionService(elementProviderName, consoleId)); flowServicesContainer.AddService(new ManagementConsoleMessageService(consoleId, viewId)); flowServicesContainer.AddService(new ElementDataExchangeService(elementProviderName)); FlowToken flowToken = flowHandle.FlowToken; IFlowUiDefinition flowUiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer); var formFlowUiDefinition = flowUiDefinition as FormFlowUiDefinition; if (formFlowUiDefinition != null) { uiContainerName = formFlowUiDefinition.UiContainerType.ContainerName; IUiControl uiForm = FormFlowUiDefinitionRenderer.Render(consoleId, elementProviderName, flowToken, formFlowUiDefinition, WebManagementChannel.Identifier, false, flowServicesContainer); IWebUiControl webForm = (IWebUiControl)uiForm; webControl = webForm.BuildWebControl(); if (string.IsNullOrEmpty(webControl.ID)) { webControl.ID = "FlowUI"; } if (RuntimeInformation.TestAutomationEnabled) { var testAutomationLocatorInformation = formFlowUiDefinition.MarkupProvider as ITestAutomationLocatorInformation; if (testAutomationLocatorInformation != null) { var htmlform = webControl.Controls.OfType <HtmlForm>().FirstOrDefault(); if (htmlform != null) { htmlform.Attributes.Add("data-qa", testAutomationLocatorInformation.TestAutomationLocator); } } } } return(webControl); } catch (Exception ex) { ErrorServices.DocumentAdministrativeError(ex); ErrorServices.RedirectUserToErrorPage(uiContainerName, ex); } return(new LiteralControl("ERROR")); }
private void scavengeCodeActivity_ExecuteCode(object sender, EventArgs e) { if (HostingEnvironment.ApplicationHost.ShutdownInitiated()) { return; } try { FlowControllerFacade.Scavenge(); } catch { // Ignore exceptions } }
public void Execute(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent) { var flowServicesContainer = new FlowControllerServicesContainer( new ManagementConsoleMessageService(this.ConsoleId), new ElementDataExchangeService(this.ElementProviderName), this ); FlowToken flowToken = ActionExecutorFacade.Execute(entityToken, actionToken, flowServicesContainer, taskManagerEvent); IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer); if (uiDefinition is FlowUiDefinitionBase flowUiDefinition) { string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true); ViewTransitionHelper.HandleNew(this.ConsoleId, this.ElementProviderName, serializedEntityToken, flowToken, flowUiDefinition); } }
public static void ExecuteElementAction(ElementHandle elementHandle, ActionHandle actionHandle, string consoleId) { var flowServicesContainer = new FlowControllerServicesContainer( new ManagementConsoleMessageService(consoleId), new ElementDataExchangeService(elementHandle.ProviderName), new ActionExecutionService(elementHandle.ProviderName, consoleId), new ElementInformationService(elementHandle) ); FlowToken flowToken = ActionExecutorFacade.Execute(elementHandle.EntityToken, actionHandle.ActionToken, flowServicesContainer); IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer); if (uiDefinition is FlowUiDefinitionBase flowUiDefinition) { string serializedEntityToken = EntityTokenSerializer.Serialize(elementHandle.EntityToken, true); ViewTransitionHelper.HandleNew(consoleId, elementHandle.ProviderName, serializedEntityToken, flowToken, flowUiDefinition); } }
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 DoInitialize() { int startTime = Environment.TickCount; Guid installationId = InstallationInformationFacade.InstallationId; Log.LogVerbose(LogTitle, "Initializing the system core - installation id = " + installationId); using (new LogExecutionTime(LogTitle, "Initialization of the static data types")) { DataProviderRegistry.InitializeDataTypes(); } using (new LogExecutionTime(LogTitle, "Auto update of static data types")) { bool typesUpdated = AutoUpdateStaticDataTypes(); if (typesUpdated) { using (new LogExecutionTime(LogTitle, "Reinitialization of the static data types")) { SqlTableInformationStore.Flush(); DataProviderRegistry.Flush(); DataProviderPluginFacade.Flush(); DataProviderRegistry.InitializeDataTypes(); } CodeGenerationManager.GenerateCompositeGeneratedAssembly(true); } } using (new LogExecutionTime(LogTitle, "Ensure data stores")) { bool dataStoresCreated = DataStoreExistenceVerifier.EnsureDataStores(); if (dataStoresCreated) { Log.LogVerbose(LogTitle, "Initialization of the system was halted, performing a flush"); _initializing = false; GlobalEventSystemFacade.FlushTheSystem(); return; } } using (new LogExecutionTime(LogTitle, "Initializing data process controllers")) { ProcessControllerFacade.Initialize_PostDataTypes(); } using (new LogExecutionTime(LogTitle, "Initializing data type references")) { DataReferenceRegistry.Initialize_PostDataTypes(); } using (new LogExecutionTime(LogTitle, "Initializing data type associations")) { DataAssociationRegistry.Initialize_PostDataTypes(); } using (new LogExecutionTime(LogTitle, "Initializing internal urls")) { InternalUrls.Initialize_PostDataTypes(); } using (new LogExecutionTime(LogTitle, "Initializing functions")) { MetaFunctionProviderRegistry.Initialize_PostDataTypes(); } Log.LogVerbose(LogTitle, "Starting initialization of administrative secondaries"); if (SystemSetupFacade.IsSystemFirstTimeInitialized && !SystemSetupFacade.SetupIsRunning) { using (new LogExecutionTime(LogTitle, "Initializing workflow runtime")) { WorkflowFacade.EnsureInitialization(); } } if (!RuntimeInformation.IsUnittest) { using (new LogExecutionTime(LogTitle, "Initializing flow system")) { FlowControllerFacade.Initialize(); } using (new LogExecutionTime(LogTitle, "Initializing console system")) { ConsoleFacade.Initialize(); } } using (new LogExecutionTime(LogTitle, "Auto installing packages")) { DoAutoInstallPackages(); } using (new LogExecutionTime(LogTitle, "Loading element providers")) { ElementProviderLoader.LoadAllProviders(); } int executionTime = Environment.TickCount - startTime; Log.LogVerbose(LogTitle, "Done initializing of the system core. ({0} ms)".FormatWith(executionTime)); }
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); } } } }