Beispiel #1
0
        /// <summary>
        ///		Ejecuta una sentencia de proceso
        /// </summary>
        private async Task ProcessExecuteAsync(BlockLogModel parent, ExecuteSentence sentence)
        {
            // Evita el warning
            await Task.Delay(1);

            // Ejecuta la sentencia
            using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start execution '{sentence.Process}'"))
            {
                try
                {
                    LibHelper.Processes.SystemProcessHelper processor = new LibHelper.Processes.SystemProcessHelper();

                    // Ejecuta el proceso
                    processor.ExecuteApplication(sentence.Process, ConvertArguments(sentence.Arguments), true, sentence.Timeout);
                    // Log
                    block.Info($"End execution '{sentence.Process}'");
                }
                catch (Exception exception)
                {
                    AddError(block, $"Error when execute '{sentence.Process}'. {exception.Message}");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///		Carga una sentencia de ejecución de un proceso
        /// </summary>
        private BaseSentence LoadExecuteSentence(MLNode rootML)
        {
            ExecuteSentence sentence = new ExecuteSentence();

            // Carga los datos
            AssignSentence(sentence, rootML);
            sentence.Process = rootML.Attributes[TagProcess].Value.TrimIgnoreNull();
            // Carga los argumentos
            foreach (MLNode nodeML in rootML.Nodes)
            {
                if (nodeML.Name == TagArgument)
                {
                    sentence.Arguments.Add(new ExecuteSentenceArgument
                    {
                        Key               = nodeML.Attributes[TagKey].Value.TrimIgnoreNull(),
                        Value             = nodeML.Attributes[TagValue].Value.TrimIgnoreNull(),
                        TransformFileName = nodeML.Attributes[TagTransformFileName].Value.GetBool()
                    }
                                           );
                }
            }
            // Devuelve la sentencia
            return(sentence);
        }