DocumentUsageReportHandlers.cs
2.25 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
namespace Sungero.Docflow
{
partial class DocumentUsageReportClientHandlers
{
public override void BeforeExecute(Sungero.Reporting.Client.BeforeExecuteEventArgs e)
{
if (DocumentUsageReport.PeriodBegin.HasValue && DocumentUsageReport.PeriodEnd.HasValue)
return;
var dialog = Dialogs.CreateInputDialog(Resources.DocumentUsageReportDialog);
dialog.HelpCode = Constants.DocumentUsageReport.HelpCode;
dialog.Buttons.AddOkCancel();
CommonLibrary.IDateDialogValue periodBegin = null;
CommonLibrary.IDateDialogValue periodEnd = null;
INavigationDialogValue<Company.IDepartment> department = null;
// Период.
var today = Calendar.UserToday;
if (!DocumentUsageReport.PeriodBegin.HasValue)
periodBegin = dialog.AddDate(Resources.DocumentUsagePeriodBegin, true, today.AddDays(-30));
if (!DocumentUsageReport.PeriodEnd.HasValue)
periodEnd = dialog.AddDate(Resources.DocumentUsagePeriodEnd, true, today);
if (DocumentUsageReport.Department == null)
department = dialog.AddSelect(Resources.Department, false, Company.Departments.Null)
.Where(x => x.Status == CoreEntities.DatabookEntry.Status.Active);
dialog.SetOnButtonClick((args) =>
{
Functions.Module.CheckReportDialogPeriod(args, periodBegin, periodEnd);
});
if (dialog.Show() != DialogButtons.Ok)
{
e.Cancel = true;
return;
}
if (!DocumentUsageReport.PeriodBegin.HasValue)
{
DocumentUsageReport.PeriodBegin = Docflow.PublicFunctions.Module.Remote.GetTenantDateTimeFromUserDay(periodBegin.Value.Value);
DocumentUsageReport.ClientPeriodBegin = periodBegin.Value.Value;
}
if (!DocumentUsageReport.PeriodEnd.HasValue)
{
DocumentUsageReport.PeriodEnd = periodEnd.Value.Value.EndOfDay().FromUserTime();
DocumentUsageReport.ClientPeriodEnd = periodEnd.Value.Value;
}
if (DocumentUsageReport.Department == null)
DocumentUsageReport.Department = department.Value;
}
}
}