IDP质量设计图纸管理
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using RestSharp;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class HttpHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// GET请求
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static string Get(string url, Dictionary<string, string> token)
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||
|
||||
var client = new RestClient(url);
|
||||
client.Timeout = -1;
|
||||
var request = new RestRequest(Method.GET);
|
||||
if (token != null)
|
||||
{
|
||||
foreach (var item in token)
|
||||
{
|
||||
request.AddHeader(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
request.AddHeader("ClientId", SysConstSetService.ClientId);
|
||||
request.AddHeader("OperationCode", url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1));
|
||||
IRestResponse response = client.Execute(request);
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// POST请求
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="jsonBody"></param>
|
||||
/// <returns></returns>
|
||||
public static string Post(string url, Dictionary<string, string> token, string jsonBody)
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
|
||||
var client = new RestClient(url);
|
||||
client.Timeout = -1;
|
||||
var request = new RestRequest(Method.POST);
|
||||
if (token != null)
|
||||
{
|
||||
foreach (var item in token)
|
||||
{
|
||||
request.AddHeader(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
request.AddHeader("ClientId", SysConstSetService.ClientId);
|
||||
request.AddHeader("OperationCode", url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1));
|
||||
if (!string.IsNullOrEmpty(jsonBody))
|
||||
{
|
||||
request.AddJsonBody(jsonBody);
|
||||
}
|
||||
|
||||
IRestResponse response = client.Execute(request);
|
||||
return response.Content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user