/// <summary> /// Va chercher les éléments des projets et de l'historique et le mets dans la classe /// approprier pour les affichers par la suite /// </summary> /// <param name="id"></param> /// <param name="projection_id"></param> /// <returns></returns> public List <ViewProject> viewProjetHistorique(int id, int projection_id) { List <ViewProject> ListVP = new List <ViewProject>(); Project p = solutiosContext.Project.Find(id); FollowUp follow = solutiosContext.FollowUp.Find(projection_id); List <FollowInfo> soumission = p.listProjectSoumission(); List <FollowInfo> estimation = follow.deinfo(); ProjectExpense pex = solutiosContext.ProjectExpense.LastOrDefault(c => c.PeProjectId == id); Expense ex = solutiosContext.Expense.LastOrDefault(c => c.ExpenseId == pex.PeExpenseId); List <ExpenseInfo> expenseInfos = ex.Listexpenses(); for (int i = 0; i < estimation.Count; i++) { if ((soumission[i].Spending != "MargeSoumis") && (soumission[i].Spending != "MargeProjeter")) { ViewProject vp = new ViewProject("", 0, 0, 0); vp.spending = soumission[i].Spending; vp.soumission = soumission[i].amount; vp.depenceP = estimation[i].amount; vp.dépensecourrante = expenseInfos[i].amount; ListVP.Add(vp); } } return(ListVP); }
/// <summary> /// Crée la string pour les labels du graphique fait en JS /// </summary> /// <param name="id"></param> /// <returns></returns> public string nomdépense(int id) { Project p = solutiosContext.Project.Find(id); List <ProjectFollowUp> PfollowUps = solutiosContext.ProjectFollowUp.Where(c => c.PfProjectId == id).ToList(); FollowUp follows = new FollowUp(); foreach (var item in PfollowUps) { follows = solutiosContext.FollowUp.FirstOrDefault(c => c.FuId == item.PfFollowUpId); } int i = 0; List <FollowInfo> f = JsonConvert.DeserializeObject <List <FollowInfo> >(follows.FuInfo); string[] test = new string[(f.Count - 2)]; foreach (var items in f) { if ((items.Spending != "MargeSoumis") && (items.Spending != "MargeProjeter")) { test[i] = items.Spending; i++; } } string jsonTest = (new JavaScriptSerializer()).Serialize(test); return(jsonTest); }
/// <summary> /// Va chercher les informations pour afficher les vieux graphiques de l'historique /// </summary> /// <param name="id"></param> /// <param name="fuid"></param> /// <returns></returns> public ViewGraph OldGraph(int id, int fuid) { ViewGraph vg = new ViewGraph(); Project p = solutiosContext.Project.Find(id); ProjectFollowUp PfollowUps = solutiosContext.ProjectFollowUp.LastOrDefault(c => c.PfProjectId == id); FollowUp follows = solutiosContext.FollowUp.Find(fuid); ProjectExpense projectExpense = solutiosContext.ProjectExpense.LastOrDefault(c => c.PeProjectId == id); Expense expense = solutiosContext.Expense.Find(projectExpense.PeExpenseId); List <FollowInfo> infos = JsonConvert.DeserializeObject <List <FollowInfo> >(follows.FuInfo); List <FollowInfo> soumis = p.listProjectSoumission(); List <ExpenseInfo> expinfo = JsonConvert.DeserializeObject <List <ExpenseInfo> >(expense.JsonExpenseInfo); string end = "]"; string projectionEX = "["; for (int i = 0; i < infos.Count; i++) { if ((infos[i].Spending != "MargeSoumis") && (infos[i].Spending != "MargeProjeter")) { double depense = soumis[i].amount - expinfo[i].amount; projectionEX = projectionEX + depense.ToString() + ","; } } projectionEX += end; string graphprojection = "["; foreach (var item in infos) { if ((item.Spending != "MargeSoumis") && (item.Spending != "MargeProjeter")) { graphprojection = graphprojection + item.amount.ToString() + ","; } } graphprojection += end; string graphreel = "["; foreach (var item in expinfo) { if ((item.Spending != "MargeSoumis") && (item.Spending != "MargeProjeter")) { graphreel = graphreel + item.amount.ToString() + ","; } } graphreel += end; string colorsoumi = "["; foreach (var item in soumis) { if ((item.Spending != "MargeSoumis") && (item.Spending != "MargeProjeter")) { colorsoumi = colorsoumi + '"' + item.color + '"' + ","; } } colorsoumi += end; string colorbar = "["; string colorbarexpense = "["; for (int i = 0; i < soumis.Count; i++) { if ((soumis[i].Spending != "MargeSoumis") && (soumis[i].Spending != "MargeProjeter")) { if ((soumis[i].amount - expinfo[i].amount) == infos[i].amount) { colorbar = colorbar + '"' + "#f4b30d" + '"' + ","; } else if ((soumis[i].amount - expinfo[i].amount) < infos[i].amount) { colorbar = colorbar + '"' + "#e02d1b" + '"' + ","; } else if ((soumis[i].amount - expinfo[i].amount) > infos[i].amount) { colorbar = colorbar + '"' + "#1cc88a" + '"' + ","; } if (soumis[i].amount == expinfo[i].amount) { colorbarexpense = colorbarexpense + '"' + "#f4b30d" + '"' + ","; } else if (soumis[i].amount < expinfo[i].amount) { colorbarexpense = colorbarexpense + '"' + "#e02d1b" + '"' + ","; } else if (soumis[i].amount > expinfo[i].amount) { colorbarexpense = colorbarexpense + '"' + "#1cc88a" + '"' + ","; } } } colorbarexpense += end; colorbar += end; vg.soumission = soumission(id); vg.soumissionColor = colorsoumi; vg.data = graphprojection; vg.projectionEX = projectionEX; vg.color = colorbar; vg.dépense = graphreel; vg.colordepense = colorbarexpense; return(vg); }