public DashboardStatisticsDataModel CreateRecueilData(List<CustomerProspectViewModel> _data, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Vigilance_Level");//set to 1 for now
            retVal.LabelString = LanguageDataPage.GetContent("Mises_à_jour");
            retVal.Statistics = new List<DashboardStatisticsModel>();

            // Recueil à jour (VERT)
            List<CustomerProspectViewModel> lstUpdated = _data.Where(cp => cp.DateUpdatedLast.HasValue && cp.DateUpdatedNext > DateTime.Now.Add(new System.TimeSpan(30, 0, 0, 0))).ToList<CustomerProspectViewModel>();
            DashboardStatisticsModel statisticsDataUpdated = new DashboardStatisticsModel();
            statisticsDataUpdated.StatCount = lstUpdated.Count();
            statisticsDataUpdated.Index = 1;
            statisticsDataUpdated.NameKey = LanguageDataPage.GetContent("Recueil_à_jour");//LanguageData.GetContent(vigilance.VigilanceLevelName);
            statisticsDataUpdated.FilterString = string.Format("Recueil|{0}", statisticsDataUpdated.Index);
            statisticsDataUpdated.ColorSetting = "10ac56,048C42";//"#10ac56";
            retVal.Statistics.Add(statisticsDataUpdated);

            // Recueil à mettre en jour (ORANGE)
            List<CustomerProspectViewModel> lstNextUpdated = _data.Where(cp => cp.DateUpdatedLast.HasValue && cp.DateUpdatedNext >= DateTime.Now && cp.DateUpdatedNext <= DateTime.Now.Add(new System.TimeSpan(30, 0, 0, 0))).ToList<CustomerProspectViewModel>();
            DashboardStatisticsModel statisticsDataNextUpdated = new DashboardStatisticsModel();
            statisticsDataNextUpdated.StatCount = lstNextUpdated.Count();
            statisticsDataNextUpdated.Index = 3;
            statisticsDataNextUpdated.NameKey = LanguageDataPage.GetContent("Mise_à_jour_prochaine");//LanguageData.GetContent(vigilance.VigilanceLevelName);
            statisticsDataNextUpdated.FilterString = string.Format("Recueil|{0}", statisticsDataNextUpdated.Index);
            statisticsDataNextUpdated.ColorSetting = "ff6b2f,F85716";//"#ffdc38";
            retVal.Statistics.Add(statisticsDataNextUpdated);

            //  -Recueil non à jour (ROUGE)
            List<CustomerProspectViewModel> lstsuperseded = _data.Where(cp => cp.DateUpdatedLast.HasValue && cp.DateUpdatedNext < DateTime.Now).ToList<CustomerProspectViewModel>();
            DashboardStatisticsModel statisticsDatasuperseded = new DashboardStatisticsModel();
            statisticsDatasuperseded.StatCount = lstsuperseded.Count();
            statisticsDatasuperseded.Index = 4;
            statisticsDatasuperseded.NameKey = LanguageDataPage.GetContent("Mise_à_jour_dépassée");//LanguageData.GetContent(vigilance.VigilanceLevelName);
            statisticsDatasuperseded.FilterString = string.Format("Recueil|{0}", statisticsDatasuperseded.Index);
            statisticsDatasuperseded.ColorSetting = "db1000,C50E00";//"#ff6b2f";
            retVal.Statistics.Add(statisticsDatasuperseded);

            //  - Aucun recueil réalisé (NOIR / GRIS)
            List<CustomerProspectViewModel> lstCurrent = _data.Where(cp => !cp.DateUpdatedLast.HasValue).ToList<CustomerProspectViewModel>();
            DashboardStatisticsModel statisticsDataCurrent = new DashboardStatisticsModel();
            statisticsDataCurrent.StatCount = lstCurrent.Count();
            statisticsDataCurrent.Index = 5;
            statisticsDataCurrent.NameKey = LanguageDataPage.GetContent("Recueil_en_cours");//LanguageData.GetContent(vigilance.VigilanceLevelName);
            statisticsDataCurrent.FilterString = string.Format("Recueil|{0}", statisticsDataCurrent.Index);
            statisticsDataCurrent.ColorSetting = "#1b1b1b";//"#db1000";
            retVal.Statistics.Add(statisticsDataCurrent);

            retVal.Chart = GetChartTag(retVal.Statistics, "RecueilId", "f5f5f5");

            return retVal;
        }
        private DashboardStatisticsDataModel CreateWaitingData(List<CustomerProspectViewModel> _data, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Dashboard");
            retVal.Statistics = new List<DashboardStatisticsModel>();
            retVal.IconStringName = "puceT5";
            retVal.LabelString = LanguageData.GetContent("waiting");
            retVal.ShowStyle = true;

            //DER
            var Der = _data.Where(cust => cust.DerStatus == Upsilab.Business.Report.ReportBL.Status.WaitingForClientSignature.ToString()).ToList();
            DashboardStatisticsModel derClients = new DashboardStatisticsModel();
            derClients.StatCount = Der.Count;
            derClients.Index = 0;
            derClients.NameKey = LanguageData.GetContent("waiting_der");
            derClients.FilterString = string.Format("Waiting|1");
            retVal.Statistics.Add(derClients);

            //LM
            var Lm = _data.Where(cust => cust.LetterStatus == Upsilab.Business.Report.ReportBL.Status.WaitingForClientSignature.ToString()).ToList();

            DashboardStatisticsModel lmClients = new DashboardStatisticsModel();
            lmClients.StatCount = Lm.Count;
            lmClients.Index = 0;
            lmClients.NameKey = LanguageData.GetContent("waiting_lm");
            lmClients.FilterString = string.Format("Waiting|3");
            retVal.Statistics.Add(lmClients);

            //Recueil
            var Rec = _data.Where(cust => cust.CurrentReportStatus == Upsilab.Business.Report.ReportBL.Status.WaitingForClientSignature.ToString()
            || cust.CurrentReportStatus == Upsilab.Business.Report.ReportBL.Status.WaitingForClientUpdate.ToString()).ToList();

            DashboardStatisticsModel recClients = new DashboardStatisticsModel();
            recClients.StatCount = Rec.Count;
            recClients.Index = 0;
            recClients.NameKey = LanguageData.GetContent("waiting_rec");
            recClients.FilterString = string.Format("Waiting|2");
            retVal.Statistics.Add(recClients);



            //RM
            var Rm = _data.Where(cust => cust.MissionStatus == Upsilab.Business.Report.ReportBL.Status.WaitingForClientSignature.ToString()).ToList();

            DashboardStatisticsModel rmClients = new DashboardStatisticsModel();
            rmClients.StatCount = Rm.Count;
            rmClients.Index = 0;
            rmClients.NameKey = LanguageData.GetContent("waiting_rm");
            rmClients.FilterString = string.Format("Waiting|4");
            retVal.Statistics.Add(rmClients);

            return retVal;
        }
        public DashboardStatisticsDataModel CreateMeasureData(List<CustomerProspectViewModel> _data, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Dashboard");//set to 1 for now
            retVal.LabelString = LanguageDataPage.GetContent("mes_vig_compl_ronforcees_non_eff");
            retVal.Statistics = new List<DashboardStatisticsModel>();

            int nbVigilanceRenforcee = _data.Where(cp => (!string.IsNullOrEmpty(cp.CurrentLabStatus) && (cp.CurrentLabStatus.CompareTo("SentToCoffreFort") == 0 || cp.CurrentLabStatus.CompareTo("Completed") == 0)) && cp.idVigilance == 5 && ((cp.NbVigilanceMeasure.HasValue && cp.NbVigilanceMeasure.Value == 0) || !cp.NbVigilanceMeasure.HasValue)).Count();
            int nbVigilanceComplementaire = _data.Where(cp => (!string.IsNullOrEmpty(cp.CurrentLabStatus) && (cp.CurrentLabStatus.CompareTo("SentToCoffreFort") == 0 || cp.CurrentLabStatus.CompareTo("Completed") == 0)) && cp.idVigilance == 4 && ((cp.NbVigilanceMeasure.HasValue && cp.NbVigilanceMeasure.Value == 0) || !cp.NbVigilanceMeasure.HasValue)).Count();

            //Pending Measures
            DashboardStatisticsModel pendingMeasure = new DashboardStatisticsModel();
            pendingMeasure.StatCount = nbVigilanceRenforcee;
            pendingMeasure.Index = 5;
            pendingMeasure.NameKey = LanguageDataPage.GetContent("Mesures_vigilance_renforcées");
            pendingMeasure.FilterString = "Measure|Renforcees";
            retVal.Statistics.Add(pendingMeasure);

            //In Progress
            DashboardStatisticsModel inProgressMeasure = new DashboardStatisticsModel();
            inProgressMeasure.StatCount = nbVigilanceComplementaire;
            inProgressMeasure.Index = 4;
            inProgressMeasure.NameKey = LanguageDataPage.GetContent("Mesures_vigilance_complémentaires");
            inProgressMeasure.FilterString = "Measure|Complementaires";
            retVal.Statistics.Add(inProgressMeasure);

            retVal.Chart = GetChartTag(retVal.Statistics, "MeasureId", "f5f5f5");

            return retVal;
        }
        public DashboardStatisticsDataModel CreateMeasureData(List<LABStudy> _data, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Dashboard");//set to 1 for now
            retVal.LabelString = LanguageDataPage.GetContent("mes_vig_compl_ronforcees_non_eff");
            retVal.Statistics = new List<DashboardStatisticsModel>();

            int nbVigilanceRenforcee = _data.Where(lab => lab.idVigilance == 5 && (lab.VigilanceMeasure != null && lab.VigilanceMeasure.Count() == 0)).Count(); // 
            int nbVigilanceComplementaire = _data.Where(lab => lab.idVigilance == 4 && (lab.VigilanceMeasure != null && lab.VigilanceMeasure.Count() == 0)).Count();

            //Pending Measures
            //string pendingString = "Pending";//need lookup
            //var pendingData = _data.Where(d => d.Status.Equals(pendingString));
            DashboardStatisticsModel pendingMeasure = new DashboardStatisticsModel();
            pendingMeasure.StatCount = 0;//nbVigilanceRenforcee; 
            pendingMeasure.Index = 5;
            pendingMeasure.NameKey = LanguageDataPage.GetContent("Mesures_vigilance_renforcées");
            pendingMeasure.FilterString = "Measure|Pending";
            retVal.Statistics.Add(pendingMeasure);

            //In Progress
            //string inProgressString = "InProgress";
            //var inProgressData = _data.Where(d => d.Status.Equals(inProgressString));
            DashboardStatisticsModel inProgressMeasure = new DashboardStatisticsModel();
            inProgressMeasure.StatCount = 0;// nbVigilanceComplementaire;
            inProgressMeasure.Index = 4;
            inProgressMeasure.NameKey = LanguageDataPage.GetContent("Mesures_vigilance_complémentaires");
            inProgressMeasure.FilterString = "Measure|InProgress";
            retVal.Statistics.Add(inProgressMeasure);

            retVal.Chart = GetChartTag(retVal.Statistics, "MeasureId", "f5f5f5");

            return retVal;
        }
        /// TODO : used this instead of CreateVigilanceData having List<LABStudy> as parameters
        public DashboardStatisticsDataModel CreateVigilanceData(List<CustomerProspectViewModel> _data, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Vigilance_Level");//set to 1 for now
            retVal.LabelString = LanguageDataPage.GetContent("Niveau_de_vigilance");
            retVal.Statistics = new List<DashboardStatisticsModel>();

            foreach (VigilanceLevel vigilance in Business.LAB.RiskVigilanceBL.GetVigilanceLevels())
            {
                //var study = _data.Where(d => (d.idNewVigilance.HasValue && d.idNewVigilance.Value.Equals(vigilance.idVigilanceLevel))
                //    || (!d.idNewVigilance.HasValue && d.idVigilance.Value.Equals(vigilance.idVigilanceLevel)));
                var study = _data.Where(d => (d.idVigilance.HasValue && d.idVigilance.Value.Equals(vigilance.idVigilanceLevel)));

                DashboardStatisticsModel statisticsData = new DashboardStatisticsModel();
                statisticsData.StatCount = study.Count();
                statisticsData.Index = vigilance.VigilanceOrder;
                statisticsData.NameKey = LanguageData.GetContent(vigilance.VigilanceLevelName);
                statisticsData.FilterString = string.Format("Vigilance|{0}", statisticsData.Index);
                statisticsData.ColorSetting = vigilance.VigilanceColor;

                retVal.Statistics.Add(statisticsData);
            }
            retVal.Chart = GetChartTag(retVal.Statistics, "VigilanceId", "dcecf5");

            return retVal;
        }
        /// TODO : used this instead of CreateRiskData having List<LABStudy> as parameters
        public DashboardStatisticsDataModel CreateRiskData(List<CustomerProspectViewModel> _data, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Risk_Level");//set to 1 for now
            retVal.LabelString = LanguageDataPage.GetContent("Niveau_de_risque");//needs localization function
            retVal.Statistics = new List<DashboardStatisticsModel>();

            foreach (RiskLevel risk in Business.LAB.RiskVigilanceBL.GetRiskLevels())
            {
                //var study = _data.Where(d => (d.idNewRisk.HasValue && d.idNewRisk.Value.Equals(risk.idRiskLevel))
                //    || (!d.idNewRisk.HasValue && d.idRisk.Value.Equals(risk.idRiskLevel)));
                var study = _data.Where(d => d.idRisk.HasValue && d.idRisk.Value.Equals(risk.idRiskLevel));

                DashboardStatisticsModel statisticsData = new DashboardStatisticsModel();
                statisticsData.StatCount = study.Count();
                statisticsData.Index = risk.RiskOrder;
                statisticsData.NameKey = LanguageData.GetContent(risk.RiskLevelName);
                statisticsData.FilterString = string.Format("Risk|{0}", statisticsData.Index);
                statisticsData.ColorSetting = risk.RiskColor;

                retVal.Statistics.Add(statisticsData);
            }

            retVal.Chart = GetChartTag(retVal.Statistics, "RiskId", "dcecf5");
            return retVal;
        }
        private DashboardStatisticsDataModel CreateRelanceData(List<CustomerProspectViewModel> customersData, DashboardStatisticsDataModel retVal)
        {
            var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Dashboard");
            retVal.Statistics = new List<DashboardStatisticsModel>();
            retVal.IconStringName = "puceT3";
            retVal.LabelString = LanguageData.GetContent("relance_automatique");

            // List<Guid> lstCustomers = customersData.Select(c => c.idCustomer).ToList<Guid>();
            var reminders = Upsilab.Business.ReportLABReminderLog.ReportLABReminderLogBL.GetLast30DaysReportRelancesSent();


            //Email de relance envoyé aux clients
            var reminders1 = reminders.Where(rem => rem.IsAlertRecipientClient).ToList();
            var lstCustomersToRemind = reminders1.Select(r => r.idCustomer).ToList<Guid>();
            var remindedClient = customersData.Where(cust => lstCustomersToRemind.Contains(cust.idCustomer)).ToList();
            DashboardStatisticsModel statSendToClientStats = new DashboardStatisticsModel();
            statSendToClientStats.StatCount = remindedClient.Count;
            statSendToClientStats.Index = 0;
            statSendToClientStats.NameKey = LanguageData.GetContent("relance_clients");
            statSendToClientStats.FilterString = string.Format("Relance|1");
            retVal.Statistics.Add(statSendToClientStats);

            //Email de relance envoyé aux conseillers
            var reminders2 = reminders.Where(rem => !rem.IsAlertRecipientClient).ToList();
            lstCustomersToRemind = reminders2.Select(r => r.idCustomer).ToList<Guid>();
            remindedClient = customersData.Where(cust => lstCustomersToRemind.Contains(cust.idCustomer)).ToList();
            DashboardStatisticsModel statSendToAdvStats = new DashboardStatisticsModel();
            statSendToAdvStats.StatCount = remindedClient.Count;
            statSendToAdvStats.Index = 0;
            statSendToAdvStats.NameKey = LanguageData.GetContent("relance_conseillers");
            statSendToAdvStats.FilterString = string.Format("Relance|2");
            retVal.Statistics.Add(statSendToAdvStats);

            //Recueils signés après relance par mail 
            List<CustomerProspectViewModel> lstCustomersRec = new List<CustomerProspectViewModel>();
            lstCustomersToRemind = reminders.Select(r => r.idCustomer).ToList<Guid>();
            remindedClient = customersData.Where(cust => lstCustomersToRemind.Contains(cust.idCustomer)).ToList();
            foreach (var cust in remindedClient)
            {
                var clientRemind = reminders.Where(rem => rem.idCustomer == cust.idCustomer).OrderByDescending(rem => rem.DateCreated).FirstOrDefault();
                if (clientRemind != null && cust.DateUpdatedNext.HasValue && (cust.DateUpdatedNext.Value - clientRemind.DateCreated).TotalDays >= 180)
                    lstCustomersRec.Add(cust);
            }

            DashboardStatisticsModel statSignedRecStats = new DashboardStatisticsModel();
            statSignedRecStats.StatCount = lstCustomersRec.Count;
            statSignedRecStats.Index = 0;
            statSignedRecStats.NameKey = LanguageData.GetContent("relance_recueil_signes");
            statSignedRecStats.FilterString = string.Format("Relance|3");
            retVal.Statistics.Add(statSignedRecStats);
            return retVal;
        }