public ActionResult SaveCfgDefinition(CfgDefinition model) { InkeyResult result = new InkeyResult(); _cfgManagerService.AddOrUpdateAllCfgDefinition(model); return(Json(result)); }
public ActionResult CfgDefinitionVersionDelete(Guid id) { InkeyResult result = new InkeyResult(); _cfgManagerService.DeleteCfgDefinitionVersion(id); return(Json(result)); }
public ActionResult CfgItemDeleteAll(string ids) { IList <Guid> idList = ids.Split(',').Select(i => { var s = i.Split('#'); Guid defItemId = Guid.Parse(s[3]); if (defItemId != Guid.Empty) { return(Guid.Empty); } else { return(Guid.Parse(s[0])); } }).Where(i => i != Guid.Empty).Distinct().ToList(); IList <Guid> idListForGolbal = ids.Split(',').Select(i => { var s = i.Split('#'); return(Guid.Parse(s[3])); }).Where(i => i != Guid.Empty).Distinct().ToList(); InkeyResult result = new InkeyResult(); if (idList.Count > 0) { _cfgManagerService.DeleteAllCfgItem(idList); } if (idListForGolbal.Count > 0) { _cfgManagerService.DeleteAllCfgDefinitionItem(idListForGolbal); } return(Json(result)); }
public ActionResult CfgItemVerEnvDeleteAll(string ids) { IList <Guid> idList = ids.Split(',').Select(i => { var s = i.Split('#'); Guid defItemId = Guid.Parse(s[3]); if (defItemId != Guid.Empty) { return(Guid.Empty); } else { return(Guid.Parse(s[2])); } }).Where(i => i != Guid.Empty).Distinct().ToList(); IList <Guid> idListForGolbal = ids.Split(',').Select(i => { var s = i.Split('#'); return(Guid.Parse(s[3])); }).Where(i => i != Guid.Empty).Distinct().ToList(); InkeyResult result = new InkeyResult(); if (idList.Count > 0) { _cfgManagerService.DeleteAllCfgItemVersionEnvironment(idList); } if (idListForGolbal.Count > 0) { result.Code = -101; result.Desc = "全局数据项不能操作"; } return(Json(result)); }
public ActionResult SaveCfgItemVerEdit(CfgItemVersion model) { InkeyResult result = new InkeyResult(); _cfgManagerService.EditCfgItemVerion(model); return(Json(result)); }
public ActionResult SaveCfgItemVerEnv(CfgItemVersionEnvironment model) { InkeyResult result = new InkeyResult(); _cfgManagerService.AddCfgEnvValue(model); return(Json(result)); }
public ActionResult SaveFunctionInfoToRole(RoleFunctionInfoTreeModel model) { InkeyResult result = new InkeyResult(); this._authManagerService.SaveAuthFunctionInfoToRole(model); return(Json(result)); }
public ActionResult SaveCfgEnv(CfgEnvironment model) { InkeyResult result = new InkeyResult(); _cfgManagerService.AddOrUpdateAllCfgEnvironment(model); return(Json(result)); }
public ActionResult CfgDefinitonItemPublishAll(Guid id) { InkeyResult result = new InkeyResult(); _cfgManagerService.PublishAllCfgDefinitonItem(id); return(Json(result)); }
public ActionResult SaveCfgItemVerEnvEdit(CfgItemVersionEnvironment model) { InkeyResult result = new InkeyResult(); model.UpdateTime = DateTime.Now; _cfgManagerService.EditCfgItemVerionEnvironment(model); return(Json(result)); }
public ActionResult SelectCfgDefinitionItem(string ids, Guid defVerId) { var idVals = ids.Split('#').Select(id => Guid.Parse(id)).ToArray(); InkeyResult result = new InkeyResult(); _cfgManagerService.SetCfgDefinitionItem(idVals[2], defVerId); return(Json(result)); }
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext) { var result = new InkeyResult(); result.Desc = "无权限,需要登录后操作"; result.Code = (int)HttpStatusCode.Unauthorized; actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, result); }
private static InkeyResult <string> GetMemcachedResult(string actionType, string sType, string vType, string cacheResult, FormatObjcet formart, List <string> pValueList) { InkeyResult <string> result = new InkeyResult <string>(); var cacheManager = new MemcachedManager(new CacheManagerActionCacheKeyFormat()); var flag = false; switch (actionType) { case "View": object value = string.Empty; flag = cacheManager.RawIsSet(formart.Key, out value, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "未设置缓存值"; return(result); } else { result.Data = value is string?(string)value : value.ToJsonString(); } break; case "Update": if (cacheManager.RawIsSet(formart.Key, out value, pValueList.ToArray()) && !(value is string)) { value = JsonConvert.DeserializeObject(cacheResult, value.GetType()); flag = cacheManager.RawSet(formart.Key, value, pValueList.ToArray()); } else { flag = cacheManager.RawSet(formart.Key, cacheResult, pValueList.ToArray()); } if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "请输入JSON"; return(result); } else { result.Code = InkeyErrorCodes.CommonBusinessFailure; //前端需要弹出提示,所有设置这个值 result.Desc = "更新成功"; } break; case "Delete": flag = cacheManager.Remove(formart.Key, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "缓存移除失败"; return(result); } break; } return(result); }
public ActionResult AddAuthRoleInfoToGroup(Guid groupId, string ids) { InkeyResult result = new InkeyResult(); IList <Guid> idList = ids.Split(',').Select(i => { return(Guid.Parse(i)); }).ToList(); this._authManagerService.AddAuthRoleInfoToGroup(groupId, idList); return(Json(result)); }
public ActionResult RemoveAuthUserInfoToRole(Guid roleId, string ids) { InkeyResult result = new InkeyResult(); IList <Guid> idList = ids.Split(',').Select(i => { return(Guid.Parse(i)); }).ToList(); this._authManagerService.RemoveAuthUserInfoToRole(roleId, idList); return(Json(result)); }
public JsonResult Login(LoginViewModel model) { var result = new InkeyResult(); AccountInfo accountInfo = (AccountInfo)IkAuthorizationContext.Current.Authenticate("13568851221"); accountInfo.UserId = 564878; accountInfo.UserName = "******"; var authorizeContainer = new InkeyAuthorizeContainer(this.HttpContext.Request); authorizeContainer.SetToken(accountInfo); return(Json(result)); }
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { if (filterContext.HttpContext.Request.IsAjaxRequest()) { var result = new InkeyResult(); result.Code = 401; result.Desc = "未授权"; filterContext.HttpContext.SkipAuthorization = true; filterContext.Result = new UnauthorizedResult(result); } else { base.HandleUnauthorizedRequest(filterContext); } }
public ActionResult SaveAuthAppInfo(AuthAppInfoModel model) { InkeyResult result = new InkeyResult(); string errorMessage; if (this.VerifyModle(out errorMessage)) { this._authManagerService.AddOrUpdateAllAuthAppInfo(model); } else { result.Code = -101; result.Desc = errorMessage; } return(Json(result)); }
public ActionResult CacheKeyAppInfoDeleteAll(string ids) { InkeyResult result = new InkeyResult(); IList <Guid> idList = ids.Split(',').Select(i => { return(Guid.Parse(i)); }).ToList(); var flag = this._cacheKeyManagerService.DeleteAllCacheKeyAppInfo(idList); if (!flag) { result.Code = -101; result.Desc = "该应用下还有相关的权限资源,不能删除"; } return(Json(result)); }
public ActionResult SaveCacheKeyValueTypeInfo(CacheKeyValueTypeInfoModel model) { InkeyResult result = new InkeyResult(); string errorMessage; if (this.VerifyModle(out errorMessage)) { this._cacheKeyManagerService.AddOrUpdateAllCacheKeyValueTypeInfo(model); } else { result.Code = -101; result.Desc = errorMessage; } return(Json(result)); }
public ActionResult SerialDefineInfoDeleteAll(string ids) { InkeyResult result = new InkeyResult(); IList <Guid> idList = ids.Split(',').Select(i => { return(Guid.Parse(i)); }).ToList(); var flag = this._serialNumberDefineService.DeleteAllSerialDefineInfo(idList); if (!flag) { result.Code = -101; result.Desc = "该应用下还有相关的权限资源,不能删除"; } return(Json(result)); }
public ActionResult SaveSerialDefineInfo(SerialDefineInfoModel model) { InkeyResult result = new InkeyResult(); string errorMessage; if (this.VerifyModle(out errorMessage)) { this._serialNumberDefineService.AddOrUpdateAllSerialDefineInfo(model); } else { result.Code = -101; result.Desc = errorMessage; } return(Json(result)); }
public InkeyResult <string> CacheManager(string actionType, Guid itemId, string sType, NameValueCollection forms, string cacheResult) { InkeyResult <string> result = new InkeyResult <string>(); var model = GetCacheKeyItemInfo(itemId); var valueTypes = GetCacheKeyValueTypeInfoList(); KeyConfigFormatObjcet formats = new KeyConfigFormatObjcet(model.AppCode, new List <KeyItem> { new KeyItem { Key = model.Code, Scope = model.KeySocpe } }, valueTypes.Select(v => new KeyTypeDefine { ValueType = v.Code, ValueClassCode = v.ClassContext, ValueTypeAssemblyName = v.ValueTypeAssemblyName }).ToList()); var formart = formats.FormatObjcets[model.Code]; List <string> pValueList = new List <string>(); foreach (var item in formart.KeyList) { string pName = item.TrimStart('{').TrimEnd('}'); string pValue = forms[pName]; if (string.IsNullOrEmpty(pValue)) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "参数不能为空,参数名称:" + pName; return(result); } pValueList.Add(pValue); } string vType = null; if (!string.IsNullOrEmpty(model.RefValueType)) { foreach (var item in valueTypes) { if (item.Code == model.RefValueType) { vType = string.Format("{0},{1}", item.Code, item.ValueTypeAssemblyName); break; } } } if (model.CacheType == CacheEnvType.Memcached) { return(GetMemcachedResult(actionType, sType, vType, cacheResult, formart, pValueList)); } return(GetRedisResult(actionType, sType, vType, cacheResult, formart, pValueList)); }
public ActionResult SaveCfgDefinitionVersion(CfgDefinitionVersion model) { InkeyResult result = new InkeyResult(); Version ver; if (Version.TryParse(model.Version, out ver)) { model.Version = VersionHelper.FormatVersion(model.Version).ToString(); _cfgManagerService.AddOrUpdateAllCfgDefinitionVersion(model); } else { result.Code = -101; result.Desc = "版本号格式错误"; } return(Json(result)); }
public ActionResult SaveCfgItemVer(CfgItemVersionEnvironment model) { InkeyResult result = new InkeyResult(); Version ver; if (Version.TryParse(model.Version, out ver)) { model.Version = VersionHelper.FormatVersion(model.Version).ToString(); _cfgManagerService.AddCfgVersionAndEnvValue(model); } else { result.Code = -101; result.Desc = "版本号格式错误"; } return(Json(result)); }
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { var apiRequestInfo = actionExecutedContext.Request.GetRequestProcessInfo(); if (actionExecutedContext.Response != null) { var response = actionExecutedContext.Response; var objectContent = response.Content as ObjectContent; if (objectContent != null) { InkeyResult result = objectContent.Value as InkeyResult; if (result != null) { apiRequestInfo.ProcessState = result.Code; apiRequestInfo.ProcessDesc = result.Desc; if (this._isNeedResultContent) { apiRequestInfo.ResultContent = result.ToJsonString(); } } } actionExecutedContext.Response.SetSimpleCookie(actionExecutedContext.Request); } else if (actionExecutedContext.Exception != null) { var inkeyException = actionExecutedContext.Exception as InkeyException; if (inkeyException != null) { logger.Error(string.Format("请求错误,地址:{0}", actionExecutedContext.Request.RequestUri), actionExecutedContext.Exception); actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.OK, new InkeyResult(inkeyException.Code, inkeyException.Desc)); apiRequestInfo.ProcessState = inkeyException.Code; apiRequestInfo.ProcessDesc = actionExecutedContext.Exception.Message; apiRequestInfo.ResultContent = actionExecutedContext.Exception.ToString(); } else { Random rd = new Random(); int errorCode = rd.Next(900000, 9999999); InkeyResult result = new InkeyResult(InkeyErrorCodes.CommonFailure, InkeyErrorCodes.CommonFailureDesc + ",日志码:" + errorCode); logger.Error(string.Format("请求错误,日志码{0},地址:{1}", errorCode, actionExecutedContext.Request.RequestUri), actionExecutedContext.Exception); actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.InternalServerError, result); apiRequestInfo.ProcessState = errorCode; apiRequestInfo.ProcessDesc = actionExecutedContext.Exception.Message; apiRequestInfo.ResultContent = actionExecutedContext.Exception.ToString(); } } apiRequestInfo.HttpStatus = (int)actionExecutedContext.Response.StatusCode; apiRequestInfo.ElapsedMilliseconds = (int)((System.DateTime.Now - apiRequestInfo.RequestStartTime).TotalMilliseconds); var responseCookies = actionExecutedContext.Request.GetAllAddedSimpleCookie(); // 获取cookie if (responseCookies.Count > 0) { foreach (CookieHeaderValue item in responseCookies) { apiRequestInfo.ResponseCookie += string.Format("{0}={1}~", item.Cookies[0].Name, item.Cookies[0].Value); } if (apiRequestInfo.ResponseCookie.Length > 0) { apiRequestInfo.ResponseCookie = apiRequestInfo.ResponseCookie.TrimEnd('~'); } } BufferRequestProcessInfo(apiRequestInfo); base.OnActionExecuted(actionExecutedContext); }
private static InkeyResult <string> GetRedisResult(string actionType, string sType, string vType, string cacheResult, FormatObjcet formart, List <string> pValueList) { InkeyResult <string> result = new InkeyResult <string>(); bool sJsonType = sType == "JSON"; var cacheManager = new RedisManager(new CacheManagerActionCacheKeyFormat()); var flag = false; switch (actionType) { case "View": flag = cacheManager.Exists(formart.Key, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "未设置缓存值"; return(result); } if (sJsonType) { result.Data = cacheManager.GetOriginalValue(formart.Key, pValueList.ToArray()); } else { if (string.IsNullOrEmpty(vType)) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "值类型未设置"; return(result); } Type type = Type.GetType(vType); if (type == null) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "值类型未定义,类型:" + vType; return(result); } byte[] oValue = cacheManager.RawGetOriginalValue(formart.Key, pValueList.ToArray()); object value = BinarySerializerManager.BinaryDeSerialize(oValue); result.Data = value.ToJsonString(); } break; case "Update": flag = cacheManager.Exists(formart.Key, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "未设置缓存值"; return(result); } if (sJsonType) { flag = cacheManager.OriginalValueAdd(formart.Key, cacheResult, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "更新失败"; return(result); } } else { if (string.IsNullOrEmpty(vType)) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "值类型未设置"; return(result); } Type type = Type.GetType(vType); if (type == null) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "值类型未定义,类型:" + vType; return(result); } var oValue = JsonSerializerManager.JsonDeserialize(cacheResult, type); if (oValue == null) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "json格式错误,类型:" + vType; return(result); } else { var value = BinarySerializerManager.BinarySerialize(oValue); flag = cacheManager.RawOriginalValueAdd(formart.Key, value, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "更新失败"; return(result); } } } result.Code = InkeyErrorCodes.CommonBusinessFailure; //前端需要弹出提示,所有设置这个值 result.Desc = "更新成功"; break; case "Delete": flag = cacheManager.Remove(formart.Key, pValueList.ToArray()); if (!flag) { result.Code = InkeyErrorCodes.CommonBusinessFailure; result.Desc = "缓存移除失败"; return(result); } break; } return(result); }
public ActionResult CacheManager(string actionType, Guid itemId, string sType, string cacheResult) { InkeyResult <string> result = this._cacheKeyManagerService.CacheManager(actionType, itemId, sType, this.Request.Form, cacheResult); return(Json(result)); }