Пример #1
0
        public void BeginSession(AgentSessionBase session)
        {
            pool.Add(session);

            session.ReleaseEvent += Session_OnReleased;
            OnSessionChanged(session);

            Log.Info($"Started Session '{session.SessionId}'.");
        }
Пример #2
0
 private string GetSessionType(AgentSessionBase session)
 {
     if (session is AgentBuildSession)
     {
         return("build");
     }
     if (session is AgentDeploySession)
     {
         return("deploy");
     }
     return(null);
 }
Пример #3
0
        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);
        }
Пример #4
0
 public SessionStateEventArgs(AgentSessionBase session)
 {
     this.Session = session;
 }
Пример #5
0
 protected void OnSessionChanged(AgentSessionBase session)
 {
     SessionChanged?.Invoke(this, new SessionStateEventArgs(session));
 }
Пример #6
0
 public bool TryGet(string sessionId, out AgentSessionBase session)
 {
     return(pool.TryGet(sessionId, out session));
 }