ApprovalRuleBaseHandlers.cs
3.8 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Docflow.ApprovalRuleBase;
namespace Sungero.Docflow
{
partial class ApprovalRuleBaseConditionsSharedCollectionHandlers
{
public virtual void ConditionsAdded(Sungero.Domain.Shared.CollectionPropertyAddedEventArgs e)
{
_added.Number = Functions.ApprovalRuleBase.GetNextNumber(_obj);
}
}
partial class ApprovalRuleBaseTransitionsSharedCollectionHandlers
{
public virtual void TransitionsAdded(Sungero.Domain.Shared.CollectionPropertyAddedEventArgs e)
{
_added.ConditionValue = null;
}
}
partial class ApprovalRuleBaseSharedHandlers
{
public virtual void ReworkPerformerTypeChanged(Sungero.Domain.Shared.EnumerationPropertyChangedEventArgs e)
{
Functions.ApprovalRuleBase.SetStateProperties(_obj);
if (!Equals(e.NewValue, ApprovalRuleBase.ReworkPerformerType.EmployeeRole) && !Equals(e.NewValue, e.OldValue))
_obj.ReworkPerformer = null;
if (!Equals(e.NewValue, ApprovalRuleBase.ReworkPerformerType.ApprovalRole) && !Equals(e.NewValue, e.OldValue))
_obj.ReworkApprovalRole = null;
}
public virtual void DocumentKindsChanged(Sungero.Domain.Shared.CollectionPropertyChangedEventArgs e)
{
var availableDocumentGroups = Functions.ApprovalRuleBase.GetAvailableDocumentGroups(_obj);
var suitableDocumentGroups = _obj.DocumentGroups.Select(d => d.DocumentGroup).Where(dg => availableDocumentGroups.Contains(dg)).ToList();
if (suitableDocumentGroups.Count < _obj.DocumentGroups.Count())
{
Functions.Module.TryToShowNotifyMessage(Functions.ApprovalRuleBase.GetIncompatibleDocumentGroupsExcludedHint(_obj));
_obj.DocumentGroups.Clear();
foreach (var documentGroup in suitableDocumentGroups)
_obj.DocumentGroups.AddNew().DocumentGroup = documentGroup;
}
_obj.State.Properties.DocumentGroups.IsEnabled = availableDocumentGroups.Any();
}
public virtual void DocumentFlowChanged(Sungero.Domain.Shared.EnumerationPropertyChangedEventArgs e)
{
if (e.NewValue != e.OldValue && e.NewValue != null)
{
var suitableDocumentKinds = _obj.DocumentKinds.Where(dk => dk.DocumentKind.DocumentFlow == e.NewValue).Select(k => k.DocumentKind).ToList();
if (suitableDocumentKinds.Count < _obj.DocumentKinds.Count())
{
Functions.Module.TryToShowNotifyMessage(ApprovalRuleBases.Resources.IncompatibleDocumentKindsExcluded);
_obj.DocumentKinds.Clear();
foreach (var documentKind in suitableDocumentKinds)
_obj.DocumentKinds.AddNew().DocumentKind = documentKind;
}
}
}
}
partial class ApprovalRuleBaseStagesSharedHandlers
{
public virtual void StagesStageBaseChanged(Sungero.Docflow.Shared.ApprovalRuleBaseStagesStageBaseChangedEventArgs e)
{
if (e.NewValue == null || !ApprovalStages.Is(e.NewValue))
_obj.Stage = null;
else if (!Equals(e.NewValue, _obj.Stage))
_obj.Stage = ApprovalStages.As(e.NewValue);
_obj.StageType = e.NewValue == null ? null : Functions.ApprovalStageBase.GetStageType(e.NewValue);
}
public virtual void StagesStageChanged(Sungero.Docflow.Shared.ApprovalRuleBaseStagesStageChangedEventArgs e)
{
if (!Equals(e.NewValue, _obj.StageBase) && e.NewValue != null)
_obj.StageBase = e.NewValue;
_obj.StageType = e.NewValue == null ? null : Functions.ApprovalStageBase.GetStageType(e.NewValue);
}
}
partial class ApprovalRuleBaseStagesSharedCollectionHandlers
{
public virtual void StagesAdded(Sungero.Domain.Shared.CollectionPropertyAddedEventArgs e)
{
_added.Number = Functions.ApprovalRuleBase.GetNextNumber(_obj);
}
}
}