Beispiel #1
0
        private async Task OnProcess(IServerSession session)
        {
            Log.Debug($"Session '{session.SessionId}' started...");
            TaskResult result;

            try {
                await PreProcessSession(session);

                if (!session.IsUserAborted)
                {
                    session.Output.WriteLine("SUCCESS.", ConsoleColor.Green);
                    result = TaskResult.Ok();
                }
                else
                {
                    session.Output.WriteLine("CANCELLED", ConsoleColor.DarkYellow);
                    result = TaskResult.Cancel();
                }
            }
            catch (Exception error) {
                if (!session.IsUserAborted)
                {
                    Log.Error($"Session '{session.SessionId}' failed!", error);

                    session.Exception = error;
                    session.Output.WriteBlock(w => w
                                              .Write("FAILED! ", ConsoleColor.DarkRed)
                                              .WriteLine(error.UnfoldMessages(), ConsoleColor.DarkYellow));

                    result = TaskResult.Error(error);
                }
                else
                {
                    session.Output.WriteLine("CANCELLED", ConsoleColor.DarkYellow);
                    result = TaskResult.Cancel();
                }
            }

            try {
                await PostProcessSession(session, result);
            }
            catch (Exception error) {
                Log.Error($"Session '{session.SessionId}' cleanup failed!", error);
            }
            finally {
                Log.Debug($"Session '{session.SessionId}' released.");

                GC.Collect();
            }
        }
Beispiel #2
0
        public async Task Abort()
        {
            IsUserAborted = true;
            TokenSource.Cancel();

            foreach (var host in hostList.Values)
            {
                try {
                    host.Abort();
                }
                catch {}
            }

            Complete(TaskResult.Cancel());
            await ReleaseAsync();
        }
Beispiel #3
0
        private async Task OnProcess(IServerSession session)
        {
            Log.Debug($"Session '{session.SessionId}' started...");
            TaskResult result;

            try {
                await PreProcessSession(session);

                session.Output.WriteLine("Build Successful.", ConsoleColor.Green);
                result = TaskResult.Ok();
            }
            catch (OperationCanceledException) {
                Log.Warn($"Session '{session.SessionId}' cancelled.");

                session.Output.WriteLine("Build Cancelled.", ConsoleColor.DarkYellow);
                result = TaskResult.Cancel();
            }
            catch (Exception error) {
                Log.Error($"Session '{session.SessionId}' failed!", error);

                session.Exception = error;
                session.Output.WriteBlock(w => w
                                          .Write("Build Failed! ", ConsoleColor.DarkRed)
                                          .WriteLine(error.UnfoldMessages(), ConsoleColor.DarkYellow));

                result = TaskResult.Error(error);
            }

            try {
                await PostProcessSession(session, result);
            }
            catch (Exception error) {
                Log.Error($"Session '{session.SessionId}' cleanup failed!", error);
            }
            finally {
                Log.Debug($"Session '{session.SessionId}' released.");

                GC.Collect();
            }
        }
Beispiel #4
0
 public bool Cancel()
 {
     return(TaskResult.Cancel());
 }