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"]); }