/// <summary> /// 根据Action执行的类型去判断,最终只执行哪个请求 /// </summary> /// <param name="actionType">执行操作的类型</param> public ActionExecute(ActionExecuteType actionType) { type = actionType; thread = new System.Threading.Thread(obj => { while (isRun) { ExecutingAction(); System.Threading.Thread.Sleep(1); } }); thread.IsBackground = true; thread.Start(); }
public GMAction(ProjectReader reader) { Version = reader.ReadInt32(); // what? if (Version != 440) { throw new Exception("Invalid Action version, got " + Version); } LibID = reader.ReadInt32(); ID = reader.ReadInt32(); Kind = (ActionType)reader.ReadInt32(); UseRelative = reader.ReadBoolean(); IsQuestion = reader.ReadBoolean(); UseApplyTo = reader.ReadBoolean(); ExeType = (ActionExecuteType)reader.ReadInt32(); Name = reader.ReadString(); Code = reader.ReadString(); ArgumentCount = reader.ReadInt32(); int argc = reader.ReadInt32(); ArgumentTypes = new List <ActionArgType>(argc); for (int i = 0; i < argc; i++) { ArgumentTypes.Add((ActionArgType)reader.ReadInt32()); } Who = reader.ReadInt32(); WhoObj = null; Relative = reader.ReadBoolean(); int argc2 = reader.ReadInt32(); Arguments = new List <string>(argc2); for (int i = 0; i < argc2; i++) { Arguments.Add(reader.ReadString()); } IsNot = reader.ReadBoolean(); }
/// <summary> /// Execute the phases of the action. /// </summary> /// <param name="type"> /// A <see cref="ActionExecuteType"/> /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> internal bool Execute(ActionExecuteType type) { if(this.Context != null && this.Context.Request != null) { this.Writer = new StreamWriter(this.Context.Request.ResponseBody); } bool result = false; if(this.NextPhase == ActionPhase.Filters) { try { this.executeFilters(); result = true; }finally { this.NextPhase = ActionPhase.Execute; } if (!result) return result; } /* if(this.NextPhase == ActionPhase.Authenticate) { try { result = this.OnAuthenticate(); }finally { this.NextPhase = ActionPhase.Lookup; } } if(!result)return result; if(this.NextPhase == ActionPhase.Lookup) { try { var lresult =this.OnLookup(); result = lresult == ActionLookupResult.Found || lresult == ActionLookupResult.Skipped; }finally { this.NextPhase = ActionPhase.Authorize; } } if(!result)return result; if(this.NextPhase == ActionPhase.Authorize) { try { result =this.OnAuthorize(); }finally { this.NextPhase = ActionPhase.Execute; } } if(!result)return result; */ if(!this.Lookup) { this.OnLookup(); } if(type == ActionExecuteType.Complete && this.NextPhase == ActionPhase.Execute) { try { this.OnExecute(); result = true; }finally { this.NextPhase = ActionPhase.Finish; } } return result; }
/// <summary> /// Execute the phases of the action. /// </summary> /// <param name="type"> /// A <see cref="ActionExecuteType"/> /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> internal bool Execute(ActionExecuteType type) { if (this.Context != null && this.Context.Request != null) { this.Writer = new StreamWriter(this.Context.Request.ResponseBody); } bool result = false; if (this.NextPhase == ActionPhase.Filters) { try { this.executeFilters(); result = true; }finally { this.NextPhase = ActionPhase.Execute; } if (!result) { return(result); } } /* * if(this.NextPhase == ActionPhase.Authenticate) * { * try * { * result = this.OnAuthenticate(); * }finally * { * this.NextPhase = ActionPhase.Lookup; * } * } * if(!result)return result; * if(this.NextPhase == ActionPhase.Lookup) * { * try * { * var lresult =this.OnLookup(); * result = lresult == ActionLookupResult.Found || lresult == ActionLookupResult.Skipped; * }finally * { * this.NextPhase = ActionPhase.Authorize; * } * } * if(!result)return result; * if(this.NextPhase == ActionPhase.Authorize) * { * try * { * result =this.OnAuthorize(); * }finally * { * this.NextPhase = ActionPhase.Execute; * } * } * if(!result)return result; */ if (!this.Lookup) { this.OnLookup(); } if (type == ActionExecuteType.Complete && this.NextPhase == ActionPhase.Execute) { try { this.OnExecute(); result = true; }finally { this.NextPhase = ActionPhase.Finish; } } return(result); }