Пример #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string _fname = "";

            QueryModel = MetaDataCache.GetQueryModelDefine(compareRequest.QueryModelName);
            //处理比对数据表

            srcData = new DataTable();
            foreach (DataColumn _dc in compareRequest.ExcelData.Columns)
            {
                if (_dc.ColumnName == "XH")
                {
                    _fname = "XH";
                }
                else
                {
                    ExcelColumnAlias _alias = ExcelColumns[_dc.ColumnName];
                    _fname = _alias.Alias;
                }
                srcData.Columns.Add(_fname, _dc.DataType);
            }

            foreach (DataRow _dr in compareRequest.ExcelData.Rows)
            {
                DataRow _newrow = srcData.NewRow();
                foreach (DataColumn _dc in compareRequest.ExcelData.Columns)
                {
                    if (_dc.ColumnName == "XH")
                    {
                        _fname = "XH";
                    }
                    else
                    {
                        ExcelColumnAlias _alias = ExcelColumns[_dc.ColumnName];
                        _fname = _alias.Alias;
                    }
                    _newrow[_fname] = _dr[_dc.ColumnName];
                }
                srcData.Rows.Add(_newrow);
            }

            //调用比对服务
            using (MetaDataQueryServiceClient _msc = new MetaDataQueryServiceClient())
            {
                CompareResult = _msc.CompareData(compareRequest, srcData);
            }

            //建立关系
            MC_QueryModel.CreateDataRelation(this.QueryModel, CompareResult);
            DataTable _mtable = CompareResult.Tables[QueryModel.MainTable.TableName];
            DataTable _ctable = CompareResult.Tables["EXCELRESULTDATA"];

            CompareResult.Relations.Add("比对的EXCEL文件", _mtable.Columns["MAINID"], _ctable.Columns["MAINID"]);
        }
        public MDCompare_ConditionItem GetCompareConditionItem()
        {
            string _emsg = "";

            if (CheckInput(ref _emsg))
            {
                MDCompare_ConditionItem _ret = new MDCompare_ConditionItem();
                _ret.ColumnIndex = this.te_xh.Text;
                _ret.Column      = new MDQuery_TableColumn(ColumnDefine);
                _ret.Operator    = GetOperator();
                ExcelColumnAlias _selectItem = this.excelSelectBox.EditValue as ExcelColumnAlias;
                _ret.CompareTagetField = _selectItem.Alias;

                return(_ret);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        private List <ExcelColumnAlias> GetTableColumns(OleDbConnection conn)
        {
            List <ExcelColumnAlias> _ret = new List <ExcelColumnAlias>();
            DataTable _columnTable       = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, TableName, null });
            int       i = 1;

            foreach (DataRow _dr in _columnTable.Rows)
            {
                string _colName = _dr["COLUMN_NAME"].ToString();
                if (_colName.Contains("\"") || _colName.Length > 15)
                {
                    throw new Exception(string.Format("字段名称字符大于15或包含引号! Column={0}", _colName));
                }
                ExcelColumnAlias _col = new ExcelColumnAlias();
                _col.Alias = string.Format("C{0}", i.ToString("D2"));
                i++;
                _col.ColumnName = _colName;
                _ret.Add(_col);
            }
            return(_ret);
        }