public void getSteamInfo(string name, ref DataTable dtStream) { DataRow r = dtStream.NewRow(); bool bCalulate = cp2File.CalculateStreamProps(name); r["streamname"] = name; r["sourcefile"] = fileName; r["prodtype"] = ""; r["tray"] = ""; int idx = arrFeedData.IndexOf(name); if (idx >= 0) { r["tray"] = arrFeedTrays[idx]; } idx = arrProductData.IndexOf(name); if (idx >= 0) { r["tray"] = arrProdTrays[idx]; r["prodtype"] = arrProdTypes[idx]; } r["CompIn"] = CompIns; r["ComponentId"] = ComponentIds; CP2Object objStream = (CP2Object)cp2File.ActivateObject("Stream", name); foreach (string s in arrStreamAttributes) { object v = objStream.GetAttribute(s); if (v != null && v is Array) { r[s] = UnitConverter.convertData(v); } else { r[s] = v; } } Marshal.FinalReleaseComObject(objStream); GC.ReRegisterForFinalize(objStream); if (bCalulate) { CP2Object objBulkDrop = (CP2Object)cp2File.ActivateObject("SrBulkProp", name); foreach (string s in arrBulkPropAttributes) { object v = objBulkDrop.GetAttribute(s); if (v != null && v is Array) { r[s] = UnitConverter.convertData(v); } else { r[s] = v; } } Marshal.FinalReleaseComObject(objBulkDrop); GC.ReRegisterForFinalize(objBulkDrop); } dtStream.Rows.Add(r); }
//private void CloseReader() //{ //Marshal.FinalReleaseComObject(objCompCalc); //GC.ReRegisterForFinalize(objCompCalc); //Marshal.FinalReleaseComObject(cp2File); //GC.ReRegisterForFinalize(cp2File); // } //复制塔的首层物流 public DataTable copyTray1Stream2(string columnName) { DBRelief dbR = new DBRelief(); DataTable dt = dbR.getStructure("stream"); string streamName = "TEMP" + Guid.NewGuid().ToString().Substring(0, 5).ToUpper(); CP2Object tempStream = (CP2Object)cp2File.CreateObject("Stream", streamName); bool b = cp2File.CopyTrayToStream(columnName, 1, (p2Phase)2, 0, (p2TrayFlow)1, streamName); string bb = b.ToString(); DataRow dr = dt.NewRow(); bool bCalulate = cp2File.CalculateStreamProps(streamName); CP2Object compCalc = (CP2Object)cp2File.ActivateObject("CompCalc", "CompCalc"); object ComponentId = compCalc.GetAttribute("ComponentId"); if (ComponentId != null && ComponentId is Array) { dr["ComponentId"] = UnitConverter.convertData(ComponentId); } else { dr["ComponentId"] = ComponentId; } object CompIn = cp2File.GetObjectNames("CompIn"); if (CompIn != null && ComponentId is Array) { dr["CompIn"] = UnitConverter.convertData(CompIn); } else { dr["CompIn"] = CompIn; } dr["streamname"] = streamName; dr["sourcefile"] = przFile; dr["tray"] = 1; dr["prodtype"] = 3; CP2Object curStream = (CP2Object)cp2File.ActivateObject("Stream", streamName); foreach (string s in arrStreamAttributes) { object v = curStream.GetAttribute(s); if (v != null && v is Array) { dr[s] = UnitConverter.convertData(v); } else { dr[s] = v; } } if (bCalulate) { CP2Object bulkDrop = (CP2Object)cp2File.ActivateObject("SrBulkProp", streamName); foreach (string s in arrBulkPropAttributes) { object v = bulkDrop.GetAttribute(s); if (v != null && v is Array) { dr[s] = UnitConverter.convertData(v); } else { dr[s] = v; } } } cp2File.DeleteObject("Stream", streamName); dt.Rows.Add(dr); //CloseReader(); //Marshal.FinalReleaseComObject(cp2Srv1); //GC.ReRegisterForFinalize(cp2Srv1); //Marshal.FinalReleaseComObject(tempStream); //GC.ReRegisterForFinalize(tempStream); // Marshal.FinalReleaseComObject(curStream); // GC.ReRegisterForFinalize(curStream); return(dt); }