VerificationTaskServerFunctions.cs
7.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.CaseArchiving.VerificationTask;
namespace DirRX.CaseArchiving.Server
{
partial class VerificationTaskFunctions
{
public Sungero.Core.StateView GetStateView(Sungero.Docflow.IOfficialDocument document)
{
if (_obj.DocumentGroup.CaseInventories.Any(d => Equals(document, d)))
return this.GetStateView();
else
return StateView.Create();
}
[Remote(IsPure = true)]
public Sungero.Core.StateView GetStateView()
{
var stateView = StateView.Create();
// Блок информации о задаче.
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))
Sungero.Docflow.PublicFunctions.Module.AddInfoToRightContent(taskBlock, status);
// Блоки информации о заданиях.
foreach (var assignment in taskAssignments)
{
var assignmentBlock = this.GetAssignmentBlock(assignment);
taskBlock.AddChildBlock(assignmentBlock);
}
return stateView;
}
/// <summary>
/// Добавить блок задачи на верификацию.
/// </summary>
/// <param name="stateView">Схема представления.</param>
/// <returns>Новый блок.</returns>
public Sungero.Core.StateBlock AddTaskBlock(Sungero.Core.StateView stateView)
{
// Создать блок задачи.
var taskBlock = stateView.AddBlock();
// Добавить ссылку на задачу и иконку.
taskBlock.Entity = _obj;
taskBlock.AssignIcon(StateBlockIconType.OfEntity, StateBlockIconSize.Large);
// Определить схлопнутость.
taskBlock.IsExpanded = _obj.Status == Sungero.Workflow.Task.Status.InProcess;
taskBlock.AddLabel(_obj.Info.LocalizedName, Sungero.Docflow.PublicFunctions.Module.CreateHeaderStyle());
return taskBlock;
}
/// <summary>
/// Добавить блок задания на верификацию.
/// </summary>
/// <param name="assignment">Задание.</param>
/// <returns>Новый блок.</returns>
public Sungero.Core.StateBlock GetAssignmentBlock(Sungero.Workflow.IAssignment assignment)
{
// Стили.
var performerDeadlineStyle = Sungero.Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle();
var boldStyle = Sungero.Docflow.PublicFunctions.Module.CreateStyle(true, false);
var grayStyle = Sungero.Docflow.PublicFunctions.Module.CreateStyle(false, true);
var separatorStyle = Sungero.Docflow.PublicFunctions.Module.CreateSeparatorStyle();
var noteStyle = Sungero.Docflow.PublicFunctions.Module.CreateNoteStyle();
var block = StateView.Create().AddBlock();
block.Entity = assignment;
// Иконка.
this.SetIcon(block, VerificationAssignments.As(assignment));
// Заголовок.
block.AddLabel(VerificationAssignments.Info.LocalizedName, boldStyle);
block.AddLineBreak();
// Кому.
var assigneeShortName = Sungero.Company.PublicFunctions.Employee.GetShortName(Sungero.Company.Employees.As(assignment.Performer), false);
var performerInfo = string.Format("{0}: {1}", Sungero.Docflow.OfficialDocuments.Resources.StateViewTo, assigneeShortName);
block.AddLabel(performerInfo, performerDeadlineStyle);
// Срок.
if (assignment.Deadline.HasValue)
{
var deadlineLabel = Sungero.Docflow.PublicFunctions.Module.ToShortDateShortTime(assignment.Deadline.Value.ToUserTime());
block.AddLabel(string.Format("{0}: {1}", Sungero.Docflow.OfficialDocuments.Resources.StateViewDeadline, deadlineLabel), performerDeadlineStyle);
}
// Текст задания.
var comment = Sungero.Docflow.PublicFunctions.Module.GetAssignmentUserComment(Sungero.Workflow.Assignments.As(assignment));
if (!string.IsNullOrWhiteSpace(comment))
{
// Разделитель.
block.AddLineBreak();
block.AddLabel(Sungero.Docflow.PublicFunctions.Module.GetSeparatorText(), separatorStyle);
block.AddLineBreak();
block.AddEmptyLine(Sungero.Docflow.PublicFunctions.Module.GetEmptyLineMargin());
block.AddLabel(comment, noteStyle);
}
// Статус.
var status = Sungero.Workflow.AssignmentBases.Info.Properties.Status.GetLocalizedValue(assignment.Status);
// Для непрочитанных заданий указать это.
if (assignment.IsRead == false)
status = Sungero.Docflow.ApprovalTasks.Resources.StateViewUnRead.ToString();
// Для исполненных заданий указать результаты, с которым они исполнены, кроме "Проверено".
if (assignment.Status == Sungero.Workflow.AssignmentBase.Status.Completed
&& assignment.Result != Storage.VerificationActAssignment.Result.Complete)
status = Storage.VerificationActAssignments.Info.Properties.Result.GetLocalizedValue(assignment.Result);
if (!string.IsNullOrWhiteSpace(status))
Sungero.Docflow.PublicFunctions.Module.AddInfoToRightContent(block, status);
// Задержка исполнения.
if (assignment.Deadline.HasValue &&
assignment.Status == Sungero.Workflow.AssignmentBase.Status.InProcess)
Sungero.Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, assignment.Deadline.Value, assignment.Performer);
return block;
}
/// <summary>
/// Установить иконку.
/// </summary>
/// <param name="block">Блок, для которого требуется установить иконку.</param>
/// <param name="assignment">Задание, от которого построен блок.</param>
private void SetIcon(StateBlock block, IVerificationAssignment assignment)
{
var iconSize = StateBlockIconSize.Large;
// Иконка по умолчанию.
block.AssignIcon(StateBlockIconType.OfEntity, iconSize);
// Прекращено, остановлено по ошибке.
if (assignment.Status == Sungero.Workflow.AssignmentBase.Status.Aborted ||
assignment.Status == Sungero.Workflow.AssignmentBase.Status.Suspended)
{
block.AssignIcon(StateBlockIconType.Abort, iconSize);
return;
}
if (assignment.Result == null)
return;
// Проверено.
if (assignment.Result == Storage.VerificationActAssignment.Result.Complete)
{
block.AssignIcon(StateBlockIconType.Completed, iconSize);
return;
}
// Переадресовано.
if (assignment.Result == Storage.VerificationActAssignment.Result.Forward)
{
block.AssignIcon(Sungero.Docflow.FreeApprovalTasks.Resources.Forward, iconSize);
}
}
}
}