public ProjectDefine() { List <string> names = new List <string>(); try { string projectIdBaseAddress = "http://172.18.84.114:8080/PDD/pdd/cim-interface!findAllProject"; var projectIdHttp = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(new Uri(projectIdBaseAddress)); var response = projectIdHttp.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream, Encoding.UTF8); var content = sr.ReadToEnd(); contentList = Newtonsoft.Json.JsonConvert.DeserializeObject <JsonCityData>(content); } catch (Exception ex) { MessageBox.Show(ex.Message); } //MessageBox.Show(content); if (contentList.result != null) { foreach (City city in contentList.result) { names.Add(city.name); } } InitializeComponent(names); UIMethod.SetFormRoundRectRgn(this, 5); //设置圆角 }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var jsonDataSource = new JsonCityData(); Application.Run(new Form1(jsonDataSource)); }
public BatchChooseCityForm() { // 获取定义好的项目 string cityId = Method.SaveProjectIdToXData.GetDefinedProject(); List <string> names = new List <string>(); try { string projectIdBaseAddress = "http://172.18.84.114:8080/PDD/pdd/cim-interface!findAllProject"; var projectIdHttp = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(new Uri(projectIdBaseAddress)); var response = projectIdHttp.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream, Encoding.UTF8); var content = sr.ReadToEnd(); contentList = Newtonsoft.Json.JsonConvert.DeserializeObject <JsonCityData>(content); } catch (Exception ex) { MessageBox.Show(ex.Message); } //MessageBox.Show(content); string city = ""; foreach (City item in contentList.result) { names.Add(item.name); if (item.oid == cityId) { city = item.name; } } InitializeComponent(names, city); }