private void button_visit_Click(object sender, EventArgs e) { try { var url = this.textBox_url.Text; var gnssOptionText = this.richTextBoxControl_postParams.Text; if (String.IsNullOrWhiteSpace(gnssOptionText)) { MessageBox.Show("请输入配置文件再试!"); return; } try { OptionManager manager = new OptionManager(); var opt = manager.Read(gnssOptionText, "nameOfOpt"); if (opt.ObsFiles == null || opt.ObsFiles.Count == 0) { MessageBox.Show("必须指定观测文件网址!O文件,D文件或O.Z都可以。"); return; } foreach (var item in opt.ObsFiles) { if (item.Contains(@":\")) { MessageBox.Show("请采用Internet的 FTP 或 网址,不要采用本地地址!O文件,D文件或O.Z都可以。\n" + item); return; } } }catch (Exception ex) { MessageBox.Show("配置文件不合法,请仔细检查后再试!" + ex.Message); return; } ShowInfo("即将发出计算服务请求,请耐心等待。。。。"); Encoding encoding = Encoding.GetEncoding("utf-8"); IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("gnssOptionText", gnssOptionText); HttpWebResponse response = HttpWebRequestUtil.CreatePostHttpResponse(url, parameters, null, null, encoding, null); string cookieString = response.Headers["Set-Cookie"]; Stream responseStream = response.GetResponseStream(); StreamReader reader = new System.IO.StreamReader(responseStream, Encoding.GetEncoding("UTF-8")); string srcString = reader.ReadToEnd(); //返回值赋值 reader.Close(); ShowInfo("计算完毕,返回结果。"); ShowInfo(srcString); }catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_visit_Click(object sender, EventArgs e) { try { var url = this.textBox_url.Text; var obsFiles = this.richTextBoxControl_obsUrls.Lines; if (obsFiles.Length == 0) { MessageBox.Show("请输入配置文件再试!"); return; } StringBuilder sb = new StringBuilder(); int i = 0; foreach (var item in obsFiles) { if (item.Contains(@":\")) { MessageBox.Show("请采用Internet的 FTP 或 网址,不要采用本地地址!O文件,D文件或O.Z都可以。\n" + item); return; } if (i != 0) { sb.Append(";"); } sb.Append(item); i++; } ShowInfo("即将发出计算服务请求,请耐心等待。。。。"); Encoding encoding = Encoding.GetEncoding("utf-8"); IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("obsUrls", sb.ToString()); HttpWebResponse response = HttpWebRequestUtil.CreatePostHttpResponse(url, parameters, null, null, encoding, null); string cookieString = response.Headers["Set-Cookie"]; Stream responseStream = response.GetResponseStream(); StreamReader reader = new System.IO.StreamReader(responseStream, Encoding.GetEncoding("UTF-8")); string srcString = reader.ReadToEnd(); //返回值赋值 reader.Close(); ShowInfo("计算完毕,返回结果。"); ShowInfo(srcString); } catch (Exception ex) { MessageBox.Show(ex.Message); } }