private ClientAction BuildClientAction(ActionSchema methodSchema, WbapRequest request) { ClientAction clientRequest = new ClientAction(); BuildClientAction(methodSchema, clientRequest, request); return(clientRequest); }
private void BuildAction(string actionId, int step, WbapAction action, WbapRequest request) { ActionFlowSchema actionSchema = WbdlSchema.Actions.FindItem(actionId); if (actionSchema == null) { throw (new E_CanNotFindActionSchema(actionId)); } bool hasBuildedRequest = false; for (int i = step; i < actionSchema.Actions.Count; i++) { ActionSchema methodSchema = actionSchema.Actions[i]; if (methodSchema.IsRunAtClient()) { if (hasBuildedRequest) { break; } ClientAction clientAction = new ClientAction(); action.ClientActions.Add(clientAction); BuildClientAction(methodSchema, clientAction, request); } else { BuildServerRequest(action.Request, actionSchema, i); hasBuildedRequest = true; break; } } }
//private WbapResponse InvokeFarAction(WbapRequest wbapRequest) //{ // WbapResponse response = new WbapResponse(); // response.PageName = schema.Id; // Dictionary<string, Object> namedParams = new Dictionary<string, object>(); // foreach (KeyValuePair<string, Object> elementItem in wbapRequest.ElementBinds) // { // string retElement = null; // if (elementItem.Key.Equals("ReturnValue")) // { // retElement = elementItem.Value.ToString(); // } // else // { // namedParams.Add(elementItem.Key, GetParamVarValue(elementItem.Value.ToString())); // } // } // Umc.Umc.InvokeFunction("sid", "msid", wbapRequest.ActionId, namedParams); // return response; //} private void BuildServerRequest(WbapRequest request, ActionFlowSchema action, int Step) { request.Step = Step; request.PageName = WbdlSchema.Id; request.ActionId = action.Id; for (int i = Step; i < action.Actions.Count; i++) { ActionSchema methodSchema = action.Actions[i]; if (methodSchema.IsRunAtClient()) { break; } for (int j = 0; j < methodSchema.Parameters.Count; j++) { ParameterSchema paramSchema = methodSchema.Parameters[j]; if (string.IsNullOrEmpty(paramSchema.Value)) { continue; } string[] realParamValues = paramSchema.Value.Split(PARAM_SPLITOR); foreach (string realParamValue in realParamValues) { if (Array.IndexOf(VAR_TYPES, realParamValue[0]) == (int)VarFlagType.Element) { string key = realParamValue.Remove(0, 1); if (!request.ElementBinds.ContainsKey(key)) { request.ElementBinds.Add(key, ""); } } else if (Array.IndexOf(VAR_TYPES, realParamValue[0]) == (int)VarFlagType.Table) { request.ElementBinds.ImportTableSchema(realParamValue.Remove(0, 1), WbdlSchema); } else if (realParamValue[0].Equals('$')) { request.ElementBinds.Add(realParamValue, ""); } else if (pageCtr.ContainsDataTable(realParamValue)) { pageCtr.BuildRequestDataBodyWithTable(request.ElementBinds, realParamValue, null); } else if (methodSchema.MethodName.Equals("UpdateDataSet", StringComparison.OrdinalIgnoreCase)) { pageCtr.BuildRequestDataBodyWithDataSet(request.ElementBinds); } } } } }
private int CreateBackAction(int step, ActionFlowSchema flowSchema) { this.clientScript = ""; //int ret = 0; for (int i = step; i < flowSchema.Actions.Count; i++) { ActionSchema ss = flowSchema.Actions[i]; if (ss.RunAt != RunAtType.Client) { return(i); } this.clientScript += ss.ClientScript + ";"; } return(0); }
private void BuildClientAction(ActionSchema methodSchema, ClientAction clientRequest, WbapRequest request) { clientRequest.FuncName = methodSchema.MethodName; clientRequest.ReturnValue = methodSchema.ReturnValue; foreach (ParameterSchema paramSchema in methodSchema.Parameters) { if (paramSchema.Value[0] == '$') { clientRequest.Parameters.Add(request.ElementBinds[paramSchema.Value]); } else { clientRequest.Parameters.Add(paramSchema.Value); } } }
public Action(Page page, ActionSchema actionSchema, int index, Action parentAction) { this.page = page; this.actionSchema = actionSchema; this.index = index; this.parentAction = parentAction; this.dsId = actionSchema.DataSourceId; try { this.obj = page.DataSources[dsId]; } catch { throw new E_NotFindDataObject(actionSchema.DataSourceId); } }
public void OnEndAnalysis(AssemblyDefinition assemblyDefinition) { if (schema == null) { schema = ProjectUtility.GetProjectAsset <ActionSchema>(); } if (schema != null) { if (actions.IsEmpty()) { schema.assemblyData.Remove(assembly); } else { schema.assemblyData[assembly] = actions; } schema.UpdateIndices(); ProjectUtility.UpdateProjectAsset(schema); } }
/// <summary> /// 执行任务流程 /// </summary> /// <param name="flowId"></param> /// <param name="flowVars"></param> /// <returns>流程结束返回真</returns> public bool InvokeFlow(ActionFlowSchema fs, Dictionary <string, string> flowVars) { changedElementsIds.Clear(); this.needDatas.Clear(); for (int step = this.nextStep; step < fs.Actions.Count; step++) { ActionSchema ss = fs.Actions[step]; if (ss.RunAt == RunAtType.Client) { this.nextStep = CreateBackAction(step, fs); return(nextStep == 0); } if (!InvokeAction(ss, flowVars)) { this.nextStep = step; return(false); } } nextStep = 0; return(true); }
public static string WriteArtifact <TAction>(string artifactFile, ActionSchema actionSchema, FieldOperationSchema operationSchema, ActionAsset actionAsset, ActionDefinitionAsset actionDefinitionAsset) where TAction : Delegate { using var blob = Create <TAction>(actionAsset.CreateModel(), actionSchema, operationSchema, actionDefinitionAsset, Unity.Collections.Allocator.Temp); return(DoWriteArtifact <TAction>(artifactFile, blob)); }
public unsafe static BlobAssetReference <ActionGraph <TAction> > Create <TAction>(ActionAssetModel model, ActionSchema actionSchema, FieldOperationSchema operationSchema, ActionDefinitionAsset definitionAsset, Allocator allocator = Allocator.Persistent) where TAction : Delegate { FormatData(model, definitionAsset, operationSchema, actionSchema, out var nodes, out var variables, out var roots, out var configLength, out var actionNodeCount, out var fieldOperationNodeCount); Type variableType = definitionAsset.variableType.IsCreated ? definitionAsset.variableType.Value : null; var memoryMap = GetConfigMemoryMap(nodes, variableType); var builder = new BlobBuilder(Unity.Collections.Allocator.Temp); ref var root = ref builder.ConstructRoot <ActionGraph <TAction> >();
public unsafe static UnsafeUntypedBlobAssetReference CreateUntyped <TAction>(ActionAssetModel model, ActionSchema actionSchema, FieldOperationSchema operationSchema, ActionDefinitionAsset definitionAsset, Allocator allocator = Allocator.Persistent) where TAction : Delegate { var blob = Create <TAction>(model, actionSchema, operationSchema, definitionAsset, allocator); return(UnsafeUntypedBlobAssetReference.Create(blob)); }
public MethodBroker(ActionSchema methodSchema) { this.methodSchema = methodSchema; }
private bool InvokeAction(ActionSchema actionSchema, Dictionary <string, string> flowVars) { object obj = null; string dsId = actionSchema.DataSourceId; try { obj = dataSources[dsId]; } catch { throw new E_NotFindDataObject(actionSchema.DataSourceId); } if (obj is IDataSource) { (obj as IDataSource).OnSetField += this.Data_OnSetField; (obj as IDataSource).OnSetData += this.Data_OnSetData; } if (actionSchema.Props != null) { if (!SetObjPropertis(actionSchema.Props, obj)) { return(false); } } //没有方法定义,就此获取页面后退出 if (String.IsNullOrEmpty(actionSchema.MethodName)) { //流程中途更新页元素面数据: GetElementDataFormObject(dsId, obj); return(true); } WbdlDataSchema dataObjSchema = pageSchema.DataSources.GetItem(actionSchema.DataSourceId); Dictionary <string, string> parametes = new Dictionary <string, string>(); bool needData = false; foreach (ParameterSchema paramSchema in actionSchema.Parameters) { // Type paramInfo = umc.Umc.GetClassMethodParamInfo(dataObjSchema.DataType, actionSchema.MethodName, paramSchema.Id).ParameterType; string paramValue = CheckValueVar(paramSchema.Value.Trim(), flowVars); if (paramValue == null) { needData = true; } else { parametes.Add(paramSchema.Id, paramValue); } } if (needData) { return(false); } // SetElementDataToObject(dsId, obj); // DataSourceSetDataNotifty onSet = delegate(IDataSource ds) // { // SetElementDataToObject(dsId, ds); // return true; // }; // if (obj is IDataSource) // { // (obj as IDataSource).OnSetData += onSet; // } try { // object retObj = umc.Umc.InvokeMethod(obj, actionSchema.MethodName, parametes); // object retObj = umc.Umc.InvokeMethod(obj, dataObjSchema.DataType, actionSchema.MethodName, parametes); } catch (Exception e) { if (e.InnerException is XUserException) { throw e.InnerException; } string inErrMessge = ""; if (e.InnerException != null) { inErrMessge = e.InnerException.Message; } Exception err = new Exception("调用活动时间,发生错误,活动名:" + actionSchema.Title + ",错误内容:" + e.Message + inErrMessge, e); throw err; } // if (obj is IDataSource) // { // (obj as IDataSource).OnSetData -= onSet; // } if (obj is IDataSource) { (obj as IDataSource).OnSetField -= this.Data_OnSetField; (obj as IDataSource).OnSetData -= this.Data_OnSetData; } GetElementDataFormObject(dsId, obj); return(true); }
private void CreateSearchTree(List <SearchTreeEntry> treeEntries, ActionModule module, ActionSchema schema, int depth) { var entries = new List <SearchTreeEntry>(); foreach (var action in schema[module.definitionAsset]) { entries.Add(new SearchTreeEntry(new GUIContent(action.Name)) { level = depth, userData = new EntryData { actionId = module.action, identifier = action.identifier, fieldOp = false, actionType = module.definitionAsset.delegateType } }); } entries.Sort((entryA, entryB) => entryA.name.CompareTo(entryB.name)); treeEntries.AddRange(entries); }
/// <summary> /// 初始化 /// </summary> /// <returns></returns> public WbapResponse Initialize(string pageName, string sessionId) { WbapResponse resp = null; //CheckPermissionRetrun ret = _ISec.CheckObjectPermission(sessionId, pageName, 1); //if (ret != CheckPermissionRetrun.Yes) //{ // resp = new WbapResponse(); // resp.ErrorNo = (int)(ret); // // Convert.ToInt32 // resp.Message = "Access denied: " + ret.ToString(); // resp.PageName = pageName; // return resp; //} //pageCtr = new PageController(pageName,sessionId); this.sessionId = sessionId; // this.schema = pageCtr.Schame; pageCtr.Initialize(); WbapRequest request = new WbapRequest(); request.ActionId = "OnLoad"; request.Step = 0; request.PageName = pageName; #region 权限管理 //ret =_ISec.CheckObjectPermission(sessionId, streamRequest.ActionId, 2); //if (ret != CheckPermissionRetrun.Yes) //{ // resp = new WbapResponse(); // resp.ErrorNo = Convert.ToInt32(ret); // resp.Message = "Access denied:" + ret.ToString(); // resp.PageName = pageName; // return resp; //} #endregion ActionBroker action = GetAction(request, ref resp, pageName, sessionId, _ISec); if (action != null) { resp = action.Execute(); } //元素捆绑 foreach (FieldBindSchema fieldBindSchema in WbdlSchema.FieldBinds) { //ret = _ISec.CheckObjectPermission(sessionId, fieldBindSchema.Id, 2); //if (ret == CheckPermissionRetrun.Yes) this.InitualElement(resp, fieldBindSchema); } //捆绑列表列属性 foreach (DataListBindSchema listBindSchema in WbdlSchema.DataListBinds) { //ret = _ISec.CheckObjectPermission(sessionId, listBindSchema.Id, 2); //if (ret == CheckPermissionRetrun.Yes) //{ foreach (FieldBindSchema fieldBindSchema in listBindSchema.Columns) { //ret = _ISec.CheckObjectPermission(sessionId, fieldBindSchema.Id, 2); //if (ret == CheckPermissionRetrun.Yes) this.InitualElement(resp, fieldBindSchema); } //} } //控件捆绑 foreach (WbdlControl wbdlControl in WbdlSchema.Controls) { ActionSchema ms = wbdlControl.DataFunction; MethodBroker mb = new MethodBroker(ms); object invokeRet = mb.Invoke(sessionId, WbdlSchema, request); WbapControl wbapControl = new WbapControl(); wbapControl.Data = invokeRet; wbapControl.VenderObject = wbdlControl.VenderObject; wbapControl.VenderUrl = wbdlControl.VerderUrl; resp.Controls.Add(wbdlControl.Id, wbapControl); } //捆绑数据; pageCtr.FillDataBodyWithDataSet(resp.ElementBinds); //捆绑列表 //foreach (PageDataList pageList in pageCtr.Page.PageLists.Values) //{ // string listId = pageList.ElementId; // if (!resp.ElementBinds.ContainsKey(listId + WbapList.TypeMarker)) // { // WbapList wbapList = pageCtr.GetWbapList(listId); // resp.ElementBinds.Add(listId + WbapList.TypeMarker, wbapList); // } //} //捆绑事件 foreach (EventSchema eventBindSchema in WbdlSchema.EventBinds) { string actionId = eventBindSchema.ActionFlow; WbapEvent wbapEvent = new WbapEvent(); wbapEvent.EventName = eventBindSchema.EventName; BuildAction(actionId, 0, wbapEvent.Action, request); resp.ElementBinds.AddEvent(eventBindSchema.Id, wbapEvent); } //替换全局变量 foreach (string elementKey in resp.ElementBinds.Keys) { if (elementKey.Length > 0 && elementKey[0] == '$') { resp.ElementBinds[elementKey] = request.ElementBinds[elementKey]; } } return(resp); }
public unsafe static UnsafeUntypedBlobAssetReference CreateUntyped(ActionAssetModel model, ActionSchema actionSchema, FieldOperationSchema operationSchema, ActionDefinitionAsset definitionAsset, Allocator allocator = Allocator.Persistent) { return((UnsafeUntypedBlobAssetReference)typeof(ActionGraphSerializer).GetGenericMethod(nameof(ActionGraphSerializer.CreateUntyped), BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(definitionAsset.delegateType).Invoke(null, new object[] { model, actionSchema, operationSchema, definitionAsset, Allocator.Temp })); }
private WbapResponse __Execute(WbapResponse response) { //CheckPermissionRetrun ret = _ISec.CheckObjectPermission(sessionId, _ActionSchema.Id, 1); //if (ret != CheckPermissionRetrun.Yes) //{ // response.ErrorNo = Convert.ToInt32(ret); // response.Message = "Access denied:" + ret.ToString(); // return response; //} for (int i = request.Step; i < _ActionSchema.Actions.Count; i++) { ActionSchema methodSchema = _ActionSchema.Actions[i]; #region client action if (methodSchema.IsRunAtClient()) { BuildAction(_ActionSchema.Id, i, response.Action); if (response.Action.Request.ActionId != null && response.Action.Request.ActionId != "") { return(response); } else { break; } } #endregion string retVarName = methodSchema.ReturnValue; //#region Menu //if (methodSchema.MethodName.ToUpper() == GetMenu) //{ // if (methodSchema.Parameters[0].Value[0] == '$') // methodSchema.Parameters[0].Value = (string)request.ElementBinds[methodSchema.Parameters[0].Value]; // XMenuObject xMenu = GetMenuBySession(this.sessionId, methodSchema.Parameters[0].Value); // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, xMenu); // else // response.ElementBinds[retVarName] = xMenu; // continue; //} //#endregion #region preocess params Object[] parameters = new Object[methodSchema.Parameters.Count]; for (int j = 0; j < methodSchema.Parameters.Count; j++) { ParameterSchema paramSchema = methodSchema.Parameters[j]; object paramValue = null; if (string.IsNullOrEmpty(paramSchema.Value)) { parameters[j] = null; continue; } if (paramSchema.Value[0] == '#') { paramValue = request.ElementBinds.GetTable(paramSchema.Value.Remove(0, 1), schema); } else if (paramSchema.Value[0] == '$') { paramValue = request.ElementBinds[paramSchema.Value]; } else { paramValue = paramSchema.Value; } //paramValue = GetParamVarValue(paramSchema.Value); if (paramValue == null) { // BuildAction(_ActionSchema.Id, i, response.Action); // return response; } parameters[j] = paramValue; } #endregion #region flow control int idx = DetectFlowCtrlExec(methodSchema.MethodName, parameters); if (idx != -1) { if (idx == BREAK) { return(response); } i = idx - 1; continue; } #endregion #region Invoke Object invokeRet = null; //try //{ invokeRet = Umc.InvokeFunction(sessionId, null, methodSchema.MethodName, parameters); //} //catch (Exception e) //{ // if (e.InnerException != null) // throw e.InnerException; // throw (e); //} #endregion ProcessMethodReturn(invokeRet, response.ElementBinds); if (!string.IsNullOrEmpty(retVarName)) { if (!response.ElementBinds.ContainsKey(retVarName)) { response.ElementBinds.Add(retVarName, invokeRet); } else { response.ElementBinds[retVarName] = invokeRet; } } //临时作废,考虑用GetType()分类型处理的方法 #region process return value //if (retVarName != null && retVarName != "" && retVarName[0] == VAR_TYPES[(int)RealParamFlagType.Element]) //{ // retVarName = retVarName.Remove(0, 1); // if (methodReturnObj is CodeTable) // { // Dictionary<string, string> option = new Dictionary<string, string>(); // foreach (CodeTableData codeTableData in (methodReturnObj as CodeTable).Datas) // { // option.Add(codeTableData.Id, codeTableData.Text); // } // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, option); // else // response.ElementBinds[retVarName] = option; // } // else // { // if (!request.ElementBinds.ContainsKey(retVarName)) // { // request.ElementBinds.Add(retVarName, methodReturnObj); // } // else // { // request.ElementBinds[retVarName] = methodReturnObj; // } // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, methodReturnObj); // else // response.ElementBinds[retVarName] = methodReturnObj; // } //} //else if (retVarName != null && retVarName != "" && retVarName[0] == VAR_TYPES[(int)RealParamFlagType.Table]) //{ // XTable table = (XTable)methodReturnObj; // response.ElementBinds.ImportTable(table, pageController, retVarName.Remove(0, 1)); //} //else if (retVarName != null && retVarName != "") //{ // if (methodReturnObj is MapTable) // { // WebLookupList lookupList = new WebLookupList(); // lookupList.ImportMapTable(methodReturnObj as MapTable, pageController); // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, lookupList); // else // response.ElementBinds[retVarName] = lookupList; // } // else // { // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, methodReturnObj); // else // response.ElementBinds[retVarName] = methodReturnObj; // } //} #endregion } //XData xData = Umc.FindObject<XData>(sessionId, null); //if (xData != null) // xData.Commit(); return(response); }