TeamMentor.CoreLib.TBot_Brain.ExecuteRazorPage C# (CSharp) Method

ExecuteRazorPage() public method

public ExecuteRazorPage ( string page ) : string
page string
return string
        public string ExecuteRazorPage(string page)
        {
            try
            {
                if (AvailableScripts.hasKey(page))
                {
                    var csFile = AvailableScripts[page];

                    var fileContents = csFile.fileContents();
                    var fileContentsHash = fileContents.hash();
                    if (TemplateService.HasTemplate(csFile).isFalse() || ScriptContentHashes.contains(fileContentsHash).isFalse())
                        {
                            Razor.Compile(fileContents, csFile);
                            ScriptContentHashes.add(fileContentsHash);
                        }
                    return Razor.Run(csFile, TmRest);
                }
            }
            catch (Exception ex)
            {
                if (ex.Message =="Thread was being aborted.")
                    return "";

                ex.log("[TBot Brain] [ExecuteRazorPage] {0} : {1}".format(page, ex.Message));
                return "Opps: Something went wrong: {0}".format(ex.Message);
            }
            return "";
        }

Usage Example

Example #1
0
        public void Script_Run_AllScripts()
        {
            SetUpNGit();
            var tbotBrain = new TBot_Brain(TmRest);
            foreach (var scriptName in tbotBrain.scriptsNames())
            {
                "================= Executing TBot script: {0}".info(scriptName);
                var html = tbotBrain.ExecuteRazorPage(scriptName); //"View_Emails_Sent");
                Assert.IsNotNull(html, "for :{0}".format(scriptName));
                var compileError = html.contains("Unable to compile template");
                if (compileError)
                {
                    html.info();
                    Assert.Fail("Failed to compile: {0}".format(scriptName));
                }
                var executionError = html.contains("Opps: Something went wrong:");
                if (executionError)
                {
                    html.info();
                    Assert.Fail("Execution error: on  {0}".format(scriptName));
                }

            }

            //"test webBrowser".popupWindow().add_WebBrowser().set_Html(html).waitForClose();
        }
All Usage Examples Of TeamMentor.CoreLib.TBot_Brain::ExecuteRazorPage