示例#1
0
        private async Task RunUserScripts(IList orders)
        {
            if (orders == null || orders.Count == 0)
            {
                return;
            }

            List <UserScript> scripts;

            using (var dbContext = _contextFactory.Get())
            {
                scripts = dbContext.UserScripts.Where(x => x.Type == UserScriptType.OrderScript).ToList();
            }

            foreach (var script in scripts)
            {
                try
                {
                    await _scriptRunner.RunOrderScript(script, orders.Cast <Order>().ToList()).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    _logger.Log(LogLevel.Error, "User script {0} generated an exception: ", script.Name);
                    _logger.Log(LogLevel.Error, ex);
                    await DialogService.ShowMessageAsync(Parent, "Error", $"User script {script.Name} generated an exception: {ex.Message}. See log for more details.");
                }
            }
        }