コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: PRZReader.cs プロジェクト: dreamingboy1997/Relief
        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();
            }
        }
コード例 #3
0
        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();
                }
            }
        }
コード例 #4
0
ファイル: PRZReader.cs プロジェクト: dreamingboy1997/Relief
        //复制塔的首层物流
        public DataTable copyTray1Stream(string columnName)
        {
            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);

            objCompCalc = (CP2Object)cp2File.ActivateObject("CompCalc", "CompCalc");
            object ComponentId = objCompCalc.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"] = fileName;
            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);

            return(dt);
        }