using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WebManager
{
public class WebResult
{
///
/// 数据定义
///
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";
///
/// 构造函数
///
/// WebServer的IP地址
/// WebServer的端口号
/// WebServer的项目名
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();
}
///
/// 更新Web网址
///
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;
}
///
/// WebServer的IP地址
///
public String WebServer_IP
{
//get { return this.webServer_IP; }
set
{
this.webServer_IP = value;
Update_Url();
}
}
///
/// WebServer的端口号
///
public String WebServer_Port
{
//get { return this.webServer_IP; }
set
{
this.webServer_Port = value;
Update_Url();
}
}
///
/// WebServer的项目名
///
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 "";
}
}
}
}