示例#1
0
        public void UrunGetir(int rowNumber)
        {
            int  i = 0, j = 1;
            bool ok = true;

            while (ok)
            {
                Console.WriteLine("Row:" + i + " J:" + j);
                string         macUrl  = "http://littlep.xyz/pc/getProducts/" + j.ToString();
                HttpWebRequest request = WebRequest.Create(macUrl) as HttpWebRequest;
                request.ContentType = "application/json";
                request.Method      = "GET";
                string jsonVerisi    = "";
                var    httpResponse1 = (HttpWebResponse)request.GetResponse();
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    StreamReader okuyucu = new StreamReader(response.GetResponseStream());
                    jsonVerisi = okuyucu.ReadToEnd();
                    Console.WriteLine(macUrl + "---" + jsonVerisi.ToString());
                    if (jsonVerisi == "null")
                    {
                        j++;
                    }
                    else
                    {
                        j++;
                        JsonService app = JsonConvert.DeserializeObject <JsonService>(jsonVerisi);
                        p_id[i]     = app.p_id;
                        p_name[i]   = app.p_name;
                        p_cat[i]    = app.p_cat;
                        p_price[i]  = app.p_price.ToString();
                        p_imgsrc[i] = app.p_imgsrc;
                        p_desc[i]   = app.p_desc;
                        Console.WriteLine("Dizi:" + p_price[i]);
                        Console.WriteLine("Json:" + app.p_price);
                        i++;
                    }
                    if (i == rowNumber)
                    {
                        ok = false;
                    }
                }
            }
        }
示例#2
0
        public static int urunSayisi()
        {
            string macUrl = "http://littlep.xyz/pc/getOrderedProducts/" + ConfigurationPage.uye;

            Console.WriteLine(macUrl);
            HttpWebRequest request = WebRequest.Create(macUrl) as HttpWebRequest;

            request.ContentType = "application/json";
            request.Method      = "GET";
            string jsonVerisi    = "";
            var    httpResponse1 = (HttpWebResponse)request.GetResponse();

            Console.WriteLine("HAY AQ");
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader okuyucu = new StreamReader(response.GetResponseStream());
                jsonVerisi = okuyucu.ReadToEnd();
                if (jsonVerisi != "null")
                {
                    JsonService app = JsonConvert.DeserializeObject <JsonService>(jsonVerisi);
                    Console.WriteLine("IDs:" + app.urunler_id);
                    string   urunids = app.urunler_id;
                    string[] urunler = urunids.Split('.');
                    int      rn      = 0;
                    for (int i = 0; i < (urunler.Length - 1); i++)
                    {
                        if (urunler[i] != null || urunler[i] != "")
                        {
                            rn++;
                        }
                    }
                    Console.WriteLine("SA KRDS");
                    return(rn);
                }
                else
                {
                    return(0);
                }
            }
        }