protected void Page_Load(object sender, EventArgs e) { NameValueCollection parameters = Request.QueryString; UCKioskData data = new UCKioskData(); string callback = ""; try { foreach (string key in parameters) { string value = parameters[key]; if (key.ToLower() == "callback") { callback = value; } } } catch (Exception ex) { UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex.Message); return; } DataTable dt = null; try { dt = data.UCKiosk_Events(); } catch (Exception ex2) { UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex2.Message); return; } string results = UCKioskTools.DataTableToJSON(dt); if (callback == "") Response.Write("{\"totalResults\": \"" + dt.Rows.Count.ToString() + "\", \"resultType\": \"UCKioskEvents\", \"results\": " + results + "}"); else Response.Write(callback + "(" + "{\"totalResults\": \"" + dt.Rows.Count.ToString() + "\", \"resultType\": \"UCKioskEvents\", \"results\": " + results + "})"); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { NameValueCollection parameters = Request.QueryString; UCKioskData data = new UCKioskData(); //DataTable csvData = UCKioskTools.GetDataTableFromCsv(AppDomain.CurrentDomain.BaseDirectory + "CSV\\" + "KioskData_Topics.csv", true); string callback = ""; try { //foreach (string key in parameters) //{ // string value = parameters[key]; // if (key.ToLower() == "collectionid") // { // filter += UCKioskTools.CreateSQLFilter("CollectionID", value); // } // else if (key.ToLower() == "collectionparentid") // { // filter += UCKioskTools.CreateSQLFilter("CollectionParentID", value); // } // else if (key.ToLower() == "collectionname") // { // filter += UCKioskTools.CreateSQLFilter("CollectionName", value); // } // else if (key.ToLower() == "alias") // { // filter += UCKioskTools.CreateSQLFilter("Alias", value); // } // else if (key.ToLower() == "callback") // { // callback = value; // } //} foreach (string key in parameters) { string value = parameters[key]; if (key.ToLower() == "callback") { callback = value; } } } catch (Exception ex) { //UCKioskTools.SendMessage("UC Kiosk API: Error", ex.ToString()); UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex.Message); return; } //DataRow[] filtered = null; //string results = ""; //try //{ // filtered = csvData.Select(filter); // results = UCKioskTools.DataRowArrayToJSON(filtered, csvData.Columns); //} //catch (Exception ex2) //{ // //UCKioskTools.SendMessage("UC Kiosk API: Error", ex2.ToString()); // UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex2.ToString()); // return; //} DataTable dt = null; try { dt = data.UCKiosk_Topic_Select(); } catch (Exception ex2) { UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex2.Message); return; } string results = UCKioskTools.DataTableToJSON(dt); //if (callback == "") // Response.Write("{\"totalResults\": \"" + filtered.Count().ToString() + "\", \"resultType\": \"UCKioskTopics\", \"results\": " + results + "}"); //else // Response.Write(callback + "(" + "{\"totalResults\": \"" + filtered.Count().ToString() + "\", \"resultType\": \"UCKioskTopics\", \"results\": " + results + "})"); if (callback == "") Response.Write("{\"totalResults\": \"" + dt.Rows.Count.ToString() + "\", \"resultType\": \"UCKioskTopics\", \"results\": " + results + "}"); else Response.Write(callback + "(" + "{\"totalResults\": \"" + dt.Rows.Count.ToString() + "\", \"resultType\": \"UCKioskTopics\", \"results\": " + results + "})"); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { NameValueCollection parameters = Request.QueryString; UCKioskData data = new UCKioskData(); string filter = ""; string callback = ""; if (parameters.Count > 0) filter = "WHERE "; try { //foreach (string key in parameters) //{ // string value = parameters[key]; // if (key.ToLower() == "infoid") // { // filter += UCKioskTools.CreateSQLFilter("InfoID", value); // } // else if (key.ToLower() == "title") // { // filter += "Title like '%" + value + "%' AND"; // } // else if (key.ToLower() == "type") // { // filter += UCKioskTools.CreateSQLFilter("Type", value); // } // else if (key.ToLower() == "url") // { // filter += UCKioskTools.CreateSQLFilter("URL", value); // } // else if (key.ToLower() == "collectionid") // { // filter += UCKioskTools.CreateSQLFilter("CollectionID", value); // } // else if (key.ToLower() == "industryid") // { // filter += UCKioskTools.CreateSQLFilter("IndustryID", value); // } // else if (key.ToLower() == "callback") // { // callback = value; // } //} foreach (string key in parameters) { string value = parameters[key]; if (key.ToLower() == "infoid") { filter += UCKioskTools.CreateSQLFilter("info.id", value); } else if (key.ToLower() == "title") { filter += "info.title like '%" + value + "%' AND"; } else if (key.ToLower() == "type") { filter += UCKioskTools.CreateSQLFilter("info_type.name", value); } else if (key.ToLower() == "url") { filter += UCKioskTools.CreateSQLFilter("info.url", value); } else if (key.ToLower() == "collectionid") { filter += UCKioskTools.CreateSQLFilter("info_collections.collection_id", value); } else if (key.ToLower() == "industryid") { filter += UCKioskTools.CreateSQLFilter("industry.id", value); } else if (key.ToLower() == "callback") { callback = value; } } } catch (Exception ex) { UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex.Message); return; } if (filter.Length > 0 && filter != "WHERE ") filter = filter.Substring(0, filter.Length - 4); if (filter == "WHERE ") filter = ""; //DataTable csvData = UCKioskTools.GetDataTableFromCsv(AppDomain.CurrentDomain.BaseDirectory + "CSV\\" + "KioskData.csv", true); //DataRow[] filtered = null; //string results = ""; //String[] cols = new String[] { "InfoID", "Title", "URL", "Type" }; //try //{ // //filtered = csvData.Select(filter); // DataView view = new DataView(csvData); // filtered = view.ToTable(false, cols).Select(filter); // results = UCKioskTools.DataRowArrayToJSON(filtered, cols); //} //catch (Exception ex2) //{ // //UCKioskTools.SendMessage("UC Kiosk API: Error", ex2.ToString()); // UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex2.ToString()); // return; //} DataTable dt = null; string results = ""; try { dt = data.UCKiosk_Select(filter); } catch (Exception ex2) { UCKioskTools.GetRequest("http://www.esri.com/FormTesting/[email protected]&[email protected]&subject=UC Kiosk API: Error&template=mwa&callback=toast&message=" + ex2.Message); return; } results = UCKioskTools.DataTableToJSON(dt); if (callback == "") Response.Write("{\"totalResults\": \"" + dt.Rows.Count.ToString() + "\", \"resultType\": \"UCKiosk\", \"results\": " + results + "}"); else Response.Write(callback + "(" + "{\"totalResults\": \"" + dt.Rows.Count.ToString() + "\", \"resultType\": \"UCKiosk\", \"results\": " + results + "})"); //if (callback == "") // Response.Write("{\"totalResults\": \"" + filtered.Count().ToString() + "\", \"resultType\": \"UCKiosk\", \"results\": " + results + "}"); //else // Response.Write(callback + "(" + "{\"totalResults\": \"" + filtered.Count().ToString() + "\", \"resultType\": \"UCKiosk\", \"results\": " + results + "})"); Response.End(); }