public void BeginSession(AgentSessionBase session) { pool.Add(session); session.ReleaseEvent += Session_OnReleased; OnSessionChanged(session); Log.Info($"Started Session '{session.SessionId}'."); }
private string GetSessionType(AgentSessionBase session) { if (session is AgentBuildSession) { return("build"); } if (session is AgentDeploySession) { return("deploy"); } return(null); }
private void SendUpdate(AgentSessionBase session) { uint? number = null; string name = null; string projectVersion = null; string gitRefspec = null; string status; var projectName = session.Project?.Name; if (!session.IsReleased) { status = "running"; } else if (session.Exception != null) { status = "failed"; } else { status = "success"; } if (session is AgentBuildSession buildSession) { number = buildSession.BuildNumber; name = "<unknown>"; // buildSession.TaskName; gitRefspec = buildSession.GitRefspec; } else if (session is AgentDeploySession deploySession) { number = deploySession.DeploymentNumber; name = "<unknown>"; // deploySession.ScriptName; projectVersion = $"{deploySession.ProjectPackageId} @{deploySession.ProjectPackageVersion}"; } var data = new { id = session.SessionId, type = GetSessionType(session), isReleased = session.IsReleased, status, number, name, projectName, projectVersion, gitRefspec, }; OnSessionChanged(data); }
public SessionStateEventArgs(AgentSessionBase session) { this.Session = session; }
protected void OnSessionChanged(AgentSessionBase session) { SessionChanged?.Invoke(this, new SessionStateEventArgs(session)); }
public bool TryGet(string sessionId, out AgentSessionBase session) { return(pool.TryGet(sessionId, out session)); }