Пример #1
0
        /// <summary>
        /// Tracks the changes a workflow operation creates.
        /// </summary>
        /// <param name="workflowOperation">The workflow operation that contains the operation that needs to be tracked</param>
        private void TrackChanges(WorkflowOperation workflowOperation, DocumentWorkflowStateType documentWorkflowStateType)
        {
            if (workflowOperation.WorkflowOrganizationId != null)
            {
                var tracker = new DocumentWorkflowTracker
                {
                    ActionName             = documentWorkflowStateType,
                    CreateDateTime         = DateTime.Now,
                    DocumentId             = workflowOperation.DocumentId,
                    TargetUserId           = workflowOperation.TargetUserId,
                    UserId                 = workflowOperation.UserId,
                    WorkflowOrganizationId = workflowOperation.WorkflowOrganizationId,
                };

                documentWorkflowTrackerService.Save(tracker);
            }
        }
Пример #2
0
        /// <summary>
        /// Checks the document out of a workflow organization unit.
        /// </summary>
        /// <param name="workflowOperation"></param>
        /// <returns>Document path id</returns>
        public Guid DocumentCheckout(WorkflowOperation workflowOperation)
        {
            //Check if the document is still inside
            if (documentWorkflowOrganizationUnitAssignmentService.GetByIds(workflowOperation.DocumentId, (Guid)workflowOperation.WorkflowOrganizationId) != null)
            {
                documentWorkflowOrganizationUnitAssignmentService.DeleteByIds(workflowOperation.DocumentId, (Guid)workflowOperation.WorkflowOrganizationId);

                // Add path to forwarded user
                var workflow = documentWorkflowUserService.Get(workflowOperation.TargetUserId);
                if (workflow == null)
                {
                    throw new DocumentWorkflowException("workflow is null");
                }
                var targetStructure = fileStructureService.GetByInstanceDataGuid(workflow.Guid);
                if (targetStructure == null)
                {
                    throw new DocumentWorkflowException("targetStructure is null");
                }

                var targetPath = new FileStructureDocumenPath
                {
                    DirectoryGuid     = (Guid)workflowOperation.DirectoryId,
                    WorkflowId        = workflowOperation.WorkflowId,
                    FileStructureGuid = targetStructure.Id,
                    Id              = Guid.NewGuid(),
                    DocumentGuid    = workflowOperation.DocumentId,
                    IsProtectedPath = false,
                    WorkflowState   = DocumentWorkflowStateType.InReview
                };

                var tracker = new DocumentWorkflowTracker
                {
                    ActionName     = DocumentWorkflowStateType.ForwardedCopy,
                    CreateDateTime = DateTime.Now,
                    DocumentId     = targetPath.DocumentGuid,
                    TargetUserId   = workflowOperation.TargetUserId,
                    UserId         = workflowOperation.UserId
                };

                documentWorkflowTrackerService.Save(tracker);
                fileStructureDocumentPathService.Save(targetPath);

                return(targetPath.Id);
            }
            throw new CoreException("S-0000009", "9ae836fb-40e8-43d3-9d57-85c17647684a", ExceptionType.Expected);
        }
Пример #3
0
        /// <summary>
        /// Sets the state to complete.
        /// </summary>
        /// <param name="workflowOperation"></param>
        public void Release(WorkflowOperation workflowOperation)
        {
            var path = fileStructureDocumentPathService.Get(workflowOperation.DocumentPath);

            path.WorkflowState = DocumentWorkflowStateType.Released;

            var tracker = new DocumentWorkflowTracker
            {
                ActionName     = DocumentWorkflowStateType.Released,
                CreateDateTime = DateTime.Now,
                DocumentId     = workflowOperation.DocumentId,
                UserId         = workflowOperation.UserId
            };

            documentWorkflowTrackerService.Save(tracker);
            fileStructureDocumentPathService.Save(path);

            flowEventService.InvokeEvent("DocumentReleased", workflowOperation.Guid, workflowOperation, workflowOperation.UserId);
        }
Пример #4
0
        /// <summary>
        /// Sends a copy to the target user.
        /// </summary>
        /// <param name="workflowOperation"></param>
        public void ForwardCopyTo(WorkflowOperation workflowOperation)
        {
            var configuration  = documentWorkflowConfigurationService.Get(workflowOperation.WorkflowId);
            var accessProvider = unityContainer.Resolve <IDocumentWorkflowAccessProvider>(configuration.AccessProviderName);

            if (workflowOperation.OperationType == WorkflowOperationType.WorkflowOrganizationUnit)
            {
                SaveWorkflowOrganizationUnitAssignment(workflowOperation, configuration.StateProviderName);
                TrackChanges(workflowOperation, DocumentWorkflowStateType.ForwardedCopy);

                if (accessProvider != null && workflowOperation.WorkflowOrganizationId.HasValue)
                {
                    accessProvider.SetOrganizationUnitAcess(workflowOperation.WorkflowOrganizationId.Value, workflowOperation.DocumentId, configuration);
                }
            }
            else
            {
                // Add path to forwarded user
                var workflow = documentWorkflowUserService.Get(workflowOperation.TargetUserId);
                if (workflow == null)
                {
                    throw new DocumentWorkflowException("workflow is null");
                }

                var targetStructure = fileStructureService.GetByInstanceDataGuid(workflow.Guid);
                if (targetStructure == null)
                {
                    throw new DocumentWorkflowException("targetStructure is null");
                }

                // TODO: Check for null
                var existingStructures = fileStructureDocumentPathService.GetByDocumentId(workflowOperation.DocumentId)
                                         .ToList();
                if (existingStructures == null)
                {
                    throw new DocumentWorkflowException("existingStructures is null");
                }

                var targetPath = existingStructures.FirstOrDefault(x => x.FileStructureGuid == targetStructure.Id);

                if (targetPath != null)
                {
                    var returnFolder = GetReturnDirectory(targetPath.FileStructureGuid, targetPath.WorkflowId.Value);
                    targetPath.DirectoryGuid = returnFolder.Id;
                    targetPath.WorkflowState = DocumentWorkflowStateType.InReview;
                }

                else
                {
                    var firstDirectory = FindWorkflowDirectory(targetStructure, workflowOperation.WorkflowId, workflowOperation.DocumentId, workflowOperation.TargetUserId);

                    if (firstDirectory == null)
                    {
                        throw new DocumentWorkflowException("existingStructures is null");
                    }

                    targetPath = new FileStructureDocumenPath
                    {
                        DirectoryGuid     = firstDirectory.Id,
                        WorkflowId        = firstDirectory.WorkflowId,
                        FileStructureGuid = targetStructure.Id,
                        Id              = Guid.NewGuid(),
                        DocumentGuid    = workflowOperation.DocumentId,
                        IsProtectedPath = false,
                        WorkflowState   = DocumentWorkflowStateType.InReview
                    };
                }

                var tracker = new DocumentWorkflowTracker
                {
                    ActionName     = DocumentWorkflowStateType.ForwardedCopy,
                    CreateDateTime = DateTime.Now,
                    DocumentId     = targetPath.DocumentGuid,
                    TargetUserId   = workflowOperation.TargetUserId,
                    UserId         = workflowOperation.UserId
                };

                documentWorkflowTrackerService.Save(tracker);
                fileStructureDocumentPathService.Save(targetPath);

                if (accessProvider != null)
                {
                    accessProvider.SetUserAccess(workflowOperation.TargetUserId, workflowOperation.DocumentId, targetPath.Id, targetStructure.Id, configuration);
                }

                flowEventService.InvokeEvent("DocumentForwardedCopy", workflowOperation.Guid, workflowOperation, workflowOperation.UserId);
            }
        }
Пример #5
0
 public bool Save(DocumentWorkflowTracker obj)
 {
     return(repository.Save(obj));
 }
Пример #6
0
 public bool Delete(DocumentWorkflowTracker obj)
 {
     return(repository.Delete(obj));
 }