BusinessUnitBoxHandlers.cs
3.12 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.Company;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.ExchangeCore.BusinessUnitBox;
namespace Sungero.ExchangeCore
{
partial class BusinessUnitBoxCertificateReceiptNotificationsPropertyFilteringServerHandler<T>
{
public virtual IQueryable<T> CertificateReceiptNotificationsFiltering(IQueryable<T> query, Sungero.Domain.PropertyFilteringEventArgs e)
{
var exchangeBoxCertificates = _obj.ExchangeServiceCertificates.Select(c => c.Certificate).ToList();
return query.Where(x => x.Enabled == true && exchangeBoxCertificates.Contains(x));
}
}
partial class BusinessUnitBoxExchangeServicePropertyFilteringServerHandler<T>
{
public virtual IQueryable<T> ExchangeServiceFiltering(IQueryable<T> query, Sungero.Domain.PropertyFilteringEventArgs e)
{
if (_obj.Status == Sungero.CoreEntities.DatabookEntry.Status.Active && _obj.BusinessUnit != null)
{
var alreadyUsedServices = Functions.BusinessUnitBox.GetUsedServicesOfBox(_obj, _obj.BusinessUnit);
if (alreadyUsedServices.Any())
query = query
.Where(x => !alreadyUsedServices.Contains(x));
}
return query;
}
}
partial class BusinessUnitBoxServerHandlers
{
public override void AfterSave(Sungero.Domain.AfterSaveEventArgs e)
{
base.AfterSave(e);
if (!e.Params.Contains(Constants.BoxBase.JobRunned))
Jobs.SyncBoxes.Enqueue();
}
public override void Created(Sungero.Domain.CreatedEventArgs e)
{
base.Created(e);
_obj.ConnectionStatus = ConnectionStatus.Waiting;
}
public override void BeforeSave(Sungero.Domain.BeforeSaveEventArgs e)
{
base.BeforeSave(e);
Functions.BusinessUnitBox.SetBusinessUnitBoxName(_obj);
Functions.BusinessUnitBox.CheckConnection(_obj);
var errors = Functions.BusinessUnitBox.BeforeSaveCheckProperties(_obj);
foreach (var error in errors)
e.AddError(error.Key, error.Value);
if (_obj.Status == Sungero.CoreEntities.DatabookEntry.Status.Active)
{
if (!Functions.BusinessUnitBox.CheckAllResponsibleCertificates(_obj, _obj.Responsible))
e.AddWarning(_obj.Info.Properties.Responsible, BusinessUnitBoxes.Resources.CertificateNotFound, _obj.Info.Properties.Responsible);
if (!Functions.BusinessUnitBox.CheckBusinessUnitTinTRRC(_obj))
e.AddWarning(BusinessUnitBoxes.Resources.OrganizationFailed);
}
}
}
partial class BusinessUnitBoxCreatingFromServerHandler
{
public override void CreatingFrom(Sungero.Domain.CreatingFromEventArgs e)
{
base.CreatingFrom(e);
e.Without(_info.Properties.Login);
e.Without(_info.Properties.Password);
e.Without(_info.Properties.OrganizationId);
e.Without(_info.Properties.ExchangeService);
e.Without(_info.Properties.FtsId);
e.Without(_info.Properties.ExchangeServiceCertificates);
e.Without(_info.Properties.HasExchangeServiceCertificates);
e.Without(_info.Properties.CertificateReceiptNotifications);
}
}
}