AcquaintanceTaskClientFunctions.cs
3.23 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Content;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.RecordManagement.AcquaintanceTask;
namespace Sungero.RecordManagement.Client
{
partial class AcquaintanceTaskFunctions
{
/// <summary>
/// Заполнить участников из списка ознакомления.
/// </summary>
/// <param name="acquaintanceList">Список ознакомления.</param>
[Public]
public void FillFromAcquaintanceList(IAcquaintanceList acquaintanceList)
{
if (acquaintanceList == null)
return;
var participants = acquaintanceList.Participants.Where(p => p.Participant.Status == Company.Employee.Status.Active);
foreach (var participant in participants)
{
var newParticipantRow = _obj.Performers.AddNew();
newParticipantRow.Performer = participant.Participant;
}
foreach (var excludedParticipant in acquaintanceList.ExcludedParticipants)
{
var newExcludedPerformer = _obj.ExcludedPerformers.AddNew();
newExcludedPerformer.ExcludedPerformer = excludedParticipant.ExcludedParticipant;
}
}
/// <summary>
/// Проверка, входит ли документ в список редактируемых форматов.
/// </summary>
/// <param name="document">Документ.</param>
/// <returns>True, если входит, иначе False.</returns>
public virtual bool IsEditableDocumentFormat(Docflow.IOfficialDocument document)
{
var whiteList = new List<string>() { "doc", "docx", "xls", "xlsx", "rtf", "odt", "ods", "txt" };
if (document.AssociatedApplication == null)
return false;
return whiteList.Contains(document.AssociatedApplication.Extension.ToLower());
}
/// <summary>
/// Проверка, нужно ли рекомендовать подписать документ перед ознакомлением.
/// </summary>
/// <param name="isElectronicAcquaintance">Значение галочки "В электронном виде".</param>
/// <param name="document">Вложенный документ.</param>
/// <returns>True, если документу требуется утверждающая подпись, иначе False.</returns>
[Public]
public virtual bool NeedShowSignRecommendation(bool isElectronicAcquaintance, Docflow.IOfficialDocument document)
{
// Проверка актуальна только для черновиков и электронного ознакомления.
var isDraft = _obj.Status.Value == Status.Draft;
if (!isDraft || !isElectronicAcquaintance)
return false;
// Нет тела - проверка не нужна.
if (document == null || !document.HasVersions)
return false;
// Проверить подпись только по белому списку.
var inWhiteList = this.IsEditableDocumentFormat(document);
var hasApprovalSignatures = Signatures.Get(document.LastVersion).Any(x => x.SignatureType == SignatureType.Approval);
return !hasApprovalSignatures && inWhiteList;
}
}
}