예제 #1
0
        /// <summary>
        /// Добавить блок с заданием.
        /// </summary>
        /// <param name="parentBlock">Основной блок.</param>
        /// <param name="assignment">Задание.</param>
        /// <param name="header">Заголовок блока.</param>
        /// <param name="result">Результат выполнения задания.</param>
        private void AddAssignmentBlock(StateBlock parentBlock, IAssignment assignment, string header, string result)
        {
            if (assignment != null && (assignment.Status != Workflow.AssignmentBase.Status.Completed || !string.IsNullOrEmpty(result)))
            {
                var isDraft    = _obj.Status == Workflow.Task.Status.Draft;
                var labelStyle = Docflow.PublicFunctions.Module.CreateStyle(false, isDraft, false);

                parentBlock.IsExpanded = true;
                var block = parentBlock.AddChildBlock();

                block.Entity = assignment;
                block.AssignIcon(StateBlockIconType.OfEntity, StateBlockIconSize.Large);

                if (assignment.Status == Workflow.AssignmentBase.Status.InProcess && assignment.IsRead == false)
                {
                    Docflow.PublicFunctions.Module.AddInfoToRightContent(block, Docflow.ApprovalTasks.Resources.StateViewUnRead);
                }
                else
                {
                    this.AddAssignmentStatusInfoToRight(block, labelStyle, assignment);
                }

                var headerStyle    = Docflow.PublicFunctions.Module.CreateHeaderStyle(isDraft);
                var performerStyle = Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle(isDraft);

                block.AddLabel(header, headerStyle);
                block.AddLineBreak();

                var resolutionPerformerName = Employees.Is(assignment.Performer) ?
                                              Company.PublicFunctions.Employee.GetShortName(Employees.As(assignment.Performer), false) :
                                              assignment.Performer.Name;
                block.AddLabel(string.Format("{0}: {1} {2}: {3}",
                                             Docflow.OfficialDocuments.Resources.StateViewTo,
                                             resolutionPerformerName,
                                             Docflow.OfficialDocuments.Resources.StateViewDeadline,
                                             Docflow.PublicFunctions.Module.ToShortDateShortTime(assignment.Deadline.Value.ToUserTime())), performerStyle);

                if (!string.IsNullOrEmpty(result))
                {
                    var separatorStyle = Docflow.PublicFunctions.Module.CreateSeparatorStyle();

                    block.AddLineBreak();
                    block.AddLabel(Docflow.Constants.Module.SeparatorText, separatorStyle);
                    block.AddLineBreak();
                    block.AddEmptyLine(Docflow.Constants.Module.EmptyLineMargin);
                    block.AddLabel(result);
                }
                else
                {
                    Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, assignment.Deadline.Value, assignment.Performer);
                }
            }
        }