/// <summary> /// 获取HttpContext中保存的状态 /// </summary> /// <param name="type"></param> /// <returns></returns> public static CommandStateBase GetCommandState(Type type) { Dictionary <Type, CommandStateBase> dict = GetCommandStateDictionary(); CommandStateBase result = null; dict.TryGetValue(type, out result); RegisterHandlerEvents(); return(result); }
protected virtual void OnPrepareCommandState(IWfProcess process) { if (PrepareCommandState != null) { PerformanceMonitorHelper.GetDefaultMonitor().WriteExecutionDuration("PrepareCommandState", () => { CommandStateBase state = PrepareCommandState(process); if (state != null) { CommandStateHelper.RegisterState(state); } }); } }
private void OnProcessReadyHandler(IWfProcess process) { if (process.LoadingType == DataLoadingType.Cloned) { string sourceResourceID = WebUtility.GetRequestQueryString("sourceResourceID", string.Empty); ICommandStatePersist originalState = LoadStateByResourceID(sourceResourceID); ExceptionHelper.FalseThrow(originalState != null, "CopyForm时,必须实现LoadStateByResourceID方法"); ICommandStatePersist persistedState = (ICommandStatePersist)originalState; CommandStateBase newState = (CommandStateBase)persistedState.CloneBusinessObject(); CommandStateHelper.RegisterState(newState); } }
/// <summary> /// 在HttpContext中注册状态 /// </summary> /// <param name="state"></param> public static void RegisterState(CommandStateBase state) { Dictionary <Type, CommandStateBase> dict = GetCommandStateDictionary(); dict[state.GetType()] = state; }