/// <summary> /// 根据token过滤 /// </summary> /// <param name="list"></param> /// <returns></returns> private List<train_code_list> GetListByToken(List<train_code_list> list) { //token var token = System.Web.HttpContext.Current.Request.Headers["Token"]; if (!string.IsNullOrEmpty(token)) { var station = (new DESHelper().DecryptString(((new DESHelper().DecryptString(token, DESHelper.key, DESHelper.iv)).Split('/')[3]), DESHelper.key, DESHelper.iv)); list = list.Where(c => c.Detail.Any(p => p.station_name == station)).ToList(); } return list; }
/// <summary> /// 获取随机码 /// </summary> /// <param name="data"></param> /// <returns></returns> public ResultMsg GetRandom(authentication data) { var resultMsg = new ResultMsg() { Status = false, Info = "", Data = data }; try { if (string.IsNullOrEmpty(data.UniqueCode)) { resultMsg.Info = "唯一码为空!"; return resultMsg; } if (string.IsNullOrEmpty(data.PID)) { resultMsg.Info = "PID为空!"; return resultMsg; } if (string.IsNullOrEmpty(data.PIN)) { resultMsg.Info = "PIN为空!"; return resultMsg; } var query = Query.And(Query.EQ("UniqueCode", data.UniqueCode),Query.EQ("PID", data.PID),Query.EQ("PIN", data.PIN)); if (Mb.FindOne<authentication>(query) != null) { var strRandom= getStr(6); if (Mb.Update<authentication>(query, Update.Set("RandomDigit", strRandom))) { resultMsg.Status = true; resultMsg.Data = strRandom; } else { resultMsg.Info = "保存随机数失败!"; } } else { resultMsg.Info = "提供的信息在数据库中不存在!"; } } catch (Exception ex) { resultMsg.Info = ex.Message; } return resultMsg; }
/// <summary> /// 获取token /// </summary> /// <param name="data"></param> /// <returns></returns> public ResultMsg GetToken(authentication data) { var resultMsg = new ResultMsg() { Status = false, Info = "", Data = data }; try { if (string.IsNullOrEmpty(data.UniqueCode)) { resultMsg.Info = "唯一码为空!"; return resultMsg; } if (string.IsNullOrEmpty(data.EncryptedStorage)) { resultMsg.Info = "加密存储区信息为空!"; return resultMsg; } var auth = Mb.FindOne<authentication>(Query.EQ("UniqueCode", data.UniqueCode)); if (auth != null) { if (data.EncryptedStorage.Replace("