Пример #1
0
        /// <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));
                }
            }
        }
Пример #2
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            if (this.dgFlow.SelectedItem != null)
            {
                WFInstance wfInstance = this.dgFlow.SelectedItem as WFInstance;
                DateTime   T1         = EAS.Application.Instance.Time;

                //回调函数。
                WfAddInHelper.WorkflowInstanceCallBack callback = () =>
                {
                    IList <WFInstance> xList = this.dgFlow.ItemsSource as IList <WFInstance>;

                    if (xList.Contains(wfInstance))
                    {
                        DataPortal <WFInstance> dataPortal = new DataPortal <WFInstance>();
                        dataPortal.BeginRead(wfInstance).Completed += (s1, e1) =>
                        {
                            QueryTask <WFInstance> task = s1 as QueryTask <WFInstance>;
                            string[] sv = task.DataEntity.Handlers.Split(',');
                            if (sv.Where(p => p == ContextHelper.Account.LoginID).Count() > 0)
                            {
                                xList.Remove(wfInstance);
                                this.dgFlow.ItemsSource = null;
                                this.dgFlow.ItemsSource = xList;
                            }
                        };
                    }
                };

                //处理流程
                WfAddInHelper.LoadWorkflowInstance(wfInstance, true, callback);
            }
        }
Пример #3
0
 private void btnStart_Click(object sender, RoutedEventArgs e)
 {
     if (this.dgFlow.SelectedItem != null)
     {
         WFDefine wfDefine = this.dgFlow.SelectedItem as WFDefine;
         WfAddInHelper.StartWorkflowInstance(wfDefine, () => {});
     }
 }
Пример #4
0
        /// <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));
                        }
                    }
                }
            };
        }
Пример #5
0
        protected override void OnOpened()
        {
            if (this.m_InstanceID == Guid.Empty)
            {
                WfAddInHelper.Start(this.WfAddIn);
            }
            else
            {
                WfAddInHelper.LoadWorkflowInstance(this.WfAddIn, true, this.m_InstanceID);
            }

            if (EAS.Application.Instance != null)
            {
                EAS.Application.Instance.AddInClosing += new AddInEventHandler(OnAddInClosing);
            }
        }