Exemple #1
0
        /// <summary>
        /// Показать диалог подтверждения выполнения без создания поручений.
        /// </summary>
        /// <param name="assignment">Задание, которое выполняется.</param>
        /// <param name="document">Документ.</param>
        /// <param name="e">Аргументы.</param>
        /// <returns>True, если диалог был, иначе false.</returns>
        public static bool ShowConfirmationDialogCreationActionItem(IAssignment assignment, IOfficialDocument document, Sungero.Workflow.Client.ExecuteResultActionArgs e)
        {
            var reviewTask       = DocumentReviewTasks.As(assignment.Task);
            var hasSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.InProcess, reviewTask.Addressee);

            if (hasSubActionItem)
            {
                return(false);
            }

            var dialogText = ReviewResolutionAssignments.Is(assignment) ?
                             Docflow.Resources.ExecuteWithoutCreatingActionItemFromAddressee : Docflow.Resources.ExecuteWithoutCreatingActionItem;
            var dialog = Dialogs.CreateTaskDialog(dialogText, MessageType.Question);

            dialog.Buttons.AddYes();
            dialog.Buttons.Default = DialogButtons.Yes;
            var createActionItemButton = dialog.Buttons.AddCustom(Docflow.Resources.CreateActionItem);

            dialog.Buttons.AddNo();

            var result = dialog.Show();

            if (result == DialogButtons.Yes)
            {
                return(true);
            }

            if (result == DialogButtons.Cancel || result == DialogButtons.No)
            {
                e.Cancel();
            }

            assignment.Save();
            var assignedBy = reviewTask.Addressee;
            var resolution = ReviewResolutionAssignments.Is(assignment) ? ReviewResolutionAssignments.As(assignment).ResolutionText : assignment.ActiveText;
            var actionItem = Functions.Module.Remote.CreateActionItemExecutionWithResolution(document, assignment.Id, resolution, assignedBy);

            actionItem.IsDraftResolution = false;
            actionItem.ShowModal();

            hasSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.InProcess, reviewTask.Addressee);
            if (hasSubActionItem)
            {
                return(true);
            }

            var hasDraftSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.Draft, reviewTask.Addressee);

            e.AddError(hasDraftSubActionItem ? Docflow.Resources.AllCreatedActionItemsShouldBeStarted : Docflow.Resources.CreatedActionItemExecutionNeeded);
            e.Cancel();
            return(true);
        }
Exemple #2
0
        public void StartActionItemsForDraftResolution(IAssignment parentAssignment)
        {
            parentAssignment.Save();
            // TODO Shklyaev: переделать метод, когда сделают 65004.
            foreach (var draftResolution in _obj.ResolutionGroup.ActionItemExecutionTasks.Where(t => t.Status == RecordManagement.ActionItemExecutionTask.Status.Draft))
            {
                // Очистить все вложения и заполнить заново, чтобы корректно отработала синхронизация вновь добавленных документов.
                var officialDocuments = draftResolution.DocumentsGroup.OfficialDocuments.ToList();
                draftResolution.DocumentsGroup.OfficialDocuments.Clear();

                var addendaDocuments = draftResolution.AddendaGroup.OfficialDocuments.ToList();
                draftResolution.AddendaGroup.OfficialDocuments.Clear();

                var othersGroup = draftResolution.OtherGroup.All.ToList();
                draftResolution.OtherGroup.All.Clear();

                ((Sungero.Workflow.IInternalTask)draftResolution).ParentAssignment = parentAssignment;
                ((Sungero.Workflow.IInternalTask)draftResolution).MainTask         = parentAssignment.MainTask;
                draftResolution.Save();

                foreach (var attachment in othersGroup)
                {
                    draftResolution.OtherGroup.All.Add(attachment);

                    var participants = Sungero.Docflow.PublicFunctions.Module.Remote.GetTaskAssignees(draftResolution).ToList();
                    foreach (var participant in participants)
                    {
                        attachment.AccessRights.Grant(participant, DefaultAccessRightsTypes.Read);
                    }
                    attachment.AccessRights.Save();
                }

                foreach (var attachment in officialDocuments)
                {
                    draftResolution.DocumentsGroup.OfficialDocuments.Add(attachment);
                }

                foreach (var attachment in addendaDocuments)
                {
                    draftResolution.AddendaGroup.OfficialDocuments.Add(attachment);
                }

                draftResolution.Save();
                ((Domain.Shared.IExtendedEntity)draftResolution).Params[PublicConstants.ActionItemExecutionTask.CheckDeadline] = true;
                draftResolution.Start();
            }
        }