Exemplo n.º 1
0
        private void NotifyAndLog(string message, params object[] args)
        {
            var text = string.Format(message, args);

            Broadcast(text);
            DocSession.Store(new DeploymentLog
            {
                CreatedBy   = User.Identity.Name,
                LoggedAt    = DateTime.Now,
                Description = text,
            });
        }
Exemplo n.º 2
0
        public HttpResponseMessage Post(DeployRequest request)
        {
            try
            {
                if (request == null || string.IsNullOrEmpty(request.TfsProjectName))
                {
                    NotifyAndLog("Deployment request is rejected because of invalid data");
                    return(new HttpResponseMessage(HttpStatusCode.NotAcceptable));
                }

                request.CreatedAt = DateTime.Now;

                NotifyAndLog("Deployment request received for project '{0}'", request.TfsProjectName);
                ProcessDeployment(request);

                request.DeploySucceeded = true;

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                NotifyAndLog(ex.Message);
                NotifyAndLog(ex.StackTrace);
                //todo: rollback process

                if (request != null)
                {
                    request.DeploySucceeded = false;
                }

                return(new HttpResponseMessage(HttpStatusCode.ExpectationFailed));
            }
            finally
            {
                if (request != null)
                {
                    DocSession.Store(request);
                }
            }
        }
Exemplo n.º 3
0
 public IEnumerable <DeployRequest> Get()
 {
     return(DocSession.Query <DeployRequest>()
            .OrderByDescending(d => d.CreatedAt)
            .Take(5));
 }