/// <summary> /// 发起流程。 /// </summary> /// <param name="wfDefine"></param> public static void StartWorkflowInstance(WFDefine wfDefine, WorkflowInstanceCallBack callBack) { System.Type T = EAS.Objects.ClassProvider.GetType(wfDefine.SilverMType); if (T == null) { MessageBox.Show(string.Format("没有找到名称为\"{0}\"的功能模块", wfDefine.Module), "提示", MessageBoxButton.OK); return; } if (EAS.Application.Instance != null) { if (typeof(Control).IsAssignableFrom(T)) { object wfAddIn = System.Activator.CreateInstance(T); WfInstanceWindow wfInstanceForm = new WfInstanceWindow(wfAddIn, true, Guid.Empty); wfInstanceForm.Closed += (s, e) => { callBack(); }; wfInstanceForm.Show(); } else if (typeof(ChildWindow).IsAssignableFrom(T)) { ChildWindow wfAddIn = System.Activator.CreateInstance(T) as ChildWindow; wfAddIn.Closed += (s, e) => { callBack(); }; WfAddInHelper.Start(wfAddIn); } else { WfAddInHelper.Start(System.Activator.CreateInstance(T)); } } }
/// <summary> /// 加载流程。 /// </summary> /// <param name="wfDefine"></param> public static void LoadWorkflowInstance(WFInstance wfInstance, bool isEnabled, WorkflowInstanceCallBack callBack) { DataPortal <WFDefine> dataPortal = new DataPortal <WFDefine>(); WFDefine wfDefine = new WFDefine(); wfDefine.FlowID = wfInstance.FlowID; dataPortal.BeginRead(wfDefine).Completed += (s, e) => { QueryTask <WFDefine> task = s as QueryTask <WFDefine>; if (task.Error != null) { MessageBox.Show(string.Format("读取流程定义错误:" + task.Error.Message, wfDefine.Module), "提示", MessageBoxButton.OK); } else // { wfDefine = task.DataEntity; System.Type T = EAS.Objects.ClassProvider.GetType(wfDefine.SilverMType); if (T == null) { MessageBox.Show(string.Format("没有找到名称为\"{0}\"的功能模块", wfDefine.Module), "提示", MessageBoxButton.OK); return; } if (EAS.Application.Instance != null) { if (typeof(Control).IsAssignableFrom(T)) { object wfAddIn = System.Activator.CreateInstance(T); WfInstanceWindow wfInstanceForm = new WfInstanceWindow(wfAddIn, isEnabled, new Guid(wfInstance.ID)); wfInstanceForm.Closed += (s2, e2) => { callBack(); }; wfInstanceForm.Show(); } else if (typeof(ChildWindow).IsAssignableFrom(T)) { ChildWindow wfAddIn = System.Activator.CreateInstance(T) as ChildWindow; wfAddIn.Closed += (s2, e2) => { callBack(); }; WfAddInHelper.LoadWorkflowInstance(wfAddIn, isEnabled, new Guid(wfInstance.ID)); } else { WfAddInHelper.LoadWorkflowInstance(System.Activator.CreateInstance(T), isEnabled, new Guid(wfInstance.ID)); } } } }; }