⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 activityinfodlg.cs

📁 这个是自己制作的工作流设计器,可以可视化的拖拉
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WorkflowDesigner;
using System.Collections;
namespace WorkflowDesigner.Designer
{
    public partial class ActivityInfoDlg : Form
    {
        public ActivityInfoDlg(WfActivity wfactivity)
        {
            InitializeComponent();
            this._wfActivity = wfactivity;
        }

        private WfActivity _wfActivity;
        /// <summary>
        /// 节点信息
        /// </summary>
        public WfActivity WfActivity
        {
            get { return _wfActivity; }
            set { _wfActivity = value; }
        }

        private void ActivityInfoDlg_Load(object sender, EventArgs e)
        {
            this.textBoxName.Text = this._wfActivity.Name.ToString();
            this.textBoxPosx.Text = this._wfActivity.X.ToString();
            this.textBoxPosY.Text = this._wfActivity.Y.ToString();
            //绑定角色信息
            BindRoleInfo();
            //绑定之前的节点信息
            BindBeforeActivity();
           
            //************赋值
            LoadWorkInfo();
            LoadNormalInfo();
            LoadUserInfo();

            LoadAppInfo();
            //绑定应用信息
            BindAppsInfo();

            LoadParamInfo();
            //绑定参数信息
            BindParamsInfo();
        }

        #region 读取时限信息
        private void LoadWorkInfo()
        {
         
            if (this._wfActivity.Workday != 0)
            {
                this.checkBoxIsWorkday.Checked = true;
                this.textBoxMustTime.Enabled = true;
                this.checkBoxIsWarningDay.Enabled = true;
            }
            if (this._wfActivity.Warning_time != 0)
            {
                this.checkBoxIsWarningDay.Checked = true;
                this.textBoxWarningTime.Enabled = true;
            }
            this.textBoxMustTime.Text = this._wfActivity.Workday.ToString("0.00");
            this.textBoxWarningTime.Text = this._wfActivity.Warning_time.ToString("0.00");
            //GetMartTemplet();


        }
        #endregion

        #region 读取节点所属用户信息
        private WfRole GetRoleInfoByRoleName(String RoleName)
        {
            foreach (WfRole vo in  Program.WorkflowControl.WfPackageDocument.RoleList)
            {
                if (vo.Name == RoleName)
                {
                    return vo;
                }
            }
            return null;
        }
        private WfActivity GetActivityByName(String Name)
        {
            foreach (DesignerVisualObject vo in this._wfActivity.Flow.VisualObjectList)
            {
                if (vo is WfActivity)
                {

                    if ((vo as WfActivity).Name == Name)
                    {
                        return (WfActivity)vo;
                    }
                }
            }
            return null;
        }
        private void LoadUserInfo()
        {
          
            this.radioButtonSelectRole.Checked = false;
            this.radioButtonBeforActiv.Checked = false;
            this.comboBoxRole.Enabled = false;
            this.comboBoxPrevActive.Enabled = false;
            if (this._wfActivity.IsSelectUser == 0)
            {
                //选择角色
                this.radioButtonSelectRole.Checked = true;
                this.comboBoxRole.Enabled = true;
               
                if (this._wfActivity.Role != null)
                {
                    this.comboBoxRole.SelectedValue = this._wfActivity.Role.Name;
                }
                else
                {
                    this.comboBoxRole.Text = "";
                    this.comboBoxRole.SelectedValue = "";
                }
            }
            else
            { 
                //选择之前节点
                this.radioButtonBeforActiv.Checked = true;
                this.comboBoxPrevActive.Enabled = true;

                if (this._wfActivity.Before_ActiveInfo != null)
                {
                    this.comboBoxRole.SelectedValue = this._wfActivity.Before_ActiveInfo.Name;
                }
                else
                {
                    this.comboBoxPrevActive.Text = "";
                    this.comboBoxPrevActive.SelectedValue = "";
                }
            }
           
        }
        #endregion

        #region 读取一般信息
        private void LoadNormalInfo()
        {
            this.checkBoxIsEnableSendBack.Checked = true;
            this.checkBoxIsSendSelf.Checked = true;
            if (this._wfActivity.IsSendBack == 0)
            {
                this.checkBoxIsEnableSendBack.Checked = false;
            }
            if (this._wfActivity.IsSendSelf == 0)
            {
                this.checkBoxIsSendSelf.Checked = false;
            }

            this.textBoxAfterSend.Text = this._wfActivity.AfterSend_Event;
            this.textBoxBeforRecive.Text = this._wfActivity.BeforeRecive_Event;


        }
        #endregion

        #region 读取应用信息
        private void LoadAppInfo()
        { 
            //得到已选择的应用信息
           IList<WfApplication> apps = this._wfActivity.AppList;
          // this.listBoxSlectedAppInfo.DataSource = apps;
           this.listBoxSlectedAppInfo.DisplayMember = "Name";
           this.listBoxSlectedAppInfo.ValueMember = "Name";
           foreach (WfApplication app in apps)
           {
               this.listBoxSlectedAppInfo.Items.Add(app);
           }

        }
        #endregion

        #region 读取参数信息
        private void LoadParamInfo()
        {
            //得到已选择的应用信息
            IList<WfParam> Params = this._wfActivity.ParamsInfo;
            // this.listBoxSlectedAppInfo.DataSource = apps;
            this.listBoxSelectedParam.DisplayMember = "Name";
            this.listBoxSelectedParam.ValueMember = "Name";
            foreach (WfParam param in Params)
            {
                this.listBoxSelectedParam.Items.Add(param);
            }
        }
        #endregion

        #region 判断
        private bool IsVaildSelectUser()
        {
            if (this.radioButtonSelectRole.Checked)
            {

                if (this.comboBoxRole.Text == "")
                {
                    MessageBox.Show("请选择节点角色!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.comboBoxRole.Focus();
                    return false;
                }
                
            }

            if (this.radioButtonBeforActiv.Checked)
            {
                if (this.comboBoxPrevActive.Text == "")
                {
                    MessageBox.Show("请选择之前的节点!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.comboBoxPrevActive.Focus();
                    return false;
                }
            }
            return true;
        }

        private bool IsVaildWorkDay()
        {
           
            if (this.checkBoxIsWorkday.Checked)
            {
                if (this.textBoxMustTime.Text.Trim() == "")
                {
                    MessageBox.Show("请填写节点时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.textBoxMustTime.Focus();
                    return false;
                }
                else
                {
                    //判断输入的格式是否正确
                    if (!CommFunction.IsWorkDay(this.textBoxMustTime.Text))
                    {
                        MessageBox.Show("请填写正确节点所需时间格式[00000.00]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.textBoxMustTime.Focus();
                        return false;
                    }
                    else if (Convert.ToDecimal(this.textBoxMustTime.Text.Trim()) == 0)
                    {
                        MessageBox.Show("请填写节点时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.textBoxMustTime.Focus();
                        return false;
                    }
                }
            }
            if (this.checkBoxIsWarningDay.Checked)
            {
                if (this.textBoxWarningTime.Text.Trim() == "")
                {
                    MessageBox.Show("请填写节点预警时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.textBoxWarningTime.Focus();
                    return false;
                }
                else
                {
                    //判断输入的格式是否正确
                    if (!CommFunction.IsWorkDay(this.textBoxWarningTime.Text))
                    {
                        MessageBox.Show("请填写正确节点预警时间格式[00000.00]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.textBoxMustTime.Focus();
                        return false;
                    }
                    else if (Convert.ToDecimal(this.textBoxWarningTime.Text.Trim()) == 0)
                    {
                        MessageBox.Show("请填写节点预警时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.textBoxWarningTime.Focus();
                        return false;
                    }
                }
            }
            return true;
        }
        #endregion

        #region 绑定信息
        private void BindRoleInfo()
        {
            IList<WfRole> Roles = Program.WorkflowControl.WfPackageDocument.RoleList;
            this.comboBoxRole.DataSource = Roles;
            this.comboBoxRole.DisplayMember = "Name";
            this.comboBoxRole.ValueMember = "Name";
        }

        private void BindAppsInfo()
        {
            IList<WfApplication> Apps =RefreshAppInfo();
            this.listBoxAppInfo.DataSource = Apps;
            this.listBoxAppInfo.DisplayMember = "Name";
            this.listBoxAppInfo.ValueMember = "Name";
        }
        private  IList<WfApplication>  RefreshAppInfo()
        {
             
            IList<WfApplication> Apps = Program.WorkflowControl.WfPackageDocument.AppList;
            IList<WfApplication> result = new List<WfApplication>();
            result.Clear();
            //得到所有的信息

            foreach (WfApplication app in Apps)
            {
                bool IsExists = false;           
                foreach (WfApplication appTemp in this.listBoxSlectedAppInfo.Items)
                {

                    if (app.Name == appTemp.Name)
                    {
                        IsExists = true;
                        break;
                       
                       
                    }
                }
                if (!IsExists)
                     result.Add(app);

            }
            return result;
        }
        private void BindParamsInfo()
        {
            IList<WfParam> Params = RefreshParamInfo();
            this.listBoxParam.DataSource = Params;
            this.listBoxParam.DisplayMember = "Name";
            this.listBoxParam.ValueMember = "Name";
        }
        private IList<WfParam> RefreshParamInfo()
        {

            IList<WfParam> Params = Program.WorkflowControl.WfPackageDocument.ParamList;
            IList<WfParam> result = new List<WfParam>();
            result.Clear();
            //得到所有的信息

            foreach (WfParam param in Params)
            {
                bool IsExists = false;
                foreach (WfParam paramTemp in this.listBoxSelectedParam.Items)
                {

                    if (param.Name == paramTemp.Name)
                    {
                        IsExists = true;
                        break;


                    }
                }
                if (!IsExists)
                    result.Add(param);

            }
            return result;
        }

        private void BindBeforeActivity()
        {
            ArrayList albeforActiv = new ArrayList();
            this.GetBeforeActivity(this._wfActivity,ref albeforActiv);

            DataTable dt = new DataTable();
            dt.Columns.Add("ID", typeof(String));
            dt.Columns.Add("Name", typeof(String));

            foreach (WfActivity act in albeforActiv)
            { 
                 DataRow dr = dt.NewRow();
                 dr["ID"] = act.Name;
                 dr["Name"] = act.Name;
                dt.Rows.Add(dr);
          
            }
            this.comboBoxPrevActive.DataSource = dt;
            this.comboBoxPrevActive.DisplayMember = "ID";
            this.comboBoxPrevActive.ValueMember = "Name";

        }

        private void GetBeforeActivity(WfActivity act, ref ArrayList al)
        {
            //遍历路径
            foreach (DesignerVisualObject vo in this._wfActivity.Flow.VisualObjectList)
            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -