EnVisageOnline/Main/Source/EnVisage/Models/OptimuseModel.cs

153 lines
3.9 KiB
C#

namespace EnVisage.Models
{
using System;
using System.Collections.Generic;
using System.Linq;
public class OptimuseModel
{
#region Properties
public List<long> WeekEndings { get; set; }
public OptimuseCapacityModel ActualCapacity { get; set; }
public OptimuseCapacityModel PlannedCapacity { get; set; }
#endregion
#region Constructors
public OptimuseModel()
{
WeekEndings = new List<long>();
ActualCapacity = new OptimuseCapacityModel();
PlannedCapacity = new OptimuseCapacityModel();
}
#endregion
}
public class OptimuseCapacityModel
{
#region Properties
public long TotalHoursCapacity { get; set; }
public long TotalResourcesCapacity { get; set; }
public OptimuseSummaryModel OverAllocatedSummary { get; set; }
public OptimuseSummaryModel UnderAllocatedSummary { get; set; }
public OptimuseSummaryModel IdealAllocatedSummary { get; set; }
#endregion
#region Constructors
public OptimuseCapacityModel()
{
OverAllocatedSummary = new OptimuseSummaryModel();
UnderAllocatedSummary = new OptimuseSummaryModel();
IdealAllocatedSummary = new OptimuseSummaryModel();
}
#endregion
}
public class OptimuseSummaryModel
{
#region Properties
public long MinResourcesValue
{
get
{
if (ResourceUsageData.Count <= 0)
return 0;
return ResourceUsageData.Values.Min(x => Math.Abs(x));
}
}
public long MaxResourcesValue
{
get
{
if (ResourceUsageData.Count <= 0)
return 0;
return ResourceUsageData.Values.Max(x => Math.Abs(x));
}
}
public long MinHoursValue
{
get
{
if (HoursUsageData.Count <= 0)
return 0;
return HoursUsageData.Values.Min(x => Math.Abs(x));
}
}
public long MaxHoursValue
{
get
{
if (HoursUsageData.Count <= 0)
return 0;
return HoursUsageData.Values.Max(x => Math.Abs(x));
}
}
public long TotalHoursValue
{
get
{
return HoursUsageData.Values.Sum(x => Math.Abs(x));
}
}
public long TotalResourcesValue
{
get
{
return ResourceUsageData.Values.Sum(x => Math.Abs(x));
}
}
public int Weeks { get; private set; }
public Dictionary<string, long> ResourceUsageData { get; private set; }
public Dictionary<string, long> HoursUsageData { get; private set; }
#endregion
#region Constructors
public OptimuseSummaryModel()
{
ResourceUsageData = new Dictionary<string, long>();
HoursUsageData = new Dictionary<string, long>();
}
#endregion
#region Methods
public void AddItem(string key, long hoursValue, long resourcesValue)
{
if (string.IsNullOrWhiteSpace(key))
throw new ArgumentNullException("key");
if (HoursUsageData.ContainsKey(key))
throw new ArgumentException(string.Format("An element with the key {0} already exists in the HoursUsageData dictionary", key));
if (ResourceUsageData.ContainsKey(key))
throw new ArgumentException(string.Format("An element with the key {0} already exists in the ResourceUsageData dictionary", key));
HoursUsageData.Add(key, hoursValue);
ResourceUsageData.Add(key, resourcesValue);
Weeks += 1;
}
#endregion
}
}