Пример #1
0
        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);
        }
Пример #2
0
 /// <summary>
 /// 单例模式
 /// </summary>
 /// <returns>FlowManager</returns>
 public static FlowManager Instance()
 {
     if (flowManager == null)
     {
         flowManager = new FlowManager();
     }
     return(flowManager);
 }
Пример #3
0
 /// <summary>
 /// 单例模式
 /// </summary>
 /// <returns>FlowManager</returns>
 public static FlowManager Instance()
 {
     if (flowManager == null)
     {
         flowManager = new FlowManager();
     }
     return flowManager;
 }
Пример #4
0
        /// <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);
        }