コード例 #1
0
ファイル: Cmd.cs プロジェクト: Herdubreid/ALM
                async Task OnExecuteAsync()
                {
                    var uri        = new UriBuilder("https://celinalm.azurewebsites.net/api/GetTextEQ");
                    var collection = System.Web.HttpUtility.ParseQueryString(string.Empty);

                    collection.Add("code", "x8MfDXaLAsUE/GUs9kF2qOEJ60WaR2tMCBkD9XX7R5hgfmuoL9Oiag==");
                    collection.Add("numb", NUMB.ToString());
                    uri.Query = collection.ToString();
                    var response = await Http.GetAsync(uri.Uri);

                    if (response.IsSuccessStatusCode)
                    {
                        var res = response.Content.ReadAsStringAsync().Result;
                        try
                        {
                            var des = JsonSerializer.Deserialize <Response>(res);
                            Console.WriteLine("Sequence {0}", des.sequence);
                            var      addresses = des.adds ?? Enumerable.Empty <Address>();
                            DateTime?last      = null;
                            foreach (var a in des.adds)
                            {
                                TimeSpan?duration = last == null
                                    ? null
                                    : a.timestamp - last;
                                Console.WriteLine("{0} ({1}) {2} {3}", a.formattedAddress, duration?.ToString(@"hh\:mm"), a.timestamp, a.distance);
                                last = a.timestamp;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
コード例 #2
0
ファイル: Cmd.cs プロジェクト: Herdubreid/ALM
                async Task OnExecuteAsync()
                {
                    var uri        = new UriBuilder("https", "celinalm.azurewebsites.net");
                    var collection = System.Web.HttpUtility.ParseQueryString(string.Empty);

                    collection.Add("numb", NUMB.ToString());
                    collection.Add("text", Text);
                    uri.Path = "api/AddTextEQ";
                    collection.Add("code", "N9WHu80FoeHVWGe0QDUXsh2ko1yreNoFqfnIgi5lY7WnZ2OenYDN1Q==");
                    uri.Query = collection.ToString();
                    var response = await Http.GetAsync(uri.Uri);

                    Console.WriteLine(response.Content.ReadAsStringAsync().Result);
                }