123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace WebManager
- {
- public class WebResult
- {
- /// <summary>
- /// 数据定义
- /// </summary>
- private String webServer_IP = "";
- private String webServer_Port = "";
- private String webServer_Path = "";
- private String Url = "";
- private const String Post = "Post";
- private const String Content_Type= "Content-Type:application/json";
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="ws_ip">WebServer的IP地址</param>
- /// <param name="ws_port">WebServer的端口号</param>
- /// <param name="ws_path">WebServer的项目名</param>
- public WebResult(String ws_ip,String ws_port,String ws_path)
- {
- this.webServer_IP = ws_ip;
- this.webServer_Port = ws_port;
- this.webServer_Path = ws_path;
- //更新Web网址
- Update_Url();
- }
- /// <summary>
- /// 更新Web网址
- /// </summary>
- private void Update_Url()
- {
- if (this.webServer_Path.Substring(0, 1) != "/")
- {
- this.webServer_Path = "/" + this.webServer_Path;
- }
- this.Url = "http://" + this.webServer_IP + ":" + this.webServer_Port + this.webServer_Path;
- }
- /// <summary>
- /// WebServer的IP地址
- /// </summary>
- public String WebServer_IP
- {
- //get { return this.webServer_IP; }
- set
- {
- this.webServer_IP = value;
- Update_Url();
- }
- }
- /// <summary>
- /// WebServer的端口号
- /// </summary>
- public String WebServer_Port
- {
- //get { return this.webServer_IP; }
- set
- {
- this.webServer_Port = value;
- Update_Url();
- }
- }
- /// <summary>
- /// WebServer的项目名
- /// </summary>
- public String WebServer_Path
- {
- //get { return this.webServer_IP; }
- set
- {
- this.webServer_Path = value;
- Update_Url();
- }
- }
- public String RequestString(String postString)
- {
- try
- {
- String res = HttpRequestHelper.DoRequest(this.Url, Post, Content_Type, postString);
- return res;
- }
- catch
- {
- return "";
- }
- }
- }
- }
|