예제 #1
0
 public FrmStartNode(StartTask startTask, string userId, string userName)
 {
     InitializeComponent();
     NowTask       = startTask;
     this.UserId   = userId;
     this.UserName = userName;
 }
예제 #2
0
        private void WorkPlace_MouseDown(object sender, MouseEventArgs e)
        {
            //点击的是右键
            if (MouseButtons == MouseButtons.Right)
            {
                if (SelectedLine.Count != 0 && SelectedItems.Count == 0) //选中直线,没有选中任务节点
                {
                    this.ContextMenu = this.contextMenu;
                }
                else if (SelectedItems.Count > 0) //选中任务节点
                {
                    this.ContextMenu = this.contextMenu;
                }
                else //直线和任务节点都没有选中
                {
                    this.ContextMenu = this.cmPanel;
                }
                return;
            }
            //点击的是左键
            if (ToolModel == true) //工具模式下
            {
                Point p = new Point(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y);

                //操作节点
                switch (this.Module)
                {
                case 1:
                    this._stId++;
                    StartTask st = new StartTask(p, _stId);
                    AddItem(st, 1);
                    break;

                case 2:
                    this._endtId++;
                    EndTask endt = new EndTask(p, _endtId);
                    AddItem(endt, 2);
                    break;

                case 3:
                    this._altId++;
                    AlternateTask at = new AlternateTask(p, _altId);
                    AddItem(at, 3);
                    break;

                case 4:
                    this._jtId++;
                    JudgeTask jt = new JudgeTask(p, _jtId);
                    AddItem(jt, 4);
                    break;

                case 5:
                    this._etId++;
                    ViewTask et = new ViewTask(p, _etId);
                    AddItem(et, 5);
                    break;

                case 6:
                    this._subId++;
                    SubFlowTask sft = new SubFlowTask(p, _subId);
                    AddItem(sft, 6);
                    break;

                case 0:     //连线
                    Point point = new Point(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y);
                    foreach (BaseComponent c in TaskItems)
                    {
                        if (c.Contains(point))
                        {
                            _startTask          = c;
                            this._isDrawingLine = true;
                            _startPoint.X       = e.X;
                            _startPoint.Y       = e.Y;
                            break;
                        }
                        else
                        {
                            _startTask          = null;
                            this._isDrawingLine = false;
                        }
                    }
                    break;

                case -1:     //自连线
                    point = new Point(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y);
                    foreach (BaseComponent c in TaskItems)
                    {
                        if (c.Contains(point))
                        {
                            _startTask = c;
                            _endTask   = c;
                            Link lnk = new Link(_startTask, _endTask);
                            lnk.flowGuid = this.WorkFlowId;
                            this.LineItems.Add(lnk);
                            IsModify = true;
                            this.Invalidate();
                            break;
                        }
                    }
                    break;
                }
                if (NowButton != null && LockModel == false)
                {
                    NowButton.Checked = false;                                          //添加完后修改toolbar按钮为非选中状态
                }
            }
            else //非工具模式下
            {
                Point         p             = new Point(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y);
                BaseComponent baseComponent = IsInAItem(p);
                _link = IsInALine(p);
                if (baseComponent != null) //鼠标点击了某一个任务节点
                {
                    if (IsInASelectedItem(p))
                    {
                        MouseDownInAComponent(p);
                    }
                    else
                    {
                        SelectedItems.Clear();
                        SelectedItems.Add(baseComponent);
                        SelectedLine.Clear();
                        MouseDownInAComponent(p);
                        this.Invalidate();
                    }
                }
                else
                {
                    if (_link != null) //点击了某条连线
                    {
                        SelectedLine.Clear();
                        SelectedLine.Add(_link);
                        SelectedItems.Clear();
                        //点中的是锚点话,拖动锚点或者删除,在这里认为是拖动.利用函数来找出startPoint,endPoint和breakIndex等
                        _isInAnchor = IsInAnchor(p);
                        _breakPoint = p;
                        this.Invalidate();
                    }
                    else
                    {
                        SelectedItems.Clear();
                        SelectedLine.Clear();
                        if (e.Button == MouseButtons.Right)
                        {
                            return;
                        }
                        else
                        {
                            _rubberband = new Rubberband(this, p);
                        }
                    }
                }
                //this.label1.Text=SelectedLine.Count.ToString();
            }
        }
예제 #3
0
        /// <summary>
        /// 读取流程模板
        /// </summary>
        public void ReadWorkFlow( )
        {
            if (WorkFlowId.Trim().Length == 0 || WorkFlowId == null)
            {
                throw new Exception("ReadWorkFlow方法错误,WorkFlowId 不能为空!");
            }

            int   taskType;
            Point p = new Point(0, 0);

            TaskItems.Clear();
            LineItems.Clear();
            BaseComponent startTask = null, endTask = null;

            #region 读取任务节点
            DataTable table = RDIFrameworkService.Instance.WorkFlowTemplateService.GetWorkTasks(SystemInfo.UserInfo, WorkFlowId);
            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow dr in table.Rows)
                {
                    taskType = Convert.ToInt32(dr[WorkTaskTable.FieldTaskTypeId].ToString());
                    p.X      = Convert.ToInt32(dr[WorkTaskTable.FieldIXPosition].ToString());
                    p.Y      = Convert.ToInt32(dr[WorkTaskTable.FieldIYPosition].ToString());

                    switch (taskType)
                    {
                    case 1:                            //启动节点
                        var st = new StartTask(p, 0)
                        {
                            TaskName    = dr[WorkTaskTable.FieldTaskCaption].ToString(),
                            TaskId      = dr[WorkTaskTable.FieldWorkTaskId].ToString(),
                            TaskType    = taskType,
                            OperRule    = dr[WorkTaskTable.FieldOperRule].ToString(),
                            WorkFlowId  = dr[WorkTaskTable.FieldWorkFlowId].ToString(),
                            Description = dr[WorkTaskTable.FieldDescription].ToString()
                        };
                        TaskItems.Add(st);
                        break;

                    case 2:                            //结束节点
                        var edTask = new EndTask(p, 0)
                        {
                            TaskName    = dr[WorkTaskTable.FieldTaskCaption].ToString(),
                            TaskId      = dr[WorkTaskTable.FieldWorkTaskId].ToString(),
                            TaskType    = taskType,
                            WorkFlowId  = dr[WorkTaskTable.FieldWorkFlowId].ToString(),
                            Description = dr[WorkTaskTable.FieldDescription].ToString()
                        };
                        TaskItems.Add(edTask);
                        break;

                    case 3:                            //交互节点
                        var alterTask = new AlternateTask(p, 0)
                        {
                            TaskName    = dr[WorkTaskTable.FieldTaskCaption].ToString(),
                            TaskId      = dr[WorkTaskTable.FieldWorkTaskId].ToString(),
                            TaskType    = taskType,
                            OperRule    = dr[WorkTaskTable.FieldOperRule].ToString(),
                            WorkFlowId  = dr[WorkTaskTable.FieldWorkFlowId].ToString(),
                            IsJumpSelf  = Convert.ToBoolean(dr[WorkTaskTable.FieldIsJumpSelf]),
                            Description = dr[WorkTaskTable.FieldDescription].ToString()
                        };
                        TaskItems.Add(alterTask);
                        break;

                    case 4:                            //判断节点
                        var judgeTask = new JudgeTask(p, 0)
                        {
                            TaskName      = dr[WorkTaskTable.FieldTaskCaption].ToString(),
                            TaskId        = dr[WorkTaskTable.FieldWorkTaskId].ToString(),
                            TaskType      = taskType,
                            WorkFlowId    = dr[WorkTaskTable.FieldWorkFlowId].ToString(),
                            TaskTypeAndOr = dr[WorkTaskTable.FieldTaskTypeAndOr].ToString(),
                            Description   = dr[WorkTaskTable.FieldDescription].ToString()
                        };
                        TaskItems.Add(judgeTask);
                        break;

                    case 5:                            //查看节点
                        var viewTask = new ViewTask(p, 0)
                        {
                            TaskName    = dr[WorkTaskTable.FieldTaskCaption].ToString(),
                            TaskId      = dr[WorkTaskTable.FieldWorkTaskId].ToString(),
                            TaskType    = taskType,
                            WorkFlowId  = dr[WorkTaskTable.FieldWorkFlowId].ToString(),
                            IsJumpSelf  = Convert.ToBoolean(dr[WorkTaskTable.FieldIsJumpSelf]),
                            OperRule    = dr[WorkTaskTable.FieldOperRule].ToString(),
                            Description = dr[WorkTaskTable.FieldDescription].ToString()
                        };
                        TaskItems.Add(viewTask);
                        break;

                    case 6:                            //子流程节点
                        var subFlowTask = new SubFlowTask(p, 0)
                        {
                            TaskName    = dr[WorkTaskTable.FieldTaskCaption].ToString(),
                            TaskId      = dr[WorkTaskTable.FieldWorkTaskId].ToString(),
                            TaskType    = taskType,
                            WorkFlowId  = dr[WorkTaskTable.FieldWorkFlowId].ToString(),
                            Description = dr[WorkTaskTable.FieldDescription].ToString()
                        };
                        TaskItems.Add(subFlowTask);
                        break;
                    }
                }
            }
            #endregion **********读取任务节点end

            #region 读取连线

            table = RDIFrameworkService.Instance.WorkFlowTemplateService.GetWorkLinks(SystemInfo.UserInfo, WorkFlowId);
            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow dr in table.Rows)
                {
                    for (int j = 0; j < TaskItems.Count; j++)                           //查找起止点
                    {
                        if (startTask == null || endTask == null)
                        {
                            if (startTask == null && ((BaseComponent)TaskItems[j]).TaskId.Equals(dr[WorkLinkTable.FieldStartTaskId].ToString()) == true)
                            {
                                startTask = (BaseComponent)TaskItems[j];
                            }
                            if (endTask == null && ((BaseComponent)TaskItems[j]).TaskId.Equals(dr[WorkLinkTable.FieldEndTaskId].ToString()) == true)
                            {
                                endTask = (BaseComponent)TaskItems[j];
                            }
                        }
                    }

                    var lnk = new Link(startTask, endTask)
                    {
                        linkGuid    = dr[WorkLinkTable.FieldWorkLinkId].ToString(),
                        flowGuid    = dr[WorkLinkTable.FieldWorkFlowId].ToString(),
                        CommandName = dr[WorkLinkTable.FieldCommandName].ToString(),
                        Condition   = dr[WorkLinkTable.FieldCondition].ToString(),
                        Des         = dr[WorkLinkTable.FieldDescription].ToString()
                    };
                    if (startTask != endTask)
                    {
                        if (dr[WorkLinkTable.FieldBreakX].ToString() != "")
                        {
                            string[] xx = dr[WorkLinkTable.FieldBreakX].ToString().Split(',');
                            string[] yy = dr[WorkLinkTable.FieldBreakY].ToString().Split(',');
                            for (int mm = 0; mm < xx.Length; mm++)
                            {
                                lnk.breakPointX.Insert(lnk.breakPointX.Count - 1, xx[mm]);
                                lnk.breakPointY.Insert(lnk.breakPointY.Count - 1, yy[mm]);
                            }
                        }
                    }
                    LineItems.Add(lnk);
                    startTask = null;
                    endTask   = null;
                }
            }
            #endregion
        }