EnVisageOnline/Main-RMO/Source/EnVisage/Models/CapacityManagmentModel.cs

370 lines
14 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using EnVisage.Code;
using System.Linq;
using System.Web.Mvc;
namespace EnVisage.Models
{
public class CapacityDetailsModel
{
public enum Spread
{
Notspecified = -1,
Equal = 0,
Less = 1,
Over = 2
}
public enum RowType
{
Project = 0,
ProjectExpenditureCategory = 1,
Vacation = 2,
Training = 3,
LoanOut = 4,
Total = 5,
Capacity = 6,
BottomCategory = 7,
Team = 8
}
public class ScenarioCalendarRowResource
{
public Guid Id { get; set; }
public Guid? ExpedentureCategoryId { get; set; }
public string Name { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
/// <summary>
/// Gets or sets a weekly array of quantity values.
/// </summary>
public decimal[] QuantityValues { get; set; }
/// <summary>
/// Gets or sets a weekly array of resource availability (i.e. UOM-vacations-trainings-loanouts) values.
/// </summary>
public decimal[] CapacityQuantityValues { get; set; }
/// <summary>
/// Gets or sets a weekly array of resource rest quantity.
/// </summary>
public decimal[] AllocatedQuantityValues { get; set; }
/// <summary>
/// Gets or sets an array of resource vacation weekly allocations.
/// </summary>
public decimal[] VacationQuantityValues { get; set; }
/// <summary>
/// Gets or sets an array of resource training weekly allocations.
/// </summary>
public decimal[] TrainingQuantityValues { get; set; }
/// <summary>
/// Gets or sets a total resource quantity for the row.
/// </summary>
public decimal GrandTotalQuantity { get; set; }
public Spread[] SpreadVal { get; set; }
/// <summary>
/// Gets or sets a weekly array of resource capacity (i.e. UOM value).
/// </summary>
public decimal[] QuantityTotalResValue { get; set; }
public bool ReadOnly { get; set; }
public bool[] ReadOnlyWeeks { get; set; }
public Guid TeamId { get; set; }
public bool AssignedToTeam { get; set; }
public Guid[] ProjectIds { get; set; }
public bool IsActiveEmployee { get; set; }
}
public class CalendarScenarioItem
{
public Guid Id { get; set; }
public string Name { get; set; }
}
public class CalendarRow
{
public Guid? ProjectId { get; set; }
public Guid? ParentProjectId { get; set; }
public Guid? PartId { get; set; }
public string Name { get; set; }
public string Name1 { get; set; }
public string Color { get; set; }
public Guid? ScenarioId { get; set; }
public Guid? ExpCatId { get; set; }
public bool EmptyScenario { get; set; }
/// <summary>
/// Gets or sets a start date of data in this row.
/// </summary>
/// <remarks>
/// 1. Project. Start Date of the project.
/// 2. Expenditure Category. Min date where scenario details records contain non-zero values. Could be zero cells in the middle of this range.
/// 3. Resource. Min date where scenario details records contain non-zero values. Could be zero cells in the middle of this range.
/// </remarks>
public long? StartDate { get; set; }
/// <summary>
/// Gets or sets an end date of data in this row.
/// </summary>
/// <remarks>
/// 1. Project. End Date and End Date of project.
/// 2. Expenditure Category. Max date where scenario details records contain non-zero values. Could be zero cells in the middle of the row.
/// 3. Resource. Max date where scenario details records contain non-zero values. Could be zero cells in the middle of this range.
/// </remarks>
public long? EndDate { get; set; }
public Guid? ResourceToAssignId { get; set; }
public ExpenditureCategoryModel.UseTypes UseType { get; set; }
public decimal[] QuantityValues { get; set; }
public decimal QuantityResValue { get; set; }
/// <summary>
/// Gets or sets a weekly array of expenditure category capacity (i.e. UOM value * number of resources).
/// </summary>
public decimal[] QuantityTotalResValue { get; set; }
public decimal[] QuantityExpCatTotalValue { get; set; }
//public decimal[] CostValues { get; set; }
public Guid?[] DetailIds { get; set; }
public bool ProjectCollapsed { get; set; }
public bool ScenarioCollapsed { get; set; }
public bool ExpCatCollapsed { get; set; }
public string CollapsedClass { get; set; }
public decimal[] RestQuantity { get; set; }
public decimal[] RestCost { get; set; }
public bool IsParentCollapsed { get; set; }
public bool IsUpperHidden { get; set; }
public bool IsLowerHidden { get; set; }
public bool IsTotals { get; set; }
public RowType RowType { get; set; }
public Spread[] SpreadVal { get; set; }
public bool[] ReadOnly { get; set; }
public Guid? TeamId { get; set; }
/// <summary>
/// Assigned to current project teams
/// </summary>
public List<ActiveScenariosTeams> Teams { get; set; }
public List<ScenarioCalendarRowResource> Resources { get; set; }
public CalendarScenarioItem[] InactiveScenarios { get; set; }
public CalendarRow()
{
QuantityValues = new decimal[0];
DetailIds = new Guid?[0];
CollapsedClass = "fa-plus-square";
RestQuantity = new decimal[0];
RestCost = new decimal[0];
ScenarioCollapsed = true;
ExpCatCollapsed = true;
ProjectCollapsed = true;
IsParentCollapsed = true;
IsTotals = false;
RowType = RowType.ProjectExpenditureCategory;
SpreadVal = new Spread[0];
EmptyScenario = true;
ReadOnly = new bool[0];
InactiveScenarios = new CalendarScenarioItem[0];
Teams = new List<ActiveScenariosTeams>();
}
}
public class Header
{
/// <summary>
/// Gets or sets a number of milliseconds between month end date and 1/1/1970.
/// </summary>
public long Milliseconds { get; set; }
/// <summary>
/// Gets or sets an index of the related month cell.
/// </summary>
public int MonthIndex { get; set; }
public int YearIndex { get; set; }
/// <summary>
/// Gets or sets a values indicating whether the header cell is collapsed or not.
/// </summary>
public bool Collapsed { get; set; }
/// <summary>
/// Gets or sets a values indicating whether to show header cell.
/// </summary>
public bool Show { get; set; }
/// <summary>
/// Gets or sets a values indicating whether the header cell represents a month or a week.
/// </summary>
public bool IsMonth { get; set; }
/// <summary>
/// Gets or sets a CSS class used for the <i>plus/minus</i> icons in the month header.
/// </summary>
public string CollapsedClass { get; set; }
/// <summary>
/// Gets or sets a text of the header cell.
/// </summary>
public string Title { get; set; }
public string Year { get; set; }
/// <summary>
/// Gets or sets an array of indexes of children cells. I.e. week cells for month cell.
/// </summary>
public int SpanCount { get; set; }
public List<int> Weeks { get; set; }
public Header()
{
Collapsed = true;
Show = false;
CollapsedClass = "fa-plus-square";
SpanCount = 0;
}
}
public class ActiveScenariosTeams
{
/// <summary>
/// Gets or sets a number of milliseconds between month end date and 1/1/1970.
/// </summary>
public Guid Id { get; set; }
public decimal[] QuantityValues { get; set; }
public decimal[] AllocatedByResources { get; set; }
public ActiveScenariosTeams()
{
}
}
/// <summary>
/// Available options for filters on a page
/// </summary>
/// <remarks>SA. ENV-799</remarks>
public class FilterOptions
{
public List<SelectListItem> Companies = new List<SelectListItem>();
public List<SelectListItem> Teams = new List<SelectListItem>();
public List<SelectListItem> Views = new List<SelectListItem>();
public List<SelectListItem> Resources = new List<SelectListItem>();
}
/// <summary>
/// Options to fill filters on the page
/// </summary>
/// <remarks>SA. ENV-799</remarks>
public FilterOptions OptionsForFilters { get; set; }
public bool PreferredTotalsDisplaying { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public Guid? CompanyId { get; set; }
public Guid? TeamId { get; set; }
public Guid? ResourceId { get; set; }
public Guid? ViewId { get; set; }
public bool GrowthScenario { get; set; }
public Guid ParentId { get; set; }
public long ActualsEndDateMs { get; set; }
/// <summary>
/// Indicates whether capacity management grid data is in Hours or in Resources.<br/>
/// null - data in Hours<br/>
/// true - data in Hours<br/>
/// false - data in Resources.
/// </summary>
[Display(Name = "Resources Mode")]
public bool IsUOMHours { get; set; }
public bool GroupByTeam { get; set; }
public bool IsCapacityModeActuals { get; set; }
//public decimal uomResourcesMultiplier { get; set; }
//public decimal uomHoursMultiplier { get; set; }
public List<SelectListItem> AvailableExpenditures { get; set; }
public List<ScenarioCalendarRowResource> AllResources { get; set; }
public string sortBy { get; set; }
public bool sortOrder { get; set; }
/// <summary>
/// Gets or sets a list of scenario details data for each expenditure category.
/// </summary>
public List<CalendarRow> Calendar { get; set; }
public List<Header> Headers { get; set; }
public List<Header> YearHeaders { get; set; }
public CapacityDetailsModel()
{
AvailableExpenditures = new List<SelectListItem>();
Calendar = new List<CalendarRow>();
Headers = new List<Header>();
YearHeaders = new List<Header>();
//uomResourcesMultiplier =Utils.GetUOMMultiplier(false);
//uomHoursMultiplier = Utils.GetUOMMultiplier(true);
// SA. ENV-799
OptionsForFilters = new FilterOptions();
}
}
public class SaveCapacityDetailsChangesModel
{
public class ChangedRow
{
public Guid Id { get; set; }
public Guid ScenarioId { get; set; }
public List<ChangedColumn> Values { get; set; }
public List<ResourcesRow> Resources { get; set; }
public ChangedRow()
{
Values = new List<ChangedColumn>();
}
}
public class ResourcesRow
{
public Guid Id { get; set; }
public List<ChangedColumn> Values { get; set; }
public bool IsAdded { get; set; }
public bool IsRemoved { get; set; }
}
public class ChangedColumn
{
public Guid? Id { get; set; }
/// <summary>
/// Number of milliseconds from 1/1/1970
/// </summary>
public long Milliseconds { get; set; }
public decimal Cost { get; set; }
public decimal Quantity { get; set; }
}
//public Guid ScenarioId { get; set; }
public List<ChangedRow> ChangedExpCats { get; set; }
public CapacityDetailsModel ScenarioFilters { get; set; }
public SaveCapacityDetailsChangesModel()
{
ChangedExpCats = new List<ChangedRow>();
}
}
public class CapacityDetailsOptionsModel
{
public string MenuId { get; set; }
public string AdditionalFilterParams { get; set; }
}
// SA. ENV-799
public class CapacityPageInitOption
{
public bool ShowUpper;
public bool ShowLower;
public bool IsUOMHours;
public bool PreferredTotalsDisplaying;
public bool IsBarMode;
public bool IsViewModeMonth;
public bool IsCapacityModeActuals;
public bool GroupByTeam;
public int ShowCapacity;
public string StartDate;
public string EndDate;
public string MenuId;
public string ModelType;
public string PagePreferences;
public string DataSection;
// SA. ENV-905. Backurl page name - to return to this page
public string PageTitle;
public CapacityDetailsModel.FilterOptions FilterOptions;
public Guid? CompanyId;
public Guid? ViewId;
public Guid? TeamId;
public Guid? ResourceId;
};
}