Esempio n. 1
0
        private void tsbNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (lbMethodName.FindString(tbName.Text) >= 0)
                {
                    MessageBox.Show("名称重复,不允许新增。", "提示");
                    return;
                }

                DataOperItem doi = new DataOperItem();
                doi.ItemName       = tbName.Text;
                doi.DBAlias        = cbxDBAlias.Text;
                doi.ProcessContext = rtbContext.Text;
                doi.ReturnName     = txtReturnName.Text;

                ItemBind ib = new ItemBind(doi.ItemName, doi.ItemName);
                ib.Tag = doi;

                lbMethodName.Items.Add(ib);
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
Esempio n. 2
0
        private void lbMethodName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                tbName.Text        = "";
                cbxDBAlias.Text    = "";
                rtbContext.Text    = "";
                txtReturnName.Text = "";

                if (lbMethodName.SelectedItem == null)
                {
                    return;
                }

                ItemBind ib = lbMethodName.SelectedItem as ItemBind;

                DataOperItem doi = ib.Tag as DataOperItem;

                tbName.Text        = doi.ItemName;
                cbxDBAlias.Text    = doi.DBAlias;
                rtbContext.Text    = doi.ProcessContext;
                txtReturnName.Text = doi.ReturnName;
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
Esempio n. 3
0
        private void tsbUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (lbMethodName.SelectedItem == null)
                {
                    return;
                }

                int fIndex = lbMethodName.FindString(tbName.Text);

                if (fIndex < 0 || fIndex == lbMethodName.Items.IndexOf(lbMethodName.SelectedItem))
                {
                    ItemBind ib = lbMethodName.SelectedItem as ItemBind;

                    ib.Name  = tbName.Text;
                    ib.Value = tbName.Text;

                    DataOperItem doi = ib.Tag as DataOperItem;

                    doi.ItemName       = tbName.Text;
                    doi.DBAlias        = cbxDBAlias.Text;
                    doi.ProcessContext = rtbContext.Text;
                    doi.ReturnName     = txtReturnName.Text;
                }
                else
                {
                    MessageBox.Show("名称存在重复,不能进行更新。", "提示");
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
        public override bool ExecuteAction(string callModuleName, ISysDesign callModule, object sender, string actName, string tag, IBizDataItems bizDatas, object eventArgs = null)
        {
            try
            {
                _returnData = null;

                if (_dbHelpers == null)
                {
                    _dbHelpers = new Dictionary <string, IDBQuery>();

                    foreach (DataOperItem doi in _dataOperDesign.DataOperItems)
                    {
                        if (_dbHelpers.ContainsKey(doi.DBAlias))
                        {
                            continue;
                        }

                        string   strErr        = "";
                        IDBQuery thridDbHelper = null;

                        thridDbHelper = SqlHelper.GetThridDBHelper(doi.DBAlias, _dbQuery, ref strErr);

                        if (thridDbHelper == null)
                        {
                            MessageBox.Show("数据处理项 [" + doi.ItemName + "] 对应数据源实例化失败:" + strErr, "提示");
                            return(false);
                        }

                        _dbHelpers.Add(doi.DBAlias, thridDbHelper);
                    }
                }

                _curBizData = null;
                if (bizDatas != null)
                {
                    _curBizData = bizDatas[0] as BizDataItem;
                }

                IDBQuery curDBHelper = null;

                switch (actName)
                {
                case DataOperActionDefine.RunProcess:

                    _returnData = new BizDataItems();

                    BizDataItem returnItem = new BizDataItem();

                    if (string.IsNullOrEmpty(tag))
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            foreach (DataOperItem doi in _dataOperDesign.DataOperItems)
                            {
                                if (string.IsNullOrEmpty(doi.DBAlias))
                                {
                                    curDBHelper = _dbQuery;
                                }
                                else
                                {
                                    curDBHelper = _dbHelpers[doi.DBAlias];
                                }

                                DataTable dtResult = SqlHelper.GetDataSource(doi.ProcessContext, curDBHelper, QueryParValueEvent);

                                returnItem.Add(doi.ReturnName, dtResult);
                            }

                            ts.Complete();
                        }
                    }
                    else
                    {
                        int index = _dataOperDesign.DataOperItems.FindIndex(T => T.ItemName == tag);
                        if (index < 0)
                        {
                            MessageBox.Show("未找到指定处理项的配置信息。", "提示");
                            return(false);
                        }

                        DataOperItem doiProcess = _dataOperDesign.DataOperItems[index];

                        if (string.IsNullOrEmpty(doiProcess.DBAlias))
                        {
                            curDBHelper = _dbQuery;
                        }
                        else
                        {
                            curDBHelper = _dbHelpers[doiProcess.DBAlias];
                        }

                        DataTable dtResult = SqlHelper.GetDataSource(doiProcess.ProcessContext, curDBHelper, QueryParValueEvent);

                        returnItem.Add(doiProcess.ReturnName, dtResult);
                    }

                    _returnData.Add(returnItem);

                    return(true);

                default:
                    break;
                }

                return(true);
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
                return(false);
            }
        }