Example #1
0
        private async Task <ScriptRunner <object> > GetCompiledBotScript(BotDto bot)
        {
            if (!_botScriptCache.ScriptStored(bot.Id))
            {
                try
                {
                    await _lock.WaitAsync();

                    var script = await _botLogic.GetBotScript(bot.Id);

                    var botScript = _botScriptCompiler.Compile(script);
                    _botScriptCache.StoreScript(bot.Id, botScript);
                }
                catch (Exception ex)
                {
                    _logger.Log($"{ex}");
                }
                finally
                {
                    _lock.Release();
                }
            }

            return(_botScriptCache.LoadScript(bot.Id));
        }
Example #2
0
        private async Task <Script> GetCompiledBotScript(BotDto bot)
        {
            if (!_botScriptCache.ScriptStored(bot.Id))
            {
                try
                {
                    var script = await _botLogic.GetBotScript(bot.Id);

                    var botScript = _botScriptCompiler.Compile(script);
                    _botScriptCache.StoreScript(bot.Id, botScript);
                }
                catch (Exception ex)
                {
                    _logger.LogError($"{ex}");
                }
            }

            return(_botScriptCache.LoadScript(bot.Id));
        }