Esempio n. 1
0
        private void AbortRelatedWorkflows(Node currentNode, WorkflowApplicationAbortReason reason)
        {
            //if (!StorageContext.Search.IsOuterEngineEnabled)
            IEnumerable <Node> nodes = null;

            if (RepositoryInstance.ContentQueryIsAllowed)
            {
                nodes = Search.ContentQuery.Query(SafeQueries.WorkflowsByRelatedContent, null, currentNode.Id).Nodes;
            }
            else
            {
                var nodeType = ActiveSchema.NodeTypes["Workflow"];
                nodes = ContentRepository.Storage.Search.NodeQuery.QueryNodesByReferenceAndType("RelatedContent", currentNode.Id, nodeType, false).Nodes;
            }

            foreach (WorkflowHandlerBase workflow in nodes)
            {
                if (workflow.WorkflowStatus == WorkflowStatusEnum.Running && workflow.AbortOnRelatedContentChange)
                {
                    InstanceManager.Abort(workflow, reason);
                }
            }
        }
Esempio n. 2
0
        public static void NotifyContentChanged(WorkflowNotificationEventArgs eventArgs)
        {
            try
            {
                WorkflowNotification[] notifications = null;
                using (var dbContext = GetDataContext())
                {
                    notifications = dbContext.WorkflowNotifications.Where(notification =>
                                                                          notification.NodeId == eventArgs.NodeId).ToArray();
                }

                //Debug.WriteLine(String.Format("##WF> NotifyContentChanged: Loaded notifications {0}: {1}", notifications.Length, String.Join(", ", notifications.Select(n => n.NodeId + "|" + n.WorkflowInstanceId))));

                foreach (var notification in notifications)
                {
                    InstanceManager.FireNotification(notification, eventArgs);
                }
            }
            catch (Exception e)
            {
                WriteError("NotifyContentChanged", e);
                throw;
            }
        }
Esempio n. 3
0
        private void StartWorkflow(WorkflowHandlerBase wfTemplate, Node currentNode)
        {
            var list         = (ContentList)currentNode.LoadContentList();
            var targetFolder = list.GetWorkflowContainer(); // Node.LoadNode(targetFolderPath);

            var wfInstance = (WorkflowHandlerBase)ContentTemplate.CreateTemplated(targetFolder, wfTemplate, wfTemplate.Name).ContentHandler;

            wfInstance.RelatedContent = currentNode;
            if (!ValidateWorkflow(wfInstance, currentNode))
            {
                wfInstance.Save();
                return;
            }

            wfInstance["OwnerSiteUrl"] = PortalContext.Current.RequestedUri.GetLeftPart(UriPartial.Authority);
            using (new SystemAccount())
            {
                //We need to save the wf instance before the engine starts it to have everything persisted to the repo.
                //Please do not remove this line.
                wfInstance.Save();
            }

            InstanceManager.Start(wfInstance);
        }
Esempio n. 4
0
 public void ReleaseWait(int notificationId)
 {
     InstanceManager.ReleaseWait(notificationId);
 }