DepartmentsAssignmentCompletionReportHandlers.cs
3.98 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
namespace Sungero.Docflow
{
partial class DepartmentsAssignmentCompletionReportServerHandlers
{
public override void AfterExecute(Sungero.Reporting.Server.AfterExecuteEventArgs e)
{
Functions.Module.DeleteReportData(Constants.DepartmentsAssignmentCompletionReport.SourceTableName, DepartmentsAssignmentCompletionReport.ReportSessionId);
}
public override void BeforeExecute(Sungero.Reporting.Server.BeforeExecuteEventArgs e)
{
var reportSessionId = System.Guid.NewGuid().ToString();
DepartmentsAssignmentCompletionReport.ReportSessionId = reportSessionId;
DepartmentsAssignmentCompletionReport.ReportDate = Calendar.Now;
DepartmentsAssignmentCompletionReport.DetailedReportLink = Hyperlinks.Functions.OpenEmployeesAssignmentCompletionReport("HyperlinkBusinessUnitId",
int.MaxValue.ToString(),
DepartmentsAssignmentCompletionReport.PeriodBegin.ToString(),
DepartmentsAssignmentCompletionReport.PeriodEnd.ToString(),
"Unwrap");
var departmentIds = DepartmentsAssignmentCompletionReport.DepartmentIds.Where(d => d != null).Select(d => d.Value).ToList();
var businessUnitIds = DepartmentsAssignmentCompletionReport.BusinessUnitIds.Where(d => d != null).Select(d => d.Value).ToList();
if (DepartmentsAssignmentCompletionReport.WidgetParameter == null)
{
if (DepartmentsAssignmentCompletionReport.BusinessUnit != null)
DepartmentsAssignmentCompletionReport.ParamsDescription += Docflow.Resources.ReportBusinessUnitFormat(DepartmentsAssignmentCompletionReport.BusinessUnit.Name,
System.Environment.NewLine);
if (DepartmentsAssignmentCompletionReport.Department != null)
DepartmentsAssignmentCompletionReport.ParamsDescription += Docflow.Resources.ReportDepartmentFormat(DepartmentsAssignmentCompletionReport.Department.Name, System.Environment.NewLine);
}
else if (!string.IsNullOrEmpty(DepartmentsAssignmentCompletionReport.WidgetParameter))
{
DepartmentsAssignmentCompletionReport.ParamsDescription += Docflow.Resources.ReportEmployeesFormat(DepartmentsAssignmentCompletionReport.WidgetParameter);
}
var needFilter = DepartmentsAssignmentCompletionReport.BusinessUnit != null || DepartmentsAssignmentCompletionReport.Department != null;
var tableData = Functions.Module.GetBusinessUnitAssignmentCompletionReportData(businessUnitIds,
departmentIds,
DepartmentsAssignmentCompletionReport.PeriodBegin.Value, DepartmentsAssignmentCompletionReport.PeriodEnd.Value.EndOfDay(),
DepartmentsAssignmentCompletionReport.Unwrap == true,
DepartmentsAssignmentCompletionReport.WithSubstitution == true, needFilter);
var rowIndex = 1;
foreach (var item in tableData)
{
item.RowIndex = rowIndex++;
item.ReportSessionId = reportSessionId;
}
Functions.Module.WriteStructuresToTable(Constants.DepartmentsAssignmentCompletionReport.SourceTableName, tableData);
}
}
}