VerificationTaskRouteHandlers.cs
5.98 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Company;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Domain.Shared;
using Sungero.Metadata;
using Sungero.SmartProcessing.VerificationTask;
using Sungero.Workflow;
namespace Sungero.SmartProcessing.Server
{
partial class VerificationTaskRouteHandlers
{
public virtual void Script4Execute()
{
// Если при верификации изменен тип документа, заполнить статус обучения классификатора в результате распознавания.
var documents = _obj.AllAttachments.Where(a => Sungero.Docflow.OfficialDocuments.Is(a)).ToList();
foreach (var document in documents)
{
var verifiedClass = SmartProcessing.Functions.Module.GetArioClassByEntityType(document);
if (!string.IsNullOrEmpty(verifiedClass))
{
var entityRecognitionInfo = Sungero.Commons.PublicFunctions.EntityRecognitionInfo.Remote.GetEntityRecognitionInfo(document);
if (entityRecognitionInfo != null &&
entityRecognitionInfo.ClassifierTrainingStatus == null &&
entityRecognitionInfo.RecognizedClass != verifiedClass)
{
entityRecognitionInfo.VerifiedClass = verifiedClass;
entityRecognitionInfo.ClassifierTrainingStatus = Sungero.Commons.EntityRecognitionInfo.ClassifierTrainingStatus.Awaiting;
entityRecognitionInfo.Save();
}
}
}
}
public virtual void EndBlock3(Sungero.SmartProcessing.Server.VerificationAssignmentEndBlockEventArguments e)
{
// Перевести все документы комплекта в статус верификации "Завершена".
var documentIds = _obj.AllAttachments
.Where(a => Content.ElectronicDocuments.Is(a))
.Select(a => Content.ElectronicDocuments.As(a)).Distinct()
.Cast<Docflow.IOfficialDocument>()
.Where(d => d.VerificationState == Docflow.OfficialDocument.VerificationState.InProcess)
.Select(d => d.Id)
.ToList();
foreach (var documentId in documentIds)
{
var document = Docflow.OfficialDocuments.Get((int)documentId);
if (document == null)
continue;
var hasEmptyRequiredProperties = Docflow.PublicFunctions.OfficialDocument.HasEmptyRequiredProperties(document);
if (hasEmptyRequiredProperties)
{
Logger.DebugFormat(Resources.DocumentSkippedByReasonFormat(document.Id, Resources.RequiredPropertyIsEmpty));
continue;
}
document.VerificationState = Docflow.OfficialDocument.VerificationState.Completed;
}
}
public virtual void StartBlock3(Sungero.SmartProcessing.Server.VerificationAssignmentArguments e)
{
// Заполнить тему задачи.
e.Block.Subject = _obj.AllAttachments.Count() > 1
? Sungero.SmartProcessing.VerificationTasks.Resources.PackageAssignmentSubjectFormatFormat(_obj.LeadingDocumentName)
: Sungero.SmartProcessing.VerificationTasks.Resources.DocumentAssignmentSubjectFormatFormat(_obj.LeadingDocumentName);
if (e.Block.Subject.Length > Tasks.Info.Properties.Subject.Length)
e.Block.Subject = e.Block.Subject.Substring(0, Tasks.Info.Properties.Subject.Length);
this.GrantAccessRights(_obj.Assignee, e);
// Отправить запрос на подготовку предпросмотра для документов.
Docflow.PublicFunctions.Module.PrepareAllAttachmentsPreviews(_obj);
Functions.VerificationTask.PrepareAllAttachmentsRepackingPreviews(_obj);
}
public virtual void StartAssignment3(Sungero.SmartProcessing.IVerificationAssignment assignment, Sungero.SmartProcessing.Server.VerificationAssignmentArguments e)
{
if (_obj.Addressee != null)
this.GrantAccessRights(_obj.Addressee, e);
assignment.Deadline = _obj.Deadline;
}
public virtual void CompleteAssignment3(Sungero.SmartProcessing.IVerificationAssignment assignment, Sungero.SmartProcessing.Server.VerificationAssignmentArguments e)
{
if (assignment.Result == SmartProcessing.VerificationAssignment.Result.Forward)
{
_obj.Deadline = assignment.NewDeadline;
assignment.Forward(assignment.Addressee, ForwardingLocation.Next, assignment.NewDeadline);
}
}
/// <summary>
/// Выдача прав исполнителю на задачу, ее вложения, и связанные с вложениями документы.
/// </summary>
/// <param name="performer">Исполнитель.</param>
/// <param name="e">Аргументы.</param>
public virtual void GrantAccessRights(IEmployee performer, Sungero.SmartProcessing.Server.VerificationAssignmentArguments e)
{
e.Block.Performers.Add(performer);
// Выдать права на вложения исполнителю.
foreach (var attachment in _obj.AllAttachments)
{
if (!attachment.AccessRights.IsGrantedDirectly(DefaultAccessRightsTypes.FullAccess, performer))
attachment.AccessRights.Grant(performer, DefaultAccessRightsTypes.FullAccess);
// Выдать права на связанные документы.
if (Sungero.Docflow.OfficialDocuments.Is(attachment))
{
var attachedDocument = Sungero.Docflow.OfficialDocuments.As(attachment);
var relatedDocuments = attachedDocument.Relations.GetRelatedFrom();
foreach (var relatedDocument in relatedDocuments)
{
if (!relatedDocument.AccessRights.IsGrantedDirectly(DefaultAccessRightsTypes.Read, performer))
relatedDocument.AccessRights.Grant(performer, DefaultAccessRightsTypes.Read);
}
}
}
// Выдать права на задачу.
_obj.AccessRights.Grant(performer, DefaultAccessRightsTypes.Change);
}
}
}