public void OnActionExecuting(ActionExecutingContext context) { context.HttpContext.Request.EnableRewind(); var reader = new StreamReader(context.HttpContext.Request.Body); string json = reader.ReadToEnd(); context.HttpContext.Request.Body.Position = 0; JObject jObject = null; try { jObject = JObject.Parse(json); } catch { } if (null == jObject) { context.Result = new ContentResult() { Content = ApiTools.GetErrorJson("json格式错误") }; return; } string systemCode = jObject.Value <string>("systemcode"); if (systemCode.IsNullOrEmpty()) { context.Result = new ContentResult() { Content = ApiTools.GetErrorJson("系统标识为空") }; return; } var systemModel = new Business.FlowApiSystem().Get(systemCode.Trim()); if (null == systemModel) { context.Result = new ContentResult() { Content = ApiTools.GetErrorJson("未找到对应的系统") }; return; } string systemIP = ',' + systemModel.SystemIP + ","; //如果设定的本地IP地址,则直接返回不比较 if (systemIP.ContainsIgnoreCase(",127.0.0.1,") || systemIP.ContainsIgnoreCase(",::1,") || systemIP.ContainsIgnoreCase(",localhost,")) { return; } string ip = context.HttpContext.Connection.RemoteIpAddress.ToString(); if (!systemIP.ContainsIgnoreCase("," + ip + ",")) { context.Result = new ContentResult() { Content = ApiTools.GetErrorJson("未授权的访问") }; return; } }
/// <summary> /// 得到token /// </summary> /// <param name="systemCode">系统标识</param> /// <returns></returns> public static string GetToken(string systemCode) { if (systemCode.IsNullOrWhiteSpace()) { return(""); } Business.FlowApiSystem flowApiSystem = new Business.FlowApiSystem(); var model = flowApiSystem.Get(systemCode); if (null == model) { return(""); } return(""); }
public IActionResult Set_Flow() { string flowId = Request.Querys("flowid"); string isAdd = Request.Querys("isadd"); if (flowId.IsNullOrWhiteSpace()) { flowId = Guid.NewGuid().ToString(); } ViewData["isAdd"] = isAdd; ViewData["openerid"] = Request.Querys("openerid"); ViewData["flowId"] = flowId; ViewData["defaultManager"] = Business.Organize.PREFIX_USER + Current.UserId; ViewData["dbconnOptions"] = new Business.DbConnection().GetOptions(); ViewData["flowTypeOptions"] = new Business.Dictionary().GetOptionsByCode("system_applibrarytype_flow", value: ""); ViewData["flowSystemOptions"] = new Business.FlowApiSystem().GetAllOptions(); return(View()); }
public string Query() { string flow_name = Request.Forms("flow_name"); string typeid = Request.Forms("typeid"); string sidx = Request.Forms("sidx"); string sord = Request.Forms("sord"); int size = Tools.GetPageSize(); int number = Tools.GetPageNumber(); string order = (sidx.IsNullOrEmpty() ? "CreateDate" : sidx) + " " + (sord.IsNullOrEmpty() ? "DESC" : sord); if (typeid.IsGuid(out Guid typeId)) { var childsId = new Business.Dictionary().GetAllChildsId(typeId); typeid = childsId.JoinSqlIn(); } Business.Flow flow = new Business.Flow(); Business.FlowApiSystem flowApiSystem = new Business.FlowApiSystem(); var flows = flow.GetPagerList(out int count, size, number, flow.GetManageFlowIds(Current.UserId), flow_name, typeid, order); Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray(); Business.User user = new Business.User(); foreach (System.Data.DataRow dr in flows.Rows) { Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject { { "id", dr["Id"].ToString() }, { "Name", dr["Name"].ToString() }, { "CreateDate", dr["CreateDate"].ToString().ToDateTime().ToDateTimeString() }, { "CreateUser", user.GetName(dr["CreateUser"].ToString().ToGuid()) }, { "Status", flow.GetStatusTitle(dr["Status"].ToString().ToInt()) }, { "SystemId", flowApiSystem.GetName(dr["SystemId"].ToString().ToGuid()) }, { "Note", dr["Note"].ToString() }, { "Opation", "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"openflow('" + dr["Id"].ToString() + "', '" + dr["Name"].ToString() + "');return false;\"><i class=\"fa fa-edit (alias)\"></i>编辑</a>" } }; jArray.Add(jObject); } return("{\"userdata\":{\"total\":" + count + ",\"pagesize\":" + size + ",\"pagenumber\":" + number + "},\"rows\":" + jArray.ToString() + "}"); }