Exemplo n.º 1
0
        public Sungero.Core.StateView GetStateView()
        {
            var stateView = StateView.Create();

            // Добавить блок информации к блоку задачи.
            var taskHeader = VerificationTasks.Resources.StateViewTaskBlockHeader;

            this.AddInformationBlock(stateView, taskHeader, _obj.Started.Value);

            // Блок информации о задаче.
            var taskBlock = this.AddTaskBlock(stateView);

            // Получить все задания по задаче.
            var taskAssignments = VerificationAssignments.GetAll(a => Equals(a.Task, _obj)).OrderBy(a => a.Created).ToList();

            // Статус задачи.
            var status = _obj.Info.Properties.Status.GetLocalizedValue(_obj.Status);

            var lastAssignment = taskAssignments.OrderByDescending(a => a.Created).FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(status))
            {
                Docflow.PublicFunctions.Module.AddInfoToRightContent(taskBlock, status);
            }

            // Блоки информации о заданиях.
            foreach (var assignment in taskAssignments)
            {
                var assignmentBlock = this.GetAssignmentBlock(assignment);

                taskBlock.AddChildBlock(assignmentBlock);
            }

            return(stateView);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Добавить блок задания на верификацию.
        /// </summary>
        /// <param name="assignment">Задание.</param>
        /// <returns>Новый блок.</returns>
        public Sungero.Core.StateBlock GetAssignmentBlock(IAssignment assignment)
        {
            // Стили.
            var performerDeadlineStyle = Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle();
            var boldStyle      = Docflow.PublicFunctions.Module.CreateStyle(true, false);
            var grayStyle      = Docflow.PublicFunctions.Module.CreateStyle(false, true);
            var separatorStyle = Docflow.PublicFunctions.Module.CreateSeparatorStyle();
            var noteStyle      = Docflow.PublicFunctions.Module.CreateNoteStyle();

            var block = StateView.Create().AddBlock();

            block.Entity = assignment;

            // Иконка.
            this.SetIcon(block, VerificationAssignments.As(assignment));

            // Заголовок.
            block.AddLabel(VerificationTasks.Resources.StateViewAssignmentBlockHeader, boldStyle);
            block.AddLineBreak();

            // Кому.
            var assigneeShortName = Company.PublicFunctions.Employee.GetShortName(Company.Employees.As(assignment.Performer), false);
            var performerInfo     = string.Format("{0}: {1}", Docflow.OfficialDocuments.Resources.StateViewTo, assigneeShortName);

            block.AddLabel(performerInfo, performerDeadlineStyle);

            // Срок.
            if (assignment.Deadline.HasValue)
            {
                var deadlineLabel = Docflow.PublicFunctions.Module.ToShortDateShortTime(assignment.Deadline.Value.ToUserTime());
                block.AddLabel(string.Format("{0}: {1}", Docflow.OfficialDocuments.Resources.StateViewDeadline, deadlineLabel), performerDeadlineStyle);
            }

            // Текст задания.
            var comment = Docflow.PublicFunctions.Module.GetAssignmentUserComment(Assignments.As(assignment));

            if (!string.IsNullOrWhiteSpace(comment))
            {
                // Разделитель.
                block.AddLineBreak();
                block.AddLabel(Docflow.PublicFunctions.Module.GetSeparatorText(), separatorStyle);
                block.AddLineBreak();
                block.AddEmptyLine(Docflow.PublicFunctions.Module.GetEmptyLineMargin());

                block.AddLabel(comment, noteStyle);
            }

            // Статус.
            var status = AssignmentBases.Info.Properties.Status.GetLocalizedValue(assignment.Status);

            // Для непрочитанных заданий указать это.
            if (assignment.IsRead == false)
            {
                status = Docflow.ApprovalTasks.Resources.StateViewUnRead.ToString();
            }

            // Для исполненных заданий указать результат, с которым они исполнены, кроме "Проверено".
            if (assignment.Status == Workflow.AssignmentBase.Status.Completed &&
                assignment.Result != SmartProcessing.VerificationAssignment.Result.Complete)
            {
                status = SmartProcessing.VerificationAssignments.Info.Properties.Result.GetLocalizedValue(assignment.Result);
            }

            if (!string.IsNullOrWhiteSpace(status))
            {
                Docflow.PublicFunctions.Module.AddInfoToRightContent(block, status);
            }

            // Задержка исполнения.
            if (assignment.Deadline.HasValue &&
                assignment.Status == Workflow.AssignmentBase.Status.InProcess)
            {
                Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, assignment.Deadline.Value, assignment.Performer);
            }

            return(block);
        }