Example #1
0
        public void BeginSession(ServerSessionBase session)
        {
            pool.Add(session);

            session.ReleaseEvent += Session_OnReleased;
            OnSessionStarted(session);
        }
Example #2
0
        private void SendUpdate(ServerSessionBase session)
        {
            var    projectName    = session.SessionId;
            string projectVersion = null;

            if (session is ServerBuildSession buildSession)
            {
                projectName    = buildSession.Project?.Name;
                projectVersion = buildSession.GitRefspec;
            }
            else if (session is ServerDeploySession deploySession)
            {
                projectName    = deploySession.Project?.Name;
                projectVersion = $"{deploySession.ProjectPackageId} @{deploySession.ProjectPackageVersion}";
            }
            else if (session is ServerUpdateSession updateSession)
            {
                projectName    = "Update Agents";
                projectVersion = updateSession.AgentIds != null
                    ? string.Join(", ", updateSession.AgentIds)
                    : "<all>";
            }

            var data = new {
                id         = session.SessionId,
                type       = GetSessionType(session),
                isReleased = session.IsReleased,
                projectName,
                projectVersion,
            };

            OnSessionChanged(data);
        }
Example #3
0
        private void SendUpdate(ServerSessionBase session)
        {
            uint?  number         = null;
            string name           = null;
            string projectName    = null;
            string projectVersion = null;
            string gitRefspec     = null;
            string status;

            if (!session.IsReleased)
            {
                status = "running";
            }
            else if (session.Exception != null)
            {
                status = "failed";
            }
            else
            {
                status = "success";
            }

            if (session is ServerBuildSession buildSession)
            {
                number      = buildSession.Build.Number;
                name        = buildSession.TaskName;
                projectName = buildSession.Project?.Name;
                gitRefspec  = buildSession.GitRefspec;
            }
            else if (session is ServerDeploySession deploySession)
            {
                number         = deploySession.Deployment.Number;
                name           = deploySession.ScriptName;
                projectName    = deploySession.Project?.Name;
                projectVersion = $"{deploySession.ProjectPackageId} @{deploySession.ProjectPackageVersion}";
            }
            else if (session is ServerUpdateSession updateSession)
            {
                projectName    = "Update Agents";
                projectVersion = updateSession.AgentIds != null
                    ? string.Join(", ", updateSession.AgentIds)
                    : "<all>";
            }

            var data = new {
                id         = session.SessionId,
                type       = GetSessionType(session),
                isReleased = session.IsReleased,
                number,
                name,
                status,
                projectName,
                projectVersion,
                gitRefspec,
            };

            OnSessionChanged(data);
        }
Example #4
0
        public void BeginSession(ServerSessionBase session)
        {
            pool.Add(session);

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

            Log.Info($"Started Session '{session.SessionId}'.");
        }
Example #5
0
 private string GetSessionType(ServerSessionBase session)
 {
     if (session is ServerBuildSession)
     {
         return("build");
     }
     if (session is ServerDeploySession)
     {
         return("deploy");
     }
     if (session is ServerUpdateSession)
     {
         return("update");
     }
     return(null);
 }
Example #6
0
 public SessionStateEventArgs(ServerSessionBase session)
 {
     this.Session = session;
 }
Example #7
0
 protected void OnSessionReleased(ServerSessionBase session)
 {
     SessionReleased?.Invoke(this, new SessionStateEventArgs(session));
 }
Example #8
0
 public bool TryGet(string sessionId, out ServerSessionBase session)
 {
     return(pool.TryGet(sessionId, out session));
 }