protected override void Execute(CodeActivityContext context) { var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(10); } var key = Key.Get(context); var fileurl = Fileurl.Get(context); var desiredstatus = Status.Get(context).ToLower(); string status = ""; var sw = new Stopwatch(); sw.Start(); do { var res = SimpleRequests.GET(fileurl, key); var o = JObject.Parse(res); status = o["status"].ToString(); if (status != desiredstatus) { System.Threading.Thread.Sleep(1000); } } while (status != desiredstatus && sw.Elapsed < timeout); context.SetValue(Result, status); }
protected override void Execute(CodeActivityContext context) { var key = Key.Get(context); var queue = Queue.Get(context); var fileurl = Fileurl.Get(context); var status = ""; while (status != "to_review" && status != "exported") { var statusres = SimpleRequests.GET(fileurl, key); var statuso = JObject.Parse(statusres); status = statuso["status"].ToString(); } var fileid = fileurl.Substring(fileurl.LastIndexOf("/") + 1); var res = SimpleRequests.GET(queue + "/export?status=exported&format=json&id=" + fileid, key); var results = JsonConvert.DeserializeObject <ExportResult>(res); try { results.LoadGeneralData(); } catch (Exception ex) { Log.Error(ex.ToString()); } context.SetValue(Result, results); }
protected override void Execute(CodeActivityContext context) { var key = Key.Get(context); var res = SimpleRequests.GET("https://api.elis.rossum.ai/v1/queues?page_size=1", key); var qs = JsonConvert.DeserializeObject <QueuesResult>(res); context.SetValue(Results, qs.results); }
protected override void Execute(CodeActivityContext context) { var key = Key.Get(context); var fileurl = Fileurl.Get(context); var res = SimpleRequests.GET(fileurl, key); var o = JObject.Parse(res); string status = o["status"].ToString(); context.SetValue(Result, status); }
protected override void Execute(CodeActivityContext context) { var username = Username.Get(context); var password = Password.Get(context); var json = "{\"username\":\"" + username + "\", \"password\":\"" + password + "\"}"; var url = "https://api.elis.rossum.ai/v1" + "/auth/login"; var res = SimpleRequests.POST(url, json); var o = JObject.Parse(res); var key = o["key"].ToString(); context.SetValue(Result, key); }
protected override void Execute(CodeActivityContext context) { var key = Key.Get(context); var queue = Queue.Get(context); var filename = Filename.Get(context); filename = Environment.ExpandEnvironmentVariables(filename); var res = SimpleRequests.HttpUploadFile(queue + "/upload", filename, key, "content", "image/jpeg"); var o = JObject.Parse(res); var fileurl = o["results"][0]["annotation"].ToString(); context.SetValue(Result, fileurl); }