ProjectDocumentSharedFunctions.cs
3.4 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Projects.ProjectDocument;
namespace Sungero.Projects.Shared
{
partial class ProjectDocumentFunctions
{
public override void FillName()
{
var documentKind = _obj.DocumentKind;
if (documentKind != null && !documentKind.GenerateDocumentName.Value && _obj.Name == Docflow.Resources.DocumentNameAutotext)
_obj.Name = string.Empty;
if (documentKind == null || !documentKind.GenerateDocumentName.Value)
return;
/*
Имя в формате: <Имя проекта>. <Вид документа> №<номер> от <дата> <содержание>.
Содержание специально без кавычек.
*/
using (TenantInfo.Culture.SwitchTo())
{
var name = string.Empty;
var project = ProjectCores.As(_obj.Project);
if (project != null)
name += project.ShortName + ". ";
if (!string.IsNullOrWhiteSpace(_obj.RegistrationNumber))
name += Sungero.Docflow.OfficialDocuments.Resources.Number + _obj.RegistrationNumber;
if (_obj.RegistrationDate != null)
name += Sungero.Docflow.OfficialDocuments.Resources.DateFrom + _obj.RegistrationDate.Value.ToString("d");
if (!string.IsNullOrWhiteSpace(_obj.Subject))
name += " " + _obj.Subject;
if (string.IsNullOrWhiteSpace(name))
name = Docflow.Resources.DocumentNameAutotext;
else if (documentKind != null)
name = documentKind.DisplayValue + " " + name;
name = Docflow.PublicFunctions.Module.TrimSpecialSymbols(name);
_obj.Name = Docflow.PublicFunctions.OfficialDocument.AddClosingQuote(name, _obj);
}
}
public override void RefreshDocumentForm()
{
base.RefreshDocumentForm();
var isNotNumerable = _obj.DocumentKind == null || _obj.DocumentKind.NumberingType == Docflow.DocumentKind.NumberingType.NotNumerable;
_obj.State.Properties.BusinessUnit.IsVisible = !isNotNumerable;
_obj.State.Properties.Department.IsVisible = !isNotNumerable;
_obj.State.Properties.OurSignatory.IsVisible = !isNotNumerable || this.GetShowOurSigningReasonParam();
_obj.State.Properties.PreparedBy.IsVisible = !isNotNumerable;
_obj.State.Properties.Assignee.IsVisible = !isNotNumerable;
}
public override void SetRequiredProperties()
{
base.SetRequiredProperties();
_obj.State.Properties.Subject.IsRequired = false;
}
public override bool NeedClearProject(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
{
return false;
}
[Obsolete("Используйте метод GetDefaultSignatory().")]
public override Sungero.Company.IEmployee GetDefaultSignatory(List<Docflow.Structures.SignatureSetting.Signatory> signatories)
{
if (Company.Employees.Current != null)
{
var businessUnit = Company.PublicFunctions.BusinessUnit.Remote.GetBusinessUnit(Company.Employees.Current);
var ceo = businessUnit != null ? businessUnit.CEO : null;
if (ceo != null && signatories.Any(s => Equals(s.EmployeeId, ceo.Id)))
return ceo;
}
return base.GetDefaultSignatory(signatories);
}
}
}