//public string[] AllowSites { get; set; } public override void OnActionExecuting(ActionExecutingContext context) { var origin = context.HttpContext.Request.Headers["Origin"].ToString(); string requestHeaders = context.HttpContext.Request.Headers["Access-Control-Request-Headers"]; Action action = () => { context.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", origin); context.HttpContext.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); context.HttpContext.Response.Headers.Add("Access-Control-Request-Headers", "Content-Type"); context.HttpContext.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); }; action(); if (context.HttpContext.Request.Path.Value.ToLower() == "/api/data/getnowdate") { base.OnActionExecuting(context); } else { try { var t = context.HttpContext.Request.Form["TimeStamp"]; var dt = EncryptHelper.AesDecrpt(t); var clientTime = DateTimeHelper.StampToDateTime(dt); var now = DateTime.Now; var sec = now.Subtract(clientTime).TotalSeconds; double interval = 90; if (interval < Math.Abs(sec)) { var result = new LotteryServiceResponse() { Code = ResponseCode.TimeStampError, Message = "请求发生异常" }; context.Result = new JsonResult(result); } else { base.OnActionExecuting(context); } } catch (Exception ex) { var result = new LotteryServiceResponse() { Code = ResponseCode.TimeStampError, Message = "请求发生异常" }; context.Result = new JsonResult(result); } } }
/// <summary> /// 校验银行卡号 /// </summary> /// <param name="_serviceProxyProvider"></param> /// <param name="entity"></param> /// <returns></returns> public async Task <IActionResult> CheckBlank([FromServices] IServiceProxyProvider _serviceProxyProvider, LotteryServiceRequest entity) { var result = new LotteryServiceResponse { Code = ResponseCode.成功, Message = "银行卡号格式正确", MsgId = entity.MsgId, Value = true }; var p = JsonHelper.Decode(entity.Param); string CardNum = p.CardNum; if (string.IsNullOrEmpty(CardNum)) { result.Message = "银行卡号不能为空"; result.Code = ResponseCode.失败; result.Value = false; } else { var bol = KaSon.FrameWork.Common.Utilities.CheckBlankCard.MatchLuhn(CardNum); if (!bol) { result.Message = "银行卡号格式不正确"; result.Code = ResponseCode.失败; result.Value = false; } else { result.Message = "银行卡号格式正确"; result.Code = ResponseCode.成功; result.Value = true; } } return(Json(result)); }
public async Task <IActionResult> GetAppendBettingDate([FromServices] IServiceProxyProvider _serviceProxyProvider, LotteryServiceRequest entity) { try { var result = new LotteryServiceResponse { Code = ResponseCode.成功, Message = "", MsgId = entity.MsgId, }; var p = JsonHelper.Decode(entity.Param); string IssuseNumber = p.IssuseNumber; string GameCode = p.GameCode; int Count = p.Count; if (string.IsNullOrEmpty(IssuseNumber)) { throw new Exception("当前期号不能为空"); } if (string.IsNullOrEmpty(GameCode)) { throw new Exception("彩票类型不能为空"); } if (Count < 1) { throw new Exception("追期数必须1期以上"); } // BettingDateHelper IList <string> list = new List <string>(); if (Count == 1) { list.Add(IssuseNumber); } var MainGameCode = new List <string>() { "SSQ", "DLT", "FC3D", "PL3" }; if (Count > 1) { int currentMaxDate = BettingDateHelper.GetMaxDate(GameCode); if (currentMaxDate == 0) { result.Message = "不支持彩种"; result.Value = list; result.Code = ResponseCode.失败; return(JsonEx(result)); } if (MainGameCode.Contains(GameCode.ToUpper())) { Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("gameCode", GameCode.ToUpper()); param.Add("currIssueNumber", IssuseNumber); param.Add("issueCount", Count); list = await _serviceProxyProvider.Invoke <List <string> >(param, "api/Data/GetMaxIssueByGameCode"); } else { list = BettingDateHelper.GetUpdate(IssuseNumber, currentMaxDate, GameCode, Count); } result.Value = list; } return(JsonEx(result)); } catch (Exception ex) { return(Json(new LotteryServiceResponse { Code = ResponseCode.失败, Message = "获取追期期号失败" + "●" + ex.ToString(), MsgId = entity.MsgId, Value = ex.ToGetMessage(), })); } }