CaseInventorySharedFunctions.cs
2.81 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.CaseArchiving.CaseInventory;
namespace DirRX.CaseArchiving.Shared
{
partial class CaseInventoryFunctions
{
/// <summary>
/// Заполнить имя документа.
/// </summary>
public override void FillName()
{
// Вид документа.
var name = _obj.DocumentKind.DisplayValue;
// Подразделение.
if (_obj.Department != null && Functions.Module.Remote.IsCreateCaseInventoryByDepartments())
name += " " + _obj.Department.DisplayValue;
using (TenantInfo.Culture.SwitchTo())
{
// Номер описи.
name += _obj.DocumentNumber.HasValue ? " № " + _obj.DocumentNumber.ToString() : string.Empty;
// Год.
name += _obj.EndOfYear.HasValue ? " за " + _obj.EndOfYear.Value.Year.ToString() + " год" : string.Empty;
}
_obj.Name = name.Length > _obj.Info.Properties.Name.Length ? name.Substring(0, _obj.Info.Properties.Name.Length - 1) : name;
}
/// <summary>
/// Отправить уведомление о завершении обработки сдаточной описи.
/// </summary>
[Public]
public virtual void SendCompletionNotification()
{
if (_obj.Archivist == null)
return;
var simpleTask = Sungero.Workflow.SimpleTasks.Create();
// Вложить опись.
simpleTask.Attachments.Add(_obj);
// Уведомить архивиста.
var step = simpleTask.RouteSteps.AddNew();
step.AssignmentType = Sungero.Workflow.SimpleTask.AssignmentType.Notice;
step.Performer = _obj.Archivist;
// Получить тему и текст уведомления в зависимости от статуса.
if (_obj.ArchiveState == ArchiveState.Complete)
{
simpleTask.Subject = Resources.InfoArchivingCompleted;
simpleTask.ActiveText = _obj.Name;
// Уведомить делопроизводителя.
if (_obj.Responsible != null && _obj.Responsible != _obj.Archivist)
{
step = simpleTask.RouteSteps.AddNew();
step.AssignmentType = Sungero.Workflow.SimpleTask.AssignmentType.Notice;
step.Performer = _obj.Responsible;
}
}
else
{
simpleTask.Subject = Resources.InfoArchivingError;
simpleTask.ActiveText = _obj.Name;
simpleTask.ActiveText += Environment.NewLine;
simpleTask.ActiveText += "При обработке описи возникли ошибки. Обратитесь к Администратору системы.";
}
simpleTask.Save();
simpleTask.Start();
}
}
}