Example #1
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, ExchangeDocumentProcessingAssignments.As(assignment));

            // Заголовок.
            block.AddLabel(ExchangeDocumentProcessingTasks.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 != Exchange.ExchangeDocumentProcessingAssignment.Result.Complete)
            {
                status = Exchange.ExchangeDocumentProcessingAssignments.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);
        }