ntminer 6 years ago
parent
commit
a710aaa7fe

+ 1 - 1
src/NTMiner/NTMinerRoot.cs

@@ -248,7 +248,7 @@ namespace NTMiner {
             this.NTMinerWalletSet = new NTMinerWalletSet();
             this.OverClockDataSet = new OverClockDataSet(this);
             this.ColumnsShowSet = new ColumnsShowSet(this);
-            this.ServerMessageSet = new ServerMessageSet(VirtualRoot.LocalMessageDbFileFullName, isServer: false);
+            this.ServerMessageSet = new ServerMessageSet(VirtualRoot.LocalDbFileFullName, isServer: false);
             // 作业和在群控客户端管理作业时
             IsJsonLocal = isWork || VirtualRoot.IsMinerStudio;
             this._minerProfile = new MinerProfile(this);

+ 0 - 4
src/NTMiner/SpecialPath.cs

@@ -50,10 +50,6 @@ namespace NTMiner {
                     if (File.Exists(shareGpuProfilesJsonFileFullName) && !File.Exists(GpuProfilesJsonFileFullName)) {
                         File.Copy(shareGpuProfilesJsonFileFullName, GpuProfilesJsonFileFullName);
                     }
-                    string shareLocalMessageDbFileFullName = Path.Combine(MainAssemblyInfo.TempDirFullName, NTKeyword.LocalMessageDbFileName);
-                    if (File.Exists(shareLocalMessageDbFileFullName) && !File.Exists(VirtualRoot.LocalMessageDbFileFullName)) {
-                        File.Copy(shareLocalMessageDbFileFullName, VirtualRoot.LocalMessageDbFileFullName);
-                    }
                     string shareUpdaterFileFullName = Path.Combine(MainAssemblyInfo.TempDirFullName, NTKeyword.UpdaterDirName, NTKeyword.NTMinerUpdaterFileName);
                     if (File.Exists(shareUpdaterFileFullName) && !File.Exists(UpdaterFileFullName)) {
                         File.Copy(shareUpdaterFileFullName, UpdaterFileFullName);

+ 6 - 0
src/NTMinerRpcClient/ServerMessage/ServerMessageSet.cs

@@ -40,6 +40,12 @@ namespace NTMiner.ServerMessage {
                                     VirtualRoot.LocalServerMessageSetTimestamp = maxTime;
                                 }
                             }
+                            using (LiteDatabase db = new LiteDatabase(_connectionString)) {
+                                var col = db.GetCollection<ServerMessageData>();
+                                foreach (var item in data) {
+                                    col.Insert(item);
+                                }
+                            }
                             VirtualRoot.RaiseEvent(new NewServerMessageLoadedEvent(data));
                         }
                     });

+ 0 - 1
src/NTMinerlib/NTKeyword.cs

@@ -12,7 +12,6 @@
             OfficialServerHost = host;
         }
 
-        public const string LocalMessageDbFileName = "localMessage.litedb";
         public const string NTMinerUpdaterFileName = "NTMinerUpdater.exe";
         public const string NTMinerServicesFileName = "NTMinerServices.exe";
         public const string GpuProfilesFileName = "gpuProfiles.json";

+ 1 - 12
src/NTMinerlib/VirtualRoot.cs

@@ -21,17 +21,6 @@ namespace NTMiner {
     /// </summary>
     public static partial class VirtualRoot {
         public static readonly string AppFileFullName = Process.GetCurrentProcess().MainModule.FileName;
-        public static string LocalMessageDbFileFullName {
-            get {
-                if (IsMinerClient) {
-                    return Path.Combine(MainAssemblyInfo.TempDirFullName, NTKeyword.LocalMessageDbFileName);
-                }
-                if (IsMinerStudio) {
-                    return Path.Combine(MainAssemblyInfo.HomeDirFullName, NTKeyword.LocalMessageDbFileName);
-                }
-                return string.Empty;
-            }
-        }
         public static string LocalDbFileFullName {
             get {
                 return Path.Combine(MainAssemblyInfo.HomeDirFullName, NTKeyword.LocalDbFileName);
@@ -154,7 +143,7 @@ namespace NTMiner {
             SMessageDispatcher = new MessageDispatcher();
             SCommandBus = new DirectCommandBus(SMessageDispatcher);
             SEventBus = new DirectEventBus(SMessageDispatcher);
-            LocalMessages = new LocalMessageSet(LocalMessageDbFileFullName);
+            LocalMessages = new LocalMessageSet(LocalDbFileFullName);
         }
 
         #region LocalServerMessageSetTimestamp

+ 1 - 2
src/UnitTests/LocalMessageTests.cs

@@ -1,13 +1,12 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using NTMiner;
-using System.IO;
 
 namespace UnitTests {
     [TestClass]
     public class LocalMessageTests {
         [TestMethod]
         public void BenchmarkTest() {
-            File.Delete(VirtualRoot.LocalMessageDbFileFullName);
+            VirtualRoot.LocalMessages.Clear();
             int times = 2000;
             Assert.IsTrue(times > NTKeyword.LocalMessageSetCapacity);
             string content = "this is a test";