public static Task <RenderContext> GetRenders(decimal id, RenderContext context) { using (var svc = new OrmService(AppConfigs.sqlfaceconn)) { var handler = svc.GetById <EasyHandler>(id); if (null == handler || handler.STS != "A") { throw new ApplicationException("不存在SQL处理器"); } var t_ps = svc.FilterWhereAsync <EasyHandlerParam>(s => s.HANDLER_ID == id); var t_ex_config = svc.GetByIdAsync <HandlerExtralConfig>(id); var t_dagsides = svc.FilterWhereAsync <ParamGraphMap>(c => c.GRAPH_ID == id); Task.WaitAll(new Task[] { t_ps, t_ex_config, t_dagsides }); var _t_ps = t_ps.ContinueWith(task => { Dictionary <decimal, string> dict = new Dictionary <decimal, string>(); foreach (var item in task.Result) { dict.Add(item.HANDLER_PARAM_ID, item.PARAM_NAME); } return(dict); }); var _t_dagsides = t_dagsides.ContinueWith(task => { //原始的键依赖关系 Dictionary <decimal, HashSet <decimal> > depends = new Dictionary <decimal, HashSet <decimal> >(); foreach (var item in task.Result) { if (!depends.ContainsKey(item.FROMKEY)) { depends.Add(item.FROMKEY, new HashSet <decimal>()); } depends[item.FROMKEY].Add(item.TOKEY); } return(depends); }); ////////逆向依赖关系 这个也可以在客户端或者服务端计算 //Dictionary<string, HashSet<string>> bydepend = new Dictionary<string, HashSet<string>>(); RenderContext vm = null; if (null != context) //选择性的从客户端取值,防止被黑,安全模式! { vm = context; vm.handler = handler; vm.parameters = t_ps.Result; } else { vm = new RenderContext { handler = handler, parameters = t_ps.Result.OrderBy(s => s.PARAM_NAME_C).OrderBy(s => s.ORDER_ID).ToList(), frontConfig = t_ex_config.Result, DAG = t_dagsides.Result, dict = _t_ps.Result, paramsScaledValues = new Dictionary <string, object>(), depends = _t_dagsides.Result, Triggers = new HashSet <decimal>(), OptionSelects = new Dictionary <string, List <Options> >() }; } EvolvingOut(vm); return(Task.FromResult(vm)); } }