Example #1
0
        /// <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);
        }
Example #2
0
        /// <summary>
        /// Va chercher les informations necessaire pour afficher le graphique a ligne briser
        /// </summary>
        /// <param name="id"></param>
        /// <returns> Liste d'élément ViewGraph </returns>
        public List <ViewGraph> graphiqueLigne(int id)
        {
            List <ViewGraph> graph = new List <ViewGraph>();
            Project          p     = solutiosContext.Project.Find(id);

            //Creation de liste de liste des informations de PROJECTION
            List <ProjectFollowUp> PfollowUps = solutiosContext.ProjectFollowUp.Where(c => c.PfProjectId == id).ToList();
            List <FollowUp>        follows    = new List <FollowUp>();

            foreach (var item in PfollowUps)
            {
                follows.Add(solutiosContext.FollowUp.Find(item.PfFollowUpId));
            }
            List <List <FollowInfo> > infos = new List <List <FollowInfo> >();

            foreach (var item in follows)
            {
                List <FollowInfo> f = JsonConvert.DeserializeObject <List <FollowInfo> >(item.FuInfo);
                infos.Add(f);
            }

            //Creation de liste de liste des informations de DÉPENSE
            List <ProjectExpense> pfExpense = solutiosContext.ProjectExpense.Where(c => c.PeProjectId == id).ToList();
            List <Expense>        expenses  = new List <Expense>();

            foreach (var exp in pfExpense)
            {
                expenses.Add(solutiosContext.Expense.Find(exp.PeExpenseId));
            }
            List <List <ExpenseInfo> > Exinfo = new List <List <ExpenseInfo> >();

            foreach (var item in expenses)
            {
                List <ExpenseInfo> f = JsonConvert.DeserializeObject <List <ExpenseInfo> >(item.JsonExpenseInfo);
                Exinfo.Add(f);
            }

            //creation de la string pour le graphique
            int counterColor = 0;

            foreach (var soumis in p.listProjectSoumission())
            {
                if ((soumis.Spending != "MargeSoumis") && (soumis.Spending != "MargeProjeter"))
                {
                    counterColor += 10;
                    ViewGraph vg   = new ViewGraph();
                    string    test = "[";
                    for (int i = 0; i < infos.Count; i++)
                    {
                        double total       = 0;
                        double totalsoumis = 0;
                        for (int j = 0; j < infos[i].Count; j++)
                        {
                            if (soumis.Spending == infos[i][j].Spending)
                            {
                                vg.label    = infos[i][j].Spending;
                                vg.color    = infos[i][j].color;
                                totalsoumis = soumis.amount + totalsoumis;
                                total       = infos[i][j].amount + Exinfo[i][j].amount + total;
                                total       = (total * 100) / totalsoumis;
                            }
                        }
                        test = test + total.ToString() + ",";
                    }
                    string end = "]";
                    test­  += end;
                    vg.data = test;

                    graph.Add(vg);
                }
            }
            return(graph);
        }