/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, AppKeyEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public HttpResponseMessage GetToken(string appkey, string appsecret) { BaseJson <Token_Preview> resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null }; Logger(typeof(OAuthController), "", "根据AppKey获取Token-GetToken", () => { //判断参数是否合法 if (string.IsNullOrEmpty(appkey) && string.IsNullOrEmpty(appsecret)) { resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.ParameterError, Message = JsonObjectStatus.ParameterError.GetEnumText(), Data = null }; } else { string exp = GlobalStaticConstant.REGRXP_APP_KEY; bool validate = StringHelper.QuickValidate(exp, appkey); if (!validate) { resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.ParameterError, Data = null, Message = JsonObjectStatus.ParameterError.GetEnumText(), BackUrl = "" }; } else { //TODO 核对是否存在appkey以及校验appsecret是否正确 AppKeyEntity appKeyEntity = _appKeyBll.GetEntity(a => a.AppKey.Equals(appkey)); if (appKeyEntity != null) { //比对密钥 if (appKeyEntity.AppSecret.Equals(appsecret)) { //获取缓存Token信息 Token_Preview token = CacheFactory.Cache().GetCache <Token_Preview>(appkey); if (token == null) { //过期时间 DateTime time = DateTimeHelper.Now.AddHours(GlobalStaticConstant.TOKEN_EXPIRE_TIME); string accessToken = GetSignToken(appkey); token = new Token_Preview { AppKey = appkey, AccessToken = accessToken, ExpireTime = time.ToString("yyyy-MM-dd HH:mm:ss") }; //插入缓存 CacheFactory.Cache().WriteCache(token, token.AppKey, time); } //返回token信息 resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.Success, Message = JsonObjectStatus.Success.GetEnumText(), Data = token }; } else { resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.Fail, Message = "AppSecret无效。", Data = null }; } } else { resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.Fail, Message = "AppKey不存在。", Data = null }; } } } }, e => { resultMsg = new BaseJson <Token_Preview> { Status = (int)JsonObjectStatus.Exception, Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message, Data = null }; }, null, ErrorHandel.Continue); return(resultMsg.ToJson().ToHttpResponseMessage()); }
public ActionResult SaveForm(string keyValue, AppKeyEntity entity) { appkeybll.SaveForm(keyValue, entity); return(Success("操作成功。")); }