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.
78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using ForwarderQuery.DB;
|
|
using ForwarderQuery.Helper;
|
|
using ForwarderQuery.Models;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Caching;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace ForwarderQuery.Controllers
|
|
{
|
|
public class ApiController : Controller
|
|
{
|
|
private MyshippingData myshippingData = new MyshippingData();
|
|
private CangdanData cangdanData = new CangdanData();
|
|
|
|
[HttpGet]
|
|
public ActionResult QueryData(string uid, string skey, string mblno, string vessel, string voyno)
|
|
{
|
|
RespCommonData resp = new RespCommonData();
|
|
|
|
var user = myshippingData.CustAuth.AsNoTracking().FirstOrDefault(x => x.USERID == uid && x.SKEY == skey);
|
|
|
|
if (user == null)
|
|
{
|
|
resp.Success = false;
|
|
resp.Message = ":身份验证错误,请检查!";
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
if (MemoryCache.Default.Contains($"{user.USERID}"))
|
|
{
|
|
resp.Success = false;
|
|
resp.Message = "操作过于频繁";
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
var succ = QueryHelper.Query(mblno, vessel, voyno, out string strResult);
|
|
if (succ)
|
|
{
|
|
EdiQueryLog log = new EdiQueryLog();
|
|
log.GID = Guid.NewGuid().ToString();
|
|
log.USERID = user.USERID;
|
|
log.COMNAME = user.comname;
|
|
log.MBLNO = mblno;
|
|
log.VESSEL = vessel;
|
|
log.VOYNO = voyno;
|
|
log.LOGTIME = DateTime.Now;
|
|
log.RESULT = strResult;
|
|
myshippingData.EdiQueryLog.Add(log);
|
|
myshippingData.SaveChanges();
|
|
|
|
resp.Success = true;
|
|
resp.Message = strResult;
|
|
|
|
|
|
var carrier = QueryHelper.QueryCarrier(mblno);
|
|
resp.Data = JsonConvert.SerializeObject(new
|
|
{
|
|
Forwarder = strResult,
|
|
Carrier = carrier
|
|
});
|
|
}
|
|
else
|
|
{
|
|
resp.Success = false;
|
|
resp.Message = "未查询到数据";
|
|
}
|
|
|
|
MemoryCache.Default.Add(new CacheItem(user.USERID, string.Empty), new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddSeconds(2) });
|
|
|
|
return Json(resp, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
}
|
|
} |