EnVisageOnline/Main/Source/EnVisage/Code/DAL/Mix.cs

152 lines
4.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using EnVisage.Models;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace EnVisage.Code.DAL.Mongo
{
[BsonIgnoreExtraElements]
[Serializable]
public abstract class BaseDALClass
{
[BsonId]
public ObjectId Id { get; set; }
public string CreatedBy { get; set; }
public DateTime CreatedAtUtc { get; set; }
}
[BsonIgnoreExtraElements]
[Serializable]
public class MixBase : BaseDALClass
{
public ObjectId Key { get; set; }
public string Name { get; set; }
public long StartDate { get; set; }
public long EndDate { get; set; }
public List<Guid> Users { get; set; }
}
/// <summary>
/// Represents information about any Mix.
/// </summary>
[BsonIgnoreExtraElements]
[Serializable]
public class Mix : MixBase
{
public List<MixTeam> Teams { get; set; }
public List<MixTeamView> TeamsViews { get; set; }
public Dictionary<string, MixProject> Projects { get; set; }
public List<Guid> ManagedProjects { get; set; }
public List<Guid> UnscheduledProjects { get; set; }
public List<Guid> QueuedProjects { get; set; }
public List<CategoryExpenditureInMongoProject> UnassignedExpProjects { get; set; } // SA. ENV-1210
public List<MixTeamLayoutRowItem> Layout { get; set; }
public Mix()
{
Teams = new List<MixTeam>();
TeamsViews = new List<MixTeamView>();
Users = new List<Guid>();
Projects = new Dictionary<string, MixProject>();
ManagedProjects = new List<Guid>();
UnscheduledProjects = new List<Guid>();
QueuedProjects = new List<Guid>();
UnassignedExpProjects = new List<CategoryExpenditureInMongoProject>(); // SA. ENV-1210
Layout = new List<MixTeamLayoutRowItem>();
}
}
[BsonIgnoreExtraElements]
[Serializable]
public class BaseAllocation<T>
{
[BsonId]
public ObjectId Id { get; set; }
public ObjectId MixId { get; set; }
public Guid ScenarioId { get; set; }
public DateTime CreatedAtUtc { get; set; }
public string CreatedBy { get; set; }
public Dictionary<string, T> Allocations { get; set; }
public BaseAllocation()
{
Allocations = new Dictionary<string, T>();
}
}
[BsonIgnoreExtraElements]
[Serializable]
public class MixTeamAllocation : BaseAllocation<decimal>
{
public string TeamId { get; set; }
public Guid ExpCatId { get; set; }
public string Name { get; set; }
public Dictionary<string, MixResourceAllocation> AllResources { get; set; }
public MixTeamAllocation()
: base()
{
AllResources = new Dictionary<string, MixResourceAllocation>();
}
}
[BsonIgnoreExtraElements]
[Serializable]
public class MixResourceAllocation : BaseAllocation<decimal>
{
public string TeamId { get; set; }
public Guid ExpCatId { get; set; }
public string ResourceId { get; set; }
public string Name { get; set; }
public MixResourceAllocation() : base() { }
}
[BsonIgnoreExtraElements]
[Serializable]
public class MixExpenditureAllocation : BaseAllocation<QuantityItem>
{
public Guid ExpCatId { get; set; }
public string ExpenditureCategoryName { get; set; }
public int Type { get; set; }
public int UseType { get; set; } //default is 1
public string CGEFX { get; set; }
public Guid GLId { get; set; }
public Guid UOMId { get; set; }
public Guid CreditId { get; set; }
public Guid? SysAttrOne { get; set; }
public Guid? SysAttrTwo { get; set; }
public int? SortOrder { get; set; }
public decimal UOMValue { get; set; }
public bool AllowResourceAssignment { get; set; }
public Dictionary<string, decimal> UnassignedAllocations { get; set; }
public MixExpenditureAllocation() : base()
{
}
}
[BsonIgnoreExtraElements]
[Serializable]
public class QuantityItem
{
public decimal Quantity { get; set; }
public decimal Cost { get; set; }
}
[BsonIgnoreExtraElements]
[Serializable]
public class CategoryExpenditureInMongoProject
{
public Guid ProjectId;
public Guid ExpCatId;
public Guid? TargetTeamId;
public string Name;
public bool AllowResourceAssignment;
}
}