Beispiel #1
0
        public virtual void StartBlock5(Sungero.RecordManagement.Server.DeadlineExtensionNotificationArguments e)
        {
            var desiredDeadline      = _obj.NewDeadline.Value;
            var desiredDeadlineLabel = Functions.DeadlineExtensionTask.GetDesiredDeadlineLabel(desiredDeadline);
            var subjectFormat        = DeadlineExtensionTasks.Resources.ExtensionDeadlineFormat(desiredDeadlineLabel);
            var subject = Functions.DeadlineExtensionTask.GetDeadlineExtensionSubject(_obj, subjectFormat);

            e.Block.Subject = Docflow.PublicFunctions.Module.TrimSpecialSymbols(subject);
            e.Block.Performers.Add(_obj.Author);

            e.Block.PreviousDeadline = _obj.CurrentDeadline;
            e.Block.NewDeadline      = desiredDeadline;

            // Отправить уведомления соисполнителям.
            var actionItemAssignment = ActionItemExecutionAssignments.Get(_obj.ParentAssignment.Id);
            var actionItemExecution  = ActionItemExecutionTasks.Get(actionItemAssignment.Task.Id);

            if (actionItemExecution.CoAssignees.Count > 0)
            {
                foreach (var performer in actionItemExecution.CoAssignees)
                {
                    e.Block.Performers.Add(performer.Assignee);
                }
            }

            Docflow.PublicFunctions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, _obj.DocumentsGroup.OfficialDocuments.FirstOrDefault());
        }
Beispiel #2
0
        public static IDeadlineExtensionTask GetDeadlineExtension(Sungero.RecordManagement.IActionItemExecutionAssignment executionAssignment)
        {
            // Проверить наличие старой задачи на продление срока.
            var oldTask = DeadlineExtensionTasks.GetAll()
                          .Where(j => Equals(j.ParentAssignment, executionAssignment))
                          .Where(j => j.Status == Workflow.Task.Status.InProcess || j.Status == Workflow.Task.Status.Draft)
                          .FirstOrDefault();

            if (oldTask != null)
            {
                return(oldTask);
            }

            var task = DeadlineExtensionTasks.CreateAsSubtask(executionAssignment);

            task.ActionItemExecutionAssignment = executionAssignment;

            task.MaxDeadline = (executionAssignment.Deadline < Calendar.Now) ? Calendar.Today : executionAssignment.Deadline;
            task.NeedsReview = false;
            task.ActionItem  = executionAssignment.ActionItem;
            var itemExecution = ActionItemExecutionTasks.As(executionAssignment.Task);
            var document      = ActionItemExecutionTasks.Get(itemExecution.Id).DocumentsGroup.OfficialDocuments.FirstOrDefault();

            if (document != null)
            {
                task.DocumentsGroup.OfficialDocuments.Add(document);
            }
            task.Subject = Functions.DeadlineExtensionTask.GetDeadlineExtensionSubject(task, DeadlineExtensionTasks.Resources.ExtendDeadlineTaskSubject);

            // Определить исполнителя. Для составного поручения взять ведущую задачу.
            var leadItemExecution   = itemExecution;
            var parentItemExecution = ActionItemExecutionTasks.As(itemExecution.ParentTask);

            if (parentItemExecution != null && parentItemExecution.IsCompoundActionItem == true)
            {
                leadItemExecution = parentItemExecution;
            }

            // Исполнителем указать контролёра, если его нет, то стартовавшего задачу, если и его нет, то автора.
            // Если контроля не было, то стартовавшего задачу.
            if (itemExecution.IsUnderControl == true)
            {
                task.Assignee = leadItemExecution.Supervisor ?? leadItemExecution.StartedBy;
            }
            else
            {
                task.Assignee = leadItemExecution.StartedBy;
            }

            if (task.Assignee == null || task.Assignee.IsSystem == true)
            {
                task.Assignee = leadItemExecution.Author;
            }

            task.CurrentDeadline = executionAssignment.Deadline;
            task.Author          = executionAssignment.Performer;

            return(task);
        }
Beispiel #3
0
        public virtual void Script4Execute()
        {
            var desiredDeadline = _obj.NewDeadline;

            // Обновить срок у задания.
            var actionItemAssignment = ActionItemExecutionAssignments.Get(_obj.ParentAssignment.Id);

            actionItemAssignment.Deadline      = desiredDeadline;
            actionItemAssignment.ScheduledDate = desiredDeadline;
            actionItemAssignment.Save();

            // Обновить срок у задачи.
            var actionItemExecution = ActionItemExecutionTasks.Get(actionItemAssignment.Task.Id);

            actionItemExecution.Deadline    = desiredDeadline;
            actionItemExecution.MaxDeadline = desiredDeadline;

            // Обновить срок у составной задачи.
            if (actionItemExecution.ActionItemType == ActionItemType.Component)
            {
                var component  = ActionItemExecutionTasks.Get(actionItemExecution.ParentTask.Id);
                var actionItem = component.ActionItemParts.FirstOrDefault(j => Equals(j.Assignee, actionItemExecution.Assignee) &&
                                                                          Equals(j.ActionItemPart, actionItemExecution.ActionItem) &&
                                                                          j.Deadline == _obj.CurrentDeadline);
                if (actionItem != null)
                {
                    actionItem.Deadline = desiredDeadline;
                }
            }

            // Продлить сроки соисполнителей.
            foreach (var performer in actionItemExecution.CoAssignees)
            {
                var subTasks = ActionItemExecutionTasks.GetAll(t => Equals(t.MainTask, actionItemExecution) &&
                                                               t.Status == Sungero.Workflow.Task.Status.InProcess &&
                                                               Equals(t.Assignee, performer.Assignee));
                foreach (var subTask in subTasks)
                {
                    subTask.Deadline    = desiredDeadline;
                    subTask.MaxDeadline = desiredDeadline;

                    // Продлить срок у активного задания соисполнителя.
                    var assignment = ActionItemExecutionAssignments.GetAll()
                                     .FirstOrDefault(a => Equals(a.Task, subTask) && a.Status == Sungero.Workflow.AssignmentBase.Status.InProcess);

                    if (assignment != null)
                    {
                        assignment.Deadline      = desiredDeadline;
                        assignment.ScheduledDate = desiredDeadline;
                    }
                }
            }
        }