public ScriptInstance(bool hasErrors, string sourceFilePath, IFrontMatter frontMatter, ScriptPage template) { HasErrors = hasErrors; SourceFilePath = sourceFilePath; FrontMatter = frontMatter; Template = template; }
protected override void OnStartProcessing(TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider) { LoggingService.AddLogEntry(LogLevel.Extended, "(Line " + tsInterface.LineNumber + ") Executing custom script at " + customScriptLocation, false); IMLScript imlScript = new IMLScript(); ScriptPage introPage = new ScriptPage(); introPage.ID = Guid.NewGuid().ToString(); /*if (LicenseService.IsTrialLicense()) * { * if (Properties.Settings.Default.WelcomeGreetingDelay > 0) * { * Delay welcomeDelay = new Delay(); * welcomeDelay.DelayTime = Properties.Settings.Default.WelcomeGreetingDelay.ToString(); * introPage.Actions.Add(welcomeDelay); * } * * introPage.Actions.Add(ScriptCompilers.ScriptUtils.CreateExternalAction(ScriptCompilers.BaseExternalCommands.CALLBUTLERINTERNAL_PlayLicenseIntroGreeting.ToString(), "")); * }*/ ScriptCompilers.ScriptUtils.ProcessPersonalizedGreeting(dataProvider, ref introPage, Properties.Settings.Default.CustomerID, tsInterface.IMLInterpreter.CallerDisplayName, tsInterface.IMLInterpreter.CallerUsername, tsInterface.IMLInterpreter.CallerHost, tsInterface.IMLInterpreter.DialedUsername); GotoPage gotoPage = new GotoPage(); gotoPage.Location = customScriptLocation; introPage.Actions.Add(gotoPage); imlScript.Pages.Add(introPage); tsInterface.IMLInterpreter.StartScript(imlScript, System.IO.Path.GetDirectoryName(customScriptLocation)); }
protected override void OnStartProcessing(TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider) { LoggingService.AddLogEntry(LogLevel.Extended, "(Line " + tsInterface.LineNumber + ") Executing custom script at " + customScriptLocation, false); IMLScript imlScript = new IMLScript(); ScriptPage introPage = new ScriptPage(); introPage.ID = Guid.NewGuid().ToString(); /*if (LicenseService.IsTrialLicense()) { if (Properties.Settings.Default.WelcomeGreetingDelay > 0) { Delay welcomeDelay = new Delay(); welcomeDelay.DelayTime = Properties.Settings.Default.WelcomeGreetingDelay.ToString(); introPage.Actions.Add(welcomeDelay); } introPage.Actions.Add(ScriptCompilers.ScriptUtils.CreateExternalAction(ScriptCompilers.BaseExternalCommands.CALLBUTLERINTERNAL_PlayLicenseIntroGreeting.ToString(), "")); }*/ ScriptCompilers.ScriptUtils.ProcessPersonalizedGreeting(dataProvider, ref introPage, Properties.Settings.Default.CustomerID, tsInterface.IMLInterpreter.CallerDisplayName, tsInterface.IMLInterpreter.CallerUsername, tsInterface.IMLInterpreter.CallerHost, tsInterface.IMLInterpreter.DialedUsername); GotoPage gotoPage = new GotoPage(); gotoPage.Location = customScriptLocation; introPage.Actions.Add(gotoPage); imlScript.Pages.Add(introPage); tsInterface.IMLInterpreter.StartScript(imlScript, System.IO.Path.GetDirectoryName(customScriptLocation)); }
protected override void OnStartProcessing(TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider) { string callFlowScriptLocation = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory) + "\\Call Flow.xml"; IMLScript imlScript = new IMLScript(); ScriptPage introPage = new ScriptPage(); introPage.ID = Guid.NewGuid().ToString(); if (Properties.Settings.Default.WelcomeGreetingDelay > 0) { Delay welcomeDelay = new Delay(); welcomeDelay.DelayTime = Properties.Settings.Default.WelcomeGreetingDelay.ToString(); introPage.Actions.Add(welcomeDelay); } /*if (LicenseService.IsTrialLicense()) * { * introPage.Actions.Add(ScriptCompilers.ScriptUtils.CreateExternalAction(ScriptCompilers.BaseExternalCommands.CALLBUTLERINTERNAL_PlayLicenseIntroGreeting.ToString(), "")); * }*/ ScriptCompilers.ScriptUtils.ProcessPersonalizedGreeting(dataProvider, ref introPage, Properties.Settings.Default.CustomerID, tsInterface.IMLInterpreter.CallerDisplayName, tsInterface.IMLInterpreter.CallerUsername, tsInterface.IMLInterpreter.CallerHost, tsInterface.IMLInterpreter.DialedUsername); if (File.Exists(callFlowScriptLocation)) { GotoPage gotoPage = new GotoPage(); gotoPage.Location = callFlowScriptLocation; introPage.Actions.Add(gotoPage); imlScript.Pages.Add(introPage); } tsInterface.IMLInterpreter.StartScript(imlScript, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory)); }
/// <summary> /// Pushes the current Page being executed. This should have enough information so that layouts and sections can work correctly. /// </summary> /// <param name="sourceFile">The Page.</param> public void PushPage(ScriptPage page) { if (page == null) { throw new ArgumentNullException(nameof(page)); } _pages.Push(page); }
private void DisassembleCodePage(TextWriter w, ScriptPage <byte> codePage) { var code = codePage.Data.AsSpan(); while (!code.IsEmpty) { DisassembleInstruction(w, ref code); } }
public ScriptTab(string title, ScriptPage scriptPage, Action <ScriptTab> close) : base(title) { var frame = new Frame(); frame.Content = scriptPage; Content = frame; ScriptPage = scriptPage; _Close = close; }
public void RunScript(int id, MapObject caller) { currentCommand = 0; this.caller = caller; currentScript = Global.GetScript(id); currentPage = GetCurrentPage(); NextCommand(); }
private void FixRawStatementAfterFrontMatter(ScriptPage page) { // In case of parsing a front matter, we don't want to include any \r\n after the end of the front-matter // So we manipulate back the syntax tree for the expected raw statement (if any), otherwise we can early // exit. var rawStatement = page.Body.Statements.FirstOrDefault() as ScriptRawStatement; if (rawStatement == null) { return; } rawStatement.Text = rawStatement.Text.TrimStart(); }
public ScriptPage <byte>[] ToPages(out uint stringsLength) { var p = new ScriptPage <byte> [pages.Count]; if (pages.Count > 0) { for (int i = 0; i < pages.Count - 1; i++) { p[i] = new ScriptPage <byte> { Data = NewPage() }; pages[i].CopyTo(p[i].Data, 0); } p[^ 1] = new ScriptPage <byte> {
private ScriptPage GetCurrentPage() { ScriptPage finalPage = null; if (currentScript != null && currentScript.Pages.Count() > 0) { // Evaluate each condition in order foreach (ScriptPage page in currentScript.Pages) { // Returns if there's no condition to be met if ((page.Switch != null && Global.GetSwitch(page.Switch)) || (page.Switch == null && page.Condition == null)) { finalPage = page; continue; } List <string> args = GetArgumentsList(page.Arguments); // Checks conditions switch (page.Condition) { case Constants.ConditionInteraction: // Verifies if there has been enough interactions with the caller ObjectInfo info = caller.SavedInformation; if (info != null) { int value = int.Parse(args[1]); if (Compare(args[0], info.NumberOfInteractions, value)) { finalPage = page; } } break; case Constants.ConditionHasItem: if (InventoryManager.Instance.HasItem(int.Parse(args[0]), int.Parse(args[1]))) { finalPage = page; } break; } } } return(finalPage); }
private void FixRawStatementAfterFrontMatter(ScriptPage page) { // In case of parsing a front matter, we don't want to include any \r\n after the end of the front-matter // So we manipulate back the syntax tree for the expected raw statement (if any), otherwise we can early // exit. var rawStatement = page.Body.Statements.FirstOrDefault() as ScriptRawStatement; if (rawStatement == null) { return; } int startOffset = rawStatement.Span.Start.Offset; int endOffset = rawStatement.Span.End.Offset; for (int i = startOffset; i <= endOffset; i++) { char c = rawStatement.Text[i]; if (c == ' ' || c == '\t') { continue; } if (c == '\r') { if (i + 1 <= endOffset && rawStatement.Text[i + 1] == '\n') { rawStatement.Span.Start = new TextPosition(i + 2, rawStatement.Span.Start.Line + 1, 0); } break; } if (c == '\n') { rawStatement.Span.Start = new TextPosition(i + 1, rawStatement.Span.Start.Line + 1, 0); } break; } }
private void ParseInternal(string text, string sourceFilePath) { // Early exit if (string.IsNullOrEmpty(text)) { HasErrors = false; Page = new ScriptPage() { Span = new SourceSpan(sourceFilePath, new TextPosition(), TextPosition.Eof) }; return; } var lexer = new Lexer(text, sourceFilePath, LexerOptions); var parser = new Parser(lexer, ParserOptions); Page = parser.Run(); HasErrors = parser.HasErrors; Messages.AddRange(parser.Messages); }
public ScriptPageArray <T> ToPages <T>() where T : struct { if (!IsPaged) { throw new InvalidOperationException("This segment is not paged"); } var data = MemoryMarshal.Cast <byte, T>(RawDataBuffer); // create pages var pageCount = (data.Length + Script.MaxPageLength) / Script.MaxPageLength; var p = new ScriptPage <T> [pageCount]; if (pageCount > 0) { for (int i = 0; i < pageCount - 1; i++) { p[i] = new ScriptPage <T> { Data = new T[Script.MaxPageLength] }; data.Slice(i * (int)Script.MaxPageLength, (int)Script.MaxPageLength).CopyTo(p[i].Data); } p[^ 1] = new ScriptPage <T> {
protected override void OnStartProcessing(TelecomScriptInterface tsInterface, CallButler.Telecom.TelecomProviderBase telecomProvider, WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider) { string callFlowScriptLocation = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory) + "\\Call Flow.xml"; IMLScript imlScript = new IMLScript(); ScriptPage introPage = new ScriptPage(); introPage.ID = Guid.NewGuid().ToString(); if (Properties.Settings.Default.WelcomeGreetingDelay > 0) { Delay welcomeDelay = new Delay(); welcomeDelay.DelayTime = Properties.Settings.Default.WelcomeGreetingDelay.ToString(); introPage.Actions.Add(welcomeDelay); } /*if (LicenseService.IsTrialLicense()) { introPage.Actions.Add(ScriptCompilers.ScriptUtils.CreateExternalAction(ScriptCompilers.BaseExternalCommands.CALLBUTLERINTERNAL_PlayLicenseIntroGreeting.ToString(), "")); }*/ ScriptCompilers.ScriptUtils.ProcessPersonalizedGreeting(dataProvider, ref introPage, Properties.Settings.Default.CustomerID, tsInterface.IMLInterpreter.CallerDisplayName, tsInterface.IMLInterpreter.CallerUsername, tsInterface.IMLInterpreter.CallerHost, tsInterface.IMLInterpreter.DialedUsername); if (File.Exists(callFlowScriptLocation)) { GotoPage gotoPage = new GotoPage(); gotoPage.Location = callFlowScriptLocation; introPage.Actions.Add(gotoPage); imlScript.Pages.Add(introPage); } tsInterface.IMLInterpreter.StartScript(imlScript, WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.SystemScriptsRootDirectory)); }
public ScriptPage Run() { Messages = new List <LogMessage>(); HasErrors = false; _blockLevel = 0; _isExpressionDepthLimitReached = false; Blocks.Clear(); ScriptPage page = Open <ScriptPage>(); ScriptMode parsingMode = CurrentParsingMode; switch (parsingMode) { case ScriptMode.FrontMatterAndContent: case ScriptMode.FrontMatterOnly: if (Current.Type != TokenType.FrontMatterMarker) { LogError(string.Format(RS.FrontMatterMarkerMissing, CurrentParsingMode, _lexer.Options.FrontMatterMarker, Current.GetText(_lexer.Text))); return(null); } _inFrontMatter = true; _inCodeSection = true; // Skip the frontmatter marker NextToken(); // Parse the front matter page.FrontMatter = ParseBlockStatement(null); // We should not be in a frontmatter after parsing the statements if (_inFrontMatter) { LogError(string.Format(RS.EndOfFrontMatterNotFound, _lexer.Options.FrontMatterMarker)); } if (parsingMode == ScriptMode.FrontMatterOnly) { return(page); } break; case ScriptMode.ScriptOnly: _inCodeSection = true; break; } page.Body = ParseBlockStatement(null); if (page.FrontMatter != null) { FixRawStatementAfterFrontMatter(page); } if (_lexer.HasErrors) { foreach (LogMessage lexerError in _lexer.Errors) { Log(lexerError); } } return(!HasErrors ? page : null); }
/// <summary> /// Initializes this instance. /// </summary> public bool TryEvaluate(ContentObject page, ScriptPage script, UPath scriptPath, ScriptObject obj = null, TemplateContext context = null) { if (page == null) { throw new ArgumentNullException(nameof(page)); } if (script == null) { throw new ArgumentNullException(nameof(script)); } if (scriptPath == null) { throw new ArgumentNullException(nameof(scriptPath)); } context = context ?? new TemplateContext(Builtins); if (obj != null) { context.PushGlobal(obj); } context.PushSourceFile((string)scriptPath); var currentScriptObject = (ScriptObject)context.CurrentGlobal; try { context.EnableOutput = true; var includeLoader = new TemplateLoaderFromIncludes(Site); context.TemplateLoader = includeLoader; currentScriptObject.SetValue(PageVariables.Site, Site, true); currentScriptObject.SetValue(PageVariables.Page, page, true); // TODO: setup include paths for script script.Evaluate(context); foreach (var includeFile in includeLoader.IncludeFiles) { page.Dependencies.Add(new FileContentDependency(includeFile)); } } catch (ScriptRuntimeException exception) { LogException(exception); return(false); } finally { if (obj != null) { context.PopGlobal(); } context.PopSourceFile(); page.Content = context.Output.ToString(); // We don't keep the site variable after this initialization currentScriptObject.Remove(PageVariables.Site); currentScriptObject.Remove(PageVariables.Page); } return(true); }