95 lines
3.3 KiB
C#
95 lines
3.3 KiB
C#
using Iniphi.Calculations;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace EnVisage.Code.DataMatrix
|
|
{
|
|
public class RMORaceMatrix
|
|
{
|
|
//main key=Iteration
|
|
//value= Project data (list collection)
|
|
//Project data key = week ordianl
|
|
// value = hashtable with key of EC, value is total planned capacity for that ec (across all teams)
|
|
|
|
private Dictionary<double, List<Dictionary<int, Hashtable>>> data = new Dictionary<double, List<Dictionary<int, Hashtable>>>();
|
|
private List<ProjectObj> _projects = new List<ProjectObj>();
|
|
private double _iterations; // columns of matrix
|
|
private int _weeks;
|
|
private int iteration;
|
|
|
|
public RMORaceMatrix()
|
|
{
|
|
|
|
}
|
|
public double BuidMatrix(List<DateTime> weeks, List<ProjectObj> projects)
|
|
{
|
|
_weeks = weeks.Count;
|
|
double iterations = Math.Pow(weeks.Count, projects.Count);
|
|
for (double i = 1; i <= iterations; i++)
|
|
{
|
|
int projectId = 0;
|
|
var ps=projects.Clone();
|
|
foreach (var project in projects.OrderBy(x => x.Position))
|
|
{
|
|
// getProjectPositionForIteration(i,project);
|
|
int ord = 0;
|
|
foreach (var weekord in weeks.OrderBy(x => x.Date))
|
|
{
|
|
Hashtable projectActualsForWeek = CalcActuals(i, ord, project, projectId);
|
|
project.ProjectAllocation[ord] = projectActualsForWeek;
|
|
|
|
|
|
ord++;
|
|
}
|
|
projectId++;
|
|
}
|
|
}
|
|
return iterations;
|
|
}
|
|
//returns the calculated capacity for a project for a week ord and a iteration
|
|
private Hashtable CalcActuals(double loopIteration, int weekord, ProjectObj project, int projectId)
|
|
{
|
|
var rt = new Hashtable();
|
|
int prjPosition = LookupPosition(loopIteration, weekord, projectId);
|
|
// determine project position and number (sooo iternation == project thats moving, any project number lower then
|
|
//iteration is in a race the lower the number the faster it moves...
|
|
//determine location of project in iteration
|
|
int position = project.Position;
|
|
|
|
if (prjPosition == weekord)
|
|
{
|
|
Hashtable allocations=project.ProjectAllocation[0];
|
|
}else if (prjPosition < weekord)
|
|
{
|
|
int idx = weekord - prjPosition;
|
|
if (project.ProjectAllocation.ContainsKey(idx))
|
|
{
|
|
return project.ProjectAllocation[idx];
|
|
|
|
}
|
|
else
|
|
{
|
|
return new Hashtable();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return new Hashtable();
|
|
}
|
|
return rt;
|
|
}
|
|
Hashtable positions = new Hashtable();
|
|
public int LookupPosition(double iteration,int weekord,int projectId)
|
|
{
|
|
//if (positions.ContainsKey(projectId) )
|
|
|
|
//if (projectId == 1 )
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
} |