public string compute(string fileContent, int iFirst, string firstValue, int iSecond, string secondValue, DataRow dr, string vapor, string liquid, string dir) { CP2ServerClass cp2Srv = new CP2ServerClass(); cp2Srv.Initialize(); string streamData = getStreamData(iFirst, firstValue, iSecond, secondValue, dr); string flashData = getFlashData(iFirst, firstValue, iSecond, secondValue, dr, vapor, liquid); StringBuilder sb = new StringBuilder(); sb.Append(fileContent).Append(streamData).Append(flashData); string onlyFileName = dir + @"\" + Guid.NewGuid().ToString().Substring(0, 5); string inpFile = onlyFileName + ".inp"; File.WriteAllText(inpFile, sb.ToString()); int resultImport = cp2Srv.Import(inpFile); string przFile = onlyFileName + ".prz"; CP2File cp2File = (CP2File)cp2Srv.OpenDatabase(przFile); int runResult = cp2Srv.RunCalcs(przFile); runResult = runResult + cp2Srv.GenerateReport(przFile); Marshal.FinalReleaseComObject(cp2Srv); GC.ReRegisterForFinalize(cp2Srv); return(przFile); }
public PRZReader(string File) { przFile = File; cp2Srv = new CP2ServerClass(); cp2Srv.Initialize(); fileName = System.IO.Path.GetFileName(przFile); //cp2File = (CP2File)cp2Srv.OpenDatabase(przFile); //////cp2Srv.RunCalcs(przFile); //objCompCalc = (CP2Object)cp2File.ActivateObject("CompCalc", "CompCalc"); }
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(); } } }
public DataTable copyStream(string przFile, string columnName) { P2Wrap91.CP2ServerClass cp2Srv = new CP2ServerClass(); cp2Srv.Initialize(); P2Wrap91.CP2File cp2File = (CP2File)cp2Srv.OpenDatabase(przFile); 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"] = convertdata(ComponentId); } else { dr["ComponentId"] = ComponentId; } object CompIn = cp2File.GetObjectNames("CompIn"); if (CompIn != null && ComponentId is Array) { dr["CompIn"] = convertdata(CompIn); } else { dr["CompIn"] = CompIn; } dr["streamname"] = streamName; dr["sourcefile"] = przFile; dr["tray"] = 1; dr["prodtype"] = 2; 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] = 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] = convertdata(v); } else { dr[s] = v; } } } cp2File.DeleteObject("Stream", streamName); dt.Rows.Add(dr); Marshal.FinalReleaseComObject(cp2Srv); GC.ReRegisterForFinalize(cp2Srv); return(dt); }