Browse Source

fix 调整代码结构

ps:长时间陷入公司项目泥潭,日夜不得休,心心念完善这个项目,无奈分身乏术,期待2019有大把空闲时间,来完善
一入IT深似海,从此假期是路人
祝小伙伴们 2019 安好
zhangtaotao 5 years ago
parent
commit
2e20e703cc
20 changed files with 63230 additions and 17 deletions
  1. 2 0
      .gitignore
  2. 1 1
      WeChatCore/Common/MethodsHelper.cs
  3. 1 1
      WeChatCore/DefineClass/ConfigDefine.cs
  4. 16 15
      WeChatCore/WeChat.cs
  5. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/Newtonsoft.Json.9.0.1.nupkg
  6. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.dll
  7. 9793 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.xml
  8. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.dll
  9. 8922 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.xml
  10. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.dll
  11. 9229 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.xml
  12. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.dll
  13. 9229 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.xml
  14. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
  15. 8756 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
  16. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll
  17. 8409 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml
  18. BIN
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll
  19. 8756 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml
  20. 116 0
      sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/tools/install.ps1

+ 2 - 0
.gitignore

@@ -93,3 +93,5 @@ sample/EasyWeChatClient/EasyWeChatClient/obj/Debug/TempPE/Properties.Resources.D
 /WeChatCore/.vs/WeChatCore/v15/Server/sqlite3/storage.ide
 /WeChatCore/.vs/WeChatCore/v15/Server/sqlite3/storage.ide-shm
 /WeChatCore/.vs/WeChatCore/v15/Server/sqlite3/storage.ide-wal
+/WeChatCore/obj/x64/Debug/DesignTimeResolveAssemblyReferencesInput.cache
+/WeChatCore/obj/Debug/WeChatCore.csprojAssemblyReference.cache

+ 1 - 1
WeChatCore/Common/MethodsHelper.cs

@@ -98,7 +98,7 @@ namespace WeChatCore.Common
             return EncryptWithMD5(NickName);
         }
         /// <summary>
-        /// 生成本地MP3文件
+        /// 判断当前路径是否存在,不存在生成路径并返回一个UUID的文件名
         /// </summary>
         /// <param name="UserName">当前用户名</param>
         /// <returns>返回文件是UUID</returns>

+ 1 - 1
WeChatCore/DefineClass/ConfigDefine.cs

@@ -24,7 +24,7 @@ namespace WeChatCore.DefineClass
             return DirectoryPath;
         }
         /// <summary>
-        /// 微信群日志
+        /// 自动回复配置文件
         /// </summary>
         public static string WeChatAutoReplyPath
         {

+ 16 - 15
WeChatCore/WeChat.cs

@@ -144,6 +144,7 @@ namespace WeChatCore
                     string XmlList = HttpMethods.Get(UrlDefine.LoginUrls, CommonDefine.Cookies, Encoding.UTF8, true).ContentData.ToString();
                     CommonDefine.GetCookieDictionary = HttpMethods.SetCookieDictionary;
                     CommonDefine.LoginResult = XMLHelper.DESerializer<LoginResultEntity>(XmlList);
+                    //此处可用于二次点击登录
                     LogWriter.Write(CommonDefine.LoginResult.wxuin, Environment.CurrentDirectory + "\\Data\\data.dat");
                     Random r = new Random();
                     BaseRequestEntity Bre = new BaseRequestEntity() { Uin = CommonDefine.LoginResult.wxuin, Sid = CommonDefine.LoginResult.wxsid, Skey = CommonDefine.LoginResult.skey, DeviceID = MethodsHelper.GetDeviceId() };
@@ -505,7 +506,7 @@ namespace WeChatCore
 
                     #region 储存消息
 
-                    if (ali.MsgType == 34)
+                    if (ali.MsgType == (int)MsgTypeEnum.Voice)
                     {
                         me.MsgType = MsgTypeEnum.Voice;
                         //语音消息
@@ -517,7 +518,7 @@ namespace WeChatCore
                         me.FileId = FileId;
                         me.FilePath = Environment.CurrentDirectory + "\\" + DirectoryDefine.VoiceMsgPath + "\\" + me.FileId + ".mp3";
                     }
-                    else if (ali.MsgType == 3)
+                    else if (ali.MsgType == (int)MsgTypeEnum.Picture)
                     {
                         me.MsgType = MsgTypeEnum.Picture;
                         //图片消息
@@ -534,7 +535,7 @@ namespace WeChatCore
                         me.FilePath = Environment.CurrentDirectory + "\\" + DirectoryDefine.ImageMsgPath + "\\" + FileId + ".jpg";//
                         me.FileTempPath = Environment.CurrentDirectory + "\\" + DirectoryDefine.ImageMsgTempPath + "\\" + FileId + ".jpg";
                     }
-                    else if (ali.MsgType == 49)
+                    else if (ali.MsgType == (int)MsgTypeEnum.Gif)
                     {
                         //TODO:GIF消息
                         me.MsgType = MsgTypeEnum.Gif;
@@ -548,7 +549,7 @@ namespace WeChatCore
                         me.FilePath = Environment.CurrentDirectory + "\\" + DirectoryDefine.ImageMsgGifPath + "\\" + FileId + ".gif";//
                         me.FileTempPath = Environment.CurrentDirectory + "\\" + DirectoryDefine.ImageMsgTempPath + "\\" + FileId + ".jpg";
                     }
-                    else if (ali.MsgType == 43)
+                    else if (ali.MsgType == (int)MsgTypeEnum.Video)
                     {
                         me.MsgType = MsgTypeEnum.Video;
                         //视频消息
@@ -576,7 +577,7 @@ namespace WeChatCore
                         me.FilePath = Environment.CurrentDirectory + "\\" + DirectoryDefine.MapImageMsgPath + "\\" + FileId + ".jpg";
                         me.MsgTime = DateTime.Now;
                     }
-                    else if (ali.MsgType == 10000)
+                    else if (ali.MsgType == (int)MsgTypeEnum.SystemMsg)
                     {
                         me.MsgType = MsgTypeEnum.SystemMsg;
                         me.MsgTime = DateTime.Now;
@@ -594,7 +595,7 @@ namespace WeChatCore
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.Message);
+                LogWriter.Write(ex.Message, LogPathDefine.ExceptionLogPath);
             }
 
         }
@@ -763,17 +764,17 @@ namespace WeChatCore
             Fe.BaseRequest = new BaseRequestEntity() { DeviceID = MethodsHelper.GetDeviceId(), Uin = CommonDefine.LoginResult.wxuin, Sid = CommonDefine.LoginResult.wxsid, Skey = CommonDefine.LoginResult.skey };
             string Boundary = "------WebKitFormBoundaryUOlSZtOip6JP4NSr";
             HttpMethods.AddContent("id", "WU_FILE_0", Boundary);
-            HttpMethods.AddContent("name", Fe.FileName,  Boundary);
-            HttpMethods.AddContent("type", Fe.FileType,  Boundary);
+            HttpMethods.AddContent("name", Fe.FileName, Boundary);
+            HttpMethods.AddContent("type", Fe.FileType, Boundary);
             HttpMethods.AddContent("lastModifiedDate", Fe.FileModiftTime.ToLocalTime().ToString(), Boundary);
-            HttpMethods.AddContent("size", Fe.DataLen.ToString(),  Boundary);
-            HttpMethods.AddContent("mediatype", Fe.Mediatype1,  Boundary);
-            HttpMethods.AddContent("uploadmediarequest",  JsonConvert.SerializeObject(Fe),  Boundary);
+            HttpMethods.AddContent("size", Fe.DataLen.ToString(), Boundary);
+            HttpMethods.AddContent("mediatype", Fe.Mediatype1, Boundary);
+            HttpMethods.AddContent("uploadmediarequest", JsonConvert.SerializeObject(Fe), Boundary);
             HttpMethods.AddContent("webwx_data_ticket", CommonDefine.GetCookieDictionary == null ? "" : CommonDefine.GetCookieDictionary["webwx_data_ticket"], Boundary);//"gScOa2YvEEtszEvhoxdwXCeg"
-            HttpMethods.AddContent("pass_ticket", CommonDefine.LoginResult.pass_ticket,  Boundary);//"ekYYf2P7xOH5iI+oYrf/GiGrZhE+fUEGMiXe3Pq71rb4MDe+7ICbD+kglD4ZE+Ey"
-            HttpMethods.AddContent("filename", Fe.FileName, Fe.FileType, FileData,  Boundary);
-            HttpMethods.OptionsDataMulitData(UrlDefine.SendFileUrl, CommonDefine.Cookies, Encoding.UTF8,Boundary);
-            HttpMethods.PostDataMulitData(UrlDefine.SendFileUrl, CommonDefine.Cookies, Encoding.UTF8,Boundary);
+            HttpMethods.AddContent("pass_ticket", CommonDefine.LoginResult.pass_ticket, Boundary);//"ekYYf2P7xOH5iI+oYrf/GiGrZhE+fUEGMiXe3Pq71rb4MDe+7ICbD+kglD4ZE+Ey"
+            HttpMethods.AddContent("filename", Fe.FileName, Fe.FileType, FileData, Boundary);
+            HttpMethods.OptionsDataMulitData(UrlDefine.SendFileUrl, CommonDefine.Cookies, Encoding.UTF8, Boundary);
+            HttpMethods.PostDataMulitData(UrlDefine.SendFileUrl, CommonDefine.Cookies, Encoding.UTF8, Boundary);
         }
         #endregion
 

BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/Newtonsoft.Json.9.0.1.nupkg


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 9793 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.xml


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 8922 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.xml


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 9229 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.xml


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 9229 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.xml


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 8756 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.xml


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 8409 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml


BIN
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 8756 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml


+ 116 - 0
sample/EasyWeChatClient/packages/Newtonsoft.Json.9.0.1/tools/install.ps1

@@ -0,0 +1,116 @@
+param($installPath, $toolsPath, $package, $project)
+
+# open json.net splash page on package install
+# don't open if json.net is installed as a dependency
+
+try
+{
+  $url = "http://www.newtonsoft.com/json/install?version=" + $package.Version
+  $dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
+
+  if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
+  {
+    # user is installing from VS NuGet console
+    # get reference to the window, the console host and the input history
+    # show webpage if "install-package newtonsoft.json" was last input
+
+    $consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
+
+    $props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
+      [System.Reflection.BindingFlags]::NonPublic)
+
+    $prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
+    if ($prop -eq $null) { return }
+  
+    $hostInfo = $prop.GetValue($consoleWindow)
+    if ($hostInfo -eq $null) { return }
+
+    $history = $hostInfo.WpfConsole.InputHistory.History
+
+    $lastCommand = $history | select -last 1
+
+    if ($lastCommand)
+    {
+      $lastCommand = $lastCommand.Trim().ToLower()
+      if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
+      {
+        $dte2.ItemOperations.Navigate($url) | Out-Null
+      }
+    }
+  }
+  else
+  {
+    # user is installing from VS NuGet dialog
+    # get reference to the window, then smart output console provider
+    # show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
+
+    $instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
+      [System.Reflection.BindingFlags]::NonPublic)
+
+    $consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
+      [System.Reflection.BindingFlags]::NonPublic)
+
+    if ($instanceField -eq $null -or $consoleField -eq $null) { return }
+
+    $instance = $instanceField.GetValue($null)
+
+    if ($instance -eq $null) { return }
+
+    $consoleProvider = $consoleField.GetValue($instance)
+    if ($consoleProvider -eq $null) { return }
+
+    $console = $consoleProvider.CreateOutputConsole($false)
+
+    $messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
+      [System.Reflection.BindingFlags]::NonPublic)
+    if ($messagesField -eq $null) { return }
+
+    $messages = $messagesField.GetValue($console)
+    if ($messages -eq $null) { return }
+
+    $operations = $messages -split "=============================="
+
+    $lastOperation = $operations | select -last 1
+
+    if ($lastOperation)
+    {
+      $lastOperation = $lastOperation.ToLower()
+
+      $lines = $lastOperation -split "`r`n"
+
+      $installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
+
+      if ($installMatch)
+      {
+        $dte2.ItemOperations.Navigate($url) | Out-Null
+      }
+    }
+  }
+}
+catch
+{
+  try
+  {
+    $pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
+
+    $selection = $pmPane.TextDocument.Selection
+    $selection.StartOfDocument($false)
+    $selection.EndOfDocument($true)
+
+    if ($selection.Text.StartsWith("Attempting to gather dependencies information for package 'Newtonsoft.Json." + $package.Version + "'"))
+    {
+      # don't show on upgrade
+      if (!$selection.Text.Contains("Removed package"))
+      {
+        $dte2.ItemOperations.Navigate($url) | Out-Null
+      }
+    }
+  }
+  catch
+  {
+    # stop potential errors from bubbling up
+    # worst case the splash page won't open  
+  }
+}
+
+# still yolo