You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.1 KiB
C#

using DSWeb.Common.DB;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DSWeb.Common.Helper
{
public class HttpFeedbackHelper
{
/// <summary>
/// 通过HTTP请求向其他系统反馈数据
/// </summary>
public static void FeedbackData(CommonDataContext commonData, string url, string json, string method = "POST")
{
var feedbask = new BackgroundTaskCommon();
feedbask.GID = Guid.NewGuid().ToString();
feedbask.Status = BackgroundTaskCommon.StatusCreate;
feedbask.Type = BackgroundTaskCommon.TypeHttpFeedback;
feedbask.CreateTime = DateTime.Now;
feedbask.ParamData = JsonConvert.SerializeObject(new
{
url,
method,
json
});
commonData.BackgroundTaskCommon.Add(feedbask);
}
public static bool FeedbackXiaHuoZhi(CommonDataContext commonData, string compid, string bsno, bool status, out string msg)
{
var para = commonData.ParamValues.AsNoTracking().FirstOrDefault(x => x.CompId == compid && x.ParaCode == "XHZ_FEEDBACK_URL");
if (para == null || string.IsNullOrEmpty(para.ItemCode))
{
msg = "下货纸反馈地址未配置";
return false;
}
var feedbask = new BackgroundTaskCommon();
feedbask.GID = Guid.NewGuid().ToString();
feedbask.Status = BackgroundTaskCommon.StatusCreate;
feedbask.Type = BackgroundTaskCommon.TypeHttpFeedback;
feedbask.CreateTime = DateTime.Now;
feedbask.ParamData = JsonConvert.SerializeObject(new
{
url = para.ItemCode,
method = "POST",
json = JsonConvert.SerializeObject(new
{
bsno,
status
})
});
commonData.BackgroundTaskCommon.Add(feedbask);
msg = "成功";
return true;
}
}
}