Ejemplo n.º 1
0
        public async Task <ActionResult> CreateRequestAsync(string accesstoken, string contents, string tag, string deletepolicy)
        {
            //var permissions= await NightscoutPermissions.CheckUploadPermissions(accesstoken);
            //var permissions = await NightscoutPermissions.CheckProcessPermissions(accesstoken);
            if (!await this.checkUploadPermissions(accesstoken))
            {
                return(this.Error("CreateRequestAsync Denied"));
            }



            if (string.IsNullOrWhiteSpace(contents))
            {
                return(this.Error("CreateRequestAsync Denied: invalid parameter contents"));
            }



            var g       = Guid.NewGuid().ToString();
            var reading = new RBS_Blob
            {
                CreatedOn    = DateTime.Now,
                ModifiedOn   = DateTime.Now,
                contents     = contents,
                uuid         = g,
                purpose      = "RBS",
                tag          = string.IsNullOrWhiteSpace(tag) ? null : tag.Substring(0, Math.Min(tag.Length, 10)),
                deletePolicy = deletepolicy == "autodelete" ? "auto" : null
            };

            //return this.Error("synthax ok");
            try{
                await MongoConnection.AsyncInsertReading(reading);
            } catch (System.TimeoutException) {
                return(Error("Timeout, database down?"));
            }

            return(Success <RBS_Blob>(reading, "CreateRequestAsync"));

            //var content = $"accesstoken: {accesstoken}, b64contents: {b64contents}, guid: {g}";
            //return Content("CreateRequestAsync IS NOT IMPLEMENTED YET:" + content);
        }
Ejemplo n.º 2
0
 public async static Task AsyncInsertReading(RBS_Blob reading)
 {
     await GetReadingsCollection().InsertOneAsync(reading);
 }