CheckReturnTaskServerFunctions.cs
5.09 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Docflow.CheckReturnTask;
using Sungero.Workflow;
namespace Sungero.Docflow.Server
{
partial class CheckReturnTaskFunctions
{
#region Предметное отображение "Задачи". Общие функции
/// <summary>
/// Получить блок задания модели контрола состояния задачи на контроль возврата.
/// </summary>
/// <param name="assignment">Задание.</param>
/// <returns>Модели контрола состояния задачи на контроль возврата.</returns>
[Public]
public static Sungero.Core.StateBlock GetAssignmentBlock(IAssignmentBase assignment)
{
// Стили.
var headerStyle = Docflow.PublicFunctions.Module.CreateHeaderStyle();
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 block = StateView.Create().AddBlock();
block.Entity = assignment;
// Заголовок.
block.AddLabel("Обработка входящего документа", headerStyle);
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);
}
// Разделитель.
block.AddLineBreak();
block.AddLabel(Docflow.Constants.Module.SeparatorText, separatorStyle);
block.AddLineBreak();
block.AddEmptyLine(Docflow.Constants.Module.EmptyLineMargin);
// Текст задания.
block.AddLabel(Docflow.PublicFunctions.Module.GetFormatedUserText(assignment.ActiveText), grayStyle);
// Статус.
var status = AssignmentBases.Info.Properties.Status.GetLocalizedValue(assignment.Status);
// Для непрочитанных заданий указать это.
if (assignment.IsRead == false)
status = Docflow.ApprovalTasks.Resources.StateViewUnRead.ToString();
if (!string.IsNullOrWhiteSpace(status))
Docflow.PublicFunctions.Module.AddInfoToRightContent(block, status);
// Задержка исполнения.
if (assignment.Deadline.HasValue &&
(assignment.Status == Workflow.AssignmentBase.Status.InProcess ||
assignment.Status == Workflow.AssignmentBase.Status.Completed))
Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, assignment.Deadline.Value, assignment.Performer);
return block;
}
#endregion
/// <summary>
/// Заполнить результат возврата.
/// </summary>
/// <param name="returnControl">Задача.</param>
/// <param name="performer">Исполнитель.</param>
/// <param name="documentIsReturned">Признак возврата документа.</param>
public static void SetReturnResult(Sungero.Docflow.ICheckReturnTask returnControl, IUser performer, bool documentIsReturned)
{
var document = returnControl.DocumentGroup.OfficialDocuments.First();
var tracking = GetTrackingByTask(returnControl);
if (tracking == null)
return;
if (documentIsReturned)
{
var resultReturned = Docflow.OfficialDocumentTracking.ReturnResult.Returned;
if (tracking.ReturnResult != resultReturned)
{
var accessRights = document.AccessRights;
tracking.ReturnResult = (accessRights.CanUpdate(performer) && accessRights.CanRegister(performer)) ?
resultReturned : Docflow.OfficialDocumentTracking.ReturnResult.AtControl;
}
}
else
{
tracking.ReturnResult = null;
tracking.ReturnDate = null;
}
}
/// <summary>
/// Получить строку выдачи.
/// </summary>
/// <param name="returnControl">Задача.</param>
/// <returns>Коллекция выдачи.</returns>
public static IOfficialDocumentTracking GetTrackingByTask(Sungero.Docflow.ICheckReturnTask returnControl)
{
var document = returnControl.DocumentGroup.OfficialDocuments.First();
return document.Tracking.Where(r => Equals(r.ReturnTask, returnControl)).FirstOrDefault();
}
}
}