/// <summary> /// 解析URL中的数据 /// </summary> /// <param name="url">目标地址</param> /// <returns>Url参数模型</returns> private FunctionUrlViewModel ConvertUrl(string url) { FunctionUrlViewModel model = new FunctionUrlViewModel(); //截取pageUrl if (url.IndexOf('(') > 0) { model.PageUrl = url.Substring(0, url.IndexOf('(')); } else { model.PageUrl = "0"; } if (model.PageUrl != "0") { //截取参数,反序列化为动态对象,并赋值 int startIndex = url.IndexOf('{'); int endIndex = url.IndexOf('}') + 1; if (startIndex > 0 && endIndex > 0) { string paramStr = url.Substring(startIndex, endIndex - startIndex); dynamic param = JsonConvert.DeserializeObject(paramStr); //解析动态对象 switch (model.PageUrl) { case "app.BizQueryView": model.SchemaCode = param.SchemaCode; model.QueryCode = param.QueryCode; model.FunctionCode = param.FunctionCode; break; case "app.MyWorkItem": model.SchemaCode = param.SchemaCode; model.WorkItemState = param.State; model.FunctionCode = param.FunctionCode; break; case "app.MyInstance": model.SchemaCode = param.SchemaCode; model.InstanceState = param.State; model.FunctionCode = param.FunctionCode; break; case "app.ShowReport": model.ReportCode = param.ReportCode; break; case "app.EditBizObject": model.SchemaCode = param.SchemaCode; model.SheetCode = param.SheetCode; model.FunctionCode = param.FunctionCode; model.Mode = param.Mode; break; default: model.PageUrl = "0"; break; } } } return(model); }
public JsonResult GetFunctionNode(string id, string appCode, string parentCode) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); FunctionNode functionNode = this.Engine.FunctionAclManager.GetFunctionNode(id); //父节点不为空,则取父节点名称 if (!string.IsNullOrEmpty(parentCode)) { appCode = parentCode; } string parentName = GetParentName(appCode); //获取功能节点信息 if (functionNode != null && !string.IsNullOrEmpty(functionNode.Code)) { FunctionUrlViewModel functionUrl = new FunctionUrlViewModel(); try { functionUrl = ConvertUrl(functionNode.Url); } catch (Exception e) { functionUrl = new FunctionUrlViewModel() { PageUrl = "0" }; } FunctionViewModel model = new FunctionViewModel() { ObjectID = functionNode.ObjectID, Code = functionNode.Code, DisplayName = functionNode.DisplayName, Description = functionNode.Description, SortKey = functionNode.SortKey, OpenNewWindow = functionNode.OpenNewWindow, IconUrl = functionNode.IconUrl, Url = functionNode.Url, IconCss = functionNode.IconCss, IconType = (int)functionNode.IconType, ParentName = parentName, PageUrl = functionUrl.PageUrl, FunctionUrl = functionUrl }; result.Success = true; result.Extend = new { FunctionNode = model, PageUrl = InitPageUrl(), WorkItemState = InitWorkItemState(), InstanceState = InitInstanceState(), ReportCode = InitReportCodeAndReporting(), ReportTree = InitReportCodeAndReportingN(), QueryCodes = GetQueries(model.FunctionUrl.SchemaCode), SheetCodes = GetSheets(model.FunctionUrl.SchemaCode) }; } else if (!string.IsNullOrEmpty(appCode)) { result.Success = true; var workItemState = InitWorkItemState(); var instanceState = InitInstanceState(); var reportCode = InitReportCodeAndReporting(); var ReportTree = InitReportCodeAndReportingN(); FunctionUrlViewModel functionUrl = new FunctionUrlViewModel() { WorkItemState = workItemState.FirstOrDefault().Value, InstanceState = instanceState.FirstOrDefault().Value, ReportCode = reportCode.FirstOrDefault().Value }; result.Extend = new { FunctionNode = new FunctionViewModel() { ParentName = parentName, ParentCode = appCode, PageUrl = "0", FunctionUrl = functionUrl }, PageUrl = InitPageUrl(), WorkItemState = workItemState, InstanceState = instanceState, ReportCode = reportCode, ReportTree = ReportTree, QueryCodes = new { }, SheetCodes = new { } }; } else { result.Success = false; } return Json(result, JsonRequestBehavior.AllowGet); })); }