コード例 #1
0
ファイル: TaskContainer.cs プロジェクト: DBailey635/C1-CMS
 /// <exclude />
 public void UpdateTasksWithFlowToken(FlowToken flowToken)
 {
     foreach (Task task in _tasks)
     {
         task.FlowToken = flowToken.Serialize();
     }
 }
コード例 #2
0
        /// <exclude />
        public static void CancelFlow(FlowToken flowToken)
        {
            if (flowToken == null) throw new ArgumentNullException("flowToken");

            IFlowController flowExecutor = FlowControllerCache.GetFlowController(flowToken, new FlowControllerServicesContainer());

            flowExecutor.CancelFlow(flowToken);
        }
コード例 #3
0
        private static FlowToken Execute(IActionExecutorSerializedParameters actionExecutor, string serializedEntityToken, string serializedActionToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            FlowToken result = actionExecutor.Execute(serializedEntityToken, serializedActionToken, actionToken, flowControllerServicesContainer);

            if (result == null)
            {
                result = new NullFlowToken();
            }

            return(result);
        }
コード例 #4
0
        private static FlowToken Execute(IActionExecutor actionExecutor, EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            FlowToken result = actionExecutor.Execute(entityToken, actionToken, flowControllerServicesContainer);

            if (result == null)
            {
                result = new NullFlowToken();
            }

            return(result);
        }
コード例 #5
0
        /// <exclude />
        public static void CancelFlow(FlowToken flowToken)
        {
            if (flowToken == null)
            {
                throw new ArgumentNullException("flowToken");
            }

            IFlowController flowExecutor = FlowControllerCache.GetFlowController(flowToken, new FlowControllerServicesContainer());

            flowExecutor.CancelFlow(flowToken);
        }
コード例 #6
0
        public TaskContainer RuntTasks(FlowToken flowToken, TaskManagerEvent taskManagerEvent)
        {
            string serializedFlowToken = flowToken.Serialize();

            List<Task> tasks;
            lock (_lock)
            {
                tasks = _tasks.Where(f => f.FlowToken == serializedFlowToken).ToList();
            }

            return new TaskContainer(tasks, taskManagerEvent);
        }
コード例 #7
0
 internal static void HandleRerender(string consoleId, string elementProviderName, FlowToken flowToken, FlowUiDefinitionBase oldUiDefinition, FlowUiDefinitionBase newUiDefinition, FlowControllerServicesContainer servicesContainer)
 {
     if (newUiDefinition.UiContainerType.ActionResultResponseType != oldUiDefinition.UiContainerType.ActionResultResponseType)
     {
         var messageService = servicesContainer.GetService<IManagementConsoleMessageService>();
         messageService.CloseCurrentView();
         HandleNew(consoleId, elementProviderName, string.Empty, flowToken, newUiDefinition);
     }
     else
     {
         // Force update in same container
         HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery, false);
     }
 }
コード例 #8
0
        /// <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);
            }
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        /// <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);
            }
        }
コード例 #11
0
        /// <exclude />
        public static IFlowUiDefinition GetCurrentUiDefinition(FlowToken flowToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            if (flowToken == null) throw new ArgumentNullException("flowToken");

            IFlowController flowExecutor = FlowControllerCache.GetFlowController(flowToken, flowControllerServicesContainer);

            IFlowUiDefinition flowResult = flowExecutor.GetCurrentUiDefinition(flowToken);

            if (flowResult == null)
            {
                flowResult = new NullFlowUiDefinition();
            }

            return flowResult;
        }
コード例 #12
0
        public void CompleteTasks(FlowToken flowToken)
        {
            string serializedFlowToken = flowToken.Serialize();

            lock (_lock)
            {
                List<Task> tasks = _tasks.Where(f => f.FlowToken == serializedFlowToken).ToList();
                foreach (Task task in tasks)
                {
                    task.TaskManager.OnCompleted(task.Id, null);
                    _tasks.Remove(task);

                    DataFacade.Delete<ITaskItem>(f => f.TaskId == task.Id);
                }
            }
        }
コード例 #13
0
        internal static void HandleNew(string consoleId, string elementProviderName, string serializedEntityToken, FlowToken flowToken, FlowUiDefinitionBase uiDefinition)
        {
            ActionResultResponseType actionViewType = uiDefinition.UiContainerType.ActionResultResponseType;

            if (actionViewType != ActionResultResponseType.None)
            {
                FlowHandle flowHandle = new FlowHandle(flowToken);
                string serializedFlowHandle = flowHandle.Serialize();
                string viewId = MakeViewId(serializedFlowHandle);

                ViewType viewType;
                switch (actionViewType)
                {
                    case ActionResultResponseType.OpenDocument:
                        viewType = ViewType.Main;
                        break;
                    case ActionResultResponseType.OpenModalDialog:
                        viewType = ViewType.ModalDialog;
                        break;
                    default:
                        throw new Exception("unknown action response type");
                }

                string url = string.Format("{0}?consoleId={1}&flowHandle={2}&elementProvider={3}",
                    UrlUtils.ResolveAdminUrl("content/flow/FlowUi.aspx"),
                    consoleId,
                    HttpUtility.UrlEncode(serializedFlowHandle),
                    HttpUtility.UrlEncode(elementProviderName));

                OpenViewMessageQueueItem openView = new OpenViewMessageQueueItem
                {
                    ViewType = viewType,
                    EntityToken = serializedEntityToken,
                    FlowHandle = flowHandle.Serialize(),
                    Url = url,
                    ViewId = viewId
                };

                if (uiDefinition is VisualFlowUiDefinitionBase)
                {
                    VisualFlowUiDefinitionBase visualUiDefinition = (VisualFlowUiDefinitionBase)uiDefinition;
                    if (string.IsNullOrEmpty(visualUiDefinition.ContainerLabel) == false) openView.Label = visualUiDefinition.ContainerLabel;
                }

                ConsoleMessageQueueFacade.Enqueue(openView, consoleId);
            }
        }
コード例 #14
0
        /// <exclude />
        public static IFlowUiDefinition GetCurrentUiDefinition(FlowToken flowToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            if (flowToken == null)
            {
                throw new ArgumentNullException("flowToken");
            }

            IFlowController flowExecutor = FlowControllerCache.GetFlowController(flowToken, flowControllerServicesContainer);

            IFlowUiDefinition flowResult = flowExecutor.GetCurrentUiDefinition(flowToken);

            if (flowResult == null)
            {
                flowResult = new NullFlowUiDefinition();
            }

            return(flowResult);
        }
コード例 #15
0
        public static string Serialize(FlowToken flowToken, bool includeHashValue)
        {
            if (flowToken == null) throw new ArgumentNullException("flowToken");

            StringBuilder sb = new StringBuilder();

            StringConversionServices.SerializeKeyValuePair(sb, "flowTokenType", TypeManager.SerializeType(flowToken.GetType()));

            string serializedFlowToken = flowToken.Serialize();
            StringConversionServices.SerializeKeyValuePair(sb, "flowToken", serializedFlowToken);

            if (includeHashValue)
            {
                StringConversionServices.SerializeKeyValuePair(sb, "flowTokenHash", HashSigner.GetSignedHash(serializedFlowToken).Serialize());
            }

            return sb.ToString();
        }
コード例 #16
0
        /// <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);
                    }
                }
            }
        }
コード例 #17
0
        public static string Serialize(FlowToken flowToken, bool includeHashValue)
        {
            if (flowToken == null)
            {
                throw new ArgumentNullException("flowToken");
            }

            StringBuilder sb = new StringBuilder();

            StringConversionServices.SerializeKeyValuePair(sb, "flowTokenType", TypeManager.SerializeType(flowToken.GetType()));

            string serializedFlowToken = flowToken.Serialize();

            StringConversionServices.SerializeKeyValuePair(sb, "flowToken", serializedFlowToken);

            if (includeHashValue)
            {
                StringConversionServices.SerializeKeyValuePair(sb, "flowTokenHash", HashSigner.GetSignedHash(serializedFlowToken).Serialize());
            }

            return(sb.ToString());
        }
コード例 #18
0
        public void CancelFlow(FlowToken flowToken)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            OnCancel(flowToken, null, null);
        }
コード例 #19
0
 public static string Serialize(FlowToken flowToken)
 {
     return(Serialize(flowToken, false));
 }
コード例 #20
0
 public AfterActionEventArgs(EntityToken entityToken, ActionToken actionToken, FlowToken flowToken)
 {
     this.EntityToken = entityToken;
     this.ActionToken = actionToken;
     this.FlowToken = flowToken;
 }
コード例 #21
0
        private static void OnCustomEvent(int customEventNumber, FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            if (customEventNumber < 1 || customEventNumber > 5) throw new ArgumentException("Number must be between 1 and 5", "customEventNumber");

            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "CustomEvent0" + customEventNumber }))
            {
                WorkflowFacade.FireCustomEvent(customEventNumber, workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }
        }
コード例 #22
0
        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();

            formServicesContainer.AddService(new BindingValidationService(bindingErrors));

            handler.Invoke(flowToken, activeInnerFormBindings, formServicesContainer);

            if (formServicesContainer.GetService<IManagementConsoleMessageService>().CloseCurrentViewRequested)
            {
                ViewTransitionHelper.HandleCloseCurrentView(formFlowUiCommand.UiContainerType);
                return;
            }
            
            var formFlowService = (FormFlowRenderingService) 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);
                    }
                }
            }
            
        }
コード例 #23
0
        public IFlowUiDefinition GetCurrentUiDefinition(FlowToken flowToken)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            if (!WorkflowFacade.WorkflowExists(workflowFlowToken.WorkflowInstanceId))
            {
                Log.LogVerbose(LogTitle, "The workflow with Id = {0} does not exists", workflowFlowToken.WorkflowInstanceId);
                return null;
            }


            using (GlobalInitializerFacade.CoreNotLockedScope)
            {
                Semaphore semaphore = WorkflowFacade.WaitForIdleStatus(workflowFlowToken.WorkflowInstanceId);
                if (semaphore != null)
                {
                    Log.LogVerbose(LogTitle, "The workflow with Id = {0} is running, waiting until its done.", workflowFlowToken.WorkflowInstanceId);

                    semaphore.WaitOne(TimeSpan.FromSeconds(10), true);

                    Log.LogVerbose(LogTitle, "Done waiting on the workflow with Id = {0}.", workflowFlowToken.WorkflowInstanceId);
                }
            }


            FormData formFunction = WorkflowFacade.GetFormData(workflowFlowToken.WorkflowInstanceId);
            if (formFunction == null)
            {
                return null;
            }

            FormFlowUiDefinition formFlowUiDefinition;
            if (formFunction.FormDefinition != null)
            {
                formFlowUiDefinition = new FormFlowUiDefinition(
                           new XmlTextReader(new StringReader(formFunction.FormDefinition)),
                           formFunction.ContainerType,
                           formFunction.ContainerLabel,
                           formFunction.Bindings,
                           formFunction.BindingsValidationRules
                    );
            }
            else if (formFunction.FormMarkupProvider != null)
            {
                formFlowUiDefinition = new FormFlowUiDefinition(
                           formFunction.FormMarkupProvider,
                           formFunction.ContainerType,
                           formFunction.ContainerLabel,
                           formFunction.Bindings,
                           formFunction.BindingsValidationRules
                    );
            }
            else
            {
                throw new NotImplementedException();
            }

            if (!string.IsNullOrEmpty(formFunction.CustomToolbarDefinition))
            {
                formFlowUiDefinition.SetCustomToolbarMarkupProvider(new XmlTextReader(new StringReader(formFunction.CustomToolbarDefinition)));
            }
            else if (formFunction.CustomToolbarMarkupProvider != null)
            {
                formFlowUiDefinition.SetCustomToolbarMarkupProvider(formFunction.CustomToolbarMarkupProvider);
            }


            AddEventHandles(formFlowUiDefinition, workflowFlowToken.WorkflowInstanceId);

            return formFlowUiDefinition;
        }
コード例 #24
0
        private static void OnPreview(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Preview" }))
            {
                WorkflowFacade.FirePreviewEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }
        }
コード例 #25
0
 /// <exclude />
 public static TaskContainer RuntTasks(FlowToken flowToken, TaskManagerEvent taskManagerEvent)
 {
     return Implementation.RuntTasks(flowToken, taskManagerEvent);
 }
コード例 #26
0
        internal static void UnregisterFlowInformation(FlowToken flowToken)
        {
            string serializedFlowToken = FlowTokenSerializer.Serialize(flowToken);

            DataFacade.Delete <IFlowInformation>(f => f.SerializedFlowToken == serializedFlowToken);
        }
コード例 #27
0
 public static string Serialize(FlowToken flowToken)
 {
     return Serialize(flowToken, false);
 }
コード例 #28
0
 public void CancelFlow(FlowToken flowToken)
 {
 }
コード例 #29
0
 /// <exclude />
 public static void FlowComplete(FlowToken flowToken)
 {
     UnregisterFlowInformation(flowToken);
 }
コード例 #30
0
 internal static void CompleteTasks(FlowToken flowToken)
 {
     Implementation.CompleteTasks(flowToken);
 }
コード例 #31
0
ファイル: FlowHandle.cs プロジェクト: DBailey635/C1-CMS
 /// <exclude />
 public FlowHandle(FlowToken FlowToken)
 {
     _flowToken = FlowToken;
 }
コード例 #32
0
        private static void OnSaveAndPublish(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Save" }))
            {
                TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer);
                serviceContainer.AddService(taskManagerFlowControllerService);

                WorkflowFacade.FireSaveAndPublishEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));

                serviceContainer.RemoveService(taskManagerFlowControllerService);
            }
        }
コード例 #33
0
 /// <exclude />
 public WorkflowTaskManagerEvent(FlowToken flowToken, Guid workflowInstanceId)
     : base(flowToken)
 {
     this.WorkflowInstanceId = workflowInstanceId;
     this.EventName = "";
 }
コード例 #34
0
        private static void OnFinish(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Finish" }))
            {
                TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer);
                serviceContainer.AddService(taskManagerFlowControllerService);

                WorkflowFacade.FireFinishEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }


            IFormFlowRenderingService formServices = serviceContainer.GetService<IFormFlowRenderingService>();

            if (!formServices.HasFieldMessages)
            {
                serviceContainer.GetService<IFormFlowRenderingService>().RerenderView();
            }
        }
コード例 #35
0
 /// <exclude />
 public SaveWorklowTaskManagerEvent(FlowToken flowToken, Guid workflowInstanceId, bool succeeded)
     : base(flowToken, workflowInstanceId)
 {
     this.Succeeded = succeeded;
 }
コード例 #36
0
        private static void OnCancel(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            if (WorkflowFacade.WorkflowExists(workflowFlowToken.WorkflowInstanceId))
            {
                using (TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Cancel" }))
                {
                    WorkflowFacade.FireCancelEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                    WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                    WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);                    
                }
            }
            else
            {
                Log.LogVerbose(LogTitle, "Cancel event suppressed because the workflow was terminated ({0})", workflowFlowToken.WorkflowInstanceId);
            }

            if (serviceContainer != null)
            {
                serviceContainer.GetService<IFormFlowRenderingService>().RerenderView();
            }
        }
コード例 #37
0
 internal static void FireOnAfterActionExecution(EntityToken entityToken, ActionToken actionToken, FlowToken flowToken)
 {
     if (_onAfterActionExecutionDelegates != null)
     {
         _onAfterActionExecutionDelegates(new AfterActionEventArgs(entityToken, actionToken, flowToken));
     }
 }
コード例 #38
0
 private static void OnCustomEvent05(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
 {
     OnCustomEvent(5, flowToken, bindings, serviceContainer);
 }
コード例 #39
0
 public AfterActionEventArgs(EntityToken entityToken, ActionToken actionToken, FlowToken flowToken)
 {
     this.EntityToken = entityToken;
     this.ActionToken = actionToken;
     this.FlowToken   = flowToken;
 }
コード例 #40
0
ファイル: ITaskManager.cs プロジェクト: DBailey635/C1-CMS
 /// <exclude />
 public FlowTaskManagerEvent(FlowToken flowToken)
 {
     this.FlowToken = flowToken;
 }
コード例 #41
0
 /// <exclude />
 public static void FlowComplete(FlowToken flowToken)
 {
     UnregisterFlowInformation(flowToken);
 }
コード例 #42
0
        public static IUiControl Render(
            string consoleId,
            string elementProviderName,
            FlowToken flowToken,
            FormFlowUiDefinition formFlowUiCommand,
            IFormChannelIdentifier channel,
            bool debugMode,
            FlowControllerServicesContainer servicesContainer)
        {
            FlowControllerServicesContainer formServicesContainer = new FlowControllerServicesContainer(servicesContainer);
            formServicesContainer.AddService(new FormFlowRenderingService());
            formServicesContainer.AddService(new FormFlowWebRenderingService());

            IFormMarkupProvider formMarkupProvider = formFlowUiCommand.MarkupProvider;
            IFormMarkupProvider customToolbarItemsMarkupProvider = formFlowUiCommand.CustomToolbarItemsMarkupProvider;
            Dictionary<string, object> innerFormBindings = formFlowUiCommand.BindingsProvider.GetBindings();
            Dictionary<IFormEventIdentifier, FormFlowEventHandler> eventHandlers = formFlowUiCommand.EventHandlers;
            Dictionary<string, List<ClientValidationRule>> bindingsValidationRules = formFlowUiCommand.BindingsValidationRules;

            FormTreeCompiler formCompiler = new FormTreeCompiler();
            IUiContainer renderingContainer = GetRenderingContainer(channel, formFlowUiCommand.UiContainerType);

            // Setting state related objects so the delegate below can access them "fresh"
            CurrentFormTreeCompiler = formCompiler;
            CurrentInnerFormBindings = innerFormBindings;
            CurrentControlContainer = (IWebUiContainer)renderingContainer;


            Dictionary<string, object> containerEventHandlerStubs = new Dictionary<string, object>();

            foreach (IFormEventIdentifier eventIdentifier in eventHandlers.Keys)
            {
                IFormEventIdentifier localScopeEventIdentifier = eventIdentifier;  // See: Local variable usage with anonymous methods within loop control structures

                EventHandler handlerStub = delegate(object sender, EventArgs e)
                {
                    try
                    {
                        BaseEventHandler(consoleId, elementProviderName, flowToken, formFlowUiCommand, servicesContainer, eventHandlers, localScopeEventIdentifier, formServicesContainer);
                    }
                    catch (Exception ex)
                    {
                        formServicesContainer.GetService<IManagementConsoleMessageService>().ShowLogEntry(typeof(FormFlowUiDefinitionRenderer), ex);
                        throw;
                    }
                };

                containerEventHandlerStubs.Add(eventIdentifier.BindingName, handlerStub);

                if (innerFormBindings.ContainsKey(eventIdentifier.BindingName))
                {
                    innerFormBindings.Remove(eventIdentifier.BindingName);
                }

                innerFormBindings.Add(eventIdentifier.BindingName, handlerStub);
            }

            XDocument document;

            using (XmlReader formMarkupReader = formMarkupProvider.GetReader())
            {
                document = XDocument.Load(formMarkupReader);
                formMarkupReader.Close();
            }

            formCompiler.Compile(document, channel, innerFormBindings, debugMode, "", bindingsValidationRules);

            IUiControl innerForm = formCompiler.UiControl;

            IUiControl customToolbarItems = null;
            if (customToolbarItemsMarkupProvider != null)
            {
                FormTreeCompiler toolbarCompiler = new FormTreeCompiler();
                using (XmlReader formMarkupReader = customToolbarItemsMarkupProvider.GetReader())
                {
                    toolbarCompiler.Compile(formMarkupReader, channel, innerFormBindings, debugMode, bindingsValidationRules);
                }
                customToolbarItems = toolbarCompiler.UiControl;
            }

            CurrentControlTreeRoot = (IWebUiControl)innerForm;

            string label = formCompiler.Label;
            if(label.IsNullOrEmpty())
            {
                label = formFlowUiCommand.ContainerLabel ?? "";
            }

            string labelField = GetFormLabelField(document);
            ResourceHandle containerIcon = formCompiler.Icon;

            return renderingContainer.Render(formCompiler.UiControl, customToolbarItems, channel, containerEventHandlerStubs, label, labelField, containerIcon);
        }
コード例 #43
0
 /// <exclude />
 public FlowHandle(FlowToken FlowToken)
 {
     _flowToken = FlowToken;
 }
コード例 #44
0
        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);
        }
コード例 #45
0
 internal static void FireOnAfterActionExecution(EntityToken entityToken, ActionToken actionToken, FlowToken flowToken)
 {
     if (_onAfterActionExecutionDelegates != null)
     {
         _onAfterActionExecutionDelegates(new AfterActionEventArgs(entityToken, actionToken, flowToken));
     }
 }
コード例 #46
0
        internal static void UnregisterFlowInformation(FlowToken flowToken)
        {
            string serializedFlowToken = FlowTokenSerializer.Serialize(flowToken);

            DataFacade.Delete<IFlowInformation>(f => f.SerializedFlowToken == serializedFlowToken);
        }
コード例 #47
0
 public IFlowUiDefinition GetCurrentUiDefinition(FlowToken flowToken)
 {
     return(new NullFlowUiDefinition());
 }