private void Save(FlowEngine flowEngine) { if (flowEngine.Attachment.Owner == -1) { throw new ArgumentException("Owner is null"); } if (flowEngine.FlowState != FlowState.Finished) { FlowKey flowKey = new FlowKey() { Owner = flowEngine.Attachment.Owner }; if (!this.dicFlow.ContainsKey(flowKey)) { this.dicFlow.Add(flowKey, flowEngine); } else if (flowEngine.GetCurrent() == null) { this.dicFlow.Remove(flowKey); } else if (this.dicFlow.ContainsKey(flowKey)) { this.dicFlow[flowKey] = flowEngine; } } string fileName = FlowManager.GetFlowFile(flowEngine.Attachment.Owner); FlowEngine.Save(fileName, flowEngine); }
public void Remove(int owner) { FlowKey flowKey = new FlowKey() { Owner = owner }; if (this.dicFlow.ContainsKey(flowKey)) { this.dicFlow.Remove(flowKey); } }
/// <summary> /// 加载流程文件 /// </summary> /// <param name="category">分类</param> /// <param name="owner">属主</param> /// <returns></returns> public FlowEngine Load(int owner) { FlowKey flowKey = new FlowKey() { Owner = owner }; if (this.dicFlow.ContainsKey(flowKey)) { return(this.dicFlow[flowKey]); } string fileName = FlowManager.GetFlowFile(owner); FlowEngine flowEngine = FlowEngine.Load(fileName); flowEngine.FinishedHandler -= new FlowEngine.FinishedEventHandler(FlowManager.FlowFinished); flowEngine.FinishedHandler += new FlowEngine.FinishedEventHandler(FlowManager.FlowFinished); if (flowEngine.FlowState != FlowState.Finished && !this.dicFlow.ContainsKey(flowKey)) { this.dicFlow.Add(flowKey, flowEngine); } return(flowEngine); }
public override bool Equals(object obj) { FlowKey other = (FlowKey)obj; return(this.Owner == other.Owner); }
/// <summary> /// 加载流程文件 /// </summary> /// <param name="category">分类</param> /// <param name="owner">属主</param> /// <returns></returns> public FlowEngine Load(int owner) { FlowKey flowKey = new FlowKey() { Owner = owner }; if (this.dicFlow.ContainsKey(flowKey)) { return this.dicFlow[flowKey]; } string fileName = FlowManager.GetFlowFile(owner); FlowEngine flowEngine = FlowEngine.Load(fileName); flowEngine.FinishedHandler -= new FlowEngine.FinishedEventHandler(FlowManager.FlowFinished); flowEngine.FinishedHandler += new FlowEngine.FinishedEventHandler(FlowManager.FlowFinished); if (flowEngine.FlowState != FlowState.Finished && !this.dicFlow.ContainsKey(flowKey)) { this.dicFlow.Add(flowKey, flowEngine); } return flowEngine; }