コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="html"></param>
        /// <param name="phase"></param>
        /// <returns></returns>
        private static string FormatPhaseTemplate(string html, Phase phase, String culture)
        {
            CultureInfo uiCulture = new CultureInfo(culture);

            Thread.CurrentThread.CurrentUICulture = uiCulture;

            String _html = html.Replace("@Title@", phase.Title);

            _html = _html.Replace("@IDFase@", phase.IDPhase.ToString());
            _html = _html.Replace("@Column1Text@", phase.Column1Text);
            _html = _html.Replace("@Column2Text@", phase.Column2Text);
            _html = _html.Replace("@Column3Text@", phase.Column3Text);
            _html = _html.Replace("@PractitionersTips@", phase.PractitionersTips);
            _html = _html.Replace("@Text@", LanguageResourceManager.GetResourceText("Text"));

            //Bullets:
            _html = _html.Replace("@FaceBulletsColumn1@", GenerateBulletValues(PhaseBulletManager.GetByPhaseAndColumn(phase.IDPhase, 1).ToList()));
            _html = _html.Replace("@FaceBulletsColumn2@", GenerateBulletValues(PhaseBulletManager.GetByPhaseAndColumn(phase.IDPhase, 2).ToList()));
            _html = _html.Replace("@FaceBulletsColumn3@", GenerateBulletValues(PhaseBulletManager.GetByPhaseAndColumn(phase.IDPhase, 3).ToList()));

            //headers
            _html = _html.Replace("@ActionPointsHeader@", LanguageResourceManager.GetResourceText("ActionPointsHeader"));
            _html = _html.Replace("@ImprovedElectoralManagementHeader@", LanguageResourceManager.GetResourceText("ImprovedElectoralManagementHeader"));
            _html = _html.Replace("@ImprovedElectoralSecurityHeader@", LanguageResourceManager.GetResourceText("ImprovedElectoralSecurityHeader"));
            _html = _html.Replace("@ImprovedInfrastructurePeaceHeader@", LanguageResourceManager.GetResourceText("ImprovedInfrastructurePeaceHeader"));
            _html = _html.Replace("@PractitionersTipsHeader@", LanguageResourceManager.GetResourceText("PractitionersTipsHeader"));
            _html = _html.Replace("@FullText@", LanguageResourceManager.GetResourceText("FullText"));


            return(_html);
        }
コード例 #2
0
        /// <summary>
        /// Generate the new Index.
        /// </summary>
        public static void GenerateIndex(CultureInfo uiCulture)
        {
            StringBuilder stringBuilderInt = new StringBuilder();
            StringBuilder stringBuilderExt = new StringBuilder();

            Thread.CurrentThread.CurrentUICulture = uiCulture;
            foreach (Factor factor in FactorManager.GetAllWithHtmlDocument())
            {
                if (factor.InternalFactor)
                {
                    stringBuilderInt.AppendLine(string.Format(IndexLinkTemplate, factor.IdFactor + ".htm", factor.Name));
                }
                else
                {
                    stringBuilderExt.AppendLine(string.Format(IndexLinkTemplate, factor.IdFactor + ".htm", factor.Name));
                }
            }

            String indexTemplate = DirectoryAndFileHelper.IndexTemplate;

            //switch (culture.Name.ToLower())
            //{
            //    case "es-es":
            //        {
            //            indexTemplate = DirectoryAndFileHelper.IndexTemplateSpanish;
            //            break;
            //        }
            //    case "fr":
            //        {
            //            indexTemplate = DirectoryAndFileHelper.IndexTemplateFrench;
            //            break;
            //        }
            //    default:
            //        {
            //            indexTemplate = DirectoryAndFileHelper.IndexTemplate;
            //            break;
            //        }
            //}

            using (StreamReader streamReader = new StreamReader(indexTemplate))
            {
                string template = streamReader.ReadToEnd();
                //factor data
                template = template.Replace("@InternalLinks@", stringBuilderInt.ToString());
                template = template.Replace("@ExternalLinks@", stringBuilderExt.ToString());

                //headers
                template = template.Replace("@KnowledgeResourcesHeader@", LanguageResourceManager.GetResourceText("KnowledgeResourcesHeader"));
                template = template.Replace("@InternalFactorsHeader@", LanguageResourceManager.GetResourceText("InternalFactorsHeader"));
                template = template.Replace("@ExternalFactorsHeader@", LanguageResourceManager.GetResourceText("ExternalFactorsHeader"));

                using (StreamWriter streamWriter2 = new StreamWriter(DirectoryAndFileHelper.Index, false))
                {
                    streamWriter2.Write(template);
                    streamWriter2.Flush();
                    streamWriter2.Close();
                }
                streamReader.Close();
            }
        }
コード例 #3
0
        public static void GenerateFactorHTML(Factor factor, String culture)
        {
            //Generate server html file
            CultureInfo uiCulture = new CultureInfo(culture);

            Thread.CurrentThread.CurrentUICulture = uiCulture;


            string content;
            string file = DirectoryAndFileHelper.ServerAppDataFolder + ConfigurationManager.AppSettings["HtmlTemplate"];

            using (StreamReader streamReader = new StreamReader(file))
            {
                content = streamReader.ReadToEnd();
                streamReader.Close();
            }

            //Updates html with database data
            string html = content.Replace("@Introduction@", CleanFormat(factor.Introduction));

            html = html.Replace("@Empirical Cases and Correlation@", CleanFormat(factor.EmpiricalCases));
            html = html.Replace("@Data Collection and Analysis methodologies@", CleanFormat(factor.DataCollection));
            html = html.Replace("@Questionnaire@", CleanFormat(factor.Questionnaire));
            html = html.Replace("@Observable indicators@", CleanFormat(factor.ObservableIndicators));
            html = html.Replace("@Title@", factor.Name);

            //headers
            html = html.Replace("@IntroductionHeader@", LanguageResourceManager.GetResourceText("IntroductionHeader"));
            html = html.Replace("@EmpiricalCasesHeader@", LanguageResourceManager.GetResourceText("EmpiricalCasesHeader"));
            html = html.Replace("@ObservableIndicatorsHeader@", LanguageResourceManager.GetResourceText("ObservableIndicatorsHeader"));
            html = html.Replace("@DataCollectionHeader@", LanguageResourceManager.GetResourceText("DataCollectionHeader"));
            html = html.Replace("@QuestionnaireHeader@", LanguageResourceManager.GetResourceText("QuestionnaireHeader"));

            DocumentManager.Save(DirectoryAndFileHelper.ServerAppDataFolder + ConfigurationManager.AppSettings["HTMLFolder"] + factor.IdFactor + ".htm", html);
        }
コード例 #4
0
        /// <summary>
        /// Generate the Model Index by modelId.
        /// </summary>
        /// <param name="modelId"></param>
        public static void GenerateModelIndex(int modelId, CultureInfo uiCulture)
        {
            StringBuilder stringBuilderInt = new StringBuilder();
            StringBuilder stringBuilderExt = new StringBuilder();

            Thread.CurrentThread.CurrentUICulture = uiCulture;

            List <ModelFactor> modelFactors = ModelFactorManager.GetByModel(modelId);

            foreach (Factor factor in FactorManager.GetAllWithHtmlDocument())
            {
                bool found = modelFactors.Any(f => f.IDFactor == factor.IdFactor);
                if (found)
                {
                    if (factor.InternalFactor)
                    {
                        stringBuilderInt.AppendLine(string.Format(IndexLinkTemplate, factor.IdFactor + ".htm", factor.Name));
                    }
                    else
                    {
                        stringBuilderExt.AppendLine(string.Format(IndexLinkTemplate, factor.IdFactor + ".htm", factor.Name));
                    }
                }
            }
            string location = DirectoryAndFileHelper.ServerAppDataFolder;

            String indexTemplate = DirectoryAndFileHelper.IndexTemplate;

            //switch (culture.Name.ToLower())
            //{
            //    case "es-es":
            //        {
            //            indexTemplate = DirectoryAndFileHelper.IndexTemplateSpanish;
            //            break;
            //        }
            //    case "fr":
            //        {
            //            indexTemplate = DirectoryAndFileHelper.IndexTemplateFrench;
            //            break;
            //        }
            //    default:
            //        {
            //            indexTemplate = DirectoryAndFileHelper.IndexTemplate;
            //            break;
            //        }
            //}

            using (StreamReader streamReader = new StreamReader(indexTemplate))
            {
                string template = streamReader.ReadToEnd();
                //factor data
                template = template.Replace("@InternalLinks@", stringBuilderInt.ToString());
                template = template.Replace("@ExternalLinks@", stringBuilderExt.ToString());

                //headers
                template = template.Replace("@KnowledgeResourcesHeader@", LanguageResourceManager.GetResourceText("KnowledgeResourcesHeader"));
                template = template.Replace("@InternalFactorsHeader@", LanguageResourceManager.GetResourceText("InternalFactorsHeader"));
                template = template.Replace("@ExternalFactorsHeader@", LanguageResourceManager.GetResourceText("ExternalFactorsHeader"));
                using (StreamWriter streamWriter2 = new StreamWriter(location + "\\" + ConfigurationManager.AppSettings["HTMLFolder"] + "\\IndexModel.htm", false))
                {
                    streamWriter2.Write(template);
                    streamWriter2.Flush();
                    streamWriter2.Close();
                }
                streamReader.Close();
            }
        }