static async Task RunAsync(string[] args)
        {
            if (args.Length < 2)
            {
                WSUtilities.PrintVersionMesssage("MIReport", "1.0");
                Console.WriteLine("MIReport.exe [settings file] [output file]");
                Console.WriteLine("MIReport.exe --example [settings file]");
                return;
            }
            if (args[0].ToLower() == "--example")
            {
                Console.WriteLine(WSSettings.WriteExample(args[1]));
                return;
            }
            try
            {
                WSSettings  settings = WSSettings.Load(args[0]);
                WSAPIClient client   = WSAPIClient.ForToken(settings);
                _ = await client.DoOIDC(settings);

                client = WSAPIClient.ForMIMEType(settings, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                var bytes = await client.GetByteArrayAsync("/api/mireport");

                using (StreamWriter sw = new StreamWriter(args[1]))
                {
                    sw.Write(bytes);
                    Console.WriteLine("{0} bytes written to {1}", bytes.Length, args[1]);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        static async Task RunAsync(string [] args)
        {
            if (args.Length < 2)
            {
                WSUtilities.PrintVersionMesssage("RiskPack", "1.0");
                Console.WriteLine("riskpack.exe [settings file] [riskID]");
                Console.WriteLine("riskpack.exe --example [settings file]");
                return;
            }
            if (args[0].ToLower() == "--example")
            {
                Console.WriteLine(WSSettings.WriteExample(args[1]));
                return;
            }
            WSSettings settings;

            try
            {
                settings = WSSettings.Load(args[0]);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR {0}", ex.Message);
                return;
            }
            string json = String.Empty, req = String.Empty;

            try
            {
                string folder = WSUtilities.MakeSafeFilename(args[1]) + DateTime.Now.ToString("_ddMMyy_HHmmss");
                Directory.CreateDirectory(folder);

                WSAPIClient client = WSAPIClient.ForToken(settings);
                _ = await client.DoOIDC(settings);

                req    = String.Format("/export/pdf/{0}", args[1]);
                client = WSAPIClient.ForPDF(settings);

                var bytes = await client.GetByteArrayAsync(req);

                WriteFile(folder, args[1] + ".pdf", bytes);

                client = WSAPIClient.ForJSON(settings);
                req    = String.Format("/api/attachments/{0}", MakeATCH(args[1]));
                json   = await client.GetStringAsync(req);

                Dictionary <String, WSAttachment> dict = JsonConvert.DeserializeObject <Dictionary <String, WSAttachment> >(json);
                foreach (string key in dict.Keys)
                {
                    WSAttachment att = dict[key];
                    client = WSAPIClient.ForMIMEType(settings, att.content_type);
                    req    = string.Format("/api/attachments/{0}/{1}", MakeATCH(args[1]), key);
                    bytes  = await client.GetByteArrayAsync(req);

                    WriteFile(folder, key, bytes);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Last URL was {0}", req);
            }
        }