//public static PageLanguageHelper GetLanguageContent_old(string SiteName, string ViewName)
        //{
        //    PageLanguageHelper returnValue = null;

        //    if (SessionManager.Exists(SiteName + ViewName))
        //    {
        //        SessionManager.Get<PageLanguageHelper>(SiteName + ViewName, out returnValue);
        //    }
        //    else
        //    {
        //        LanguageContent languageContent = new LanguageContent()
        //        {
        //            SiteName = SiteName,
        //            ViewFeatureName = ViewName
        //        };

        //        var currentLanguage = SessionManager.GetCurrentLanguage();

        //        if (currentLanguage != null)
        //        {
        //            languageContent.idLanguageType = currentLanguage.idLanguageType;
        //        }
        //        else
        //        {
        //            languageContent.idLanguageType = LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.French).idLanguageType;
        //        }

        //        returnValue = new PageLanguageHelper(GetPageLanguageContent(languageContent));

        //        SessionManager.Add<PageLanguageHelper>(returnValue, SiteName + ViewName);
        //    }

        //    return returnValue;
        //}

        public static PageLanguageHelper GetLanguageContent(string siteName, string viewName)
        {
            PageLanguageHelper returnValue = null;
            int idLanguageType = 1; //French ?
            if (ConfigurationManager.ExtranetType != @"EXE")
            {
                var currentLanguage = SessionManager.GetCurrentLanguage();

                if (currentLanguage != null)
                {
                    idLanguageType = currentLanguage.idLanguageType;
                }
                else
                {
                    idLanguageType = LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.French).idLanguageType;
                }
            }
            
            returnValue = new PageLanguageHelper(GetPageLanguageContent(siteName, viewName, idLanguageType));

            return returnValue;
        }
        //update
        //private static float GeneratePMRLesPersonnesHabilitées(FoxitPDFGenerator instance, Data.Model.Report report, PageLanguageHelper languageData, int idOptionAttribute, float yStartPoint = 0)
        //{
        //    if (yStartPoint + 310 >= 700)
        //    {
        //        instance.CreatePage();
        //        yStartPoint = 0;
        //    }

        //    yStartPoint = yStartPoint + 20; //spacing

        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(languageData.GetContent("PersonnesHabiliteesSection_Line1"), yStartPoint, 500, 20);
        //    ReportBL.PlotBooleanValue(instance, ReportBL.GetBooleanValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), String.Empty, "Title"), yStartPoint, 40);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"Madame", yStartPoint, 500, 20, 60);
        //    ReportBL.PlotBooleanValue(instance, ReportBL.GetBooleanValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), Boolean.FalseString, "Title"), yStartPoint, 110);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"Monsieur", yStartPoint, 500, 20, 130);

        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(String.Format(@"Nom : {0}", ReportBL.GetStringValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), "Name")), yStartPoint + 20, 500, 20);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(String.Format(@"Prénom : {0}", ReportBL.GetStringValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), "FirstName")), yStartPoint + 35, 500, 20);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(String.Format(@"Date de naissance : {0}", ReportBL.GetStringValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), "DateOfBirth")), yStartPoint + 50, 500, 20);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(String.Format(@"Fonction : {0}", ReportBL.GetStringValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), "Function")), yStartPoint + 65, 500, 20);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(String.Format(@"Nationalité : {0}", ReportBL.GetStringValue(ReportBL.GetReportOptionAttributeValueFromReportInstance(report, idOptionAttribute), "Nationality")), yStartPoint + 80, 500, 20);

        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[8], idReport), yStartPoint + 100);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"Résident", yStartPoint + 100, 500, 20, 20);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[9], idReport), yStartPoint + 100, 80);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"Non Résident", yStartPoint + 100, 500, 20, 100);

        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(String.Format(@"Pays de résidence : {0}", ReportBL.GetStringValue(ReportOptionBL.GetReportOptionAttributeValueByIdOptionAttributeAndIdReport(values[10], idReport))), yStartPoint + 120, 500, 20);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"La personne habilitée est-elle domiciliée dans un pays définis par le GAFI ?  (Accédez à la ", yStartPoint + 140, 500, 20, 100);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"liste de ces  pays sur : http://www.fatf-gafi.org/fr/)", yStartPoint + 155, 500, 20, 100);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[11], idReport), yStartPoint + 170, 100);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"OUI", yStartPoint + 170, 500, 20, 120);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[12], idReport), yStartPoint + 170, 150);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"NON", yStartPoint + 170, 500, 20, 170);

        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"La personne habilitée est-elle domiciliée dans un centre dit « Off-shore » ?  (Accédez à ", yStartPoint + 200, 500, 20, 100);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"la liste de ces  pays sur : http://www.oecd.org/ctp/harmful/43775845.pdf)", yStartPoint + 215, 500, 20, 100);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[13], idReport), yStartPoint + 230, 100);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"OUI", yStartPoint + 230, 500, 20, 120);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[14], idReport), yStartPoint + 230, 150);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"NON", yStartPoint + 230, 500, 20, 170);

        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"Cette personne est-elle bénéficiaire effectif * ?", yStartPoint + 260, 500, 20);
        //    instance.AddReceuil_DetailText_Justify_Calibri_Label(@"Le bénéficiaire effectif est la personne dont la participation directe ou indirecte au capital de la personne morale est supérieure ou égale à 25%", yStartPoint + 275, 500, 20);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[15], idReport), yStartPoint + 290);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"OUI", yStartPoint + 290, 500, 20, 20);
        //    ReportBL.PlotBooleanValue(instance, ReportOptionBL.GetReportOptionValueByIdOptionAndIdReport(values[16], idReport), yStartPoint + 290, 50);
        //    instance.AddReceuil_DefaultText_Justify_Calibri_Label(@"NON", yStartPoint + 290, 500, 20, 70);

        //    //added spacing
        //    return yStartPoint + 310;
        //}

        private static float GeneratePMRLesBénéficiaireEffectif(FoxitPDFGenerator instance, ReportOptionAttributeValue data, PageLanguageHelper languageData, float yStartPoint = 0)
        {
            if (data != null)
            {

                //if (yStartPoint + 530 >= 700)
                //{
                instance.CreatePage();
                yStartPoint = 0;
                //}

                // yStartPoint = yStartPoint + 20; //spacing

                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line1"), yStartPoint, 500, 20);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.Title, yStartPoint, 40, "2");
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line1_Item2"), yStartPoint, 500, 20, 60);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.Title, yStartPoint, 110, "1");
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line1_Item1"), yStartPoint, 500, 20, 130);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.Title, yStartPoint, 200, "3");
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line1_Item3"), yStartPoint, 500, 20, 220);


                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line2"), data.CustomObjectValue.Name), yStartPoint + 20, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line2"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Name, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line3"), data.CustomObjectValue.MaidenName), yStartPoint + 35, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line3"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.MaidenName, yStartPoint, answer_width, 20, answer_x);

                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line4"), data.CustomObjectValue.FirstName), yStartPoint + 50, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line4"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.FirstName, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line5"), data.CustomObjectValue.DateOfBirth), yStartPoint + 65, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line5"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.DateOfBirth, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line6_Item1"), data.CustomObjectValue.Phone), yStartPoint + 80, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line6_Item1"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Phone, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line6_Item2"), data.CustomObjectValue.Mobile), yStartPoint + 80, 500, 20, 200);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line6_Item2"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Mobile, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line7"), data.CustomObjectValue.Email), yStartPoint + 95, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line7"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Email, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line8"), data.CustomObjectValue.Address), yStartPoint + 120, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line8"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Address, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line9"), data.CustomObjectValue.Function), yStartPoint + 135, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line9"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Function, yStartPoint, answer_width, 20, answer_x);

                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line10"), data.CustomObjectValue.Nationality), yStartPoint + 150, 500, 20);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line10"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Nationality, yStartPoint, answer_width, 20, answer_x);


                //instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line11"), yStartPoint + 165, 500, 20, 100);
                //instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line12"), yStartPoint + 180, 500, 20, 100);
                instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line11"), languageData.GetContent("LesBénéficiaireEffectifSection_Line12")), yStartPoint += interline * 1.5f, 500 - 100, 40, 100);

                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsGAFI, yStartPoint += interline * 1.5f, 100, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 115);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsGAFI, yStartPoint, 145, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 170);
                instance.AddDefaultText(string.Format("{0} {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line13"), data.CustomObjectValue.GAFICountry), yStartPoint += interline, 500, 20, 100);

                //instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line14"), yStartPoint + 240, 500, 20, 100);
                //instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line15"), yStartPoint + 255, 500, 20, 100);
                instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line14"), languageData.GetContent("LesBénéficiaireEffectifSection_Line15")), yStartPoint += interline * 1.5f, 500 - 100, 40, 100);

                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsOffshore, yStartPoint += interline * 1.5f, 100, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 115);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsOffshore, yStartPoint, 150, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 165);
                instance.AddDefaultText(string.Format("{0} {1}", languageData.GetContent("LesBénéficiaireEffectifSection_Line16"), data.CustomObjectValue.OffshoreCountry), yStartPoint += interline, 500, 20, 100);

                instance.AddDefaultBoldText(languageData.GetContent("LesBénéficiaireEffectifSection_Line17"), yStartPoint += interline * 1.5f, 500, 20, 15);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsPPE, yStartPoint += interline, 35, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 50);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsPPE, yStartPoint, 85, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 105);

                /*instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line18"), yStartPoint + 340, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line19"), yStartPoint + 355, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line20"), yStartPoint + 370, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line21"), yStartPoint + 385, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line22"), yStartPoint + 400, 500, 20);
                */
                //string strBenef = String.Format(@"{0} {1} {2} {3} {4}",
                //    languageData.GetContent("LesBénéficiaireEffectifSection_Line18"),
                //    languageData.GetContent("LesBénéficiaireEffectifSection_Line19"),
                //    languageData.GetContent("LesBénéficiaireEffectifSection_Line20"),
                //    languageData.GetContent("LesBénéficiaireEffectifSection_Line21"),
                //    languageData.GetContent("LesBénéficiaireEffectifSection_Line22"));
                string strBenef = languageData.GetContent("LesBénéficiaireEffectifSection_Line18_1");
                instance.AddJustifyText(strBenef, yStartPoint += interline * 2, 500, 100); ;

                /*instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line23"), yStartPoint + 415, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line24"), yStartPoint + 430, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line25"), yStartPoint + 445, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line26"), yStartPoint + 460, 500, 20);
                instance.AddReceuil_DetailText_Justify_Calibri_Label(languageData.GetContent("LesBénéficiaireEffectifSection_Line27"), yStartPoint + 475, 500, 20);
                */
                instance.AddJustifyText(String.Format(@"{0} {1} {2} {3} {4}", languageData.GetContent("LesBénéficiaireEffectifSection_Line23"), languageData.GetContent("LesBénéficiaireEffectifSection_Line24"), languageData.GetContent("LesBénéficiaireEffectifSection_Line25"), languageData.GetContent("LesBénéficiaireEffectifSection_Line26"), languageData.GetContent("LesBénéficiaireEffectifSection_Line27")), yStartPoint += interline * 3.5f, 500, 100);

                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line28"), yStartPoint += interline * 3.5f, 500, 20, 15);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsBusinessRel, yStartPoint += interline, 35, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 55);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsBusinessRel, yStartPoint, 85, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 105);
                instance.AddDefaultText(languageData.GetContent("LesBénéficiaireEffectifSection_Line29"), yStartPoint += interline, 500, 20, 35);

                //added spacing
                //return yStartPoint + 545;
                return yStartPoint;
            }
            return yStartPoint;
        }
         private int SetOptionFor(List<int> lstOptionToInsert, List<int> lstDataToFound, string[] criteria1, string[] criteria2, PageLanguageHelper pageHelper, bool checkData = false)
        {
            int clientsCount = 0;
            //System.Text.StringBuilder sb = new System.Text.StringBuilder();
            try
            {

                using (UpsilabEntities retrieveContext = new UpsilabEntities())
                {

                    var clients = retrieveContext.CustomerProspect.Include("Report").Where(cli => cli.isDeleted.HasValue && !cli.isDeleted.Value && cli.IsCorporation.HasValue &&
                        !cli.IsCorporation.Value);

                    foreach (var cli in clients)
                    {
                        if (cli.Report != null)
                        {
                            // test
                            if (cli.idCustomer.ToString().Equals("656bb16a-6782-41e6-b954-f7c11e5ca54d"))
                            {
                                string found = "";
                            }
                            var latestReport = cli.Report.Where(r => r.Status != "Canceled").OrderByDescending(r => r.DateUpdated).FirstOrDefault();
                            if (latestReport != null)
                            {

                                bool dataFound = false;
                                //if (IsOptionAttribute) //recherche dans la table ReportOptionAttributeValue
                                //{
                                var allAnswers = retrieveContext.ReportOptionAttributeValue.Where(roav => roav.idReport == latestReport.idReport);

                                if (allAnswers.Any())
                                {
                                    foreach (ReportOptionAttributeValue rov in allAnswers)
                                    {
                                        dataFound = IsAnyDataAnd(rov, criteria1);
                                        if (!dataFound && criteria2 !=null && criteria2.Length > 0)
                                        {
                                            dataFound = IsAnyDataAnd(rov, criteria2);
                                        }
                                        if (!dataFound && pageHelper!=null)
                                        {
                                            int idOptionAttribute = 0;
                                            Int32.TryParse(Convert.ToString(rov.idOptionAttribute), out idOptionAttribute);
                                            var obj = Upsilab.Business.Report.ReportOptionBL.GetOptionAttributeById(idOptionAttribute);
                                            if (obj != null)
                                            {
                                                var des = pageHelper.GetContent(obj.NameKey);
                                                dataFound = !string.IsNullOrEmpty(des);
                                            }
                                            
                                        }
                                        if (dataFound) break;
                                    }

                                    
                                }

                                if (dataFound)
                                {
                                    bool insertDone = false;
                                    foreach (int opt in lstOptionToInsert)
                                    {
                                        var isAlreadyChecked = retrieveContext.ReportOptionValue.Any(rov => rov.idReport == latestReport.idReport && rov.idOption == opt);
                                        if (!isAlreadyChecked)
                                        {
                                            ReportOptionValue rov = new ReportOptionValue()
                                            {
                                                idReport = latestReport.idReport,
                                                idOption = opt,
                                                DateCreated = DateTime.Now,
                                                DateUpdated = DateTime.Now,
                                                Value = string.Empty,
                                            };
                                            insertDone = true;
                                            retrieveContext.ReportOptionValue.AddObject(rov);

                                            Option objOption = OptionBL.GetOptionById(opt);
                                            if (objOption != null)
                                            {
                                                while (objOption.idParent.HasValue)
                                                {
                                                    ReportOptionValue optionParentValue =
                                                        (from rov1 in
                                                            retrieveContext.ReportOptionValue.Include("Option")
                                                            where
                                                                rov1.idReport == latestReport.idReport &&
                                                                rov1.idOption == objOption.idParent.Value
                                                            select rov1).FirstOrDefault();
                                                    if (optionParentValue == null)
                                                    {
                                                        optionParentValue = new ReportOptionValue()
                                                        {
                                                            idReport = latestReport.idReport,
                                                            idOption = objOption.idParent.Value,
                                                            Value = string.Empty,
                                                            DateCreated = DateTime.Now,
                                                            DateUpdated = DateTime.Now
                                                        };

                                                        //Add ReportOptionValue to DB : don't save yet
                                                        retrieveContext.ReportOptionValue.AddObject(optionParentValue);

                                                        //Check if this parent option has already parent ?
                                                        objOption = optionParentValue.Option;
                                                    }
                                                    else
                                                    {
                                                        optionParentValue.DateUpdated = DateTime.Now;
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            var RoptionChild = retrieveContext.ReportOptionValue.FirstOrDefault(rov => rov.idReport == latestReport.idReport && rov.idOption == opt);
                                            if (RoptionChild != null)
                                            {
                                                Option objOptionChild = OptionBL.GetOptionById(RoptionChild.idOption);
                                                if (objOptionChild != null)
                                                {
                                                    while (objOptionChild.idParent.HasValue)
                                                    {
                                                        ReportOptionValue optionParentValue = (from rov2 in retrieveContext.ReportOptionValue.Include("Option")
                                                                                               where rov2.idReport == latestReport.idReport && rov2.idOption == objOptionChild.idParent.Value
                                                                                               select rov2).FirstOrDefault();

                                                        if (optionParentValue == null)
                                                        {
                                                            optionParentValue = new ReportOptionValue()
                                                            {
                                                                idReport = latestReport.idReport,
                                                                idOption = objOptionChild.idParent.Value,
                                                                Value = string.Empty,
                                                                DateCreated = DateTime.Now,
                                                                DateUpdated = DateTime.Now
                                                            };

                                                            //Add ReportOptionValue to DB : don't save yet
                                                            retrieveContext.ReportOptionValue.AddObject(optionParentValue);

                                                            //Check if this parent option has already parent ?
                                                            objOptionChild = optionParentValue.Option;
                                                        }
                                                        else
                                                        {
                                                            optionParentValue.DateUpdated = DateTime.Now;
                                                            break;
                                                        }
                                                    }


                                                }
                                            }
                                        }
                                    }
                                    if (insertDone)
                                        clientsCount++;
                                }

                            }
                        }
                    }
                    retrieveContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //return string.Format("{0} Clients traités : {1} ", clientsCount, sb.ToString());
            return clientsCount;
        }
        private static float GeneratePMRLesPersonnesHabilitées(FoxitPDFGenerator instance, ReportOptionAttributeValue data, PageLanguageHelper languageData, float yStartPoint = 0)
        {
            if (data != null)
            {

                if (yStartPoint + 310 >= 700)
                {
                    instance.CreatePage();
                    yStartPoint = 0;
                }

                yStartPoint = yStartPoint + 20; //spacing

                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line1"), yStartPoint, 500, 20);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.Title, yStartPoint, 40, "2");
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line1_Item3"), yStartPoint, 500, 20, 60);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.Title, yStartPoint, 110, "1");
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line1_Item2"), yStartPoint, 500, 20, 130);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.Title, yStartPoint, 200, "3");
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line1_Item4"), yStartPoint, 500, 20, 220);

                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line2"), data.CustomObjectValue.Name), yStartPoint + 20, 500, 20);
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line2"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Name, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line3"), data.CustomObjectValue.FirstName), yStartPoint + 35, 500, 20);
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line3"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.FirstName, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PDFPM_telPortable"), data.CustomObjectValue.Phone), yStartPoint + 50, 500, 20);//tel
                instance.AddDefaultText(languageData.GetContent("PDFPM_telPortable"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Phone, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PDFPM_fax"), data.CustomObjectValue.Fax), yStartPoint + 65, 500, 20);//fax
                instance.AddDefaultText(languageData.GetContent("PDFPM_fax"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Fax, yStartPoint, answer_width, 20, answer_x);

                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PDFPM_email"), data.CustomObjectValue.Email), yStartPoint + 80, 500, 20);//email
                instance.AddDefaultText(languageData.GetContent("PDFPM_email"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Email, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(languageData.GetContent("PDFPM_adresse"), yStartPoint + 95, 500, 20);//adresse
                //instance.AddDefaultText(data.CustomObjectValue.Address, yStartPoint + 95, 400, 60, 50);//adresse
                instance.AddDefaultText(languageData.GetContent("PDFPM_adresse"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.MaidenName, yStartPoint, answer_width, 60, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PDFPM_cp"), data.CustomObjectValue.ZipCode), yStartPoint + 140, 500, 20);//cp
                instance.AddDefaultText(languageData.GetContent("PDFPM_cp"), yStartPoint += interline * 2.8f, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.ZipCode, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PDFPM_ville"), data.CustomObjectValue.City), yStartPoint + 155, 500, 20);//ville
                instance.AddDefaultText(languageData.GetContent("PDFPM_ville"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.City, yStartPoint, answer_width, 20, answer_x);

                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line4"), data.CustomObjectValue.DateOfBirth), yStartPoint + 170, 500, 20);
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line4"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.DateOfBirth, yStartPoint, answer_width, 20, answer_x);

                // instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line5"), data.CustomObjectValue.Function), yStartPoint + 185, 500, 20);
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line5"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Function, yStartPoint, answer_width, 20, answer_x);

                //instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line6"), data.CustomObjectValue.Nationality), yStartPoint + 200, 500, 20);
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line6"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Nationality, yStartPoint, answer_width, 20, answer_x);

                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsResident, yStartPoint += interline, 0, "1");
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line7_Item1"), yStartPoint, 500, 20, 15);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsResident, yStartPoint, 80, "2");
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line7_Item2"), yStartPoint, 500, 20, 95);

                //   instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line8"), data.CustomObjectValue.Country), yStartPoint + 230, 500, 20);
                //instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line9"), yStartPoint + 245, 500, 20, 100);
                //instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line10"), yStartPoint + 260, 500, 20, 100);
                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line8"), yStartPoint += interline, label_width, height);
                instance.AddAnswer(data.CustomObjectValue.Country, yStartPoint, answer_width, 20, answer_x);

                instance.AddBlueBorder(yStartPoint += 25, 70, 400, 92);
                instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line9"), languageData.GetContent("PersonnesHabiliteesSection_Line10")), yStartPoint += 10, 380, 40, 80);

                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsFATF, yStartPoint += interline * 1.5f, 100, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 120);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsFATF, yStartPoint, 150, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 170);


                //instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line11"), yStartPoint + 290, 500, 20, 100);
                //instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line12"), yStartPoint + 305, 500, 20, 100);
                instance.AddDefaultText(String.Format(@"{0} : {1}", languageData.GetContent("PersonnesHabiliteesSection_Line11"), languageData.GetContent("PersonnesHabiliteesSection_Line12")), yStartPoint += interline, 380, 40, 80);

                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsOffshore, yStartPoint += interline * 1.5f, 100, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 115);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsOffshore, yStartPoint, 150, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 165);

                instance.AddDefaultText(languageData.GetContent("PersonnesHabiliteesSection_Line13"), yStartPoint += interline * 1.8f, 500, 20);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsOwner, yStartPoint += interline, 0, "1");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_Yes_Caps"), yStartPoint, 500, 20, 15);
                ReportBL.PlotBooleanValue(instance, data.CustomObjectValue.IsOwner, yStartPoint, 50, "2");
                instance.AddDefaultText(languageData.GetContent("Report_Symbol_No_Caps"), yStartPoint, 500, 20, 65);
                instance.AddReference(languageData.GetContent("PersonnesHabiliteesSection_Line14"), yStartPoint += interline * 1.3f, 500, 20);

                return yStartPoint + 380;
            }
            //added spacing
            return yStartPoint;
        }