init commit all code

This commit is contained in:
路 范
2021-12-20 17:17:49 +08:00
parent 66d48149a6
commit f60ad763ed
1325 changed files with 1744918 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Getf.Service.Transfer.Client.WinService.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Getf.Service.Transfer.Client.WinService.HttpHandler
{
public class HttpDataHandler : IDataHandler
{
public TransInfo HandlerData(TransInfo srcData)
{
var r = new TransInfo();
var action = srcData.Body.Action;
if (String.IsNullOrWhiteSpace(action))
{
r.TransResultInfo = GetResult(-320, "Action(url|method)参数不能为空");
return r;
}
var url = action;
HttpService httpService = new HttpService();
var jsonStr = String.IsNullOrWhiteSpace(srcData.Body.Param) ? "{}" : srcData.Body.Param;
var rData = httpService.DoRequest(url, JsonConvert.DeserializeObject<JObject>(jsonStr), out string msg);
if (rData == null)
{
r.TransResultInfo = new TransResult()
{
Code = -301,
Message = msg
};
return r;
}
if (rData is string)
{
r.TransResultInfo = new TransResult()
{
Code = 0,
Message = (string)rData
};
return r;
}
r.TransResultInfo = new TransResult()
{
Code = 0
};
r.Data = (byte[])rData;
return r;
}
private TransResult GetResult(int code, string message)
{
return new TransResult()
{
Code = code,
Message = message
};
}
}
}