Ejemplo n.º 1
0
        public void run()
        {
            DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design);

            DbElementType[]       dbtype      = new DbElementType[] { DbElementTypeInstance.PIPE };
            TypeFilter            filter      = new TypeFilter(dbtype);
            AndFilter             finalfilter = new AndFilter();
            AttributeStringFilter filter2     = new AttributeStringFilter(DbAttribute.GetDbAttribute("Name"), FilterOperator.Equals, "/babo");

            finalfilter.Add(filter);
            finalfilter.Add(filter2);


            DBElementCollection spwl_collects = new DBElementCollection(Outfit_Elements, finalfilter);

            Console.WriteLine("스펙월드갯수:" + spwl_collects.Cast <DbElement>().Count());

            int speccnt = 0;
            List <DbElement> working_dbelement = new List <DbElement>();


            foreach (DbElement element in spwl_collects)
            {
                //element.Delete();
                DbCopyOption dd = new DbCopyOption();

                //dd.ToName="/bbboa";
                //DbElement de= element.CreateCopyHierarchyAfter(CurrentElement.Element, dd);
                //de.InsertBefore(CurrentElement.Element);
                DbElement xx = DbElement.GetElement("/xx1");

                CurrentElement.Element.InsertAfterLast(xx);
                //de.InsertAfterLast(element.Owner);
                ////Console.WriteLine("스펙월드]" + spwl.GetAsString(DbAttributeInstance.NAME));
                //foreach (DbElement spec in spwl.Members())
                //{


                //    //spec.CreateLast(DbElementType.GetElementType("Sele"));


                //    string specname = spec.GetAsString(DbAttributeInstance.NAME);
                //    if (specname.Substring(1, 2) == "/*")
                //        continue;

                //    working_dbelement.Add(spec);
                //    speccnt++;
                //    //Console.WriteLine("   -->스펙]"+spec.GetAsString(DbAttributeInstance.NAME));
                //}
            }
            //MDB.CurrentMDB.GetWork();
        }
Ejemplo n.º 2
0
        private DBElementCollection Get_Element_Collection(DbElement Outfit_Elements, DbElementType [] dbtypes, string search_txt, string modulename)
        {
            DBElementCollection result_collection = null;

            try
            {
                TypeFilter filter      = new TypeFilter(dbtypes);
                AndFilter  finalfilter = new AndFilter();

                AttributeStringFilter filter2 = null;
                AttributeRefFilter    filter3 = null;

                if (search_txt.StartsWith("*") && search_txt.EndsWith("*"))
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.EndsWith, search_txt.Replace("*", ""));
                }
                else if (search_txt.EndsWith("*") && !search_txt.StartsWith("*"))
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.StartsWith, search_txt.Replace("*", ""));
                }
                else if (search_txt.StartsWith("*") && search_txt.EndsWith("*"))
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.Contains, search_txt.Replace("*", ""));
                }
                else
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.Equals, search_txt.Replace("*", ""));
                }
                if (modulename.Trim() != "")
                {
                    filter3 = new AttributeRefFilter(DbAttributeInstance.OWNER, FilterOperator.Equals, DbElement.GetElement("/" + modulename));
                    finalfilter.Add(filter3);
                }

                finalfilter.Add(filter);
                finalfilter.Add(filter2);


                result_collection = new DBElementCollection(Outfit_Elements, finalfilter);
            }

            catch (Exception ee)
            {
                Console.WriteLine("오류");
            }

            return(result_collection);
        }
Ejemplo n.º 3
0
        public DBElementCollection ElementCollectionOfZones()
        {
            TypeFilter            zoneFilter  = new TypeFilter(DbElementTypeInstance.ZONE);
            AttributeStringFilter valueFilter = new AttributeStringFilter(DbAttributeInstance.FUNC, FilterOperator.Equals, "modelcatalogue");

            AndFilter af = new AndFilter(zoneFilter, valueFilter);

            DBElementCollection zones = new DBElementCollection(DbType.Design, af);

            foreach (DbElement item in zones)
            {
                Console.WriteLine(item.GetAsString(DbAttributeInstance.FUNC));
            }
            Console.WriteLine(zones.Count());
            return(zones);
        }
Ejemplo n.º 4
0
        private void CreateSpecification(string connstr, string query, string dept)
        {
            OdbcConnection  conn = new OdbcConnection(connstr);
            OdbcCommand     cmd  = new OdbcCommand(query, conn);
            DataTable       dt   = new DataTable();
            OdbcDataAdapter da   = new OdbcDataAdapter(cmd);

            da.Fill(dt);

            string comp_ref_query = "select * from STD_PDST_COMP_REF_AM";

            cmd.CommandText = comp_ref_query;
            DataTable comp_ref_dt = new DataTable();

            da.SelectCommand = cmd;
            da.Fill(comp_ref_dt);



            DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Catalogue);

            DbElementType[] dbtype      = new DbElementType[] { DbElementTypeInstance.SPWLD };
            TypeFilter      filter      = new TypeFilter(dbtype);
            AndFilter       finalfilter = new AndFilter();

            AttributeStringFilter filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("Description"), FilterOperator.Equals, "HMD_PIPE_SPEC");


            finalfilter.Add(filter);
            finalfilter.Add(filter2);



            DBElementCollection spwl_collects = new DBElementCollection(Outfit_Elements, finalfilter);


            Console.WriteLine("스펙갯수:" + spwl_collects.Cast <DbElement>().Count());

            //dt.Rows.OfType<DataRow>().Where(x => x[1].ToString() == "WB").Count();
            //dt.Rows.OfType<DataRow>().GroupBy(x=>x[11].ToString())
            //var xx =spwl_collects.Cast<DbElement>().Where(x => x.GetAsString(DbAttributeInstance.NAME).Substring(0, 2) == "AA");
            int speccnt = 0;
            List <DbElement> working_dbelement = new List <DbElement>();


            var system_analysis = dt.Rows.OfType <DataRow>().GroupBy(x => x["LINE_NO"], x => x["NOM_DIA"], (lineno, nomdia) => new { lineno, nomdia }).OrderBy(x => x.lineno.ToString());
            int cnt             = 0;

            foreach (var lineno in system_analysis)
            {
                cnt++;
                //if (cnt == 3)
                //    break;
                //스펙생성부분
                //DbElement spec_element = DbElement.GetElement("/PROJ_SPWL").CreateAfter(DbElementTypeInstance.SPECIFICATION);
                string    specname     = dept + "." + lineno.lineno.ToString().Replace(' ', '.');
                DbElement spec_element = null;

                if (DbElement.GetElement("/" + specname).IsNull)
                {
                    spec_element = DbElement.GetElement("/PROJ_SPWL").CreateLast(DbElementTypeInstance.SPECIFICATION);
                    spec_element.SetAttribute(DbAttributeInstance.NAME, "/" + specname);
                    spec_element.SetAttribute(DbAttributeInstance.QUES, "TYPE");
                    spec_element.SetAttribute(DbAttributeInstance.PURP, "PIPE");
                    spec_element.SetAttribute(DbAttributeInstance.DESC, "PROJ.SPEC");
                }

                try
                {
                    //SPEC TEXT 추가
                    DbElement spectext_element = spec_element.CreateLast(DbElementTypeInstance.TEXT);
                    spectext_element.SetAttribute(DbAttributeInstance.NAME, "/" + specname + "." + "PIPINGTEXT");
                    spectext_element.SetAttribute(DbAttributeInstance.STEX, "PIPING");
                    spectext_element.SetAttribute(DbAttributeInstance.RTEX, "PIPING");
                }
                catch (Exception ee) { }

                try
                {
                    foreach (var nomdia in lineno.nomdia)
                    {
                        //Aveva.Pdms.Utilities.Messaging.PdmsException.


                        Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |size: {0} |", nomdia.ToString())).RunInPdms();
                        DataRow[] targetrow = dt.Rows.OfType <DataRow>().Where(row => row["LINE_NO"].ToString() == lineno.lineno.ToString() && row["NOM_DIA"].ToString() == nomdia.ToString()).ToArray();

                        string press = targetrow[0]["PRESS"].ToString();
                        string temp  = targetrow[0]["TEMP"].ToString();

                        string matlspec = targetrow[0]["MATL_SPEC"].ToString();
                        string connspec = targetrow[0]["PIPE_C_TYPE"].ToString() + "/" + targetrow[0]["PIPE_C_STD"].ToString() + "/" + targetrow[0]["PIPE_C_MATL"].ToString();
                        connspec = connspec.Replace("\n", "");
                        string valvespec = targetrow[0]["VALVE_C_TYPE"].ToString();

                        DataRow[] matl_datarow  = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == matlspec).ToArray();
                        DataRow[] conn_datarow  = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == connspec).ToArray();
                        DataRow[] valve_datarow = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == valvespec).ToArray();


                        List <int> diameters = get_dias(nomdia.ToString());

                        //Material Spec생성
                        if (matl_datarow.Count() == 0)
                        {
                            //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError();
                            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} material ref 없음|", matlspec)).RunInPdms();
                        }
                        else
                        {
                            //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError();
                            DbElement material_spec = DbElement.GetElement(matl_datarow[0][1].ToString());
                            string[]  allowtype     = new string[] { "ELBO" };//
                            foreach (DbElement element in material_spec.Members())
                            {
                                if (element.GetElementType().ToString() != "TEXT")
                                {
                                    //if (!allowtype.Contains(element.GetAsString(DbAttributeInstance.TANS)))
                                    //    continue;
                                    //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError();
                                    reculsive_copy_spec(spec_element, element, specname, diameters);
                                }
                            }
                        }
                        //Conn spec 생성
                        if (conn_datarow.Count() == 0)
                        {
                            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} conn ref 없음|", connspec)).RunInPdms();
                        }
                        else
                        {
                            //Gasket 생성
                            DbElement gask_spec = null;
                            if (connspec.Contains("5K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF05/HMDP_SPEC");
                            }
                            else if (connspec.Contains("10K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF10/HMDP_SPEC");
                            }
                            else if (connspec.Contains("16K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF16/HMDP_SPEC");
                            }
                            else if (connspec.Contains("20K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF20/HMDP_SPEC");
                            }
                            else if (connspec.Contains("30K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF30/HMDP_SPEC");
                            }
                            foreach (DbElement element in gask_spec.Members())
                            {
                                reculsive_copy_spec(spec_element, element, specname, diameters);
                            }
                            //Flange Spec
                            DbElement conn_spec = DbElement.GetElement(conn_datarow[0][1].ToString());
                            foreach (DbElement element in conn_spec.Members())
                            {
                                reculsive_copy_spec(spec_element, element, specname, diameters);
                            }
                        }
                        //Valve Spec생성
                        if (valve_datarow.Count() == 0)
                        {
                            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} valve ref 없음|", valvespec).Replace("\n", "")).RunInPdms();
                        }
                        else
                        {
                            DbElement valve_spec = DbElement.GetElement(valve_datarow[0][1].ToString());
                            foreach (DbElement element in valve_spec.Members())
                            {
                                reculsive_copy_spec(spec_element, element, specname, diameters);
                            }
                        }

                        //DbElement conn_spec = DbElement.GetElement("/PFSF30/HMDP_SPEC");
                        //DbElement valve_spec = DbElement.GetElement("/PVVVV10/HMDP_SPEC");


                        //Select 생성
                    }
                }
                catch (Exception ee)
                {
                    Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} 오륭", "11")).RunInPdms();
                    Console.WriteLine("오류:" + ee.Message);
                }
                //break;
            }
            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |뻥뻥2|")).RunInPdms();
            //MDB.CurrentMDB.SaveWork("스펙생성");

            //CurrentElement.Element.Copy(DbElement.GetElement("/ACCOM.(DF)"));
            //DbElement de = CurrentElement.Element.Clone();

            //지정된 Element 뒤에 object생성하는 부분
            //DbElement xx= CurrentElement.Element.CreateAfter(DbElementTypeInstance.SPECIFICATION);
            //xx.SetAttribute(DbAttributeInstance.NAME, "/바보야4");



            //새로운 Element를 만들고 다른object의 하위구조를 모두 복사하는 부분.

            //DbElement xx = CurrentElement.Element.CreateAfter(DbElementTypeInstance.SPECIFICATION);
            //DbCopyOption op=new DbCopyOption();
            //op.ToName="vvd";

            ////DbElement yy= DbElement.GetElement("/ALDJSAFKL");
            //xx.CopyHierarchy(DbElement.GetElement("/ALDJSAFKL"),op);

            //DbCopyOption op = new DbCopyOption();


            // ALDJSAFKL을 복사하는데 /xxx 다음에 만들어서 복사한다.
            //DbElement yy= DbElement.GetElement("/ALDJSAFKL").CreateCopyHierarchyAfter(DbElement.GetElement("/xxx"), op);
            //테스트가 필요하네요

            //삭제
            //DbElement.GetElement("/xxx").Delete();

            //Rename
            //DbElement.GetElement("/보바").SetAttribute(DbAttributeInstance.NAME, "/보바1");

            //CurrentElement.Element.Copy(DbElement.GetElement("/보바1"));
            //MDB.CurrentMDB.SaveWork("여기는 테스트1");
            //



            //foreach (DbElement element in spwl_collects)
            //{
            //    //element.Delete();
            //    DbCopyOption dd= new DbCopyOption();

            //    //dd.ToName="/bbboa";
            //    //DbElement de= element.CreateCopyHierarchyAfter(CurrentElement.Element, dd);
            //    //de.InsertBefore(CurrentElement.Element);
            //    //DbElement xx=DbElement.GetElement("/ACCOM.(DF)");

            //    CurrentElement.Element.InsertAfterLast(xx);
            //    //de.InsertAfterLast(element.Owner);
            //    ////Console.WriteLine("스펙월드]" + spwl.GetAsString(DbAttributeInstance.NAME));
            //    //foreach (DbElement spec in spwl.Members())
            //    //{


            //    //    //spec.CreateLast(DbElementType.GetElementType("Sele"));


            //    //    string specname = spec.GetAsString(DbAttributeInstance.NAME);
            //    //    if (specname.Substring(1, 2) == "/*")
            //    //        continue;

            //    //    working_dbelement.Add(spec);
            //    //    speccnt++;
            //    //    //Console.WriteLine("   -->스펙]"+spec.GetAsString(DbAttributeInstance.NAME));
            //    //}
            //}
            //MDB.CurrentMDB.GetWork();
        }