76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
|
#region << 版 本 注 释 >>
|
|||
|
/*----------------------------------------------------------------
|
|||
|
* 创建者:13118
|
|||
|
* 创建时间:2022/3/17 14:52:03
|
|||
|
* 版本:V1.0.0
|
|||
|
* 描述:
|
|||
|
*
|
|||
|
* ----------------------------------------------------------------
|
|||
|
* 修改人:
|
|||
|
* 时间:
|
|||
|
* 修改说明:
|
|||
|
*
|
|||
|
* 版本:V1.0.1
|
|||
|
*----------------------------------------------------------------*/
|
|||
|
#endregion << 版 本 注 释 >>
|
|||
|
|
|||
|
using ARI.EAP.HOST.SRD;
|
|||
|
using Glorysoft.SECS.EQP.Utilities;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
|
|||
|
namespace ARI.EAP.HOST.Utilities
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// HttpUtils 的摘要说明
|
|||
|
/// 调用http接口工具类
|
|||
|
/// </summary>
|
|||
|
public static class HttpUtils
|
|||
|
{
|
|||
|
public static HttpWebResponse sentPOST(string url,string content)
|
|||
|
{
|
|||
|
HttpWebRequest postRequest=(HttpWebRequest)WebRequest.Create(url);
|
|||
|
postRequest.Method = "POST";
|
|||
|
postRequest.ContentType = Configuration.conf.httpConfiguration.contentType;
|
|||
|
postRequest.Timeout = 10000;
|
|||
|
try
|
|||
|
{
|
|||
|
using (StreamWriter dataStream = new StreamWriter(postRequest.GetRequestStream()))
|
|||
|
{
|
|||
|
dataStream.Write(content);
|
|||
|
dataStream.Close();
|
|||
|
}
|
|||
|
HttpWebResponse response = (HttpWebResponse)postRequest.GetResponse();
|
|||
|
return response;
|
|||
|
}catch(Exception e)
|
|||
|
{
|
|||
|
LoggerService.SYSLogger.Error(e);
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static HttpWebResponse sentGET(string url,string param)
|
|||
|
{
|
|||
|
url = url + param;
|
|||
|
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(url);
|
|||
|
getRequest.Method = "GET";
|
|||
|
getRequest.ContentType = Configuration.conf.httpConfiguration.contentType;
|
|||
|
try
|
|||
|
{
|
|||
|
HttpWebResponse response = (HttpWebResponse)getRequest.GetResponse();
|
|||
|
return response;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
LoggerService.SYSLogger.Error(e);
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|