コード例 #1
0
ファイル: Programs.cs プロジェクト: szitus2/Locsi
        public async Task SavePrograms()
        {
            ProgramClassForJSON dd = new ProgramClassForJSON();

            dd.programs = programs;
            string     jsonString = JsonConvert.SerializeObject(dd);
            HttpClient client     = new HttpClient();

            System.Uri          uri     = new Uri("http://" + Common.Instance.LocsiHostname + "/setprograms");
            HttpContent         content = new StringContent(jsonString);
            HttpResponseMessage resp    = await client.PostAsync(uri, content);
        }
コード例 #2
0
ファイル: Programs.cs プロジェクト: szitus2/Locsi
        public async Task GetPrograms()
        {
            try
            {
                HttpClient client = new HttpClient();

                System.Uri          uri      = new System.Uri("http://" + Common.Instance.LocsiHostname + "/getprograms");
                HttpResponseMessage response = await client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();


                    ProgramClassForJSON dd = JsonConvert.DeserializeObject <ProgramClassForJSON>(content);
                    programs = dd.programs;
                }
            }
            catch
            {
                System.Threading.Thread.Sleep(1000);
                await GetPrograms();
            }
        }