Ejemplo n.º 1
0
        void Run()
        {
            var saveBase = textBox1.Text;

            WeChatInterface.ILogger logger = new Logger(this.listBox1);
            bool   toHtml    = radioButton3.Checked;
            string indexPath = Path.Combine(saveBase, "index.html");

            WeChatInterface.Export(((IPhoneBackup)comboBox1.SelectedItem).path, saveBase, indexPath, toHtml, files92, logger);

            try
            {
                if (toHtml)
                {
                    System.Diagnostics.Process.Start(indexPath);
                }
            }
            catch (Exception) { }
            groupBox1.Enabled = groupBox3.Enabled = groupBox4.Enabled = true;
            button2.Enabled   = true;

            MessageBox.Show("处理完成", "提示");
        }
Ejemplo n.º 2
0
        void Run()
        {
            var saveBase = textBox1.Text;        //读取文本框中的保存地址

            Directory.CreateDirectory(saveBase); //创建这个文件夹 该函数为创建多级文件夹
            AddLog("分析文件夹结构");
            //((IPhoneBackup)comboBox1.SelectedItem).path  找到苹果备份的文件夹的绝对路径

            wechat = new WeChatInterface(((IPhoneBackup)comboBox1.SelectedItem).path, files92);
            wechat.BuildFilesDictionary();
            AddLog("查找UID");
            var UIDs = wechat.FindUIDs();

            AddLog("找到" + UIDs.Count + "个账号的消息记录");
            var uidList = new List <DisplayItem>();

            foreach (var uid in UIDs)
            {
                var userBase = Path.Combine("Documents", uid);
                AddLog("开始处理UID: " + uid);
                AddLog("读取账号信息");
                if (wechat.GetUserBasics(uid, userBase, out Friend myself))
                {
                    AddLog("微信号:" + myself.ID() + " 昵称:" + myself.DisplayName());
                }
                else
                {
                    AddLog("没有找到本人信息,用默认值替代");
                }
                var userSaveBase = Path.Combine(saveBase, myself.ID());
                Directory.CreateDirectory(userSaveBase);
                AddLog("正在打开数据库");
                if (!wechat.OpenMMSqlite(userBase, out SQLiteConnection conn))//conn
                {
                    AddLog("打开MM.sqlite失败,跳过");
                    continue;
                }
                if (wechat.OpenWCDBContact(userBase, out SQLiteConnection wcdb))//wcdb
                {
                    AddLog("存在WCDB,与旧版好友列表合并使用");
                }
                AddLog("读取好友列表");
                if (!wechat.GetFriendsDict(conn, wcdb, myself, out Dictionary <string, Friend> friends, out int friendcount))
                {
                    AddLog("读取好友列表失败,跳过");
                    continue;
                }
                AddLog("找到" + friendcount + "个好友/聊天室");
                AddLog("查找对话");
                wechat.GetChatSessions(conn, out List <string> chats);
                AddLog("找到" + chats.Count + "个对话");
                var emojidown = new HashSet <DownloadTask>();
                var chatList  = new List <DisplayItem>();
                foreach (var chat in chats)
                {
                    var    hash = chat;
                    string displayname = chat, id = displayname;
                    Friend friend = null;
                    if (friends.ContainsKey(hash))
                    {
                        friend      = friends[hash];
                        displayname = friend.DisplayName();
                        AddLog("处理与" + displayname + "的对话");
                        id = friend.ID();
                    }
                    else
                    {
                        AddLog("未找到好友信息,用默认名字代替");
                    }
                    if (radioButton4.Checked)
                    {
                        if (wechat.SaveTextRecord(conn, Path.Combine(userSaveBase, id + ".txt"), displayname, id, myself, chat, friend, friends, out int count))
                        {
                            AddLog("成功处理" + count + "条");
                        }
                        else
                        {
                            AddLog("失败");
                        }
                    }
                    else if (radioButton3.Checked)
                    {
                        if (wechat.SaveHtmlRecord(conn, userBase, userSaveBase, displayname, id, myself, chat, friend, friends, out int count, out HashSet <DownloadTask> _emojidown))
                        {
                            AddLog("成功处理" + count + "条");
                            chatList.Add(new DisplayItem()
                            {
                                pic = "Portrait/" + (friend != null ? friend.FindPortrait() : "*****@*****.**"), text = displayname, link = id + ".html"
                            });
                        }
                        else
                        {
                            AddLog("失败");
                        }
                        emojidown.UnionWith(_emojidown);
                    }
                }
                conn.Close();
                if (radioButton3.Checked)
                {
                    wechat.MakeListHTML(chatList, Path.Combine(userSaveBase, "聊天记录.html"));
                }
                var portraitdir = Path.Combine(userSaveBase, "Portrait");
                Directory.CreateDirectory(portraitdir);
                var downlist = new HashSet <DownloadTask>();
                foreach (var item in friends)
                {
                    var tfriend = item.Value;
                    if (!tfriend.PortraitRequired)
                    {
                        continue;
                    }
                    if (tfriend.Portrait != null && tfriend.Portrait != "")
                    {
                        downlist.Add(new DownloadTask()
                        {
                            url = tfriend.Portrait, filename = tfriend.ID() + ".jpg"
                        });
                    }
                    //if (tfriend.PortraitHD != null && tfriend.PortraitHD != "") downlist.Add(new DownloadTask() { url = tfriend.PortraitHD, filename = tfriend.ID() + "_hd.jpg" });
                }
                var downloader = new Downloader(6);
                if (downlist.Count > 0)
                {
                    AddLog("下载" + downlist.Count + "个头像");
                    foreach (var item in downlist)
                    {
                        downloader.AddTask(item.url, Path.Combine(portraitdir, item.filename));
                    }
                    try
                    {
                        File.Copy("res\\[email protected]", Path.Combine(portraitdir, "*****@*****.**"));
                    }
                    catch (Exception) { }
                }
                var emojidir = Path.Combine(userSaveBase, "Emoji");
                Directory.CreateDirectory(emojidir);
                if (emojidown != null && emojidown.Count > 0)
                {
                    AddLog("下载" + emojidown.Count + "个表情");
                    foreach (var item in emojidown)
                    {
                        downloader.AddTask(item.url, Path.Combine(emojidir, item.filename));
                    }
                }
                uidList.Add(new DisplayItem()
                {
                    pic = myself.ID() + "/Portrait/" + myself.FindPortrait(), text = myself.DisplayName(), link = myself.ID() + "/聊天记录.html"
                });
                downloader.StartDownload();
                downloader.WaitToEnd();
                AddLog("完成当前账号");
            }
Ejemplo n.º 3
0
        void run()
        {
            var saveBase = textBox1.Text;

            Directory.CreateDirectory(saveBase);
            AddLog("分析文件夹结构");
            wechat = new WeChatInterface(currentBackup, files92);
            wechat.BuildFilesDictionary(weixinapp);
            AddLog("查找UID");
            var UIDs = wechat.FindUIDs();

            AddLog("找到" + UIDs.Count + "个账号的消息记录");
            foreach (var uid in UIDs)
            {
                var userBase = Path.Combine("Documents", uid);
                AddLog("开始处理UID: " + uid);
                AddLog("读取账号信息");
                Friend myself;
                if (wechat.GetUserBasics(uid, userBase, out myself))
                {
                    AddLog("微信号:" + myself.ID() + " 昵称:" + myself.DisplayName());
                }
                else
                {
                    AddLog("没有找到本人信息,用默认值替代");
                }
                var userSaveBase = Path.Combine(saveBase, myself.ID());
                Directory.CreateDirectory(userSaveBase);
                AddLog("正在打开数据库");
                SQLiteConnection conn, wcdb;
                if (!wechat.OpenMMSqlite(userBase, out conn))
                {
                    AddLog("打开MM.sqlite失败,跳过");
                    continue;
                }
                if (wechat.OpenWCDBContact(userBase, out wcdb))
                {
                    AddLog("存在WCDB,与旧版好友列表合并使用");
                }
                AddLog("读取好友列表");
                Dictionary <string, Friend> friends;
                int friendcount;
                if (!wechat.GetFriendsDict(conn, wcdb, myself, out friends, out friendcount))
                {
                    AddLog("读取好友列表失败,跳过");
                    continue;
                }
                AddLog("找到" + friendcount + "个好友/聊天室");
                AddLog("查找对话");
                List <string> chats;
                wechat.GetChatSessions(conn, out chats);
                AddLog("找到" + chats.Count + "个对话");
                var emojidown = new HashSet <DownloadTask>();
                foreach (var chat in chats)
                {
                    var    hash = chat;
                    string displayname = chat, id = displayname;
                    Friend friend = null;
                    if (friends.ContainsKey(hash))
                    {
                        friend      = friends[hash];
                        displayname = friend.DisplayName();
                        AddLog("处理与" + displayname + "的对话");
                        id = friend.ID();
                    }
                    else
                    {
                        AddLog("未找到好友信息,用默认名字代替");
                    }
                    if (radioButton4.Checked)
                    {
                        int count;
                        if (wechat.SaveTextRecord(conn, Path.Combine(userSaveBase, id + ".txt"), displayname, id, myself, chat, friend, friends, out count))
                        {
                            AddLog("成功处理" + count + "条");
                        }
                        else
                        {
                            AddLog("失败");
                        }
                    }
                    else if (radioButton3.Checked)
                    {
                        int count;
                        HashSet <DownloadTask> _emojidown;
                        if (wechat.SaveHtmlRecord(conn, userBase, userSaveBase, displayname, id, myself, chat, friend, friends, out count, out _emojidown))
                        {
                            AddLog("成功处理" + count + "条");
                        }
                        else
                        {
                            AddLog("失败");
                        }
                        emojidown.UnionWith(_emojidown);
                    }
                }

                var portraitdir = Path.Combine(userSaveBase, "Portrait");
                Directory.CreateDirectory(portraitdir);
                var downlist = new HashSet <DownloadTask>();
                foreach (var item in friends)
                {
                    var tfriend = item.Value;
                    if (!tfriend.PortraitRequired)
                    {
                        continue;
                    }
                    if (tfriend.Portrait != null && tfriend.Portrait != "")
                    {
                        downlist.Add(new DownloadTask()
                        {
                            url = tfriend.Portrait, filename = tfriend.ID() + ".jpg"
                        });
                    }
                    //if (tfriend.PortraitHD != null && tfriend.PortraitHD != "") downlist.Add(new DownloadTask() { url = tfriend.PortraitHD, filename = tfriend.ID() + "_hd.jpg" });
                }
                var downloader = new Downloader(6);
                if (downlist.Count > 0)
                {
                    AddLog("下载" + downlist.Count + "个头像");
                    foreach (var item in downlist)
                    {
                        downloader.AddTask(item.url, Path.Combine(portraitdir, item.filename));
                    }
                    try
                    {
                        File.Copy("*****@*****.**", Path.Combine(portraitdir, "*****@*****.**"));
                    }
                    catch (Exception) { }
                }
                var emojidir = Path.Combine(userSaveBase, "Emoji");
                Directory.CreateDirectory(emojidir);
                if (emojidown != null && emojidown.Count > 0)
                {
                    AddLog("下载" + emojidown.Count + "个表情");
                    foreach (var item in emojidown)
                    {
                        downloader.AddTask(item.url, Path.Combine(emojidir, item.filename));
                    }
                }
                downloader.StartDownload();
                downloader.WaitToEnd();
                AddLog("完成当前账号");
            }
            AddLog("任务结束");
            groupBox1.Enabled = groupBox3.Enabled = groupBox4.Enabled = true;
            button2.Enabled   = true;
            wechat            = null;
            MessageBox.Show("处理完成");
        }