|
@@ -25,603 +25,602 @@ using Syncfusion.UI.Xaml.Grid.Helpers;
|
|
|
using Syncfusion.Windows.Tools.Controls;
|
|
|
using SelectionChangedEventArgs = System.Windows.Controls.SelectionChangedEventArgs;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
+namespace PRSDesktop;
|
|
|
+
|
|
|
+public class EmployeeResourcePlannerValue
|
|
|
{
|
|
|
- public class EmployeeResourcePlannerValue
|
|
|
- {
|
|
|
- public Guid ID { get; set; }
|
|
|
-
|
|
|
- public Brush Background { get; set; }
|
|
|
- public Brush Foreground { get; set; }
|
|
|
- public String Text { get; set; }
|
|
|
+ public Guid ID { get; set; }
|
|
|
+
|
|
|
+ public Brush Background { get; set; }
|
|
|
+ public Brush Foreground { get; set; }
|
|
|
+ public String Text { get; set; }
|
|
|
|
|
|
- private String _color = "";
|
|
|
- public String Color
|
|
|
+ private String _color = "";
|
|
|
+ public String Color
|
|
|
+ {
|
|
|
+ get { return _color; }
|
|
|
+ set
|
|
|
{
|
|
|
- get { return _color; }
|
|
|
- set
|
|
|
- {
|
|
|
- _color = value;
|
|
|
- var color = String.IsNullOrWhiteSpace(value) ? Colors.Transparent : (Color)ColorConverter.ConvertFromString(value);
|
|
|
- Background = new SolidColorBrush(color);
|
|
|
- Foreground = new SolidColorBrush(ImageUtils.GetForegroundColor(color));
|
|
|
- }
|
|
|
+ _color = value;
|
|
|
+ var color = String.IsNullOrWhiteSpace(value) ? Colors.Transparent : (Color)ColorConverter.ConvertFromString(value);
|
|
|
+ Background = new SolidColorBrush(color);
|
|
|
+ Foreground = new SolidColorBrush(ImageUtils.GetForegroundColor(color));
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+public partial class EmployeeResourcePlanner : UserControl
|
|
|
+{
|
|
|
+
|
|
|
+ private enum Suppress
|
|
|
+ {
|
|
|
+ This
|
|
|
+ }
|
|
|
|
|
|
- public partial class EmployeeResourcePlanner : UserControl
|
|
|
+ private EmployeeResourceModel[] _employees = Array.Empty<EmployeeResourceModel>();
|
|
|
+ private StandardLeaveModel[] _standardleaves = Array.Empty<StandardLeaveModel>();
|
|
|
+ private LeaveRequestModel[] _leaverequests = Array.Empty<LeaveRequestModel>();
|
|
|
+ private JobModel[] _jobs = Array.Empty<JobModel>();
|
|
|
+ private ActivityModel[] _activities = Array.Empty<ActivityModel>();
|
|
|
+
|
|
|
+ private CoreFilterDefinitions _jobfilters = new CoreFilterDefinitions();
|
|
|
+
|
|
|
+ public event LoadSettings<EmployeeResourcePlannerProperties> LoadSettings;
|
|
|
+ public event SaveSettings<EmployeeResourcePlannerProperties> SaveSettings;
|
|
|
+
|
|
|
+ private void DoLoadSettings()
|
|
|
{
|
|
|
+ Properties = LoadSettings?.Invoke(this) ?? new EmployeeResourcePlannerProperties();
|
|
|
+ _jobfilters = new GlobalConfiguration<CoreFilterDefinitions>("Job").Load();
|
|
|
|
|
|
- private enum Suppress
|
|
|
- {
|
|
|
- This
|
|
|
- }
|
|
|
-
|
|
|
- private EmployeeResourceModel[] _employees = new EmployeeResourceModel[] { };
|
|
|
- private StandardLeaveModel[] _standardleaves = new StandardLeaveModel[] { };
|
|
|
- private LeaveRequestModel[] _leaverequests = new LeaveRequestModel[] { };
|
|
|
- private JobModel[] _jobs = new JobModel[] { };
|
|
|
- private ActivityModel[] _activities = new ActivityModel[] { };
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DoSaveSettings()
|
|
|
+ {
|
|
|
+ SaveSettings?.Invoke(this, Properties);
|
|
|
+ }
|
|
|
+
|
|
|
+ public EmployeeResourcePlannerProperties Properties { get; set; }
|
|
|
|
|
|
- private CoreFilterDefinitions _jobfilters = new CoreFilterDefinitions();
|
|
|
-
|
|
|
- public event LoadSettings<EmployeeResourcePlannerProperties> LoadSettings;
|
|
|
- public event SaveSettings<EmployeeResourcePlannerProperties> SaveSettings;
|
|
|
+ public EmployeeResourcePlanner()
|
|
|
+ {
|
|
|
+ using (new EventSuppressor(Suppress.This))
|
|
|
+ InitializeComponent();
|
|
|
+ }
|
|
|
|
|
|
- private void DoLoadSettings()
|
|
|
+ private Filter<Job>? GetJobFilter()
|
|
|
+ {
|
|
|
+ var jobfilter = _jobfilters.FirstOrDefault(x => String.Equals(x.Name, Properties.JobFilter));
|
|
|
+ return !String.IsNullOrWhiteSpace(jobfilter?.Filter)
|
|
|
+ ? Serialization.Deserialize<Filter<Job>>(jobfilter.Filter)
|
|
|
+ : LookupFactory.DefineFilter<Job>();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Setup()
|
|
|
+ {
|
|
|
+ using (new EventSuppressor(Suppress.This))
|
|
|
{
|
|
|
- Properties = LoadSettings?.Invoke(this) ?? new EmployeeResourcePlannerProperties();
|
|
|
- _jobfilters = new GlobalConfiguration<CoreFilterDefinitions>("Job").Load();
|
|
|
+ DoLoadSettings();
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- private void DoSaveSettings()
|
|
|
- {
|
|
|
- SaveSettings?.Invoke(this, Properties);
|
|
|
- }
|
|
|
-
|
|
|
- public EmployeeResourcePlannerProperties Properties { get; set; }
|
|
|
+ EmployeeSelector.Setup();
|
|
|
+ EmployeeSelector.Settings = Properties.EmployeeSettings;
|
|
|
+ EmployeeSelector.Selection = Properties.EmployeeSelection;
|
|
|
|
|
|
- public EmployeeResourcePlanner()
|
|
|
- {
|
|
|
- using (new EventSuppressor(Suppress.This))
|
|
|
- InitializeComponent();
|
|
|
- }
|
|
|
+ LeaveType.SelectedIndex = Properties.IncludeUnApprovedLeave ? 1 : 0;
|
|
|
|
|
|
- private Filter<Job>? GetJobFilter()
|
|
|
- {
|
|
|
- var jobfilter = _jobfilters.FirstOrDefault(x => String.Equals(x.Name, Properties.JobFilter));
|
|
|
- return !String.IsNullOrWhiteSpace(jobfilter?.Filter)
|
|
|
- ? Serialization.Deserialize<Filter<Job>>(jobfilter.Filter)
|
|
|
- : LookupFactory.DefineFilter<Job>();
|
|
|
- }
|
|
|
-
|
|
|
- public void Setup()
|
|
|
- {
|
|
|
- using (new EventSuppressor(Suppress.This))
|
|
|
- {
|
|
|
- DoLoadSettings();
|
|
|
-
|
|
|
- EmployeeSelector.Setup();
|
|
|
- EmployeeSelector.Settings = Properties.EmployeeSettings;
|
|
|
- EmployeeSelector.Selection = Properties.EmployeeSelection;
|
|
|
-
|
|
|
- LeaveType.SelectedIndex = Properties.IncludeUnApprovedLeave ? 1 : 0;
|
|
|
-
|
|
|
- FromDate.DateTime = DateTime.Today;
|
|
|
- ToDate.DateTime = DateTime.Today.AddYears(1);
|
|
|
-
|
|
|
- MultiQuery query = new MultiQuery();
|
|
|
-
|
|
|
- query.Add<Job>(
|
|
|
- GetJobFilter(),
|
|
|
- JobModel.Columns,
|
|
|
- new SortOrder<Job>(x => x.JobNumber)
|
|
|
- );
|
|
|
-
|
|
|
- query.Add<StandardLeave>(
|
|
|
- null,
|
|
|
- StandardLeaveModel.Columns
|
|
|
- );
|
|
|
-
|
|
|
- query.Add<LeaveRequest>(
|
|
|
- new Filter<LeaveRequest>(x => x.Status).IsNotEqualTo(LeaveRequestStatus.Rejected),
|
|
|
- LeaveRequestModel.Columns
|
|
|
- );
|
|
|
-
|
|
|
- query.Add<Activity>(
|
|
|
- LookupFactory.DefineFilter<Activity>(),
|
|
|
- new Columns<Activity>(x => x.ID).Add(x => x.Code).Add(x => x.Description),
|
|
|
- new SortOrder<Activity>(x => x.Code)
|
|
|
- );
|
|
|
-
|
|
|
- query.Query();
|
|
|
-
|
|
|
- _jobs = query.Get<Job>().Rows.Select(r => new JobModel(r)).ToArray();
|
|
|
- _standardleaves = query.Get<StandardLeave>().Rows.Select(r=>new StandardLeaveModel(r)).ToArray();
|
|
|
- _leaverequests = query.Get<LeaveRequest>().Rows.Select(r => new LeaveRequestModel(r)).ToArray();
|
|
|
- _activities = query.Get<Activity>().Rows.Select(r => new ActivityModel(r)).ToArray();
|
|
|
- ActivityType.ItemsSource = _activities;
|
|
|
- ActivityType.SelectedValue = Properties.ActivityType;
|
|
|
-
|
|
|
- JobFilter.ItemsSource = _jobfilters;
|
|
|
- JobFilter.SelectedValue = _jobfilters.FirstOrDefault(x => String.Equals(x.Name, Properties.JobFilter));
|
|
|
- }
|
|
|
+ FromDate.DateTime = DateTime.Today;
|
|
|
+ ToDate.DateTime = DateTime.Today.AddYears(1);
|
|
|
+
|
|
|
+ MultiQuery query = new MultiQuery();
|
|
|
+
|
|
|
+ query.Add<Job>(
|
|
|
+ GetJobFilter(),
|
|
|
+ JobModel.Columns,
|
|
|
+ new SortOrder<Job>(x => x.JobNumber)
|
|
|
+ );
|
|
|
+
|
|
|
+ query.Add<StandardLeave>(
|
|
|
+ null,
|
|
|
+ StandardLeaveModel.Columns
|
|
|
+ );
|
|
|
+
|
|
|
+ query.Add<LeaveRequest>(
|
|
|
+ new Filter<LeaveRequest>(x => x.Status).IsNotEqualTo(LeaveRequestStatus.Rejected),
|
|
|
+ LeaveRequestModel.Columns
|
|
|
+ );
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- public void Shutdown(CancelEventArgs? cancel)
|
|
|
- {
|
|
|
+ query.Add<Activity>(
|
|
|
+ LookupFactory.DefineFilter<Activity>(),
|
|
|
+ new Columns<Activity>(x => x.ID).Add(x => x.Code).Add(x => x.Description),
|
|
|
+ new SortOrder<Activity>(x => x.Code)
|
|
|
+ );
|
|
|
+
|
|
|
+ query.Query();
|
|
|
+
|
|
|
+ _jobs = query.Get<Job>().Rows.Select(r => new JobModel(r)).ToArray();
|
|
|
+ _standardleaves = query.Get<StandardLeave>().Rows.Select(r=>new StandardLeaveModel(r)).ToArray();
|
|
|
+ _leaverequests = query.Get<LeaveRequest>().Rows.Select(r => new LeaveRequestModel(r)).ToArray();
|
|
|
+ _activities = query.Get<Activity>().Rows.Select(r => new ActivityModel(r)).ToArray();
|
|
|
+ ActivityType.ItemsSource = _activities;
|
|
|
+ ActivityType.SelectedValue = Properties.ActivityType;
|
|
|
+
|
|
|
+ JobFilter.ItemsSource = _jobfilters;
|
|
|
+ JobFilter.SelectedValue = _jobfilters.FirstOrDefault(x => String.Equals(x.Name, Properties.JobFilter));
|
|
|
}
|
|
|
|
|
|
- public void Refresh()
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Shutdown(CancelEventArgs? cancel)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Refresh()
|
|
|
+ {
|
|
|
+ using (new WaitCursor())
|
|
|
{
|
|
|
- using (new WaitCursor())
|
|
|
- {
|
|
|
- _employees = EmployeeSelector.GetEmployeeData((row, rosters) => new EmployeeResourceModel(row, rosters));
|
|
|
- var empids = _employees.Select(x => x.ID).ToArray();
|
|
|
+ _employees = EmployeeSelector.GetEmployeeData((row, rosters) => new EmployeeResourceModel(row, rosters));
|
|
|
+ var empids = _employees.Select(x => x.ID).ToArray();
|
|
|
|
|
|
- DateTime fromdate = FromDate.DateTime.HasValue ? FromDate.DateTime.Value.Date : DateTime.Today;
|
|
|
- DateTime todate = ToDate.DateTime.HasValue ? ToDate.DateTime.Value.Date : DateTime.Today.AddYears(1);
|
|
|
+ DateTime fromdate = FromDate.DateTime.HasValue ? FromDate.DateTime.Value.Date : DateTime.Today;
|
|
|
+ DateTime todate = ToDate.DateTime.HasValue ? ToDate.DateTime.Value.Date : DateTime.Today.AddYears(1);
|
|
|
+
|
|
|
+ MultiQuery query = new MultiQuery();
|
|
|
+
|
|
|
+ query.Add<Assignment>(
|
|
|
+ new Filter<Assignment>(x => x.EmployeeLink.ID).InList(empids)
|
|
|
+ .And(x => x.Date).IsGreaterThanOrEqualTo(fromdate)
|
|
|
+ .And(x => x.Date).IsLessThanOrEqualTo(todate),
|
|
|
+ AssignmentModel.Columns,
|
|
|
+ new SortOrder<Assignment>(x => x.EmployeeLink.ID).ThenBy(x => x.Date).ThenBy(x => x.Booked.Duration, SortDirection.Descending)
|
|
|
+ );
|
|
|
|
|
|
- MultiQuery query = new MultiQuery();
|
|
|
-
|
|
|
- query.Add<Assignment>(
|
|
|
- new Filter<Assignment>(x => x.EmployeeLink.ID).InList(empids)
|
|
|
- .And(x => x.Date).IsGreaterThanOrEqualTo(fromdate)
|
|
|
- .And(x => x.Date).IsLessThanOrEqualTo(todate),
|
|
|
- AssignmentModel.Columns,
|
|
|
- new SortOrder<Assignment>(x => x.EmployeeLink.ID).ThenBy(x => x.Date).ThenBy(x => x.Booked.Duration, SortDirection.Descending)
|
|
|
- );
|
|
|
|
|
|
+ query.Query();
|
|
|
|
|
|
- query.Query();
|
|
|
+ var assignments = query.Get<Assignment>().Rows.Select(r => new AssignmentModel(r)).ToArray();
|
|
|
|
|
|
- var assignments = query.Get<Assignment>().Rows.Select(r => new AssignmentModel(r)).ToArray();
|
|
|
|
|
|
+ var data = new DataTable();
|
|
|
+ data.Columns.Add("Date", typeof(DateTime));
|
|
|
|
|
|
- var data = new DataTable();
|
|
|
- data.Columns.Add("Date", typeof(DateTime));
|
|
|
+ foreach (var employee in _employees)
|
|
|
+ data.Columns.Add(employee.ID.ToString(), typeof(object));
|
|
|
|
|
|
+ for (var curdate = fromdate; curdate <= todate; curdate = curdate.AddDays(1))
|
|
|
+ {
|
|
|
+ var leavevalue = GetStandardLeave(curdate, _standardleaves);
|
|
|
+ var values = new List<object> { curdate };
|
|
|
foreach (var employee in _employees)
|
|
|
- data.Columns.Add(employee.ID.ToString(), typeof(object));
|
|
|
-
|
|
|
- for (var curdate = fromdate; curdate <= todate; curdate = curdate.AddDays(1))
|
|
|
{
|
|
|
- var leavevalue = GetStandardLeave(curdate, _standardleaves);
|
|
|
- var values = new List<object> { curdate };
|
|
|
- foreach (var employee in _employees)
|
|
|
- {
|
|
|
- var value = new EmployeeResourcePlannerValue();
|
|
|
- var bOK = CheckAssignments(employee, curdate, assignments, value);
|
|
|
- bOK = bOK || CheckRoster(employee, curdate, value);
|
|
|
- bOK = bOK || CheckStandardLeave(leavevalue, value);
|
|
|
- bOK = bOK || CheckLeaveRequest(employee, curdate, _leaverequests, value);
|
|
|
+ var value = new EmployeeResourcePlannerValue();
|
|
|
+ var bOK = CheckAssignments(employee, curdate, assignments, value);
|
|
|
+ bOK = bOK || CheckRoster(employee, curdate, value);
|
|
|
+ bOK = bOK || CheckStandardLeave(leavevalue, value);
|
|
|
+ bOK = bOK || CheckLeaveRequest(employee, curdate, _leaverequests, value);
|
|
|
|
|
|
- values.Add(value);
|
|
|
- }
|
|
|
-
|
|
|
- data.Rows.Add(values.ToArray());
|
|
|
+ values.Add(value);
|
|
|
}
|
|
|
|
|
|
- dataGrid.ItemsSource = data;
|
|
|
+ data.Rows.Add(values.ToArray());
|
|
|
}
|
|
|
+
|
|
|
+ dataGrid.ItemsSource = data;
|
|
|
}
|
|
|
-
|
|
|
- private bool CheckAssignments(EmployeeResourceModel employee, DateTime curdate, AssignmentModel[] assignments, EmployeeResourcePlannerValue value)
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CheckAssignments(EmployeeResourceModel employee, DateTime curdate, AssignmentModel[] assignments, EmployeeResourcePlannerValue value)
|
|
|
+ {
|
|
|
+ var assignment = assignments.FirstOrDefault(x => (x.EmployeeID == employee.ID) && (x.Date == curdate.Date));
|
|
|
+ if (assignment == null)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ value.ID = assignment.ID;
|
|
|
+ value.Text = (value.ID != Guid.Empty) ? assignment.JobNumber : "XX";
|
|
|
+ value.Color = assignment.Color;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CheckRoster(EmployeeResourceModel employee, DateTime curdate, EmployeeResourcePlannerValue value)
|
|
|
+ {
|
|
|
+ value.Text = "";
|
|
|
+ var roster = RosterUtils.GetRoster(employee.Roster, employee.Start, curdate);
|
|
|
+
|
|
|
+ var color1 = Colors.LightGray;
|
|
|
+ var color2 = Colors.LightGray;
|
|
|
+ if (roster?.Enabled == true)
|
|
|
{
|
|
|
- var assignment = assignments.FirstOrDefault(x => (x.EmployeeID == employee.ID) && (x.Date == curdate.Date));
|
|
|
- if (assignment == null)
|
|
|
- return false;
|
|
|
-
|
|
|
- value.ID = assignment.ID;
|
|
|
- value.Text = (value.ID != Guid.Empty) ? assignment.JobNumber : "XX";
|
|
|
- value.Color = assignment.Color;
|
|
|
- return true;
|
|
|
+ color1 = Colors.LightYellow;
|
|
|
+ if (roster.Duration >= 5.0F)
|
|
|
+ color2 = Colors.LightYellow;
|
|
|
}
|
|
|
|
|
|
- private bool CheckRoster(EmployeeResourceModel employee, DateTime curdate, EmployeeResourcePlannerValue value)
|
|
|
- {
|
|
|
- value.Text = "";
|
|
|
- var roster = RosterUtils.GetRoster(employee.Roster, employee.Start, curdate);
|
|
|
+ value.Foreground = new SolidColorBrush(ImageUtils.GetForegroundColor(ImageUtils.MixColors(color1, 0.5, color2))) { Opacity = 0.8 };
|
|
|
+ value.Background = new LinearGradientBrush(color1,color2,90.0F) { Opacity = 0.8 };
|
|
|
|
|
|
- var color1 = Colors.LightGray;
|
|
|
- var color2 = Colors.LightGray;
|
|
|
- if (roster?.Enabled == true)
|
|
|
- {
|
|
|
- color1 = Colors.LightYellow;
|
|
|
- if (roster.Duration >= 5.0F)
|
|
|
- color2 = Colors.LightYellow;
|
|
|
- }
|
|
|
+ return roster?.Enabled == false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private EmployeeResourcePlannerValue? GetStandardLeave(DateTime curdate, StandardLeaveModel[] standardleaves)
|
|
|
+ {
|
|
|
+ var standardleave = standardleaves.FirstOrDefault(x =>
|
|
|
+ (x.From <= curdate)
|
|
|
+ && (x.To.Add(x.ToTime) > curdate)
|
|
|
+ );
|
|
|
+ return (standardleave != null)
|
|
|
+ ? new EmployeeResourcePlannerValue() { Text = standardleave.Code, Color = standardleave.Color}
|
|
|
+ : null;
|
|
|
+ }
|
|
|
|
|
|
- value.Foreground = new SolidColorBrush(ImageUtils.GetForegroundColor(ImageUtils.MixColors(color1, 0.5, color2))) { Opacity = 0.8 };
|
|
|
- value.Background = new LinearGradientBrush(color1,color2,90.0F) { Opacity = 0.8 };
|
|
|
+ private bool CheckStandardLeave(EmployeeResourcePlannerValue? leavevalue, EmployeeResourcePlannerValue value)
|
|
|
+ {
|
|
|
+ if (leavevalue == null)
|
|
|
+ return false;
|
|
|
+ value.Text = leavevalue.Text;
|
|
|
+ value.Color = leavevalue.Color;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CheckLeaveRequest(EmployeeResourceModel employee, DateTime curdate, LeaveRequestModel[] leaverequests, EmployeeResourcePlannerValue value)
|
|
|
+ {
|
|
|
+ var leaverequest = leaverequests.FirstOrDefault(c =>
|
|
|
+ (c.EmployeeID == employee.ID)
|
|
|
+ && (c.From <= curdate)
|
|
|
+ && (c.To.Add(c.ToTime) > curdate)
|
|
|
+ && (Properties.IncludeUnApprovedLeave ? true : c.Status == LeaveRequestStatus.Approved));
|
|
|
|
|
|
- return roster?.Enabled == false;
|
|
|
- }
|
|
|
-
|
|
|
- private EmployeeResourcePlannerValue? GetStandardLeave(DateTime curdate, StandardLeaveModel[] standardleaves)
|
|
|
+ if (leaverequest == null)
|
|
|
+ return false;
|
|
|
+ value.Text = leaverequest.Code;
|
|
|
+ value.Color = (leaverequest.Status == LeaveRequestStatus.Approved) ? leaverequest.Color : Colors.DimGray.ToString();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region AutoGenerate Columns / Styling
|
|
|
+
|
|
|
+ private class EmployeeResourcePlannerBackgroundConverter : IValueConverter
|
|
|
+ {
|
|
|
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- var standardleave = standardleaves.FirstOrDefault(x =>
|
|
|
- (x.From <= curdate)
|
|
|
- && (x.To.Add(x.ToTime) > curdate)
|
|
|
- );
|
|
|
- return (standardleave != null)
|
|
|
- ? new EmployeeResourcePlannerValue() { Text = standardleave.Code, Color = standardleave.Color}
|
|
|
- : null;
|
|
|
+ if (value is not EmployeeResourcePlannerValue val)
|
|
|
+ return DependencyProperty.UnsetValue;
|
|
|
+ return val.Background;
|
|
|
}
|
|
|
|
|
|
- private bool CheckStandardLeave(EmployeeResourcePlannerValue? leavevalue, EmployeeResourcePlannerValue value)
|
|
|
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- if (leavevalue == null)
|
|
|
- return false;
|
|
|
- value.Text = leavevalue.Text;
|
|
|
- value.Color = leavevalue.Color;
|
|
|
- return true;
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
-
|
|
|
- private bool CheckLeaveRequest(EmployeeResourceModel employee, DateTime curdate, LeaveRequestModel[] leaverequests, EmployeeResourcePlannerValue value)
|
|
|
+ }
|
|
|
+
|
|
|
+ private class EmployeeResourcePlannerForegroundConverter : IValueConverter
|
|
|
+ {
|
|
|
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- var leaverequest = leaverequests.FirstOrDefault(c =>
|
|
|
- (c.EmployeeID == employee.ID)
|
|
|
- && (c.From <= curdate)
|
|
|
- && (c.To.Add(c.ToTime) > curdate)
|
|
|
- && (Properties.IncludeUnApprovedLeave ? true : c.Status == LeaveRequestStatus.Approved));
|
|
|
-
|
|
|
- if (leaverequest == null)
|
|
|
- return false;
|
|
|
- value.Text = leaverequest.Code;
|
|
|
- value.Color = (leaverequest.Status == LeaveRequestStatus.Approved) ? leaverequest.Color : Colors.DimGray.ToString();
|
|
|
- return true;
|
|
|
+ if (value is not EmployeeResourcePlannerValue val)
|
|
|
+ return DependencyProperty.UnsetValue;
|
|
|
+ return val.Foreground;
|
|
|
}
|
|
|
-
|
|
|
- #region AutoGenerate Columns / Styling
|
|
|
-
|
|
|
- private class EmployeeResourcePlannerBackgroundConverter : IValueConverter
|
|
|
- {
|
|
|
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- if (value is not EmployeeResourcePlannerValue val)
|
|
|
- return DependencyProperty.UnsetValue;
|
|
|
- return val.Background;
|
|
|
- }
|
|
|
|
|
|
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private class EmployeeResourcePlannerForegroundConverter : IValueConverter
|
|
|
+ private class EmployeeResourcePlannerFontStyleConverter : IValueConverter
|
|
|
+ {
|
|
|
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- if (value is not EmployeeResourcePlannerValue val)
|
|
|
- return DependencyProperty.UnsetValue;
|
|
|
- return val.Foreground;
|
|
|
- }
|
|
|
-
|
|
|
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ if (value is not EmployeeResourcePlannerValue val)
|
|
|
+ return DependencyProperty.UnsetValue;
|
|
|
+ return FontStyles.Normal;
|
|
|
}
|
|
|
|
|
|
- private class EmployeeResourcePlannerFontStyleConverter : IValueConverter
|
|
|
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- if (value is not EmployeeResourcePlannerValue val)
|
|
|
- return DependencyProperty.UnsetValue;
|
|
|
- return FontStyles.Normal;
|
|
|
- }
|
|
|
-
|
|
|
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private class EmployeeResourcePlannerFontWeightConverter : IValueConverter
|
|
|
+ private class EmployeeResourcePlannerFontWeightConverter : IValueConverter
|
|
|
+ {
|
|
|
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- if (value is not EmployeeResourcePlannerValue val)
|
|
|
- return DependencyProperty.UnsetValue;
|
|
|
- return FontWeights.Normal;
|
|
|
- }
|
|
|
-
|
|
|
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ if (value is not EmployeeResourcePlannerValue val)
|
|
|
+ return DependencyProperty.UnsetValue;
|
|
|
+ return FontWeights.Normal;
|
|
|
}
|
|
|
|
|
|
- private class EmployeeResourcePlannerContentConverter : IValueConverter
|
|
|
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- if (value is not EmployeeResourcePlannerValue val)
|
|
|
- return DependencyProperty.UnsetValue;
|
|
|
- return val.Text;
|
|
|
- }
|
|
|
-
|
|
|
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
-
|
|
|
- private void DataGrid_AutoGeneratingColumn(object? sender, AutoGeneratingColumnArgs e)
|
|
|
+ }
|
|
|
+
|
|
|
+ private class EmployeeResourcePlannerContentConverter : IValueConverter
|
|
|
+ {
|
|
|
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
{
|
|
|
- e.Column.TextAlignment = TextAlignment.Center;
|
|
|
- e.Column.HorizontalHeaderContentAlignment = HorizontalAlignment.Center;
|
|
|
- e.Column.ColumnSizer = GridLengthUnitType.None;
|
|
|
+ if (value is not EmployeeResourcePlannerValue val)
|
|
|
+ return DependencyProperty.UnsetValue;
|
|
|
+ return val.Text;
|
|
|
+ }
|
|
|
|
|
|
- var value = (e.Column.ValueBinding as Binding)!;
|
|
|
- if (value.Path.Path.Equals("Date"))
|
|
|
- {
|
|
|
- e.Column.Width = 80;
|
|
|
- e.Column.HeaderStyle = Resources["DateHeaderStyle"] as Style;
|
|
|
- e.Column.AllowFocus = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var style = new Style(typeof(GridCell));
|
|
|
- style.Setters.Add(new Setter(BackgroundProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerBackgroundConverter() }));
|
|
|
- style.Setters.Add(new Setter(ForegroundProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerForegroundConverter() }));
|
|
|
- style.Setters.Add(new Setter(FontStyleProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerFontStyleConverter() }));
|
|
|
- style.Setters.Add(new Setter(FontWeightProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerFontWeightConverter() }));
|
|
|
- e.Column.CellStyle = style;
|
|
|
- e.Column.Width = 55;
|
|
|
- e.Column.HeaderStyle = Resources["ContentHeaderStyle"] as Style;
|
|
|
-
|
|
|
- e.Column.HeaderText = (Guid.TryParse(value.Path.Path, out Guid id))
|
|
|
- ? _employees.FirstOrDefault(x => String.Equals(x.ID, id))?.Name ?? value.Path.Path
|
|
|
- : value.Path.Path;
|
|
|
-
|
|
|
- e.Column.DisplayBinding = new Binding { Path = new PropertyPath(e.Column.MappingName), Converter = new EmployeeResourcePlannerContentConverter() };
|
|
|
- //e.Column.ValueBinding = new Binding() { Path = new PropertyPath(e.Column.MappingName), Converter = new LeaveContentConverter() };
|
|
|
- //e.Column.UseBindingValue = true;
|
|
|
- e.Column.AllowFocus = true;
|
|
|
- }
|
|
|
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DataGrid_AutoGeneratingColumn(object? sender, AutoGeneratingColumnArgs e)
|
|
|
+ {
|
|
|
+ e.Column.TextAlignment = TextAlignment.Center;
|
|
|
+ e.Column.HorizontalHeaderContentAlignment = HorizontalAlignment.Center;
|
|
|
+ e.Column.ColumnSizer = GridLengthUnitType.None;
|
|
|
|
|
|
- #endregion
|
|
|
-
|
|
|
- private bool HasData()
|
|
|
+ var value = (e.Column.ValueBinding as Binding)!;
|
|
|
+ if (value.Path.Path.Equals("Date"))
|
|
|
{
|
|
|
- foreach (var cell in dataGrid.GetSelectedCells())
|
|
|
- {
|
|
|
- if (!cell.IsDataRowCell)
|
|
|
- continue;
|
|
|
- var propertyCollection = dataGrid.View.GetPropertyAccessProvider();
|
|
|
- var cellValue = propertyCollection.GetValue(cell.RowData, cell.Column.MappingName);
|
|
|
- if (cellValue is EmployeeResourcePlannerValue val && val.ID != Guid.Empty)
|
|
|
- return true;
|
|
|
- }
|
|
|
+ e.Column.Width = 80;
|
|
|
+ e.Column.HeaderStyle = Resources["DateHeaderStyle"] as Style;
|
|
|
+ e.Column.AllowFocus = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var style = new Style(typeof(GridCell));
|
|
|
+ style.Setters.Add(new Setter(BackgroundProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerBackgroundConverter() }));
|
|
|
+ style.Setters.Add(new Setter(ForegroundProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerForegroundConverter() }));
|
|
|
+ style.Setters.Add(new Setter(FontStyleProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerFontStyleConverter() }));
|
|
|
+ style.Setters.Add(new Setter(FontWeightProperty, new Binding(value.Path.Path) { Converter = new EmployeeResourcePlannerFontWeightConverter() }));
|
|
|
+ e.Column.CellStyle = style;
|
|
|
+ e.Column.Width = 55;
|
|
|
+ e.Column.HeaderStyle = Resources["ContentHeaderStyle"] as Style;
|
|
|
|
|
|
- return false;
|
|
|
+ e.Column.HeaderText = (Guid.TryParse(value.Path.Path, out Guid id))
|
|
|
+ ? _employees.FirstOrDefault(x => String.Equals(x.ID, id))?.Name ?? value.Path.Path
|
|
|
+ : value.Path.Path;
|
|
|
+
|
|
|
+ e.Column.DisplayBinding = new Binding { Path = new PropertyPath(e.Column.MappingName), Converter = new EmployeeResourcePlannerContentConverter() };
|
|
|
+ //e.Column.ValueBinding = new Binding() { Path = new PropertyPath(e.Column.MappingName), Converter = new LeaveContentConverter() };
|
|
|
+ //e.Column.UseBindingValue = true;
|
|
|
+ e.Column.AllowFocus = true;
|
|
|
}
|
|
|
-
|
|
|
- private bool HasData(GridCellInfo cell)
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ private bool HasData()
|
|
|
+ {
|
|
|
+ foreach (var cell in dataGrid.GetSelectedCells())
|
|
|
{
|
|
|
if (!cell.IsDataRowCell)
|
|
|
- return false;
|
|
|
+ continue;
|
|
|
var propertyCollection = dataGrid.View.GetPropertyAccessProvider();
|
|
|
var cellValue = propertyCollection.GetValue(cell.RowData, cell.Column.MappingName);
|
|
|
- return cellValue is EmployeeResourcePlannerValue val && val.ID != Guid.Empty;
|
|
|
+ if (cellValue is EmployeeResourcePlannerValue val && val.ID != Guid.Empty)
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- private void DataGrid_ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool HasData(GridCellInfo cell)
|
|
|
+ {
|
|
|
+ if (!cell.IsDataRowCell)
|
|
|
+ return false;
|
|
|
+ var propertyCollection = dataGrid.View.GetPropertyAccessProvider();
|
|
|
+ var cellValue = propertyCollection.GetValue(cell.RowData, cell.Column.MappingName);
|
|
|
+ return cellValue is EmployeeResourcePlannerValue val && val.ID != Guid.Empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DataGrid_ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
|
|
+ {
|
|
|
+ var vc = dataGrid.GetVisualContainer();
|
|
|
+ var p = Mouse.GetPosition(vc);
|
|
|
+ var rci = vc.PointToCellRowColumnIndex(p);
|
|
|
+ if (rci.RowIndex < 1 || rci.ColumnIndex < 1)
|
|
|
{
|
|
|
- var vc = dataGrid.GetVisualContainer();
|
|
|
- var p = Mouse.GetPosition(vc);
|
|
|
- var rci = vc.PointToCellRowColumnIndex(p);
|
|
|
- if (rci.RowIndex < 1 || rci.ColumnIndex < 1)
|
|
|
- {
|
|
|
- e.Handled = true;
|
|
|
- return;
|
|
|
- }
|
|
|
+ e.Handled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- dataGrid.ContextMenu.Items.Clear();
|
|
|
- var bAssign = !HasData(dataGrid.CurrentCellInfo);
|
|
|
- var bClear = HasData();
|
|
|
+ dataGrid.ContextMenu.Items.Clear();
|
|
|
+ var bAssign = !HasData(dataGrid.CurrentCellInfo);
|
|
|
+ var bClear = HasData();
|
|
|
|
|
|
- if (bAssign)
|
|
|
+ if (bAssign)
|
|
|
+ {
|
|
|
+ foreach (var job in _jobs)
|
|
|
{
|
|
|
- foreach (var job in _jobs)
|
|
|
+ var assign = new MenuItem
|
|
|
{
|
|
|
- var assign = new MenuItem
|
|
|
- {
|
|
|
- Header = job.Name,
|
|
|
- Tag = job
|
|
|
- };
|
|
|
- assign.Click += AssignJobClick;
|
|
|
- dataGrid.ContextMenu.Items.Add(assign);
|
|
|
- }
|
|
|
+ Header = job.Name,
|
|
|
+ Tag = job
|
|
|
+ };
|
|
|
+ assign.Click += AssignJobClick;
|
|
|
+ dataGrid.ContextMenu.Items.Add(assign);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (bClear && bAssign)
|
|
|
- dataGrid.ContextMenu.Items.Add(new Separator());
|
|
|
-
|
|
|
-
|
|
|
- if (bClear)
|
|
|
- {
|
|
|
- var clear = new MenuItem { Header = "Clear Assignments" };
|
|
|
- clear.Click += ClearJobClick;
|
|
|
- dataGrid.ContextMenu.Items.Add(clear);
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private void GetSelectionData(out DateTime from, out DateTime to, out Guid[] employees, out Guid[] assignments)
|
|
|
+
|
|
|
+ if (bClear && bAssign)
|
|
|
+ dataGrid.ContextMenu.Items.Add(new Separator());
|
|
|
+
|
|
|
+
|
|
|
+ if (bClear)
|
|
|
{
|
|
|
- var emps = new List<Guid>();
|
|
|
- var items = new List<Guid>();
|
|
|
- from = DateTime.MaxValue;
|
|
|
- to = DateTime.MinValue;
|
|
|
- foreach (var cell in dataGrid.GetSelectedCells())
|
|
|
- {
|
|
|
- var binding = (cell.Column.ValueBinding as Binding)!;
|
|
|
- if (Guid.TryParse(binding.Path.Path, out var emp))
|
|
|
- if (!emps.Contains(emp))
|
|
|
- emps.Add(emp);
|
|
|
- var row = (cell.RowData as DataRowView)!;
|
|
|
- var date = (DateTime)row.Row.ItemArray.First()!;
|
|
|
- if (date < from)
|
|
|
- from = date;
|
|
|
- if (date > to)
|
|
|
- to = date;
|
|
|
- Guid itemid = (row[binding.Path.Path] as EmployeeResourcePlannerValue).ID;
|
|
|
- if (itemid != Guid.Empty)
|
|
|
- items.Add(itemid);
|
|
|
- }
|
|
|
-
|
|
|
- employees = emps.ToArray();
|
|
|
- assignments = items.ToArray();
|
|
|
+ var clear = new MenuItem { Header = "Clear Assignments" };
|
|
|
+ clear.Click += ClearJobClick;
|
|
|
+ dataGrid.ContextMenu.Items.Add(clear);
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GetSelectionData(out DateTime from, out DateTime to, out Guid[] employees, out Guid[] assignments)
|
|
|
+ {
|
|
|
+ var emps = new List<Guid>();
|
|
|
+ var items = new List<Guid>();
|
|
|
+ from = DateTime.MaxValue;
|
|
|
+ to = DateTime.MinValue;
|
|
|
+ foreach (var cell in dataGrid.GetSelectedCells())
|
|
|
+ {
|
|
|
+ var binding = (cell.Column.ValueBinding as Binding)!;
|
|
|
+ if (Guid.TryParse(binding.Path.Path, out var emp))
|
|
|
+ if (!emps.Contains(emp))
|
|
|
+ emps.Add(emp);
|
|
|
+ var row = (cell.RowData as DataRowView)!;
|
|
|
+ var date = (DateTime)row.Row.ItemArray.First()!;
|
|
|
+ if (date < from)
|
|
|
+ from = date;
|
|
|
+ if (date > to)
|
|
|
+ to = date;
|
|
|
+ Guid itemid = (row[binding.Path.Path] as EmployeeResourcePlannerValue).ID;
|
|
|
+ if (itemid != Guid.Empty)
|
|
|
+ items.Add(itemid);
|
|
|
+ }
|
|
|
+
|
|
|
+ employees = emps.ToArray();
|
|
|
+ assignments = items.ToArray();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- private void AssignJobClick(object sender, RoutedEventArgs e)
|
|
|
+ private void AssignJobClick(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if ((sender as MenuItem)?.Tag is not JobModel job)
|
|
|
+ return;
|
|
|
+ GetSelectionData(out var from, out var to, out var ids, out var assignments);
|
|
|
+ var updates = new List<Assignment>();
|
|
|
+ foreach (var id in ids)
|
|
|
{
|
|
|
- JobModel? job = (sender as MenuItem)?.Tag as JobModel;
|
|
|
- if (job == null)
|
|
|
- return;
|
|
|
- GetSelectionData(out var from, out var to, out var ids, out var assignments);
|
|
|
- var updates = new List<Assignment>();
|
|
|
- foreach (var id in ids)
|
|
|
+ for (DateTime curdate = from; curdate <= to; curdate = curdate.AddDays(1))
|
|
|
{
|
|
|
- for (DateTime curdate = from; curdate <= to; curdate = curdate.AddDays(1))
|
|
|
+ var employee = _employees.FirstOrDefault(x => x.ID == id);
|
|
|
+ if (employee != null)
|
|
|
{
|
|
|
- var employee = _employees.FirstOrDefault(x => x.ID == id);
|
|
|
- if (employee != null)
|
|
|
+ bool bAvail =
|
|
|
+ (GetStandardLeave(curdate, _standardleaves) == null)
|
|
|
+ && !CheckLeaveRequest(employee, curdate, _leaverequests, new EmployeeResourcePlannerValue());
|
|
|
+
|
|
|
+ var roster = bAvail ? RosterUtils.GetRoster(employee.Roster, employee.Start, curdate) : null;
|
|
|
+ if (roster?.Enabled == true)
|
|
|
{
|
|
|
- bool bAvail =
|
|
|
- (GetStandardLeave(curdate, _standardleaves) == null)
|
|
|
- && !CheckLeaveRequest(employee, curdate, _leaverequests, new EmployeeResourcePlannerValue());
|
|
|
-
|
|
|
- var roster = bAvail ? RosterUtils.GetRoster(employee.Roster, employee.Start, curdate) : null;
|
|
|
- if (roster?.Enabled == true)
|
|
|
- {
|
|
|
- var assign = new Assignment();
|
|
|
- assign.Date = curdate;
|
|
|
- assign.Booked.Start = roster.Start;
|
|
|
- assign.Booked.Finish = roster.Finish;
|
|
|
- assign.JobLink.ID = job.ID;
|
|
|
- assign.EmployeeLink.ID = id;
|
|
|
- assign.ActivityLink.ID = Properties.ActivityType;
|
|
|
- updates.Add(assign);
|
|
|
- }
|
|
|
-
|
|
|
- if (roster?.SplitShift == true)
|
|
|
- {
|
|
|
- var assign = new Assignment();
|
|
|
- assign.Date = curdate;
|
|
|
- assign.Booked.Start = roster.Start2;
|
|
|
- assign.Booked.Finish = roster.Finish2;
|
|
|
- assign.JobLink.ID = job.ID;
|
|
|
- assign.EmployeeLink.ID = id;
|
|
|
- assign.ActivityLink.ID = Properties.ActivityType;
|
|
|
- updates.Add(assign);
|
|
|
- }
|
|
|
+ var assign = new Assignment();
|
|
|
+ assign.Date = curdate;
|
|
|
+ assign.Booked.Start = roster.Start;
|
|
|
+ assign.Booked.Finish = roster.Finish;
|
|
|
+ assign.JobLink.ID = job.ID;
|
|
|
+ assign.EmployeeLink.ID = id;
|
|
|
+ assign.ActivityLink.ID = Properties.ActivityType;
|
|
|
+ assign.JobScope.ID = job.DefaultScopeID;
|
|
|
+ updates.Add(assign);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (roster?.SplitShift == true)
|
|
|
+ {
|
|
|
+ var assign = new Assignment();
|
|
|
+ assign.Date = curdate;
|
|
|
+ assign.Booked.Start = roster.Start2;
|
|
|
+ assign.Booked.Finish = roster.Finish2;
|
|
|
+ assign.JobLink.ID = job.ID;
|
|
|
+ assign.EmployeeLink.ID = id;
|
|
|
+ assign.ActivityLink.ID = Properties.ActivityType;
|
|
|
+ assign.JobScope.ID = job.DefaultScopeID;
|
|
|
+ updates.Add(assign);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (updates.Any())
|
|
|
+ }
|
|
|
+ if (updates.Any())
|
|
|
+ {
|
|
|
+ using (new WaitCursor())
|
|
|
{
|
|
|
- using (new WaitCursor())
|
|
|
- {
|
|
|
- new Client<Assignment>().Save(updates, "Assigned from Employee Resource Planner");
|
|
|
- Refresh();
|
|
|
- }
|
|
|
+ new Client<Assignment>().Save(updates, "Assigned from Employee Resource Planner");
|
|
|
+ Refresh();
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- private void ClearJobClick(object sender, RoutedEventArgs e)
|
|
|
+ private void ClearJobClick(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ GetSelectionData(out DateTime from, out DateTime to, out Guid[] ids, out Guid[] assignments);
|
|
|
+ if (assignments.Any() && MessageBox.Show("Clear Assignments?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
{
|
|
|
- GetSelectionData(out DateTime from, out DateTime to, out Guid[] ids, out Guid[] assignments);
|
|
|
- if (assignments.Any() && MessageBox.Show("Clear Assignments?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
+ var deletes = assignments.Select(x => new Assignment() { ID = x }).ToArray();
|
|
|
+ using (new WaitCursor())
|
|
|
{
|
|
|
- var deletes = assignments.Select(x => new Assignment() { ID = x }).ToArray();
|
|
|
- using (new WaitCursor())
|
|
|
- {
|
|
|
- new Client<Assignment>().Delete(deletes, "Deleted from Employee Resource Planner");
|
|
|
- Refresh();
|
|
|
- }
|
|
|
+ new Client<Assignment>().Delete(deletes, "Deleted from Employee Resource Planner");
|
|
|
+ Refresh();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public void Heartbeat(TimeSpan time)
|
|
|
- {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Heartbeat(TimeSpan time)
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- private void _employees_OnSettingsChanged(object sender, EmployeeSelectorSettingsChangedArgs args)
|
|
|
- {
|
|
|
- Properties.EmployeeSettings = args.Settings;
|
|
|
- DoSaveSettings();
|
|
|
- }
|
|
|
+ private void _employees_OnSettingsChanged(object sender, EmployeeSelectorSettingsChangedArgs args)
|
|
|
+ {
|
|
|
+ Properties.EmployeeSettings = args.Settings;
|
|
|
+ DoSaveSettings();
|
|
|
+ }
|
|
|
|
|
|
- private void _employees_OnSelectionChanged(object sender, EmployeeSelectorSelectionChangedArgs args)
|
|
|
- {
|
|
|
- Properties.EmployeeSelection = args.Selection;
|
|
|
- DoSaveSettings();
|
|
|
- Refresh();
|
|
|
- }
|
|
|
+ private void _employees_OnSelectionChanged(object sender, EmployeeSelectorSelectionChangedArgs args)
|
|
|
+ {
|
|
|
+ Properties.EmployeeSelection = args.Selection;
|
|
|
+ DoSaveSettings();
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
|
|
|
- private void DateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
- {
|
|
|
- if (EventSuppressor.IsSet(Suppress.This))
|
|
|
- return;
|
|
|
- Refresh();
|
|
|
- }
|
|
|
+ private void DateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (EventSuppressor.IsSet(Suppress.This))
|
|
|
+ return;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
|
|
|
- private void LeaveType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
- if (EventSuppressor.IsSet(Suppress.This))
|
|
|
- return;
|
|
|
- Properties.IncludeUnApprovedLeave = LeaveType.SelectedIndex > 0;
|
|
|
- DoSaveSettings();
|
|
|
- Refresh();
|
|
|
- }
|
|
|
+ private void LeaveType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (EventSuppressor.IsSet(Suppress.This))
|
|
|
+ return;
|
|
|
+ Properties.IncludeUnApprovedLeave = LeaveType.SelectedIndex > 0;
|
|
|
+ DoSaveSettings();
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
|
|
|
- private void ActivityType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
- if (EventSuppressor.IsSet(Suppress.This))
|
|
|
- return;
|
|
|
- Properties.ActivityType = (Guid)(ActivityType.SelectedValue ?? Guid.Empty);
|
|
|
- DoSaveSettings();
|
|
|
- }
|
|
|
+ private void ActivityType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (EventSuppressor.IsSet(Suppress.This))
|
|
|
+ return;
|
|
|
+ Properties.ActivityType = (Guid)(ActivityType.SelectedValue ?? Guid.Empty);
|
|
|
+ DoSaveSettings();
|
|
|
+ }
|
|
|
|
|
|
- private void JobFilter_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ private void JobFilter_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (EventSuppressor.IsSet(Suppress.This))
|
|
|
+ return;
|
|
|
+ var sel = JobFilter.SelectedValue as CoreFilterDefinition;
|
|
|
+ Properties.JobFilter = sel?.Name ?? "";
|
|
|
+ using (new WaitCursor())
|
|
|
{
|
|
|
- if (EventSuppressor.IsSet(Suppress.This))
|
|
|
- return;
|
|
|
- var sel = JobFilter.SelectedValue as CoreFilterDefinition;
|
|
|
- Properties.JobFilter = sel?.Name ?? "";
|
|
|
- using (new WaitCursor())
|
|
|
- {
|
|
|
- DoSaveSettings();
|
|
|
- _jobs = new Client<Job>().Query(
|
|
|
- GetJobFilter(),
|
|
|
- JobModel.Columns,
|
|
|
- new SortOrder<Job>(x => x.JobNumber)
|
|
|
- ).Rows.Select(r => new JobModel(r)).ToArray();
|
|
|
- }
|
|
|
+ DoSaveSettings();
|
|
|
+ _jobs = new Client<Job>().Query(
|
|
|
+ GetJobFilter(),
|
|
|
+ JobModel.Columns,
|
|
|
+ new SortOrder<Job>(x => x.JobNumber)
|
|
|
+ ).Rows.Select(r => new JobModel(r)).ToArray();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private void JobFilterButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ private void JobFilterButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ var window = new DynamicGridFilterEditor(_jobfilters, typeof(Job));
|
|
|
+ if (window.ShowDialog() == true)
|
|
|
{
|
|
|
- var window = new DynamicGridFilterEditor(_jobfilters, typeof(Job));
|
|
|
- if (window.ShowDialog() == true)
|
|
|
- {
|
|
|
- new GlobalConfiguration<CoreFilterDefinitions>("Job").Save(_jobfilters);
|
|
|
- JobFilter.SelectedValue = _jobfilters.FirstOrDefault(x => String.Equals(x.Name, Properties.JobFilter));
|
|
|
- }
|
|
|
+ new GlobalConfiguration<CoreFilterDefinitions>("Job").Save(_jobfilters);
|
|
|
+ JobFilter.SelectedValue = _jobfilters.FirstOrDefault(x => String.Equals(x.Name, Properties.JobFilter));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
+}
|