//获得设备和物流线的个数和名字信息 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); }
public DataSet getDataFromFile() { try { DBRelief dbRelief = new DBRelief(); List <string> streamList = new List <string>(); DataSet dsStructure = dbRelief.getDataStructure(); DataTable dtEqlist = dsStructure.Tables["eqlist"].Clone(); DataTable dtStream = dsStructure.Tables["stream"].Clone(); DataTable dtEqType = dsStructure.Tables["eqtype"]; cp2File = (CP2File)cp2Srv.OpenDatabase(przFile); objCompCalc = (CP2Object)cp2File.ActivateObject("CompCalc", "CompCalc"); foreach (DataRow dr in dtEqType.Rows) { string otype = dr["eqtypename"].ToString(); object objectnames = cp2File.GetObjectNames(otype); if (objectnames.ToString() != "") { if (objectnames is Array) { string[] oNames = (string[])objectnames; foreach (string name in oNames) { getEqDataFromFile(otype, name, ref streamList, ref dtEqlist, ref dtStream); } } else { string name = (string)objectnames; getEqDataFromFile(otype, name, ref streamList, ref dtEqlist, ref dtStream); } } } Marshal.FinalReleaseComObject(cp2Srv); GC.ReRegisterForFinalize(cp2Srv); DataSet ds = new DataSet(); ds.Tables.Add(dtStream); ds.Tables.Add(dtEqlist); return(ds); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { //CloseReader(); } }
public PRZPicker(string File) { przFile = File; cp2Srv = new CP2ServerClass(); cp2Srv.Initialize(); fileName = System.IO.Path.GetFileName(przFile); cp2File = (CP2File)cp2Srv.OpenDatabase(przFile); objCompCalc = (CP2Object)cp2File.ActivateObject("CompCalc", "CompCalc"); object ComponentId = objCompCalc.GetAttribute("ComponentId"); if (ComponentId != null && ComponentId is Array) { ComponentIds = UnitConverter.convertData(ComponentId); } else { if (ComponentId == null) { ComponentIds = string.Empty; } else { ComponentIds = ComponentId.ToString(); } } object CompIn = cp2File.GetObjectNames("CompIn"); if (CompIn != null && ComponentId is Array) { CompIns = UnitConverter.convertData(CompIn); } else { if (CompIn == null) { CompIns = string.Empty; } else { CompIns = CompIn.ToString(); } } }
//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); }