QueryMSMQList queryMSMQ = new QueryMSMQList(".//private$//coreexchange");
List<QueryMSMQCommon> queryList = queryMSMQ.mReceive();
DataSet dsQueueMSMQ = new DataSet();
DataTable dsQueueTable = new DataTable();
DataColumn cTransactionId = new DataColumn("事务ID");
DataColumn cSender = new DataColumn("文档发送方");
DataColumn cReceive = new DataColumn("文档接收方");
DataColumn cReceiveTime = new DataColumn("文档接收时间");
dsQueueTable.Columns.Add(cTransactionId);
dsQueueTable.Columns.Add(cSender);
dsQueueTable.Columns.Add(cReceive);
dsQueueTable.Columns.Add(cReceiveTime);
dsQueueMSMQ.Tables.Add(dsQueueTable);
DataRow[] dataRow = new DataRow[queryList.Count];
for (int i = 0; i < queryList.Count; i++)
{
dataRow[i] = dsQueueTable.NewRow();
dataRow[i][0] = queryList[i].TransactionID;
dataRow[i][1] = queryList[i].Sender;
string sReceive = null;
for (int iReceive = 0; iReceive < queryList[i].Receive.Count; iReceive++)
{
sReceive = queryList[i].Receive[iReceive] + "," + sReceive;
}
dataRow[i][2] = sReceive;
dataRow[i][3] = queryList[i].ReceiveTime;
dsQueueTable.Rows.Add(dataRow[i]);
}
dataGridView1.DataSource = dsQueueMSMQ.Tables[0];
第一步:
创建dataset对象:
DataSet dsQueueMSMQ = new DataSet();
第二步
创建table对象:
DataTable dsQueueTable = new DataTable();
第三步:
创建DataColumn 对象:
DataColumn cTransactionId = new DataColumn("事务ID");
DataColumn cSender = new DataColumn("文档发送方");
DataColumn cReceive = new DataColumn("文档接收方");
DataColumn cReceiveTime = new DataColumn("文档接收时间");
第四步:
把所有的列加入table中,把table加入dataset中:
dsQueueTable.Columns.Add(cTransactionId);
dsQueueTable.Columns.Add(cSender);
dsQueueTable.Columns.Add(cReceive);
dsQueueTable.Columns.Add(cReceiveTime);
dsQueueMSMQ.Tables.Add(dsQueueTable);
第五步:创建dataRow对象并且把rows加入table中:
for (int i = 0; i < queryList.Count; i++)
{
dataRow[i] = dsQueueTable.NewRow();
dataRow[i][0] = queryList[i].TransactionID;
dataRow[i][1] = queryList[i].Sender;
string sReceive = null;
for (int iReceive = 0; iReceive < queryList[i].Receive.Count; iReceive++)
{
sReceive = queryList[i].Receive[iReceive] + "," + sReceive;
}
dataRow[i][2] = sReceive;
dataRow[i][3] = queryList[i].ReceiveTime;
dsQueueTable.Rows.Add(dataRow[i]);
}