public override void OnException(HttpActionExecutedContext context) { if (context.Exception != null) { if (context.Exception is InvalidOperationException || context.Exception is ArgumentException) { context.Response = new HttpResponseMessage(HttpStatusCode.BadRequest); context.Response.Content = new ObjectContent(typeof(GlobalJsonResult <EmptyResult>), GlobalJsonResult <EmptyResult> .Error(context.Exception, HttpStatusCode.BadRequest), new JsonMediaTypeFormatter()); } else if (context.Exception is UnauthorizedAccessException) { context.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized); context.Response.Content = new ObjectContent(typeof(GlobalJsonResult <EmptyResult>), GlobalJsonResult <EmptyResult> .Error(context.Exception, HttpStatusCode.Unauthorized), new JsonMediaTypeFormatter()); } else { context.Response = new HttpResponseMessage(HttpStatusCode.InternalServerError); context.Response.Content = new ObjectContent(typeof(GlobalJsonResult <EmptyResult>), GlobalJsonResult <EmptyResult> .Error(context.Exception, HttpStatusCode.InternalServerError), new JsonMediaTypeFormatter()); } } base.OnException(context); }
public GlobalJsonResult <Project> GetWorkingProject() { var projectId = store.GetWorkingProjectId(); var result = dispatcher.Dispatch(ProjectActions.GetProject(projectId)); return(GlobalJsonResult <Project> .Success(System.Net.HttpStatusCode.OK, result)); }
public override void OnException(HttpActionExecutedContext context) { if (context.Exception != null) { var loggerHub = GlobalHost.ConnectionManager.GetHubContext <LoggerHub>(); loggerHub.Clients.All.broadcastMessage("log", new[] { DateTime.Now.ToString("s"), context.Exception.Message, context.Exception.StackTrace }); if (context.Exception is InvalidOperationException || context.Exception is ArgumentException) { context.Response = new HttpResponseMessage(HttpStatusCode.BadRequest); context.Response.Content = new ObjectContent(typeof(GlobalJsonResult <EmptyResult>), GlobalJsonResult <EmptyResult> .Error(context.Exception, HttpStatusCode.BadRequest), new JsonMediaTypeFormatter()); } else if (context.Exception is UnauthorizedAccessException) { context.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized); context.Response.Content = new ObjectContent(typeof(GlobalJsonResult <EmptyResult>), GlobalJsonResult <EmptyResult> .Error(context.Exception, HttpStatusCode.Unauthorized), new JsonMediaTypeFormatter()); } else { context.Response = new HttpResponseMessage(HttpStatusCode.InternalServerError); context.Response.Content = new ObjectContent(typeof(GlobalJsonResult <EmptyResult>), GlobalJsonResult <EmptyResult> .Error(context.Exception, HttpStatusCode.InternalServerError), new JsonMediaTypeFormatter()); } } base.OnException(context); }
public GlobalJsonResult <EmptyResult> Load(int videoId, [FromBody] LoadVideoPlaybackRequest request) { var video = videoComponentService.GetById(videoId); videoPlayer.Load(video); return(GlobalJsonResult <EmptyResult> .Success(HttpStatusCode.OK)); }
public GlobalJsonResult <EmptyResult> New([FromBody] VideoMetadataCreateRequest request) { var video = videoComponentService.Initialize(request.Id, request); videoComponentService.Save(video); return(GlobalJsonResult <EmptyResult> .Success(HttpStatusCode.Created)); }
public GlobalJsonResult <Build> UpdateBuild([FromBody] UpdateBuildRequest request) { var build = request.Map(); dataAccessDispatcher.Dispatch(BuildActions.UpdateBuild(build)); return(GlobalJsonResult <Build> .Success(System.Net.HttpStatusCode.OK, build)); }
public GlobalJsonResult <bool> NewSession([FromBody] NewSessionRequest request) { var client = request.Map(); clientStore.Set(client); return(GlobalJsonResult <bool> .Success(System.Net.HttpStatusCode.OK, true)); }
public GlobalJsonResult <EmptyResult> Clear(int videoId) { var video = videoService.GetById(videoId); video.ClearFrames(); return(GlobalJsonResult <EmptyResult> .Success(HttpStatusCode.OK)); }
public GlobalJsonResult <EmptyResult> Append(int videoId, [FromBody] AppendFramesRequest request) { var video = videoService.GetById(videoId); var frames = request.AppendFrameRequests .Select(req => frameService.Initialize(1, req)); video.AddFrames(frames); return(GlobalJsonResult <EmptyResult> .Success(HttpStatusCode.Created)); }
public GlobalJsonResult <InstallationStatusResult> GetInstallationStatus() { var installationStatus = installation.GetStatus(); var result = new InstallationStatusResult(); result.PopulateFrom(installationStatus); return(GlobalJsonResult <InstallationStatusResult> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <RollbackResult> RollbackComponentsForVersion([FromBody] RollbackRequest request) { installation.RollbackInstallationVersion(request.FailedInstallationComponentId, Version.Parse(request.FailedInstallationVersion)); var version = installation.GetCurrentVersion(); var result = new RollbackResult(); result.PopulateFrom(version); return(GlobalJsonResult <RollbackResult> .Success(System.Net.HttpStatusCode.NoContent, result)); }
public GlobalJsonResult <EmptyResult> Put([FromBody] VideoMetadataPutRequest request) { var video = videoComponentService.GetById(request.Id); PutRequest.DoThisIfValueIsNotDefault(request.FileName, v => video.SetFileName(v)); PutRequest.DoThisIfValueIsNotDefault(request.FrameRate, v => video.SetFrameRate(v)); videoComponentService.Save(video); return(GlobalJsonResult <EmptyResult> .Success(HttpStatusCode.OK)); }
public GlobalJsonResult <InstallationResult> StartInstallation([FromBody] StartInstallationRequest request) { var installationResult = installation.StartInstallation(); var result = new InstallationResult(); result.PopulateFrom(installationResult); return(result.IsSuccess ? GlobalJsonResult <InstallationResult> .Success(System.Net.HttpStatusCode.Created, result) : GlobalJsonResult <InstallationResult> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <InstallationResult> InstallNextComponent([FromBody] ComponentInstallationRequest request) { var installationResult = installation.InstallNextComponent(request.InstallationComponentId, Version.Parse(request.Version)); var result = new InstallationResult(); result.PopulateFrom(installationResult); return(result.IsSuccess ? GlobalJsonResult <InstallationResult> .Success(System.Net.HttpStatusCode.Created, result) : GlobalJsonResult <InstallationResult> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <IEnumerable <VideoMetadataResult> > GetAll() { var results = videoComponentService .GetAll() .Select(v => { var result = new VideoMetadataResult(); result.Populate(v); return(result); }); return(GlobalJsonResult <IEnumerable <VideoMetadataResult> > .Success(HttpStatusCode.OK, results)); }
public GlobalJsonResult <VideoMetadataResponse> GetProjectVideoMetadata(int projectId) { var video = dispatcher.Dispatch(VideoActions.GetVideoForProject(projectId)); Guard.This(video).AgainstDefaultValue(string.Format("No video exists for project with id {0}", projectId)); Guard.This(video.FilePath).WithRule(path => File.Exists(path), string.Format("Video {0} does not exist", video.FilePath)); videoFileReader.Open(video.FilePath); var result = new VideoMetadataResponse(); result.Populate(videoFileReader); return(GlobalJsonResult <VideoMetadataResponse> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <ProjectVideo> AddMostRecentVideoUploadToProject(int projectId, int videoReferenceId) { var result = dispatcher.Dispatch(VideoActions.SetVideoForProject(projectId, videoReferenceId)); // When a video changes, create new version of project devices var projectDevices = dispatcher.Dispatch(ProjectDeviceActions.GetProjectDevices(projectId)); foreach (var projectDevice in projectDevices) { var latestProjectDeviceVersion = dispatcher.Dispatch(ProjectDeviceActions.GetLatestProjectDeviceVersion(projectDevice.Id)); dispatcher.Dispatch(ProjectDeviceActions.SetLatestProjectDeviceVersion(latestProjectDeviceVersion)); } return(GlobalJsonResult <ProjectVideo> .Success(System.Net.HttpStatusCode.Created, result)); }
public GlobalJsonResult <Dictionary <string, string> > GetProjectDeviceStatuses(int projectId) { var projectDevices = dataAccessDispatcher.Dispatch(DeviceActions.GetProjectDevices(projectId)); var statuses = new Dictionary <string, string>(); foreach (var projectDevice in projectDevices) { var name = string.IsNullOrEmpty(projectDevice.Name) ? projectDevice.IpAddress : projectDevice.Name; var status = deviceStatusService.IsOnline(projectDevice) ? ProjectDevicePlaybackStatus.Ready : ProjectDevicePlaybackStatus.NotOnline; statuses.Add(name, status.ToString()); } return(GlobalJsonResult <Dictionary <string, string> > .Success(System.Net.HttpStatusCode.OK, statuses)); }
public GlobalJsonResult <Project> Update([FromBody] Project project) { dispatcher.Dispatch(ProjectActions.UpdateProject(project)); return(GlobalJsonResult <Project> .Success(System.Net.HttpStatusCode.OK, project)); }
public GlobalJsonResult <VideoReference> GetProjectVideo(int projectId) { var result = dispatcher.Dispatch(VideoActions.GetVideoForProject(projectId)); return(GlobalJsonResult <VideoReference> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <VideoReference> FinishVideoUpload() { var result = videoUploader.ConsumeAndFinishUpload(); return(GlobalJsonResult <VideoReference> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <EmptyResult> PreUploadVideo(string fileName) { videoUploader.PreUpload(fileName); return(GlobalJsonResult <EmptyResult> .Success(System.Net.HttpStatusCode.OK)); }
public GlobalJsonResult <IEnumerable <VideoReference> > GetVideoReferences() { var result = dispatcher.Dispatch(VideoActions.GetVideoReferences()); return(GlobalJsonResult <IEnumerable <VideoReference> > .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <IEnumerable <Project> > GetAll() { var projects = dispatcher.Dispatch(ProjectActions.GetAllProjects()); return(GlobalJsonResult <IEnumerable <Project> > .Success(System.Net.HttpStatusCode.OK, projects)); }
public GlobalJsonResult <EmptyResult> SetWorkingProject(int projectId) { store.SetCurrentProject(projectId); return(GlobalJsonResult <EmptyResult> .Success(System.Net.HttpStatusCode.Created)); }
public GlobalJsonResult <bool> HasWorkingProject() { var result = store.HasWorkingProject(); return(GlobalJsonResult <bool> .Success(System.Net.HttpStatusCode.OK, result)); }
public GlobalJsonResult <Project> CopyProject(Project project) { var newProject = dispatcher.Dispatch(ProjectActions.CopyProject(project)); return(GlobalJsonResult <Project> .Success(System.Net.HttpStatusCode.Created, newProject)); }
public GlobalJsonResult <Project> Get(int id) { var project = dispatcher.Dispatch(ProjectActions.GetProject(id)); return(GlobalJsonResult <Project> .Success(System.Net.HttpStatusCode.OK, project)); }
public GlobalJsonResult <DateTime> Get() { return(GlobalJsonResult <DateTime> .Success(System.Net.HttpStatusCode.OK, DateTime.Now)); }
public GlobalJsonResult <EmptyResult> Delete(int id) { dispatcher.Dispatch(ProjectActions.DeleteProject(id)); return(GlobalJsonResult <EmptyResult> .Success(System.Net.HttpStatusCode.NoContent)); }