Beispiel #1
0
        private async Task RunImpl(Rules Item, RoutedItem routedItem)
        {
            var taskInfo = $"task: {routedItem.TaskID}";

            //get destRules that match this connection and
            var destRulesToProcess = Item.destRules.FindAll(e => e.fromConnectionName == routedItem.fromConnection);

            //loop the rules
            foreach (var destRule in destRulesToProcess)
            {
                //run the scripts for this rule
                foreach (var scriptname in destRule.preProcessToConnectionScriptNames)
                {
                    if (scriptname.Equals("ruleTags"))
                    {
                        //run the scripts for the rule tags
                        foreach (var ruleTag in destRule.ruleTags)
                        {
                            var tagscript = Item.scripts.Find(e => e.name == ruleTag.scriptName);
                            routedItem.ruleDicomTag = ruleTag;
                            _logger.Log(LogLevel.Debug, $"{taskInfo} running tag script {tagscript.name}");

                            await _scriptService.RunAsync(tagscript, routedItem);
                        }
                    }
                    else
                    {
                        var script = Item.scripts.Find(e => e.name == scriptname);
                        _logger.Log(LogLevel.Debug, $"{taskInfo} running tag script {script.name}");
                        //await script.RunAsync(routedItem);
                        await _scriptService.RunAsync(script, routedItem);
                    }
                }
            }
        }
        /// <summary>
        /// RunPostProcessToConnectionScripts is intended to be run once for each toConnection after outbound processing.
        /// </summary>
        /// <param name="Item"></param>
        /// <param name="routedItem"></param>
        /// <returns></returns>
        public async Task RunPostProcessToConnectionScripts(Rules Item, RoutedItem routedItem)
        {
            Throw.IfNull(Item);
            Throw.IfNull(routedItem);

            var taskInfo = $"task: {routedItem.TaskID}";

            try
            {
                //get destRules that match this connection and
                var destRulesToProcess = Item.destRules.FindAll(e => e.fromConnectionName == routedItem.fromConnection);

                //loop the rules
                foreach (var destRule in destRulesToProcess)
                {
                    //run the scripts for this rule
                    foreach (var scriptname in destRule.postProcessToConnectionScriptNames)
                    {
                        if (scriptname.Equals("ruleTags"))
                        {
                            //run the scripts for the rule tags
                            foreach (var ruleTag in destRule.ruleTags)
                            {
                                var tagscript = Item.scripts.Find(e => e.name == ruleTag.scriptName);
                                routedItem.ruleDicomTag = ruleTag;
                                _logger.Log(LogLevel.Debug, $"{taskInfo} running tag script {tagscript.name}");
                                //await tagscript.RunAsync(routedItem);
                                await _scriptService.RunAsync(tagscript, routedItem);
                            }
                        }
                        else
                        {
                            var script = Item.scripts.Find(e => e.name == scriptname);
                            _logger.Log(LogLevel.Debug, $"{taskInfo} running script {script.name}");
                            //await script.RunAsync(routedItem);
                            await _scriptService.RunAsync(script, routedItem);
                        }
                    }
                }
            }
            catch (TaskCanceledException)
            {
                _logger.Log(LogLevel.Information, $"Task was canceled.");
            }
            catch (Exception e)
            {
                _logger.LogFullException(e);
            }
        }
Beispiel #3
0
        private async Task ProcessScripts(string scriptname, List <Script> scripts, RoutedItem routedItem, DestRule destRule)
        {
            Throw.IfNull(destRule);

            var taskInfo = GetTaskInfo(routedItem);

            _logger.Log(LogLevel.Debug, $"{taskInfo} script {scriptname}");

            if (!scriptname.Equals("ruleTags"))
            {
                var script = scripts.Find(e => e.name == scriptname);
                _logger.Log(LogLevel.Debug, $"{taskInfo} running script {script.name}");
                await _scriptService.RunAsync(script, routedItem);

                return;
            }

            //run the scripts for the rule tags
            foreach (Tag ruleTag in destRule.ruleTags)
            {
                await ProcessScriptFromTag(ruleTag, routedItem, scripts);
            }
        }