private void LoveSaveForm_FormClosing(object sender, FormClosingEventArgs e) { DBhelper.CloseCnxn(); }
//点击事件 <=步骤3 private void btnStart_Click(object sender, EventArgs e) { #region 自用字段初始化 diaryList.Clear(); chatList.Clear(); memosList.Clear(); diaries.Clear(); chats.Clear(); memos.Clear(); #endregion btnStart.Text = "若卡住,点我重试!"; AddResult("捕捉核心参数中..."); #region 修改注册表 //修改注册表,阻止"application/x-javascript"型文件被下载 SetRegistryKey(); #endregion #region 获取必要参数 //得到peeruin,diaryTotal,chatTotal GetNecessary(); #endregion AddResult("成功捕获核心参数!"); AddResult($"验证号:{g_tk}"); AddResult($"登陆QQ号:{uin}"); AddResult($"情侣QQ号{peeruin}"); #region 获取需要解析的原始文本 AddResult("开始检索内容...(若卡住,请再次点击上方按钮)"); //获取所有diary记录的json文本 AddResult($"检测到共有情侣日志{diaryTotal}篇,开始解析详细内容..."); GetAllDiaryJson(); AddResult("完成!"); //获取所有chat记录的json文件 AddResult($"检测到共有密语聊天记录{chatTotal}条,开始解析详细内容..."); GetAllChatJson(); AddResult("完成!"); //获取所有memos记录的json文件 AddResult("检测到纪念日信息若干,开始解析详细内容..."); GetAllMemos(); AddResult($"完成!共{memosList.Count}个."); #endregion AddResult("全部解析已完成!开始将数据保存至数据库,并将相关图片保存至本地..."); #region 解析原始文本生成Result btnStart.Text = "保存数据中,请不要结束进程!"; //创建数据库 CopyDatabaseToResult(); //解析diary diaryList.ForEach(str => { JObject jo = JObject.Parse(str); jo.SelectToken("data").Select(p => p).ToList().ForEach(jodata => { Diary d = new Diary(jodata); diaries.Add(d); d.Save(); }); }); //解析chat chatList.ForEach(str => { JObject jo = JObject.Parse(str); jo.SelectToken("data").Select(p => p).ToList().ForEach(jodata => { ChatItem ci = new ChatItem(jodata); chats.Add(ci); ci.SaveToDatabase(); if (ci.hasImage()) { ci.DownloadImageTo(Constant.ChatImageDownloadPath); } }); }); //解析memos memosList.ForEach(str => { JObject jo = JObject.Parse(str); jo.SelectToken("memos").Select(p => p).ToList().ForEach(jodata => { string time = jodata["time"].ToString(); int year = Convert.ToInt32(time.Substring(0, 4)); int month = Convert.ToInt32(time.Substring(5, 2)); int day = Convert.ToInt32(time.Substring(8, 2)); Memos mm = new Memos( jodata["name"].ToString(), year, month, day, jodata["lunar"].ToString().Trim() == "1" ? true : false ); memos.Add(mm); mm.SaveToDatabase(); }); }); #endregion DBhelper.CloseCnxn(); PageHelper ph = new PageHelper(); ph.CreateAll(diaries, chats, memos); #region 打开文件夹供查看 AddResult($"全部工作已完成!!"); AddResult($"{uin}与{peeruin}的情侣空间中包含的主要内容已成功导出并保存到本地!"); MessageBox.Show("导出成功!即将弹出导出结果.", "导出成功!", MessageBoxButtons.OK, MessageBoxIcon.Question); Process.Start("explorer.exe", Constant.ResultPath + "index.html"); #endregion btnStart.Visible = false; btnResult.Visible = true; btnResult.Enabled = true; }