/// <summary> /// Handles raw report result by transforming it to user friendly state /// </summary> /// <param name="rawResult"></param> /// <returns></returns> protected Report ProcessCompletedJob(AppResultsHolder rawResult) { var results = new List <Result>(); foreach (var prop in rawResult.ResultProps) { string resultPropType = prop.Type.ToLower(); switch (resultPropType) { case "plaintext": results.Add(new Result(prop.Name, new TextResultValue(prop.Value))); break; case "pdf": string filename = string.Format("report_{0}.{1}", rawResult.Status.IdJob, resultPropType); var reportFileUrl = GetReportFileUrl(prop.Value); ResultValue resultValue = new FileResultValue(filename, resultPropType, reportFileUrl); results.Add(new Result(prop.Name, resultValue)); break; } } Report finalResult = new Report(); finalResult.Succeeded = rawResult.Status.CompletedSuccesfully ?? false; finalResult.setResults(results); return(finalResult); }
private static void Main(string[] args) { var chains0 = new AppChains("https://beacon.sequencing.com/"); Console.WriteLine(chains0.GetPublicBeacon(1, 2, "A")); var chains = new AppChains("147fc0683b08e94c6c2835efba60b815eb501a13", "https://api.sequencing.com/v1", "https://beacon.sequencing.com/"); //Low level method invocation example AppResultsHolder rawReport = chains.GetRawReport("Chain9", "FILE:80599"); printRawResponse(rawReport); //High level method invocation example Report result = chains.GetReport("Chain9", "FILE:80599"); printReport("147fc0683b08e94c6c2835efba60b815eb501a13", result); Console.WriteLine("Press any key"); Console.ReadKey(); }
private static void Main(string[] args) { var chains = new AppChains("<your token goes here>", "https://api.sequencing.com/", "https://beacon.sequencing.com/"); //Low level method invocation example AppResultsHolder rawReport = chains.GetRawReport("Chain9", "80599"); PrintRawResponse(rawReport); //High level method invocation example Report result = chains.GetReport("Chain9", "80599"); PrintReport("<your token goes here>", result); Console.WriteLine("Press any key"); Console.ReadKey(); }
/// <summary> /// Retrieves raw report data from the API server /// </summary> /// <param name="job">job id</param> /// <returns></returns> protected AppResultsHolder GetRawReportImpl(AppResultsHolder appResult) { while (true) { try { if (appResult.Status.Status == "Completed") { return(appResult); } Task.Delay(DEFAULT_REPORT_RETRY_TIMEOUT).Wait(); appResult = backendFacade.GetAppResults(appResult.Status.IdJob); } catch (Exception e) { throw new ApplicationException("Error processing job:" + appResult.Status.IdJob, e); } } }
/// <summary> /// Retrieves report data from the API server /// </summary> /// <param name="job">identifier to retrieve report</param> /// <returns></returns> protected Report GetReportImpl(AppResultsHolder resultHolder) { return(ProcessCompletedJob(GetRawReportImpl(resultHolder))); }
private static void printRawResponse(AppResultsHolder rawReport) { Console.WriteLine(rawReport); }