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, }); }
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); } } }