示例#1
0
 public CommandEmission(ICommandSpec CommandSpec, Option <FilePath> OutputPath)
 {
     this.CommandSpec = CommandSpec;
     this.OutputPath  = OutputPath;
     this.Description = Succeeded
         ? AppMessage.Inform($"Emitted {CommandSpec.SpecName}")
         : OutputPath.Message;
 }
示例#2
0
    public static Task <CommandProcessExecutionLog> Invoke(FilePath ExecutablePath, string args, string workdir = null)
    {
        var proc = new Process
        {
            StartInfo = new ProcessStartInfo
            {
                FileName               = ExecutablePath,
                Arguments              = args,
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                WorkingDirectory       = workdir ?? Environment.CurrentDirectory
            },
            EnableRaisingEvents = true,
        };

        var result = new CommandProcessExecutionLog();

        proc.OutputDataReceived += (sender, e) =>
        {
            if (isNotBlank(e.Data))
            {
                result.StatusMessages.Add(e.Data);
                SystemConsole.Get().Write(AppMessage.Inform(e.Data));
            }
        };
        proc.ErrorDataReceived += (sender, e) =>
        {
            if (isNotBlank(e.Data))
            {
                result.ErrorMessages.Add(e.Data);
                SystemConsole.Get().Write(AppMessage.Error(e.Data));
            }
        };

        proc.Start();
        proc.BeginOutputReadLine();
        proc.BeginErrorReadLine();


        return(Task.Run(() =>
        {
            proc.WaitForExit();
            result.ExitCode = proc.ExitCode;

            proc.Dispose();

            return result;
        }));
    }
示例#3
0
 public static FileWriteResult Success(FilePath DstPath, IAppMessage Message = null)
 => new FileWriteResult(DstPath, Message ?? AppMessage.Inform($"The {DstPath} file was successfully written"));
示例#4
0
 static IAppMessage ControllerStarting()
 => AppMessage.Inform("Starting controller and subject orchestrations", new
 {
 });
示例#5
0
 public IAppMessage ToMessage()
 => AppMessage.Inform(
     $"{nameof(TotalSubmissions)}: @{nameof(TotalSubmissions)}, "
     + $"{nameof(TotalDispatches)}: @{nameof(TotalDispatches)}, " +
     $"{nameof(TotalCompletions)}: @{nameof(TotalCompletions)} " +
     $"{nameof(Duration)}: @{nameof(Duration)}s", this);
示例#6
0
 /// <summary>
 /// Defines a status message
 /// </summary>
 /// <param name="text">The message text</param>
 /// <param name="callerFile">The file from which the call was made</param>
 /// <param name="callerName">The name of the invoking member</param>
 /// <returns></returns>
 public static IAppMessage inform(string text,
                                  [CallerFilePath] string callerFile   = null,
                                  [CallerMemberName] string callerName = null)
 => AppMessage.Inform(text, callerFile, callerName);
示例#7
0
 /// <summary>
 /// Defines a correlated status message with typed content
 /// </summary>
 /// <typeparam name="C">The content type</typeparam>
 /// <param name="CT">The correlation value</param>
 /// <param name="template">A content-bound template string</param>
 /// <param name="content">The typed content</param>
 /// <param name="callerFile">The file from which the call was made</param>
 /// <param name="callerName">The name of the invoking member</param>
 /// <returns></returns>
 public static IAppMessage inform <C>(CorrelationToken CT, string template, C content,
                                      [CallerFilePath] string callerFile   = null,
                                      [CallerMemberName] string callerName = null)
 => AppMessage.Inform(CT, template, content, callerFile, callerName);
示例#8
0
 public IAppMessage ToMessage()
 => AppMessage.Inform(
     "Pending:@PendingTaskCount Executing:@ExecutingTaskCount Executed:@ExecutedTaskCount Spinners:@SpinnerCount Revolutions:@RevolutionCount Last Submitted: @LastSubmissionCount", this);
示例#9
0
 public static IAppMessage Stopped()
 => AppMessage.Inform("Agent execution stopped");
示例#10
0
 public static IAppMessage Stopping()
 => AppMessage.Inform("Stopping agent");
示例#11
0
 public static IAppMessage WaitingForTasks(int Count, int Timeout)
 => AppMessage.Inform("Waiting a maximum of @Timeout ms for @Count currently executing tasks to finish", new
 {
     Count,
     Timeout
 });
示例#12
0
 public static IAppMessage TaskGroupExecutionCancelled(string GroupName)
 => AppMessage.Inform("The @GroupName task group was cancelled", new
 {
     GroupName
 });
示例#13
0
 protected static IAppMessage Describe <C>(string template, C content,
                                           [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null)
 => AppMessage.Inform(template, content, callerFile, callerName);