public void getPPL(int mode, string programName, string programEntry) { string address = "http://kdspykim2.cafe24.com:8080/get_ppl_data?"; if (mode == INQUIRY) { programName = d_program_name.Text.ToString(); programEntry = d_program_entry.Text.ToString(); } string programKey = programName + "_" + programEntry; string query = address + "drama_code=" + programKey; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(query); request.Method = "GET"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(stream, Encoding.UTF8); string result = streamReader.ReadToEnd(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(result); JsonArrayCollection items = (JsonArrayCollection)obj; pplDataList.clearList(); foreach (JsonObjectCollection item in items) { string productCode = item["product_code"].GetValue().ToString(); string programCode = item["drama_code"].GetValue().ToString(); string productName = item["product_name"].GetValue().ToString(); string brandName = item["brand_name"].GetValue().ToString(); string productImage = item["product_image"].GetValue().ToString(); string price = item["price"].GetValue().ToString(); string storeLink = item["store_link"].GetValue().ToString(); int startTime = Convert.ToInt32(item["start_time"].GetValue()); int endTime = Convert.ToInt32(item["end_time"].GetValue()); PPLData pplData = new PPLData(productCode, programCode, productName, brandName, productImage, price, storeLink, startTime, endTime); pplDataList.insertPPLData(pplData); } }
public void insertPPLData(PPLData pplData) { pplList.Add(pplData); }