コード例 #1
0
        // POST api/analysis
        public async Task <HttpResponseMessage> Post()
        {
            //string partitionKey = Guid.NewGuid().ToString();
            Random ram          = new Random();
            int    partitionKey = ram.Next();

            byte[] image = await Request.Content.ReadAsByteArrayAsync();

            IYasudaAnalysis analysis = ServiceProxy.Create <IYasudaAnalysis>(
                new Uri("fabric:/Services/YasudaAnalysis"),
                new ServicePartitionKey(partitionKey));
            await analysis.StartAnalysis(partitionKey, image);

            var bodystr  = @"{""TaskId"":""" + partitionKey + @"""}";
            var bodycont = new StringContent(bodystr);

            bodycont.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var resp = new HttpResponseMessage();

            resp.Content = bodycont;
            //resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return(resp);
        }