Ejemplo n.º 1
0
 public virtual PendingWorkflowItem GetPendingWorkflowItem(Repository repository, string roleName, string id)
 {
     return(PendingWorkflowItemProvider.Get(new PendingWorkflowItem {
         Repository = repository, RoleName = roleName, Name = id
     }));
 }
Ejemplo n.º 2
0
        public virtual void ProcessPendingWorkflowItem(Repository repository, string workflowName, string roleName, string pendingWorkflowItemId, string userName, bool passed, string comment)
        {
            var pendingItem = PendingWorkflowItemProvider.Get(new PendingWorkflowItem()
            {
                RoleName = roleName, Name = pendingWorkflowItemId, Repository = repository
            });

            if (pendingItem != null)
            {
                var content = new TextFolder(repository, pendingItem.ContentFolder).CreateQuery().WhereEquals("UUID", pendingItem.ContentUUID).FirstOrDefault();
                if (content != null)
                {
                    var  workflow = Get(repository, workflowName);
                    bool finished = false;
                    if (workflow != null)
                    {
                        WorkflowItem nextWorkflowItem = null;
                        if (passed)
                        {
                            nextWorkflowItem = GetNextWorkflowItem(repository, workflow, pendingItem.WorkflowItemSequence + 1);
                            if (nextWorkflowItem == null)
                            {
                                finished = true;
                            }
                        }
                        else
                        {
                            nextWorkflowItem = GetNextWorkflowItem(repository, workflow, pendingItem.WorkflowItemSequence - 1);
                        }
                        if (nextWorkflowItem != null)
                        {
                            CreatePendingWorkflowItem(repository, content, userName, workflow, nextWorkflowItem, comment);
                        }
                    }

                    if (finished)
                    {
                        var published = content.Published.HasValue ? content.Published.Value : false;
                        if (passed && !published)
                        {
                            ServiceFactory.TextContentManager.Update(repository, new Schema(repository, content.SchemaName), content.UUID
                                                                     , new string[] { "Published" }, new object[] { true }, userName);
                        }
                    }
                    WorkflowHistory history = new WorkflowHistory()
                    {
                        Id                   = WorkflowHistoryProvider.All(content).Count() + 1,
                        Repository           = repository,
                        WorkflowName         = pendingItem.WorkflowName,
                        WorkflowItemSequence = pendingItem.WorkflowItemSequence,
                        ItemDisplayName      = pendingItem.ItemDisplayName,
                        ContentFolder        = pendingItem.ContentFolder,
                        ContentUUID          = pendingItem.ContentUUID,
                        ContentSummary       = content.GetSummary(),
                        RoleName             = pendingItem.RoleName,
                        Passed               = passed,
                        ProcessingUtcDate    = DateTime.UtcNow,
                        ProcessingUser       = userName,
                        Finished             = finished,
                        Comment              = comment
                    };

                    WorkflowHistoryProvider.Add(history);
                }
                PendingWorkflowItemProvider.Remove(pendingItem);
            }
        }