private WechatSearchInfo CreateSearchInfoWithAccountNode(string srcPageDir, PhMenuNode accountNode)
        {
            var aNewInfo = new WechatSearchInfo();

            aNewInfo.Account = Regex.Match(accountNode.Name, @"(.*)/.*").Groups[1].Value;
            if (string.IsNullOrEmpty(aNewInfo.Account))
            {
                aNewInfo.Account = Regex.Match(accountNode.Name, @"(.*)-.*").Groups[1].Value;
            }
            aNewInfo.StartFile = Path.Combine(srcPageDir, Regex.Match(accountNode.Url, @".*\.html").Value);

            if (accountNode.Childs.First(p => p.Name.Contains("通讯录")).Childs.Count(p => p.Name.Contains("好友列表")) > 0)
            {
                var friendNode = accountNode.Childs.First(p => p.Name.Contains("通讯录")).Childs.First(p => p.Name.Contains("好友列表"));
                aNewInfo.FriendsFiles = MakeFilesPath(srcPageDir, accountNode.Childs.First(p => p.Name.Contains("通讯录")), friendNode);
            }

            if (accountNode.Childs.Count(p => p.Name.Contains("群成员列表")) > 0)
            {
                var groupNode = accountNode.Childs.First(p => p.Name.Contains("群成员列表"));
                aNewInfo.GroupsFiles = MakeFilesPath(srcPageDir, accountNode, groupNode);
            }

            return(aNewInfo);
        }
Ejemplo n.º 2
0
        private PhMenuNode GetTheNodeWithMatch(Match aMatch)
        {
            var newPhMenuNode = new PhMenuNode();

            newPhMenuNode.Id   = aMatch.Groups[1].Value;
            newPhMenuNode.Name = Encoding.UTF8.GetString(Convert.FromBase64String(aMatch.Groups[2].Value));
            newPhMenuNode.Url  = aMatch.Groups[3].Value;
            newPhMenuNode.Icon = aMatch.Groups[4].Value;

            return(newPhMenuNode);
        }
        private List <string> MakeFilesPath(string srcPageDir, PhMenuNode parentNode, PhMenuNode aNode)
        {
            var startNumber = Convert.ToInt32(Regex.Match(aNode.Url, @"Contents(\d*)\.html").Groups[1].Value);
            var endNumber   = Convert.ToInt32(Regex.Match(parentNode.Childs[parentNode.Childs.IndexOf(aNode) + 1].Url, @"(Contents)(\d*)\.html").Groups[2].Value);
            var baseDir     = Path.Combine(srcPageDir, Regex.Match(aNode.Url, @"(Contents)(\d*)\.html").Groups[1].Value + "{0}.html");;

            var listString = new List <string>();

            for (var i = startNumber; i <= endNumber; i++)
            {
                listString.Add(string.Format(baseDir, i));
            }

            return(listString);
        }
        private WechatSearchInfo CreateSearchInfoWithAccountNode(string srcPageDir, PhMenuNode accountNode)
        {
            var aNewInfo = new WechatSearchInfo();

            aNewInfo.Account   = Regex.Match(accountNode.Name, @"账号:(.*)\(.*\)").Groups[1].Value;
            aNewInfo.StartFile = Path.Combine(srcPageDir, Regex.Match(accountNode.Url, @".*\.html").Value);

            var friendNode = accountNode.Childs.First(p => p.Name.Contains("好友统计"));
            var groupNode  = accountNode.Childs.First(p => p.Name.Contains("群联系人"));

            aNewInfo.FriendsFiles = MakeFilesPath(srcPageDir, accountNode, friendNode);
            aNewInfo.GroupsFiles  = MakeFilesPath(srcPageDir, accountNode, groupNode);

            return(aNewInfo);
        }
Ejemplo n.º 5
0
        private PhMenuNode GetNodeChilds(string menuFileContent, PhMenuNode parentNode, string regexInfo)
        {
            var matchResults = Regex.Matches(menuFileContent, regexInfo.Replace("_id", parentNode.Id));
            var phMenuNodes  = new List <PhMenuNode>();

            foreach (Match aMatchResult in matchResults)
            {
                var newPhMenuNode = GetTheNodeWithMatch(aMatchResult);
                GetNodeChilds(menuFileContent, newPhMenuNode, regexInfo);

                phMenuNodes.Add(newPhMenuNode);
            }
            parentNode.Childs = phMenuNodes;

            return(parentNode);
        }