Exemple #1
0
        public HttpResponseMessage Post([FromBody] JToken jsonbody)
        {
            // Process the jsonbody
            var requestStream = HttpContext.Current.Request.InputStream;

            Stream req = requestStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);

            string json = jsonbody.ToString();

            ActionRequest ar = null;

            try
            {
                // assuming JSON.net/Newtonsoft library from http://json.codeplex.com/
                ar = JsonConvert.DeserializeObject <ActionRequest>(json);
            }
            catch
            {
                // Try and handle malformed POST body
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            _notificationService = new NotificationService();
            ProgressState ps = ar.ToProgressObject(ar, ar.StateString);

            _notificationService.SendNotification(ps);

            _progressHub.sendProgressUpdate(ps);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }