|
|
@@ -19,12 +19,26 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
|
|
|
public XFApiService(XFDbContext context, ILoggerFactory loggerFactory):base(context, loggerFactory)
|
|
|
{
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 提交信件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="b">信件内容</param>
|
|
|
+ /// <param name="onFails">失败回调</param>
|
|
|
+ /// <returns></returns>
|
|
|
public async Task<bool> PostLetter(Bundle b, OnFails onFails)
|
|
|
{
|
|
|
+ XFApiResult rObj = await HttpPostAsync<XFApiResult>("http://118.178.118.50/test1/letter/submitLetter", b.ToDictionary(), onFails);
|
|
|
+
|
|
|
+ if (rObj == null)
|
|
|
+ return false;
|
|
|
+ if (rObj.Data == null || !rObj.Data.Success)
|
|
|
+ {
|
|
|
+ Logger.LogError("数据提交省统一平台失败,原因:{0}", rObj.Message);
|
|
|
+ onFails(string.Format("数据提交省统一平台失败,原因:{0}", rObj.Message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
- //XFApiResult rObj = await HttpPostAsync("http://118.178.118.50/test1/letter/submitLetter", b.ToDictionary(), onFails);
|
|
|
-
|
|
|
//if (rObj != null)
|
|
|
//{
|
|
|
// b.SearchCode = rObj.Data.Data;
|
|
|
@@ -33,6 +47,88 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
|
|
|
//return false;
|
|
|
}
|
|
|
/// <summary>
|
|
|
+ /// 查询码是否有效
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="queryCode">查询码</param>
|
|
|
+ /// <param name="onFails">失败回调</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<bool> QueryCodeIsValid(string queryCode, OnFails onFails)
|
|
|
+ {
|
|
|
+ Dictionary<string, string> d = new Dictionary<string, string>();
|
|
|
+ d.Add("query_code", queryCode);
|
|
|
+ XFApiResult rObj = await HttpPostAsync<XFApiResult>("http://<服务器IP>/query/code", d, onFails);
|
|
|
+
|
|
|
+ if (rObj == null)
|
|
|
+ return false;
|
|
|
+ if (rObj.Data == null || !rObj.Data.Success)
|
|
|
+ {
|
|
|
+ Logger.LogError("数据提交省统一平台失败,原因:{0}", rObj.Message);
|
|
|
+ onFails(string.Format("数据提交省统一平台失败,原因:{0}", rObj.Message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 查询信件详细信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="queryCode">查询码</param>
|
|
|
+ /// <param name="onFails">失败回调</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Bundle> GetBundleByQueryCode(string queryCode, OnFails onFails)
|
|
|
+ {
|
|
|
+ Dictionary<string, string> d = new Dictionary<string, string>();
|
|
|
+ d.Add("query_code", queryCode);
|
|
|
+ XFApiResult rObj = await HttpPostAsync<XFApiResult>("http://<服务器IP>/query/letterDetail", d, onFails);
|
|
|
+
|
|
|
+ if (rObj == null)
|
|
|
+ return null;
|
|
|
+ if (rObj.Data == null || !rObj.Data.Success)
|
|
|
+ {
|
|
|
+ Logger.LogError("数据提交省统一平台失败,原因:{0}", rObj.Message);
|
|
|
+ onFails(string.Format("数据提交省统一平台失败,原因:{0}", rObj.Message));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ return bundle;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<bool> IsEvaluate(string letter_id, OnFails onFails)
|
|
|
+ {
|
|
|
+ Dictionary<string, string> d = new Dictionary<string, string>();
|
|
|
+ d.Add("letter_id", letter_id);
|
|
|
+ XFApiIsEvaluateResult rObj = await HttpPostAsync<XFApiIsEvaluateResult>("http://<服务器IP>/query/letterDetail", d, onFails);
|
|
|
+
|
|
|
+ if (rObj == null)
|
|
|
+ return false;
|
|
|
+ if (rObj.Data == null)
|
|
|
+ {
|
|
|
+ Logger.LogError("数据提交省统一平台失败,原因:{0}", rObj.Message);
|
|
|
+ onFails(string.Format("数据提交省统一平台失败,原因:{0}", rObj.Message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return rObj.Data.SFKPJ;
|
|
|
+ }
|
|
|
+ //http://<服务器IP>/query/submitEvaluate
|
|
|
+ public async Task<bool> SubmitEvaluate(EvaluateModel e, OnFails onFails)
|
|
|
+ {
|
|
|
+ Dictionary<string, string> d = e.ToDictionary();
|
|
|
+ XFApiResult rObj = await HttpPostAsync<XFApiResult>("http://<服务器IP>/query/letterDetail", d, onFails);
|
|
|
+
|
|
|
+ if (rObj == null)
|
|
|
+ return false;
|
|
|
+ if (rObj.Data == null || !rObj.Data.Success)
|
|
|
+ {
|
|
|
+ Logger.LogError("数据提交省统一平台失败,原因:{0}", rObj.Message);
|
|
|
+ onFails(string.Format("数据提交省统一平台失败,原因:{0}", rObj.Message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
/// POST 异步
|
|
|
/// </summary>
|
|
|
/// <param name="url"></param>
|
|
|
@@ -40,7 +136,7 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
|
|
|
/// <param name="encoding"></param>
|
|
|
/// <param name="timeOut"></param>
|
|
|
/// <returns></returns>
|
|
|
- async Task<XFApiResult> HttpPostAsync(string url, Dictionary<string, string> formData, OnFails onFails)
|
|
|
+ async Task<T> HttpPostAsync<T>(string url, Dictionary<string, string> formData, OnFails onFails)
|
|
|
{
|
|
|
HttpClientHandler handler = new HttpClientHandler();
|
|
|
HttpClient client = new HttpClient(handler);
|
|
|
@@ -54,16 +150,16 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
|
|
|
{
|
|
|
Logger.LogError("省统一平台异常反馈:状态“{0}”", r.StatusCode);
|
|
|
onFails(string.Format("省统一平台异常反馈:状态“{0}”", r.StatusCode));
|
|
|
- return null;
|
|
|
+ return default(T);
|
|
|
}
|
|
|
byte[] tmp = await r.Content.ReadAsByteArrayAsync();
|
|
|
string rStr = Encoding.UTF8.GetString(tmp);
|
|
|
- XFApiResult rObj = JsonConvert.DeserializeObject<XFApiResult>(rStr);
|
|
|
- if (rObj == null || rObj.Data == null || !rObj.Data.Success)
|
|
|
+ T rObj = JsonConvert.DeserializeObject<T>(rStr);
|
|
|
+ if (rObj == null)
|
|
|
{
|
|
|
- Logger.LogError("数据提交省统一平台失败,原因:{0}", rObj.Message);
|
|
|
- onFails(string.Format("数据提交省统一平台失败,原因:{0}", rObj.Message));
|
|
|
- return null;
|
|
|
+ Logger.LogError("数据提交省统一平台失败,原因:{0}", "数据为空");
|
|
|
+ onFails(string.Format("数据提交省统一平台失败,原因:{0}", "数据为空"));
|
|
|
+ return default(T);
|
|
|
}
|
|
|
return rObj;
|
|
|
}
|
|
|
@@ -86,7 +182,6 @@ namespace Winsoft.GOV.XF.WebApi.WXCore.Services
|
|
|
FillFormDataStream(formData, ms);//填充formData
|
|
|
HttpContent hc = new StreamContent(ms);
|
|
|
|
|
|
-
|
|
|
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html"));
|
|
|
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xhtml+xml"));
|
|
|
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml", 0.9));
|