Esempio n. 1
0
        /// <summary>
        /// 根据信息获取活创建对应的Model节点信息
        /// </summary>
        /// <param name="org"></param>
        /// <returns></returns>
        private ITreeNodeModel GetOrCreateCacheOrgsNode(NodeInfoFromDB org)
        {
            ITreeNodeModel model;

            if (!_cacheOrgs.TryGetValue(org.Index, out model))
            {
                model = _trans.TransFromNodeInfo(org);
                _cacheOrgs.Add(org.Index, model);
            }
            return(model);
        }
Esempio n. 2
0
 public ITreeNodeModel TransFromNodeInfo(NodeInfoFromDB info)
 {
     throw new NotImplementedException();
 }
Esempio n. 3
0
        public void CreateFile()
        {
            StringBuilder sb      = new StringBuilder();
            List <int>    liCount = new List <int> {
                30, 20, 20, 20
            };                                                   //每个节点的子节点数量
            //根  zhongguo 中国 1
            NodeInfoFromDB root = new NodeInfoFromDB {
                ParentIndex = "0", Index = "1", Name = "中国"
            };

            List <string> liProvinceName = new List <string> {
                "浙江", "杭州", "萧山", "西兴"
            };
            List <string> liNodeIndex = new List <string> {
                "zhejiang", "hangzhou", "xiaoshan", "xixing"
            };
            List <List <NodeInfoFromDB> > matrix = new List <List <NodeInfoFromDB> >();

            matrix.Add(new List <NodeInfoFromDB> {
                root
            });

            //先添加第一层
            List <NodeInfoFromDB> listFirst = new List <NodeInfoFromDB>();//z浙江01到30

            for (int j = 1; j < liCount[0] + 1; ++j)
            {
                var temp = new NodeInfoFromDB {
                    Index = liNodeIndex[0] + j.ToString().PadLeft(2, '0'), Name = liProvinceName[0] + j.ToString().PadLeft(2, '0'), ParentIndex = "1"
                };
                listFirst.Add(temp);
            }
            matrix.Add(listFirst);

            List <NodeInfoFromDB> listRow = new List <NodeInfoFromDB>(listFirst);//当前行

            for (int i = 1; i < liProvinceName.Count; ++i)
            {
                List <NodeInfoFromDB> listTemp = new List <NodeInfoFromDB>();//下一行
                foreach (var item in listRow)
                {
                    for (int jk = 1; jk < liCount[i] + 1; ++jk)
                    {
                        var temp = new NodeInfoFromDB
                        {
                            Index       = item.Index.Replace(liNodeIndex[i - 1], liNodeIndex[i]) + jk.ToString().PadLeft(2, '0'),
                            Name        = item.Name.Replace(liProvinceName[i - 1], liProvinceName[i]) + jk.ToString().PadLeft(2, '0'),
                            ParentIndex = item.Index
                        };
                        listTemp.Add(temp);
                    }
                }
                listRow = new List <NodeInfoFromDB>(listTemp);
                matrix.Add(listTemp);
            }



            foreach (var line in matrix)
            {
                foreach (var cell in line)
                {
                    sb.AppendLine(string.Format("{0}&{1}&{2}", cell.Index, cell.Name, cell.ParentIndex));
                }
            }
            System.IO.File.WriteAllText("1.txt", sb.ToString());
        }