using AssistClient.Utils;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AssistClient
{
public static class WebApi
{
private static bool debug=false;
///
/// date,sn
///
///
///
///
public static JObject getDefectFromSN(JObject req)
{
if (debug)
{
//JObject data = new JObject()
//{
// {$"Defect_{sn}_1_X111_Y222",JArray.Parse(File.ReadAllText(@"d:\\test.json")) },
//};
//return new JObject()
//{
// {"code",200},
// {"data",data},
//};
}
JObject resp = HttpUtil.postSync($"http://{Config.ServerIP}:{Config.ServerPort}" + "/api/get_defect_from_sn", req.ToString());
if (!resp.Value("success"))//框架库内
throw new Exception(resp.Value("data"));//框架库内
//成功接收返回
JObject obj = JObject.Parse(resp.Value("data"));
//if (obj.Value("code") != 200)
// throw new Exception(resp.Value("data"));
return obj;
}
///
/// date,sn,file_name
///
///
///
///
public static JObject getDefectBmpBase64(JObject req)
{
if (debug)
{
//return new JObject()
//{
// {"code",200},
// {"data",Convert.ToBase64String(File.ReadAllBytes(Config.Defect_SavePath+"\\"+ file_name))},
//};
}
JObject resp = HttpUtil.postSync($"http://{Config.ServerIP}:{Config.ServerPort}" + "/api/get_defect_pic", req.ToString());
if (!resp.Value("success"))//框架库内
throw new Exception(resp.Value("data"));//框架库内
//成功接收返回
JObject obj = JObject.Parse(resp.Value("data"));
//if (obj.Value("code") != 200)
// throw new Exception(resp.Value("data"));
return obj;
}
}
}