//获得设备和物流线的个数和名字信息 public int getAllEqAndStreamCount(DataTable dtEqType, ref ArrayList eqList, ref ArrayList streamList) { int count = 0; foreach (DataRow dr in dtEqType.Rows) { string otype = dr["eqtypename"].ToString(); int ct = cp2File.GetObjectCount(otype); if (ct > 0) { object objectnames = cp2File.GetObjectNames(otype); if (objectnames is Array) { string[] oNames = (string[])objectnames; foreach (string name in oNames) { EqInfo eq = new EqInfo(); eq.eqName = name; eq.eqType = otype; if (otype == "Column") { eq.isColumn = true; } eqList.Add(eq); } } else { EqInfo eq = new EqInfo(); eq.eqName = objectnames.ToString(); eq.eqType = otype; if (otype == "Column") { eq.isColumn = true; } eqList.Add(eq); } count = count + ct; } } int streamCount = cp2File.GetObjectCount("Stream"); count = streamCount + count; object streamnames = cp2File.GetObjectNames("Stream"); if (streamnames is Array) { string[] oNames = (string[])streamnames; foreach (string name in oNames) { streamList.Add(name); } } else { streamList.Add(streamnames.ToString()); } return(count); }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { dbRelief = new DBRelief(dbFile); DataSet dsStructure = dbRelief.getDataStructure(); DataTable dtEqType = dsStructure.Tables["eqtype"]; dtEqList = dsStructure.Tables["eqlist"]; dtStream = dsStructure.Tables["stream"]; picker = new PRZPicker(curprzFile); int total = picker.getAllEqAndStreamCount(dtEqType, ref eqList, ref streamList); int eqCount = eqList.Count; for (int i = 1; i <= eqList.Count; i++) { EqInfo eq = (EqInfo)eqList[i - 1]; picker.getEqInfo(eq.eqType, eq.eqName, ref dtEqList); int percents = (i * 100) / total; backgroundWorker.ReportProgress(percents, i); } for (int i = 1; i <= streamList.Count; i++) { picker.getSteamInfo(streamList[i - 1].ToString(), ref dtStream); int percents = ((eqCount + i) * 100) / total; backgroundWorker.ReportProgress(percents); } backgroundWorker.ReportProgress(100); } catch (Exception ex) { string lines = ex.ToString(); using (StreamWriter writer = new StreamWriter("log.txt", true)) { writer.WriteLine(ex.ToString()); } } }