Example #1
0
        void LoadActives(CWorkflow wf)
        {
            dataGridView2.Rows.Clear();
            CWorkflowDef       WorkflowDef = wf.GetWorkflowDef();
            List <CBaseObject> lstObj      = wf.ActivesMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CActives Actives = (CActives)obj;

                dataGridView2.Rows.Add(1);
                DataGridViewRow row = dataGridView2.Rows[dataGridView2.Rows.Count - 1];

                CActivesDef ActivesDef = (CActivesDef)WorkflowDef.ActivesDefMgr.Find(Actives.WF_ActivesDef_id);
                row.Cells[0].Value = ActivesDef.Name;
                row.Cells[1].Value = Actives.GetResultString();
                row.Cells[2].Value = Actives.Comment;
                CUser user = (CUser)Program.Ctx.UserMgr.Find(Actives.B_User_id);
                if (user != null)
                {
                    row.Cells[3].Value = user.Name;
                }
                row.Tag = Actives;
            }
        }
    void GetActivesData()
    {
        string    WF_Workflow_id = Request["WF_Workflow_id"];
        CWorkflow wf             = (CWorkflow)m_BaseObjectMgr.WorkflowMgr.Find(new Guid(WF_Workflow_id));

        string             sData       = "";
        CWorkflowDef       WorkflowDef = wf.GetWorkflowDef();
        List <CBaseObject> lstObj      = wf.ActivesMgr.GetList();

        foreach (CBaseObject obj in lstObj)
        {
            CActives Actives = (CActives)obj;

            CActivesDef ActivesDef = (CActivesDef)WorkflowDef.ActivesDefMgr.Find(Actives.WF_ActivesDef_id);
            CUser       User = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(Actives.B_User_id);
            CRole       Role = (CRole)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.FindTopCompany().RoleMgr.Find(Actives.B_Role_id);
            string      UserName = "", RoleName = "";
            UserName = (User != null) ? User.Name : "";
            RoleName = (Role != null) ? Role.Name : "";

            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Result\":\"{2}\", \"Comment\":\"{3}\", \"UserName\":\"{4}\", \"RoleName\":\"{5}\" }},"
                                   , Actives.Id
                                   , ActivesDef.Name
                                   , Actives.GetResultString()
                                   , Actives.Comment
                                   , UserName
                                   , RoleName);
        }

        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, lstObj.Count);

        Response.Write(sJson);
    }
Example #3
0
        private void tbtEdit2_Click(object sender, EventArgs e)
        {
            if (m_WorkflowDef.FW_Table_id == Guid.Empty)
            {
                MessageBox.Show("请先选择表对象!");
                return;
            }
            if (dataGridView.CurrentRow == null)
            {
                MessageBox.Show("请先选择活动!");
                return;
            }
            CActivesDef ActivesDef = (CActivesDef)dataGridView.CurrentRow.Tag;

            if (dataGridView2.CurrentRow == null)
            {
                MessageBox.Show("请先选择连接!");
                return;
            }
            CLink Link = (CLink)dataGridView2.CurrentRow.Tag;

            LinkInfo frm = new LinkInfo();

            frm.m_WorkflowDef = m_WorkflowDef;
            frm.m_PreActives  = ActivesDef;
            frm.m_Link        = Link;
            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            LoadLink(ActivesDef);
        }
Example #4
0
 void LoadData()
 {
     txtPreActives.Text = m_PreActives.Name;
     if (m_bIsNew)
     {
         return;
     }
     if (m_Link.Result == enumApprovalResult.Accept)
     {
         cbResult.SelectedIndex = 0;
     }
     else
     {
         cbResult.SelectedIndex = 1;
     }
     txtCondiction.Text = m_Link.Condiction;
     for (int i = 0; i < cbNextActives.Items.Count; i++)
     {
         DataItem    item       = (DataItem)cbNextActives.Items[i];
         CActivesDef ActivesDef = (CActivesDef)item.Data;
         if (ActivesDef.Id == m_Link.NextActives)
         {
             cbNextActives.SelectedIndex = i;
             break;
         }
     }
     //启动活动
     if (m_PreActives.WType == ActivesType.Start)
     {
         cbResult.Enabled = false;
         btAdd.Enabled    = false;
     }
 }
Example #5
0
        private void btOk_Click(object sender, EventArgs e)
        {
            if (cbNextActives.SelectedIndex == -1)
            {
                MessageBox.Show("请选择后置活动!");
                return;
            }
            DataItem    item           = (DataItem)cbNextActives.SelectedItem;
            CActivesDef NextActivesDef = (CActivesDef)item.Data;

            m_Link.Result      = (cbResult.SelectedIndex == 0) ? enumApprovalResult.Accept : enumApprovalResult.Reject;
            m_Link.Condiction  = txtCondiction.Text.Trim();
            m_Link.NextActives = NextActivesDef.Id;


            if (m_bIsNew)
            {
                m_WorkflowDef.LinkMgr.AddNew(m_Link);
            }
            else
            {
                m_WorkflowDef.LinkMgr.Update(m_Link);
            }


            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #6
0
        private void tbtEdit_Click(object sender, EventArgs e)
        {
            if (dataGridView.CurrentRow == null)
            {
                MessageBox.Show("请先选择活动!");
                return;
            }
            CActivesDef ActivesDef = (CActivesDef)dataGridView.CurrentRow.Tag;

            if (ActivesDef.WType == ActivesType.Start)
            {
                MessageBox.Show("启动活动不能修改!");
                return;
            }
            if (ActivesDef.WType == ActivesType.Success)
            {
                MessageBox.Show("成功结束活动不能修改!");
                return;
            }
            if (ActivesDef.WType == ActivesType.Failure)
            {
                MessageBox.Show("失败结束活动不能修改!");
                return;
            }

            ActivesDefInfo frm = new ActivesDefInfo();

            frm.m_WorkflowDef = m_WorkflowDef;
            frm.m_ActivesDef  = ActivesDef;
            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            LoadActives();
        }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.Redirect("../Login.aspx");
            Response.End();
        }

        string B_Company_id = Request["B_Company_id"];

        if (string.IsNullOrEmpty(B_Company_id))
        {
            m_Company = Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.FindTopCompany();
        }
        else
        {
            m_Company = (CCompany)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.Find(new Guid(B_Company_id));
        }

        string wfid = Request["wfid"];

        if (string.IsNullOrEmpty(wfid))
        {
            Response.End();
            return;
        }
        m_WorkflowDef = (CWorkflowDef)m_Company.WorkflowDefMgr.Find(new Guid(wfid));
        if (m_WorkflowDef == null) //可能是新建的
        {
            if (Session["AddWorkflowDef"] == null)
            {
                Response.End();
                return;
            }
            m_WorkflowDef = (CWorkflowDef)Session["AddWorkflowDef"];
        }
        string PreActives = Request["PreActives"];

        m_PreActives = (CActivesDef)m_WorkflowDef.ActivesDefMgr.Find(new Guid(PreActives));

        m_LinkMgr = m_WorkflowDef.LinkMgr;

        m_Table = m_LinkMgr.Table;

        if (Request.Params["Action"] == "Cancel")
        {
            m_LinkMgr.Cancel();
            Response.End();
        }
        else if (Request.Params["Action"] == "PostData")
        {
            PostData();
            Response.End();
        }
        else if (Request.Params["Action"] == "GetCondiction")
        {
            GetCondiction();
            Response.End();
        }
    }
Example #8
0
        void LoadData()
        {
            if (m_WorkflowDef == null)
            {
                m_bIsNew          = true;
                m_WorkflowDef     = new CWorkflowDef();
                m_WorkflowDef.Ctx = Program.Ctx;
                m_WorkflowDef.WF_WorkflowCatalog_id = m_Catalog_id;
                CActivesDef startActivesDef = new CActivesDef();
                startActivesDef.Ctx = Program.Ctx;
                startActivesDef.WF_WorkflowDef_id = m_WorkflowDef.Id;
                startActivesDef.WType             = ActivesType.Start;
                startActivesDef.Name = "启动";
                startActivesDef.Idx  = 0;
                m_WorkflowDef.ActivesDefMgr.AddNew(startActivesDef);

                CActivesDef SuccessActivesDef = new CActivesDef();
                SuccessActivesDef.Ctx = Program.Ctx;
                SuccessActivesDef.WF_WorkflowDef_id = m_WorkflowDef.Id;
                SuccessActivesDef.WType             = ActivesType.Success;
                SuccessActivesDef.Name = "成功结束";
                SuccessActivesDef.Idx  = -1;
                m_WorkflowDef.ActivesDefMgr.AddNew(SuccessActivesDef);

                CActivesDef FailureActivesDef = new CActivesDef();
                FailureActivesDef.Ctx = Program.Ctx;
                FailureActivesDef.WF_WorkflowDef_id = m_WorkflowDef.Id;
                FailureActivesDef.WType             = ActivesType.Failure;
                FailureActivesDef.Name = "失败结束";
                FailureActivesDef.Idx  = -2;
                m_WorkflowDef.ActivesDefMgr.AddNew(FailureActivesDef);

                CLink Link = new CLink();
                Link.Ctx = Program.Ctx;
                Link.WF_WorkflowDef_id = m_WorkflowDef.Id;
                Link.Result            = enumApprovalResult.Accept;
                Link.PreActives        = startActivesDef.Id;
                Link.NextActives       = SuccessActivesDef.Id;
                m_WorkflowDef.LinkMgr.AddNew(Link);
            }

            txtName.Text = m_WorkflowDef.Name;


            CTable Table = (CTable)Program.Ctx.TableMgr.Find(m_WorkflowDef.FW_Table_id);

            if (Table != null)
            {
                txtTable.Text = Table.Name;
            }
            LoadActives();
            if (dataGridView.Rows.Count > 0)
            {
                CActivesDef ActivesDef = (CActivesDef)dataGridView.Rows[0].Tag;
                LoadLink(ActivesDef);
            }
        }
Example #9
0
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= dataGridView.Rows.Count)
            {
                return;
            }
            CActivesDef ActivesDef = (CActivesDef)dataGridView.Rows[e.RowIndex].Tag;

            LoadLink(ActivesDef);
        }
    public CWorkflowDef GetWorkflowDef()
    {
        if (Session["AddWorkflowDef"] == null)
        {
            CUser        user        = (CUser)Session["User"];
            CWorkflowDef WorkflowDef = new CWorkflowDef();
            WorkflowDef.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
            Guid Catalog_id = Guid.Empty;
            if (!string.IsNullOrEmpty(Request["catalog_id"]))
            {
                Catalog_id = new Guid(Request["catalog_id"]);
            }
            WorkflowDef.WF_WorkflowCatalog_id = Catalog_id;
            WorkflowDef.B_Company_id          = m_Company.Id;
            WorkflowDef.Creator = user.Id;
            CActivesDef startActivesDef = new CActivesDef();
            startActivesDef.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
            startActivesDef.WF_WorkflowDef_id = WorkflowDef.Id;
            startActivesDef.WType             = ActivesType.Start;
            startActivesDef.Name    = "启动";
            startActivesDef.Idx     = 0;
            startActivesDef.Creator = user.Id;
            WorkflowDef.ActivesDefMgr.AddNew(startActivesDef);

            CActivesDef SuccessActivesDef = new CActivesDef();
            SuccessActivesDef.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
            SuccessActivesDef.WF_WorkflowDef_id = WorkflowDef.Id;
            SuccessActivesDef.WType             = ActivesType.Success;
            SuccessActivesDef.Name    = "成功结束";
            SuccessActivesDef.Idx     = -1;
            SuccessActivesDef.Creator = user.Id;
            WorkflowDef.ActivesDefMgr.AddNew(SuccessActivesDef);

            CActivesDef FailureActivesDef = new CActivesDef();
            FailureActivesDef.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
            FailureActivesDef.WF_WorkflowDef_id = WorkflowDef.Id;
            FailureActivesDef.WType             = ActivesType.Failure;
            FailureActivesDef.Name    = "失败结束";
            FailureActivesDef.Idx     = -2;
            FailureActivesDef.Creator = user.Id;
            WorkflowDef.ActivesDefMgr.AddNew(FailureActivesDef);

            CLink Link = new CLink();
            Link.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
            Link.WF_WorkflowDef_id = WorkflowDef.Id;
            Link.Result            = enumApprovalResult.Accept;
            Link.PreActives        = startActivesDef.Id;
            Link.NextActives       = SuccessActivesDef.Id;
            Link.Creator           = user.Id;
            WorkflowDef.LinkMgr.AddNew(Link);

            Session["AddWorkflowDef"] = WorkflowDef;
        }
        return((CWorkflowDef)Session["AddWorkflowDef"]);
    }
Example #11
0
        void LoadData()
        {
            CActivesDefMgr ActivesDefMgr = new CActivesDefMgr();

            ActivesDefMgr.Ctx = Program.Ctx;
            string sWhere = string.Format("id='{0}'", m_Actives.WF_ActivesDef_id);

            ActivesDefMgr.GetList(sWhere);
            CActivesDef ActivesDef = (CActivesDef)ActivesDefMgr.GetFirstObj();

            if (ActivesDef != null)
            {
                txtName.Text = ActivesDef.Name;
            }
        }
Example #12
0
 private void ActivesDefInfo_Load(object sender, EventArgs e)
 {
     if (m_ActivesDef == null)
     {
         m_bIsNew         = true;
         m_ActivesDef     = new CActivesDef();
         m_ActivesDef.Ctx = Program.Ctx;
         m_ActivesDef.WF_WorkflowDef_id = m_WorkflowDef.Id;
         m_ActivesDef.Idx   = m_WorkflowDef.ActivesDefMgr.NewIdx();
         m_ActivesDef.WType = ActivesType.Middle;
         CLink link1 = new CLink();
         link1.Ctx = Program.Ctx;
         link1.WF_WorkflowDef_id = m_WorkflowDef.Id;
         link1.PreActives        = m_ActivesDef.Id;
         link1.Result            = enumApprovalResult.Accept;
         CActivesDef adSuccess = m_WorkflowDef.ActivesDefMgr.FindSuccess();
         if (adSuccess != null)
         {
             link1.NextActives = adSuccess.Id;
         }
         else
         {
             link1.NextActives = Guid.Empty;
         }
         m_WorkflowDef.LinkMgr.AddNew(link1);
         CLink link2 = new CLink();
         link2.Ctx = Program.Ctx;
         link2.WF_WorkflowDef_id = m_WorkflowDef.Id;
         link2.PreActives        = m_ActivesDef.Id;
         link2.Result            = enumApprovalResult.Reject;
         CActivesDef adFailure = m_WorkflowDef.ActivesDefMgr.FindFailure();
         if (adFailure != null)
         {
             link2.NextActives = adFailure.Id;
         }
         else
         {
             link2.NextActives = Guid.Empty;
         }
         m_WorkflowDef.LinkMgr.AddNew(link2);
     }
     LoadUser();
     LoadData();
 }
    void GetLinkData()
    {
        string ActivesId = Request["ActivesId"];

        if (string.IsNullOrEmpty(ActivesId))
        {
            return;
        }
        Guid guidActivesId = new Guid(ActivesId);

        CWorkflowDef       WorkflowDef = GetWorkflowDef();
        List <CBaseObject> lstObj      = WorkflowDef.LinkMgr.GetList();

        string sData  = "";
        int    iCount = 0;

        foreach (CBaseObject obj in lstObj)
        {
            CLink Link = (CLink)obj;
            if (Link.PreActives != guidActivesId)
            {
                continue;
            }
            CActivesDef next = (CActivesDef)WorkflowDef.ActivesDefMgr.Find(Link.NextActives);

            sData += string.Format("{{ \"id\": \"{0}\",\"Result\":\"{1}\",\"ResultName\":\"{2}\", \"Condiction\":\"{3}\", \"NextActives\":\"{4}\", \"NextActivesName\":\"{5}\"}},"
                                   , Link.Id
                                   , Link.Result
                                   , (Link.Result == enumApprovalResult.Accept)?"接受":"拒绝"
                                   , Link.Condiction
                                   , Link.NextActives
                                   , (next != null)?next.Name:"");
            iCount++;
        }
        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, iCount);

        Response.Write(sJson);
    }
Example #14
0
        private void tbtDel2_Click(object sender, EventArgs e)
        {
            if (dataGridView2.CurrentRow == null)
            {
                MessageBox.Show("请先选择连接!");
                return;
            }

            CActivesDef ActivesDef = (CActivesDef)dataGridView.CurrentRow.Tag;

            if (ActivesDef.WType == ActivesType.Start)
            {
                MessageBox.Show("启动活动有且仅有一个连接!");
                return;
            }

            CLink Link = (CLink)dataGridView2.CurrentRow.Tag;

            m_WorkflowDef.LinkMgr.Delete(Link);

            dataGridView2.Rows.Remove(dataGridView2.CurrentRow);
        }
Example #15
0
        void LoadNextActives()
        {
            cbNextActives.Items.Clear();
            List <CBaseObject> lstObj = m_WorkflowDef.ActivesDefMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CActivesDef ActivesDef = (CActivesDef)obj;
                if (ActivesDef == m_PreActives)
                {
                    continue;
                }
                if (ActivesDef.WType == ActivesType.Start)
                {
                    continue;
                }
                DataItem item = new DataItem();
                item.name = ActivesDef.Name;
                item.Data = ActivesDef;
                cbNextActives.Items.Add(item);
            }
        }
Example #16
0
        void LoadLink(CActivesDef ActivesDef)
        {
            dataGridView2.Rows.Clear();
            List <CBaseObject> lstObj = m_WorkflowDef.LinkMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CLink link = (CLink)obj;
                if (link.PreActives == ActivesDef.Id)
                {
                    dataGridView2.Rows.Add(1);
                    DataGridViewRow item = dataGridView2.Rows[dataGridView2.Rows.Count - 1];
                    item.Cells[0].Value = link.Result;
                    item.Cells[1].Value = link.Condiction;
                    CActivesDef NextActivesDef = (CActivesDef)m_WorkflowDef.ActivesDefMgr.Find(link.NextActives);
                    if (NextActivesDef != null)
                    {
                        item.Cells[2].Value = NextActivesDef.Name;
                    }
                    item.Tag = link;
                }
            }
        }
Example #17
0
        private void tbtDel_Click(object sender, EventArgs e)
        {
            if (dataGridView.CurrentRow == null)
            {
                MessageBox.Show("请先选择活动!");
                return;
            }
            CActivesDef ActivesDef = (CActivesDef)dataGridView.CurrentRow.Tag;

            if (ActivesDef.WType == ActivesType.Start)
            {
                MessageBox.Show("启动活动不能删除!");
                return;
            }
            if (ActivesDef.WType == ActivesType.Success)
            {
                MessageBox.Show("成功结束活动不能删除!");
                return;
            }
            if (ActivesDef.WType == ActivesType.Failure)
            {
                MessageBox.Show("失败结束活动不能删除!");
                return;
            }

            m_WorkflowDef.ActivesDefMgr.Delete(ActivesDef);
            //删除相关的连接
            List <CLink> lstLink = m_WorkflowDef.LinkMgr.FindByPreActives(ActivesDef.Id);

            foreach (CLink Link in lstLink)
            {
                m_WorkflowDef.LinkMgr.Delete(Link);
            }

            dataGridView.Rows.Remove(dataGridView.CurrentRow);
            dataGridView2.Rows.Clear();
        }
Example #18
0
        private void tbtNew2_Click(object sender, EventArgs e)
        {
            if (m_WorkflowDef.FW_Table_id == Guid.Empty)
            {
                MessageBox.Show("请先选择表对象!");
                return;
            }
            if (dataGridView.CurrentRow == null)
            {
                MessageBox.Show("请先选择活动!");
                return;
            }
            CActivesDef ActivesDef = (CActivesDef)dataGridView.CurrentRow.Tag;

            if (ActivesDef.WType == ActivesType.Start)
            {
                MessageBox.Show("启动活动有且仅有一个连接!");
                return;
            }
            else if (ActivesDef.WType == ActivesType.Success ||
                     ActivesDef.WType == ActivesType.Failure)
            {
                MessageBox.Show("结束活动不能有连接!");
                return;
            }

            LinkInfo frm = new LinkInfo();

            frm.m_WorkflowDef = m_WorkflowDef;
            frm.m_PreActives  = ActivesDef;
            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            LoadLink(ActivesDef);
        }
    void GetActivesData()
    {
        CWorkflowDef       WorkflowDef = GetWorkflowDef();
        List <CBaseObject> lstObj      = WorkflowDef.ActivesDefMgr.GetList();
        //按序号排序
        SortedList <int, CActivesDef> sortObj = new SortedList <int, CActivesDef>();

        foreach (CBaseObject obj in lstObj)
        {
            CActivesDef ActivesDef = (CActivesDef)obj;
            sortObj.Add(ActivesDef.Idx, ActivesDef);
        }
        CActivesDef SuccessActivesDef = null;
        CActivesDef FailureActivesDef = null;

        string sData = "";

        foreach (KeyValuePair <int, CActivesDef> pair in sortObj)
        {
            CActivesDef ActivesDef = pair.Value;
            if (ActivesDef.WType == ActivesType.Success)
            {
                SuccessActivesDef = ActivesDef;
                continue;
            }
            if (ActivesDef.WType == ActivesType.Failure)
            {
                FailureActivesDef = ActivesDef;
                continue;
            }
            CUser  User = (CUser)Global.GetCtx(Session["TopCompany"].ToString()).UserMgr.Find(ActivesDef.B_User_id);
            CRole  Role = (CRole)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.FindTopCompany().RoleMgr.Find(ActivesDef.B_Role_id);
            string AType = "", UserName = "", RoleName = "";
            AType    = ActivesDef.AType;
            UserName = (User != null) ? User.Name : "";
            RoleName = (Role != null) ? Role.Name : "";

            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Idx\":\"{2}\", \"WType\":\"{3}\", \"AType\":\"{4}\", \"UserName\":\"{5}\", \"RoleName\":\"{6}\" }},"
                                   , ActivesDef.Id
                                   , ActivesDef.Name
                                   , ActivesDef.Idx
                                   , ActivesDef.WType
                                   , AType
                                   , UserName
                                   , RoleName);
        }

        //成功/失败结束活动放最后
        if (SuccessActivesDef != null)
        {
            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Idx\":\"{2}\", \"WType\":\"{3}\", \"B_User_id\":\"{4}\", \"UserName\":\"{5}\" }},"
                                   , SuccessActivesDef.Id
                                   , SuccessActivesDef.Name
                                   , SuccessActivesDef.Idx
                                   , SuccessActivesDef.WType
                                   , SuccessActivesDef.B_User_id
                                   , "");
        }
        if (FailureActivesDef != null)
        {
            sData += string.Format("{{ \"id\": \"{0}\",\"Name\":\"{1}\", \"Idx\":\"{2}\", \"WType\":\"{3}\", \"B_User_id\":\"{4}\", \"UserName\":\"{5}\" }},"
                                   , FailureActivesDef.Id
                                   , FailureActivesDef.Name
                                   , FailureActivesDef.Idx
                                   , FailureActivesDef.WType
                                   , FailureActivesDef.B_User_id
                                   , "");
        }

        sData = "[" + sData + "]";
        string sJson = string.Format("{{\"Rows\":{0},\"Total\":\"{1}\"}}"
                                     , sData, lstObj.Count);

        Response.Write(sJson);
    }
Example #20
0
    void PostData()
    {
        CUser       user       = (CUser)Session["User"];
        CActivesDef BaseObject = new CActivesDef();

        BaseObject.Ctx     = Global.GetCtx(Session["TopCompany"].ToString());
        BaseObject.Creator = user.Id;
        //默认链接==
        CLink link1 = new CLink();

        link1.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
        link1.WF_WorkflowDef_id = m_WorkflowDef.Id;
        link1.PreActives        = BaseObject.Id;
        link1.Result            = enumApprovalResult.Accept;
        CActivesDef adSuccess = m_WorkflowDef.ActivesDefMgr.FindSuccess();

        if (adSuccess != null)
        {
            link1.NextActives = adSuccess.Id;
        }
        else
        {
            link1.NextActives = Guid.Empty;
        }
        link1.Creator = user.Id;
        m_WorkflowDef.LinkMgr.AddNew(link1);
        CLink link2 = new CLink();

        link2.Ctx = Global.GetCtx(Session["TopCompany"].ToString());
        link2.WF_WorkflowDef_id = m_WorkflowDef.Id;
        link2.PreActives        = BaseObject.Id;
        link2.Result            = enumApprovalResult.Reject;
        CActivesDef adFailure = m_WorkflowDef.ActivesDefMgr.FindFailure();

        if (adFailure != null)
        {
            link2.NextActives = adFailure.Id;
        }
        else
        {
            link2.NextActives = Guid.Empty;
        }
        link2.Creator = user.Id;
        m_WorkflowDef.LinkMgr.AddNew(link2);
        //==
        List <CBaseObject> lstCol = m_Table.ColumnMgr.GetList();
        bool bHasVisible          = false;

        foreach (CBaseObject obj in lstCol)
        {
            CColumn col = (CColumn)obj;

            if (col.Code.Equals("id", StringComparison.OrdinalIgnoreCase))
            {
                continue;
            }
            else if (col.Code.Equals("Created", StringComparison.OrdinalIgnoreCase))
            {
                continue;
            }
            else if (col.Code.Equals("Creator", StringComparison.OrdinalIgnoreCase))
            {
                //BaseObject.SetColValue(col, Program.User.Id);
                continue;
            }
            else if (col.Code.Equals("Updated", StringComparison.OrdinalIgnoreCase))
            {
                continue;
            }
            else if (col.Code.Equals("Updator", StringComparison.OrdinalIgnoreCase))
            {
                //BaseObject.SetColValue(col, Program.User.Id);
                continue;
            }

            BaseObject.SetColValue(col, Request.Params[col.Code]);
            bHasVisible = true;
        }
        if (!bHasVisible)
        {
            Response.Write("没有可修改字段!");
            return;
        }
        m_ActivesDefMgr.AddNew(BaseObject);
    }
Example #21
0
        private void btOk_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("名称不能空!");
                return;
            }
            if (txtTable.Text.Trim() == "")
            {
                MessageBox.Show("请选择对象表!");
                return;
            }
            m_WorkflowDef.Name = txtName.Text.Trim();
            if (cbCatalog.SelectedIndex < 1)
            {
                m_WorkflowDef.WF_WorkflowCatalog_id = Guid.Empty;
            }
            else
            {
                DataItem         item    = (DataItem)cbCatalog.SelectedItem;
                CWorkflowCatalog catalog = (CWorkflowCatalog)item.Data;
                m_WorkflowDef.WF_WorkflowCatalog_id = catalog.Id;
            }
            //保证启动活动有后置活动,中间活动有前置活动与后置活动
            List <CBaseObject> lstObj = m_WorkflowDef.ActivesDefMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CActivesDef ActivesDef = (CActivesDef)obj;
                if (ActivesDef.WType == ActivesType.Start)
                {
                    bool         bHas    = false;
                    List <CLink> lstLink = m_WorkflowDef.LinkMgr.FindByPreActives(ActivesDef.Id);
                    foreach (CLink link in lstLink)
                    {
                        CActivesDef Next = (CActivesDef)m_WorkflowDef.ActivesDefMgr.Find(link.NextActives);
                        if (Next.WType == ActivesType.Middle)
                        {
                            bHas = true;
                            break;
                        }
                    }
                    if (!bHas)
                    {
                        MessageBox.Show("启动活动没有实际后置活动!");
                        return;
                    }
                }
                else if (ActivesDef.WType == ActivesType.Middle)
                {
                    List <CLink> lstLink = m_WorkflowDef.LinkMgr.FindByPreActives(ActivesDef.Id);
                    if (lstLink.Count == 0)
                    {
                        MessageBox.Show(string.Format("{0} 没有后置活动!", ActivesDef.Name));
                        return;
                    }
                    List <CLink> lstLink2 = m_WorkflowDef.LinkMgr.FindByPreActives(ActivesDef.Id);
                    if (lstLink2.Count == 0)
                    {
                        MessageBox.Show(string.Format("{0} 没有前置活动!", ActivesDef.Name));
                        return;
                    }
                }
            }


            if (m_bIsNew)
            {
                m_Company.WorkflowDefMgr.AddNew(m_WorkflowDef);
            }
            else
            {
                m_Company.WorkflowDefMgr.Update(m_WorkflowDef);
            }

            if (!m_Company.WorkflowDefMgr.Save(true))
            {
                MessageBox.Show("保存失败!");
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #22
0
        void LoadActives()
        {
            dataGridView.Rows.Clear();
            List <CBaseObject> lstObj = m_WorkflowDef.ActivesDefMgr.GetList();
            //按序号排序
            SortedList <int, CActivesDef> sortObj = new SortedList <int, CActivesDef>();

            foreach (CBaseObject obj in lstObj)
            {
                CActivesDef ActivesDef = (CActivesDef)obj;
                sortObj.Add(ActivesDef.Idx, ActivesDef);
            }
            CActivesDef SuccessActivesDef = null;
            CActivesDef FailureActivesDef = null;

            foreach (KeyValuePair <int, CActivesDef> pair in sortObj)
            {
                CActivesDef ActivesDef = pair.Value;
                if (ActivesDef.WType == ActivesType.Success)
                {
                    SuccessActivesDef = ActivesDef;
                    continue;
                }
                if (ActivesDef.WType == ActivesType.Failure)
                {
                    FailureActivesDef = ActivesDef;
                    continue;
                }
                dataGridView.Rows.Add(1);
                DataGridViewRow item = dataGridView.Rows[dataGridView.Rows.Count - 1];
                item.Cells[0].Value = ActivesDef.Idx;
                item.Cells[1].Value = ActivesDef.Name;
                CUser user = (CUser)Program.Ctx.UserMgr.Find(ActivesDef.B_User_id);
                if (user != null)
                {
                    item.Cells[2].Value = user.Name;
                }
                item.Tag = ActivesDef;
            }
            //成功/失败结束活动放最后
            if (SuccessActivesDef != null)
            {
                dataGridView.Rows.Add(1);
                DataGridViewRow item = dataGridView.Rows[dataGridView.Rows.Count - 1];
                item.Cells[0].Value = SuccessActivesDef.Idx;
                item.Cells[1].Value = SuccessActivesDef.Name;
                CUser user = (CUser)Program.Ctx.UserMgr.Find(SuccessActivesDef.B_User_id);
                if (user != null)
                {
                    item.Cells[2].Value = user.Name;
                }
                item.Tag = SuccessActivesDef;
            }
            if (FailureActivesDef != null)
            {
                dataGridView.Rows.Add(1);
                DataGridViewRow item = dataGridView.Rows[dataGridView.Rows.Count - 1];
                item.Cells[0].Value = FailureActivesDef.Idx;
                item.Cells[1].Value = FailureActivesDef.Name;
                CUser user = (CUser)Program.Ctx.UserMgr.Find(FailureActivesDef.B_User_id);
                if (user != null)
                {
                    item.Cells[2].Value = user.Name;
                }
                item.Tag = FailureActivesDef;
            }
        }