48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.NetworkInformation;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GetHttpData.SDK
|
|
{
|
|
public class HttpDataHelper
|
|
{
|
|
#region 方法 -> 通过Json方式添加数据
|
|
/// <summary>
|
|
/// 通过Json方式添加数据
|
|
/// Mr.Cai 2018-1-3
|
|
/// </summary>
|
|
/// <param name="ipAddress">完整请求地址</param>
|
|
/// <param name="interfaceName">接口名字</param>
|
|
/// <param name="tableName">表名</param>
|
|
/// <param name="code">授权码</param>
|
|
/// <param name="josnString">json参数数组</param>
|
|
/// <param name="orderString">其它参数</param>
|
|
/// <returns></returns>
|
|
|
|
public static string InsertDataByJson(string ipAddress, string interfaceName,
|
|
string tableName, string code, string josnString, string orderString = "")
|
|
{
|
|
if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(interfaceName)
|
|
|| string.IsNullOrEmpty(tableName) || string.IsNullOrEmpty(josnString))
|
|
{
|
|
throw new Exception("请求地址、接口名、表名或请求参数不可为空!");
|
|
}
|
|
|
|
try
|
|
{
|
|
string[] args = { code, tableName, josnString, orderString };
|
|
return WSHelper.InvokeWebService(ipAddress, interfaceName, args).ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("网络请求失败:" + ex.ToString());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|