コード例 #1
0
        public async Task <IEnumerable <NotificationItem> > CountDataAsync(string url)
        {
            var list = new List <NotificationItem>();

            using (var client = new HttpClient())
            {
                try
                {
                    var api = await client.GetStringAsync(url);

                    var json = JArray.Parse(api);
                    Queue = json;
                    foreach (var value in json)
                    {
                        Console.WriteLine(api);
                        var result = JObject.Parse(value.ToString());
                        var model  = new NotificationItem()
                        {
                            Jumlah = result["Jumlah"].ToString() as string
                        };
                        list.Add(model);
                    }
                }
                catch { }
            }
            return(list);
        }
コード例 #2
0
        public async Task <IEnumerable <NotificationItem> > LoadDataAsync(string url)
        {
            var list = new List <NotificationItem>();

            using (var client = new HttpClient())
            {
                try
                {
                    var api = await client.GetStringAsync(url);

                    var json = JArray.Parse(api);
                    Queue = json;
                    foreach (var value in json)
                    {
                        var result = JObject.Parse(value.ToString());
                        var model  = new NotificationItem()
                        {
                            Nama    = result["first_name"].ToString() as string,
                            Company = result["company"].ToString() as string
                        };
                        list.Add(model);
                    }
                }
                catch { }
            }
            return(list);
        }
コード例 #3
0
        public bool SenderData(NotificationItem model, HttpVerbs verbs)
        {
            var result = false;
            var json   = JsonConvert.SerializeObject(model);
            var task   = Task.Run(async() => await DataSenderAsync(json, verbs));

            if (task.Result)
            {
                result = true;
            }
            return(result);
        }
コード例 #4
0
        public async Task <IEnumerable <NotificationItem> > CountData(string url)
        {
            var list = new List <NotificationItem>();
            var task = await LoadDataAsync(url);

            foreach (var value in Queue)
            {
                var result = JObject.Parse(value.ToString());
                var model  = new NotificationItem()
                {
                    Jumlah = result["Jumlah"].ToString() as string
                };
                list.Add(model);
            }
            return(list);
        }
コード例 #5
0
        public async Task <IEnumerable <NotificationItem> > LoadData(string url)
        {
            var list = new List <NotificationItem>();
            var task = await LoadDataAsync(url);

            foreach (var value in Queue)
            {
                var result = JObject.Parse(value.ToString());
                var model  = new NotificationItem()
                {
                    Nama    = result["first_name"].ToString() as string,
                    Company = result["company"].ToString() as string
                };
                list.Add(model);
            }
            return(list);
        }