144 lines
5.4 KiB
C#
144 lines
5.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using EnVisage.Models;
|
|
using EnVisage.Code.DAL.Mongo;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
/// <summary>
|
|
/// Represents a data model for the Mix entity. This model is used to communicat between server and client.
|
|
/// </summary>
|
|
public class MixCalendarModel
|
|
{
|
|
/// <summary>Contains ends of all working weeks</summary>
|
|
public List<long> FiscalCalendarWeekEndings { get; set; }
|
|
|
|
/// <summary>Contains Years->Months->Days</summary>
|
|
public Dictionary<string, Dictionary<string, List<int>>> WeekEndings { get; set; }
|
|
|
|
public Dictionary<string, MixProjectModel> Projects { get; set; }
|
|
public List<Guid> ManagedProjects { get; set; }
|
|
public List<Guid> UnscheduledProjects { get; set; }
|
|
public List<Guid> QueuedProjects { get; set; }
|
|
public List<CategoryExpenditureInProject> UnassignedExpendituresProjects { get; set; } // SA. ENV-1210
|
|
public List<MixTeamLayoutRowItem> Layout { get; set; }
|
|
|
|
/// <summary>
|
|
/// Selected in the filter teams
|
|
/// </summary>
|
|
public List<MixTeamModel> Teams { get; set; }
|
|
public Dictionary<string, Dictionary<string, int>> Vacations { get; set; }
|
|
public Dictionary<string, Dictionary<string, int>> Trainings { get; set; }
|
|
|
|
|
|
public MixCalendarModel()
|
|
{
|
|
FiscalCalendarWeekEndings = new List<long>();
|
|
WeekEndings = new Dictionary<string, Dictionary<string, List<int>>>();
|
|
Teams = new List<MixTeamModel>();
|
|
Projects = new Dictionary<string, MixProjectModel>();
|
|
Vacations = new Dictionary<string, Dictionary<string, int>>();
|
|
Trainings = new Dictionary<string, Dictionary<string, int>>();
|
|
|
|
ManagedProjects = new List<Guid>();
|
|
UnscheduledProjects = new List<Guid>();
|
|
QueuedProjects = new List<Guid>();
|
|
UnassignedExpendituresProjects = new List<CategoryExpenditureInProject>(); // SA. ENV-1210
|
|
Layout = new List<MixTeamLayoutRowItem>();
|
|
}
|
|
|
|
public void AssignFrom(Mix mongoMix)
|
|
{
|
|
if (mongoMix.Projects != null)
|
|
{
|
|
Projects = mongoMix.Projects.Select(p => new MixProjectModel()
|
|
{
|
|
Id = p.Value.Id,
|
|
Name = p.Value.Name,
|
|
Pinned = p.Value.Pinned,
|
|
Scenario = (ScenarioCalendarMixModel)p.Value.Scenario,
|
|
Teams = p.Value.Teams.Select(t => t).ToList()
|
|
}).ToDictionary(k => k.Id.ToString());
|
|
}
|
|
|
|
if (mongoMix.Teams != null)
|
|
{
|
|
Teams = mongoMix.Teams.Select(x => new MixTeamModel
|
|
{
|
|
Id = x.Id,
|
|
Name = x.Name,
|
|
IsNew = x.IsNew,
|
|
CompanyId = x.CompanyId,
|
|
CostCenterId = x.CostCenterId,
|
|
UserId = (x.UserId != null) ? x.UserId : null,
|
|
PlannedCapacity = (x.PlannedCapacity != null) ? x.PlannedCapacity.ToList() : new List<MixTeamCapacity>(),
|
|
ExpCategories = (x.ExpCategories != null) ? x.ExpCategories.Select(ec => new ActivityExpCategoryFooterModel()
|
|
{
|
|
Id = ec.Value.Id,
|
|
Name = ec.Value.Name,
|
|
NeedCapacity = ec.Value.NeedCapacity,
|
|
ActualCapacityValues = ec.Value.ActualCapacityValues,
|
|
AllocatedCapacity = ec.Value.AllocatedCapacity,
|
|
PlannedCapacityValues = ec.Value.PlannedCapacityValues,
|
|
UomValue = ec.Value.UomValue,
|
|
Resources = (ec.Value.Resources != null) ? ec.Value.Resources.Select(r => new ActivityResourceFooterModel()
|
|
{
|
|
Id = r.Value.Id,
|
|
Name = r.Value.Name,
|
|
AllocatedCapacity = r.Value.AllocatedCapacity,
|
|
TotalCapacity = r.Value.TotalCapacity
|
|
}).ToDictionary(k => k.Id.ToString(), v => v) : new Dictionary<string, ActivityResourceFooterModel>()
|
|
}).ToDictionary(k => k.Id.ToString(), v => v) : new Dictionary<string, ActivityExpCategoryFooterModel>()
|
|
}).ToList();
|
|
}
|
|
|
|
ManagedProjects = new List<Guid>();
|
|
UnscheduledProjects = new List<Guid>();
|
|
QueuedProjects = new List<Guid>();
|
|
UnassignedExpendituresProjects = new List<CategoryExpenditureInProject>(); // SA. ENV-1210
|
|
|
|
if (mongoMix.ManagedProjects != null)
|
|
ManagedProjects.AddRange(mongoMix.ManagedProjects);
|
|
|
|
if (mongoMix.UnscheduledProjects != null)
|
|
UnscheduledProjects.AddRange(mongoMix.UnscheduledProjects);
|
|
|
|
if (mongoMix.QueuedProjects != null)
|
|
QueuedProjects.AddRange(mongoMix.QueuedProjects);
|
|
|
|
// SA. ENV-1210
|
|
if (mongoMix.UnassignedExpProjects != null)
|
|
UnassignedExpendituresProjects = mongoMix.UnassignedExpProjects.Select(i =>
|
|
new CategoryExpenditureInProject
|
|
{
|
|
ProjectId = i.ProjectId,
|
|
ExpCatId = i.ExpCatId,
|
|
TargetTeamId = i.TargetTeamId,
|
|
Name = i.Name
|
|
}).ToList();
|
|
|
|
|
|
Layout = mongoMix.Layout.Select(l => new MixTeamLayoutRowItem()
|
|
{
|
|
Index = l.Index,
|
|
Row = l.Row,
|
|
ProjectId = l.ProjectId,
|
|
TeamId = l.TeamId
|
|
}).ToList();
|
|
}
|
|
}
|
|
|
|
// SA. ENV-1210.
|
|
public class CategoryExpenditureInProject
|
|
{
|
|
public CategoryExpenditureInProject()
|
|
{
|
|
}
|
|
|
|
public Guid ProjectId { get; set; }
|
|
public Guid ExpCatId { get; set; }
|
|
public Guid? TargetTeamId { get; set; }
|
|
public string Name { get; set; }
|
|
}
|
|
} |