Пример #1
0
    // Use this for initialization
    void Start()
    {
        UTreeNodeData a1111a = new UTreeNodeData(10011111, "a1111a");
        UTreeNodeData a1111  = new UTreeNodeData(1001111, "a1111");
        UTreeNodeData a111   = new UTreeNodeData(100111, "a111");
        UTreeNodeData a11    = new UTreeNodeData(10011, "a11");

        a111.AddChild(a1111);
        a111.AddChild(a1111a);
        a11.AddChild(a111);
        UTreeNodeData a1 = new UTreeNodeData(1001, "a1");

        a1.AddChild(a11);
        UTreeNodeData a2 = new UTreeNodeData(1002, "a2");
        UTreeNodeData a3 = new UTreeNodeData(1003, "a3");
        UTreeNodeData b1 = new UTreeNodeData(2001, "b1");
        UTreeNodeData b2 = new UTreeNodeData(2002, "b2");
        UTreeNodeData b3 = new UTreeNodeData(2003, "b3");
        UTreeNodeData c1 = new UTreeNodeData(3001, "c1");
        UTreeNodeData a  = new UTreeNodeData(1000, "a");

        a.AddChild(a1);
        a.AddChild(a2);
        a.AddChild(a3);
        UTreeNodeData b = new UTreeNodeData(2000, "b");

        b.AddChild(b1);
        b.AddChild(b2);
        b.AddChild(b3);
        UTreeNodeData c = new UTreeNodeData(3000, "c");

        c.AddChild(c1);
        UTreeNodeData d = new UTreeNodeData(4000, "d");
        UTreeNodeData e = new UTreeNodeData(5000, "e");

        data1 = new List <UTreeNodeData>();
        data1.Add(a);
        data1.Add(b);
        data1.Add(c);
        data1.Add(d);
        data1.Add(e);
        //data1.Add(a);

        UTreeNodeData i1 = new UTreeNodeData(4001, "i1");
        UTreeNodeData i  = new UTreeNodeData(4000, "i");

        i.AddChild(i1);
        UTreeNodeData j1 = new UTreeNodeData(5001, "j1");
        UTreeNodeData j  = new UTreeNodeData(5000, "j");

        data2 = new List <UTreeNodeData>();
        data2.Add(i);
        data2.Add(j);
        btn.onClick.AddListener(delegate(){ SetTreeData2(data1); });
    }
Пример #2
0
    public List <UTreeNodeData> GetLevelData()
    {
        floorList = new List <string>();
        #region 查询数据库
        SqliteConnection conn = Tools.Instance.SqlConnection();
        SqliteCommand    cmd  = conn.CreateCommand();
        cmd.CommandText = "Select distinct Layer from ElementDB";
        SqliteDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows)
        {
            while (dr.Read())
            {
                floorList.Add(dr.GetString(0));//得到所有的层数
            }
        }
        #endregion
        UTreeNodeData leveltree = new UTreeNodeData(1, "楼层");
        int           count     = 0;
        foreach (var item in floorList)
        {
            count++;
            UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
            leveltree.AddChild(levelChildNode);
        }
        levelNodeData = new List <UTreeNodeData>();
        levelNodeData.Add(leveltree);

        return(levelNodeData);
    }
Пример #3
0
    private void LevelTreeInit()
    {
        /********读取模型***********/
        //List<string> levelList = new List<string>();
        //foreach (var item in ReadModelXML.idAndLevels.Values)
        //{
        //    if (!levelList.Contains(item))
        //        levelList.Add(item);
        //}
        /********读取模型***********/

        List <string> levelList = new List <string>
        {
            "结构B2层", "结构B1层", "结构1层", "结构2层", "结构3层", "结构4层", "结构5层", "结构6层",
            "结构7层", "结构8层", "结构9层", "结构10层", "结构11层", "结构12层", "结构13层", "结构14层",
            "结构15层", "结构16层", "结构17层", "结构18层", "结构RMF层", "结构RF层", "结构TF层"
        };

        //UTreeNodeData levelChildNode = new UTreeNodeData(2, "结构B2");
        UTreeNodeData leveltree = new UTreeNodeData(1, "楼梯");
        //levelTree.AddChild(levelChildNode);
        int count = 0;

        foreach (var item in levelList)
        {
            count++;
            UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
            leveltree.AddChild(levelChildNode);
        }
        levelData = new List <UTreeNodeData>();
        levelData.Add(leveltree);
    }
Пример #4
0
    private void CompoentTreeInit()
    {
        List <string> compoentList = new List <string>()
        {
            "墙", "梁", "板", "柱", "基础"
        };
        UTreeNodeData compoenttree = new UTreeNodeData(1, "构件");
        int           count        = 0;

        foreach (var item in compoentList)
        {
            count++;
            UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
            compoenttree.AddChild(levelChildNode);
        }
        compoentData = new List <UTreeNodeData>();
        compoentData.Add(compoenttree);
    }
Пример #5
0
    private void CompoentTreeInit()
    {
        #region
        //List<string> compoentList = new List<string>() { "墙", "梁", "板", "柱", "基础" };
        //UTreeNodeData compoenttree = new UTreeNodeData(1, "构件");
        //int count = 0;
        //foreach (var item in compoentList)
        //{
        //    count++;
        //    UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
        //    compoenttree.AddChild(levelChildNode);
        //}
        //compoentData = new List<UTreeNodeData>();
        //compoentData.Add(compoenttree);
        #endregion
        List <string>    compoentList = new List <string>();
        SqliteConnection conn         = new SqliteConnection();
        conn = Tools.Instance.SqlConnection();

        SqliteCommand cmd1 = conn.CreateCommand();
        cmd1.CommandText = "Select distinct GategoryName From Attribute order by Id";
        SqliteDataReader dr = cmd1.ExecuteReader();
        if (dr.HasRows)
        {
            while (dr.Read())
            {
                string temp = dr.GetString(0);

                compoentList.Add(temp);
            }
        }
        UTreeNodeData compoenttree = new UTreeNodeData(1, "构件");
        int           count        = 0;
        foreach (var item in compoentList)
        {
            count++;
            UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
            compoenttree.AddChild(levelChildNode);
        }
        compoentData = new List <UTreeNodeData>();
        compoentData.Add(compoenttree);
    }
Пример #6
0
    private void LevelTreeInit()
    {
        /********读取模型***********/
        List <string>    levelList = new List <string>();
        SqliteConnection conn      = new SqliteConnection();

        conn = Tools.Instance.SqlConnection();

        SqliteCommand cmd1 = conn.CreateCommand();

        cmd1.CommandText = "Select distinct FloorNums From Attribute order by Id";
        SqliteDataReader dr = cmd1.ExecuteReader();

        if (dr.HasRows)
        {
            while (dr.Read())
            {
                string temp = dr.GetString(0);
                // Debug.Log(temp);
                levelList.Add(temp);
            }
        }

        //foreach (var item in ReadModelXML.idAndLevels.Values)
        //{
        //    if (!levelList.Contains(item))
        //        levelList.Add(item);
        //}
        /********读取模型***********/
        UTreeNodeData leveltree = new UTreeNodeData(1, "楼层");

        int count = 0;

        foreach (var item in levelList)
        {
            count++;
            UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
            leveltree.AddChild(levelChildNode);
        }
        levelData = new List <UTreeNodeData>();
        levelData.Add(leveltree);
    }
Пример #7
0
    public List <UTreeNodeData> GetComData()
    {
        List <string> fullCode = new List <string>(); //12位编码
        List <string> nineCode = new List <string>(); //9位编码

        List <string> treeList = new List <string>(); //构件分类集合

        //Dictionary<string, string> xmlNodePathDic = new Dictionary<string, string>();//根据前9位编码得到xml节点路径

        comNodeData = new List <UTreeNodeData>();

        #region 查询数据库和xml清单规则得到一个list<string>  E混凝土及钢筋混凝土工程_E.3现浇混凝土梁_010503002001
        SqliteConnection conn2 = Tools.Instance.SqlConnection();
        SqliteCommand    cmd2  = conn2.CreateCommand();
        cmd2.CommandText = "Select distinct Code from InventoryDB";
        SqliteDataReader dr2 = cmd2.ExecuteReader();
        if (dr2.HasRows)
        {
            while (dr2.Read())
            {
                string temp = dr2.GetString(0);
                fullCode.Add(temp);//得到12位编码
            }
        }

        string tempCode = "";
        foreach (string item in fullCode)
        {
            string code9 = item.Substring(0, 9);
            string it    = item;
            if (code9 != tempCode)
            {
                nineCode.Add(code9);//得到9位编码
                tempCode = code9;
            }
        }
        string str2013 = Resources.Load("国标清单2013").ToString();
        xmldoc = new XmlDocument();
        xmldoc.LoadXml(str2013);


        XmlNodeList node = xmldoc.SelectSingleNode("//工程量计算规范").ChildNodes;
        foreach (XmlNode item in node)               //item D砌筑工程
        {
            foreach (XmlNode it in item.ChildNodes)  //it  D.1砖砌体
            {
                foreach (XmlNode i in it.ChildNodes) // i  砖基础
                {
                    foreach (XmlNode b in i.ChildNodes)
                    {
                        for (int j = 0; j < fullCode.Count; j++)
                        {
                            if (b.InnerText == fullCode[j].Substring(0, 9))
                            {
                                string treeNode = "";

                                treeNode = item.Name + "_" + it.Name + "_" + fullCode[j];
                                string nodePath = "//工程量计算规范//" + item.Name + "//" + it.Name + "//" + i.Name;
                                if (!xmlNodePathDic.ContainsKey(fullCode[j].Substring(0, 9)))
                                {
                                    xmlNodePathDic.Add(fullCode[j].Substring(0, 9), nodePath);//根据9位编码获取Xml节点的路径
                                }
                                if (fullCode[j].Contains(b.InnerText))
                                {
                                    treeList.Add(treeNode);// 存放:  E混凝土及钢筋混凝土工程_E.3现浇混凝土梁_010503002001
                                }
                                //Debug.Log(treeNode);
                                //   break;
                            }
                        }
                    }
                }
            }
        }
        #endregion

        #region
        List <CompoentCount> countList = new List <CompoentCount>();
        int z = 0;
        Debug.Log(treeList.Count);
        foreach (string temptree in treeList)
        {
            z++;
            string        nodeClass = temptree.Split('_')[0];
            string        codeName  = temptree.Split('_')[1];
            string        codeNum   = temptree.Split('_')[2];
            CompoentCount mycount   = new CompoentCount()
            {
                ProjectName = "",
                NodeClass   = nodeClass,
                CodeName    = codeName,
                CodeNum     = codeNum
            };
            countList.Add(mycount);
        }
        var datas = countList.GroupBy(c => new { c.NodeClass }).ToList();
        foreach (var dataA in datas)
        {
            z++;
            UTreeNodeData node0 = new UTreeNodeData(z, dataA.First().NodeClass);
            Debug.Log("0" + dataA.First().NodeClass);
            var item1 = dataA.GroupBy(c => new { c.CodeName }).ToList();
            foreach (var item11 in item1)
            {
                z++;
                UTreeNodeData node1 = new UTreeNodeData(z, item11.First().CodeName); //E.3现浇混凝土梁
                Debug.Log("1" + item11.First().CodeName);
                node0.AddChild(node1);
                var item2 = item11.GroupBy(c => new { c.CodeNum }).ToList();//矩形梁
                foreach (var item22 in item2)
                {
                    z++;
                    UTreeNodeData node2 = new UTreeNodeData(z, item22.First().CodeNum);
                    Debug.Log("2" + item22.First().CodeNum);
                    node1.AddChild(node2);
                }
            }

            comNodeData.Add(node0);
        }

        #endregion

        return(comNodeData);
    }
Пример #8
0
    private void CompoentTreeInit()
    {
        compoentData = new List <UTreeNodeData>();
        path        += "38#结构模型算量信息";
        this._path   = path;
        //ReadComponentXml();
        XmlDocument xml = new XmlDocument();
        //xml.Load(path);
        string s1 = Resources.Load(path).ToString();

        xml.LoadXml(s1);
        List <string>        elementTypes = new List <string>();
        List <CompoentCount> countList    = new List <CompoentCount>();
        //List<CompoentCount> afterList = new List<CompoentCount>();
        Dictionary <string, List <string> > elementsList = new Dictionary <string, List <string> >();
        XmlNode mainNode = xml.SelectSingleNode("算量信息");
        var     nodes    = mainNode.ChildNodes;

        foreach (XmlNode childNode in nodes)
        {
            string  elementId = childNode.Name;
            XmlNode name      = childNode.SelectSingleNode("项目名称");
            XmlNode code      = childNode.SelectSingleNode("项目编码");
            string  codeText  = code.InnerText;
            string  nameText  = name.InnerText;

            if (elementsList.ContainsKey(codeText))
            {
                elementsList[codeText].Add(elementId);
            }
            else
            {
                elementsList.Add(codeText, new List <string>());
                elementsList[codeText].Add(elementId);
                elementTypes.Add(nameText + " " + codeText);
            }
        }
        this._elementList = elementsList;
        elementTypes.Sort();
        //编码规范

        XmlDocument xmlRule = new XmlDocument();

        path = path.Replace("算量信息", "清单规则");
        // xmlRule.Load(path);
        string s2 = Resources.Load(path).ToString();

        xmlRule.LoadXml(s2);
        //List<string> projectNameList = new List<string>();
        //List<string> nodeClassList = new List<string>();
        //List<string> codeNameList = new List<string>();
        //List<string> codeNumList = new List<string>();
        //int i = 0; int j = 0; int k = 0; int l = 0;

        int i = 0;

        foreach (string elementType in elementTypes)
        {
            i++;
            string        temp        = GetCountData(elementType.Split(' ')[1], path);
            string        projectName = temp.Split('$')[0];
            string        nodeClass   = temp.Split('$')[1];
            string        codeName    = elementType.Split(' ')[1];
            string        codeNum     = elementType.Split(' ')[2];
            CompoentCount mycount     = new CompoentCount()
            {
                ProjectName = projectName,
                NodeClass   = nodeClass,
                CodeName    = codeName,
                CodeNum     = codeNum
            };
            countList.Add(mycount);
        }


        var datas = countList.GroupBy(c => new { c.ProjectName }).ToList();

        foreach (var dataA in datas)
        {
            i++;
            UTreeNodeData node0 = new UTreeNodeData(i, dataA.First().ProjectName);
            var           item1 = dataA.GroupBy(c => new { c.NodeClass }).ToList();

            foreach (var item11 in item1)
            {
                i++;
                UTreeNodeData node1 = new UTreeNodeData(i, item11.First().NodeClass);
                node0.AddChild(node1);
                var item2 = item11.GroupBy(c => new { c.CodeName }).ToList();
                foreach (var item22 in item2)
                {
                    i++;
                    UTreeNodeData node2 = new UTreeNodeData(i, item22.First().CodeName);
                    node1.AddChild(node2);
                    var item3 = item22.GroupBy(c => new { c.CodeNum }).ToList();

                    foreach (var item33 in item3)
                    {
                        i++;
                        UTreeNodeData node3 = new UTreeNodeData(i, item33.First().CodeNum);
                        node2.AddChild(node3);
                    }
                }
            }
            compoentData.Add(node0);
        }

        //compoentTree.SetDataProvider(compoentData);
    }
Пример #9
0
    private void LevelTreeInit()
    {
        compoentData = new List <UTreeNodeData>();
        List <string>    levelList = new List <string>();
        SqliteConnection conn      = Tools.Instance.SqlConnection();
        SqliteCommand    cmd       = conn.CreateCommand();

        cmd.CommandText = "Select distinct Layer from ElementDB";
        SqliteDataReader dr = cmd.ExecuteReader();

        if (dr.HasRows)
        {
            while (dr.Read())
            {
                floorNum.Add(dr.GetString(0));//得到所有的层数
            }
        }

        int num = floorNum.Count;
        SqliteConnection conn2 = Tools.Instance.SqlConnection();
        SqliteCommand    cmd2  = conn2.CreateCommand();

        cmd2.CommandText = "Select distinct Code from InventoryDB";
        SqliteDataReader dr2 = cmd2.ExecuteReader();

        if (dr2.HasRows)
        {
            while (dr2.Read())
            {
                string temp = dr2.GetString(0);
                fullCode.Add(temp);//得到12位编码
            }
        }

        string tempCode = "";

        foreach (string item in fullCode)
        {
            string code9 = item.Substring(0, 9);
            string it    = item;
            if (code9 != tempCode)
            {
                nineCode.Add(code9);//得到9位编码
                tempCode = code9;
            }
        }
        string str2013 = Resources.Load("国标清单2013").ToString();

        xmldoc = new XmlDocument();
        xmldoc.LoadXml(str2013);


        XmlNodeList node = xmldoc.SelectSingleNode("//工程量计算规范").ChildNodes;

        foreach (XmlNode item in node)               //item D砌筑工程
        {
            foreach (XmlNode it in item.ChildNodes)  //it  D.1砖砌体
            {
                foreach (XmlNode i in it.ChildNodes) // i  砖基础
                {
                    foreach (XmlNode b in i.ChildNodes)
                    {
                        for (int j = 0; j < fullCode.Count; j++)
                        {
                            if (b.InnerText == fullCode[j].Substring(0, 9))
                            {
                                string treeNode = "";

                                treeNode = item.Name + "_" + it.Name + "_" + fullCode[j];
                                string nodePath = "//工程量计算规范//" + item.Name + "//" + it.Name + "//" + i.Name;
                                if (!xmlNodePathDic.ContainsKey(fullCode[j].Substring(0, 9)))
                                {
                                    xmlNodePathDic.Add(fullCode[j].Substring(0, 9), nodePath);//根据9位编码获取Xml节点的路径
                                }


                                if (fullCode[j].Contains(b.InnerText))
                                {
                                    treeList.Add(treeNode);// 存放:  E混凝土及钢筋混凝土工程_E.3现浇混凝土梁_010503002001
                                }

                                //Debug.Log(treeNode);
                                //   break;
                            }
                        }
                    }
                }
            }
        }
        List <CompoentCount> countList = new List <CompoentCount>();
        int z = 0;

        Debug.Log(treeList.Count);
        foreach (string temptree in treeList)
        {
            z++;
            string        nodeClass = temptree.Split('_')[0];
            string        codeName  = temptree.Split('_')[1];
            string        codeNum   = temptree.Split('_')[2];
            CompoentCount mycount   = new CompoentCount()
            {
                ProjectName = "",
                NodeClass   = nodeClass,
                CodeName    = codeName,
                CodeNum     = codeNum
            };
            countList.Add(mycount);
        }
        var datas = countList.GroupBy(c => new { c.NodeClass }).ToList();

        foreach (var dataA in datas)
        {
            z++;
            UTreeNodeData node0 = new UTreeNodeData(z, dataA.First().NodeClass);
            Debug.Log("0" + dataA.First().NodeClass);
            var item1 = dataA.GroupBy(c => new { c.CodeName }).ToList();
            foreach (var item11 in item1)
            {
                z++;
                UTreeNodeData node1 = new UTreeNodeData(z, item11.First().CodeName); //E.3现浇混凝土梁
                Debug.Log("1" + item11.First().CodeName);
                node0.AddChild(node1);
                var item2 = item11.GroupBy(c => new { c.CodeNum }).ToList();//矩形梁
                foreach (var item22 in item2)
                {
                    z++;
                    UTreeNodeData node2 = new UTreeNodeData(z, item22.First().CodeNum);
                    Debug.Log("2" + item22.First().CodeNum);
                    node1.AddChild(node2);
                }
            }

            compoentData.Add(node0);
        }


        //foreach (var item in ReadModelXML.idAndLevels.Values)
        //{
        //    if (!levelList.Contains(item))
        //        levelList.Add(item);
        //}
        //List<string> levelList = new List<string>
        //{
        //  "结构B2","结构B1","结构1","结构2","结构3","结构4","结构5","结构6",
        //  "结构7","结构8","结构9","结构10","结构11","结构12","结构13","结构14",
        //  "结构15","结构16","结构17","结构18","结构RMF","结构RF","结构TF"
        //};

        //UTreeNodeData levelChildNode = new UTreeNodeData(2, "结构B2");
        UTreeNodeData leveltree = new UTreeNodeData(1, "楼层");
        //levelTree.AddChild(levelChildNode);
        int count = 0;

        foreach (var item in floorNum)
        {
            count++;
            UTreeNodeData levelChildNode = new UTreeNodeData(count, item);
            leveltree.AddChild(levelChildNode);
        }
        levelData = new List <UTreeNodeData>();
        levelData.Add(leveltree);
    }