|
@@ -69,8 +69,8 @@ namespace PRSDesktop
|
|
|
|
|
|
public class EmployeeQualificationDashboardProperties : IDashboardProperties
|
|
|
{
|
|
|
- public List<Guid>? Employees { get; set; } = null;
|
|
|
- public List<Guid>? Qualifications { get; set; } = null;
|
|
|
+ public Dictionary<Guid, bool>? Employees { get; set; } = null;
|
|
|
+ public Dictionary<Guid, bool>? Qualifications { get; set; } = null;
|
|
|
}
|
|
|
|
|
|
public class EmployeeQualificationDashboardElement : DashboardElement<EmployeeQualificationDashboard, HumanResources, EmployeeQualificationDashboardProperties> { }
|
|
@@ -83,8 +83,9 @@ namespace PRSDesktop
|
|
|
private DataTable DataTable;
|
|
|
private CoreTable CoreTable;
|
|
|
|
|
|
- private HashSet<Guid> Employees;
|
|
|
- private HashSet<Guid> Qualifications;
|
|
|
+ private List<Guid> AllEmployees;
|
|
|
+ private Dictionary<Guid, bool> Employees;
|
|
|
+ private Dictionary<Guid, bool> Qualifications;
|
|
|
|
|
|
private Dictionary<Guid, string> ColumnHeaders;
|
|
|
|
|
@@ -107,8 +108,8 @@ namespace PRSDesktop
|
|
|
|
|
|
public void Refresh()
|
|
|
{
|
|
|
- Properties.Qualifications = Qualifications.ToList();
|
|
|
- Properties.Employees = Employees.ToList();
|
|
|
+ Properties.Qualifications = Qualifications;
|
|
|
+ Properties.Employees = Employees;
|
|
|
|
|
|
CoreTable = new();
|
|
|
CoreTable.TableName = "Qualifications";
|
|
@@ -117,7 +118,7 @@ namespace PRSDesktop
|
|
|
var employeeFilter = EmployeeFilter;
|
|
|
var results = Client.QueryMultiple(
|
|
|
new KeyedQueryDef<Employee>(nameof(Employee),
|
|
|
- employeeFilter,
|
|
|
+ new Filter<Employee>(x => x.ID).InList(Employees.Where(x => x.Value).Select(x => x.Key).ToArray()),
|
|
|
new Columns<Employee>(x => x.ID, x => x.Name)),
|
|
|
new KeyedQueryDef<EmployeeQualification>(nameof(EmployeeQualification),
|
|
|
new Filter<EmployeeQualification>(x => x.Employee.ID).InQuery(employeeFilter, x => x.ID),
|
|
@@ -126,7 +127,7 @@ namespace PRSDesktop
|
|
|
x => x.Qualification.ID,
|
|
|
x => x.Expiry)),
|
|
|
new KeyedQueryDef<Qualification>(nameof(Qualification),
|
|
|
- new Filter<Qualification>(x => x.ID).InList(Qualifications.ToArray()),
|
|
|
+ new Filter<Qualification>(x => x.ID).InList(Qualifications.Where(x => x.Value).Select(x => x.Key).ToArray()),
|
|
|
new Columns<Qualification>(x => x.ID, x => x.Description)));
|
|
|
|
|
|
CoreTable.Columns.Add(new CoreColumn() { ColumnName = "Employee", DataType = typeof(string) });
|
|
@@ -152,10 +153,6 @@ namespace PRSDesktop
|
|
|
foreach (var employee in results[nameof(Employee)].Rows)
|
|
|
{
|
|
|
var employeeID = employee.Get<Employee, Guid>(x => x.ID);
|
|
|
- if (!Employees.Contains(employeeID))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
EmployeeIDs.Add(employeeID);
|
|
|
|
|
|
List<object?> values = new()
|
|
@@ -205,23 +202,41 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static bool IsEmployeeActive(Employee employee)
|
|
|
+ => (employee.StartDate == DateTime.MinValue || employee.StartDate < DateTime.Now)
|
|
|
+ && (employee.FinishDate == DateTime.MinValue || employee.FinishDate > DateTime.Now);
|
|
|
+
|
|
|
public void Setup()
|
|
|
{
|
|
|
- var employees = Properties.Employees?.ToHashSet();
|
|
|
- var qualifications = Properties.Qualifications?.ToHashSet();
|
|
|
- if (employees == null || qualifications == null)
|
|
|
+ var employeeFilter = EmployeeFilter;
|
|
|
+ var results = Client.QueryMultiple(
|
|
|
+ new KeyedQueryDef<Employee>(nameof(Employee),
|
|
|
+ new Filter<Employee>().All(),
|
|
|
+ new Columns<Employee>(x => x.ID, x => x.StartDate, x => x.FinishDate)),
|
|
|
+ new KeyedQueryDef<Qualification>(nameof(Qualification),
|
|
|
+ new Filter<Qualification>().All(),
|
|
|
+ new Columns<Qualification>(x => x.ID)));
|
|
|
+
|
|
|
+ var employees = results[nameof(Employee)].ToObjects<Employee>().ToDictionary(
|
|
|
+ x => x.ID,
|
|
|
+ x => IsEmployeeActive(x));
|
|
|
+ if (Properties.Employees is not null)
|
|
|
+ {
|
|
|
+ employees = employees
|
|
|
+ .ToDictionary(
|
|
|
+ x => x.Key,
|
|
|
+ x => !Properties.Employees.ContainsKey(x.Key) || Properties.Employees[x.Key]);
|
|
|
+ }
|
|
|
+
|
|
|
+ var qualifications = results[nameof(Qualification)].Rows.Select(x => x.Get<Qualification, Guid>(x => x.ID)).ToDictionary(x => x, x => true);
|
|
|
+ if(Properties.Qualifications is not null)
|
|
|
{
|
|
|
- var employeeFilter = EmployeeFilter;
|
|
|
- var results = Client.QueryMultiple(
|
|
|
- new KeyedQueryDef<Employee>(nameof(Employee), employeeFilter, new Columns<Employee>(x => x.ID, x => x.StartDate, x => x.FinishDate)),
|
|
|
- new KeyedQueryDef<Qualification>(nameof(Qualification),
|
|
|
- new Filter<Qualification>().All(),
|
|
|
- new Columns<Qualification>(x => x.ID)));
|
|
|
-
|
|
|
-
|
|
|
- employees ??= results[nameof(Employee)].Rows.Select(x => x.Get<Employee, Guid>(x => x.ID)).ToHashSet();
|
|
|
- qualifications ??= results[nameof(Qualification)].Rows.Select(x => x.Get<Qualification, Guid>(x => x.ID)).ToHashSet();
|
|
|
+ qualifications = qualifications
|
|
|
+ .ToDictionary(
|
|
|
+ x => x.Key,
|
|
|
+ x => !Properties.Qualifications.ContainsKey(x.Key) || Properties.Qualifications[x.Key]);
|
|
|
}
|
|
|
+
|
|
|
Employees = employees;
|
|
|
Qualifications = qualifications;
|
|
|
|
|
@@ -386,7 +401,7 @@ namespace PRSDesktop
|
|
|
var hideQualification = new MenuItem() { Header = $"Hide '{column.ColumnName}'" };
|
|
|
hideQualification.Click += (sender, e) =>
|
|
|
{
|
|
|
- Qualifications.Remove(QualificationIDs[rci.ColumnIndex - 1]);
|
|
|
+ Qualifications[QualificationIDs[rci.ColumnIndex - 1]] = false;
|
|
|
Refresh();
|
|
|
};
|
|
|
menu.Items.Add(hideQualification);
|
|
@@ -404,7 +419,7 @@ namespace PRSDesktop
|
|
|
var hideEmployee = new MenuItem() { Header = $"Hide '{row["Employee"]}'" };
|
|
|
hideEmployee.Click += (sender, e) =>
|
|
|
{
|
|
|
- Employees.Remove(EmployeeIDs[rci.RowIndex - 1]);
|
|
|
+ Employees[EmployeeIDs[rci.RowIndex - 1]] = false;
|
|
|
Refresh();
|
|
|
};
|
|
|
menu.Items.Add(hideEmployee);
|
|
@@ -419,17 +434,23 @@ namespace PRSDesktop
|
|
|
|
|
|
private void SelectEmployee_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- var window = new EntitySelectionWindow(typeof(Employee), Employees, typeof(EmployeeSelectionGrid));
|
|
|
+ var window = new EntitySelectionWindow(typeof(Employee), Employees.Where(x => x.Value).Select(x => x.Key).ToHashSet(), typeof(EmployeeSelectionGrid));
|
|
|
window.ShowDialog();
|
|
|
- Employees = window.Entities;
|
|
|
+
|
|
|
+ Employees = Employees.ToDictionary(
|
|
|
+ x => x.Key,
|
|
|
+ x => window.Entities.Contains(x.Key));
|
|
|
+
|
|
|
Refresh();
|
|
|
}
|
|
|
|
|
|
private void SelectQualification_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- var window = new EntitySelectionWindow(typeof(Qualification), Qualifications);
|
|
|
+ var window = new EntitySelectionWindow(typeof(Qualification), Qualifications.Where(x => x.Value).Select(x => x.Key).ToHashSet());
|
|
|
window.ShowDialog();
|
|
|
- Qualifications = window.Entities;
|
|
|
+ Qualifications = Qualifications.ToDictionary(
|
|
|
+ x => x.Key,
|
|
|
+ x => window.Entities.Contains(x.Key));
|
|
|
Refresh();
|
|
|
}
|
|
|
|