public ClientResult Get(string guid, string select) { var result = ClientResult.Error("获取数据失败"); try { List <int> cache_selectIndex = new List <int>(); if (_cache.TryGetValue(CACHE_KEY + guid, out cache_selectIndex)) { var selectIndex = select.Split(','); if (cache_selectIndex.Count == selectIndex.Length) { foreach (var item in selectIndex) { if (cache_selectIndex.IndexOf(int.Parse(item)) < 0) { throw new Exception("请选择正确的图案"); } } result = ClientResult.Success("恭喜,选择正确"); } else { result = ClientResult.Error("请选择正确的图案"); } } } catch (Exception) { result = ClientResult.Error("请选择正确的图案"); } return(result); }
public IHttpActionResult Get(string guid, string select) { var result = ClientResult.Error("获取数据失败"); try { var cache = new CacheHelper(); var cache_selectIndex = cache.Get <List <int> >("captcha_" + guid); var selectIndex = select.Split(','); if (cache_selectIndex.Count == selectIndex.Length) { foreach (var item in selectIndex) { if (cache_selectIndex.IndexOf(int.Parse(item)) < 0) { throw new Exception("请选择正确的图案"); } } result = ClientResult.Success("恭喜,选择正确"); } else { result = ClientResult.Error("请选择正确的图案"); } } catch (Exception) { result = ClientResult.Error("请选择正确的图案"); } return(Json(result)); }
public IHttpActionResult demo() { var result = ClientResult.Error("获取数据失败"); try { var myapi = new MyAPI(); result = ClientResult.Success(myapi.GetCaptcha("123456")); } catch (Exception ex) { result = ClientResult.Error("获取数据失败"); } return(Json(result)); }