anycmd 4 роки тому
батько
коміт
655df46d55

+ 3 - 18
src/AppModels/Vms/KernelOutputViewModel.cs

@@ -294,16 +294,7 @@ namespace NTMiner.Vms {
 
         public bool IsFoundOneGpuShare {
             get {
-                if (!string.IsNullOrEmpty(FoundOneShare) && FoundOneShare.Contains("?<gpu>")) {
-                    return true;
-                }
-                if (!string.IsNullOrEmpty(AcceptOneShare) && AcceptOneShare.Contains("?<gpu>")) {
-                    return true;
-                }
-                if (!string.IsNullOrEmpty(GpuAcceptShare) && GpuAcceptShare.Contains("?<gpu>")) {
-                    return true;
-                }
-                return false;
+                return this.GetIsFoundOneGpuShare();
             }
         }
 
@@ -341,19 +332,13 @@ namespace NTMiner.Vms {
 
         public bool IsRejectOneGpuShare {
             get {
-                return !string.IsNullOrEmpty(RejectOneShare) || !string.IsNullOrEmpty(GpuRejectShare);
+                return this.GetIsRejectOneGpuShare();
             }
         }
 
         public bool IsGotOneIncorrectGpuShare {
             get {
-                if (!string.IsNullOrEmpty(GpuGotOneIncorrectShare) && GpuGotOneIncorrectShare.Contains("?<gpu>")) {
-                    return true;
-                }
-                if (!string.IsNullOrEmpty(GpuIncorrectShare) && GpuIncorrectShare.Contains("?<gpu>")) {
-                    return true;
-                }
-                return false;
+                return this.GetIsGotOneIncorrectGpuShare();
             }
         }
 

+ 2 - 2
src/AppViews0/MinerStudio/Views/Ucs/MqCountsPage.xaml

@@ -11,7 +11,7 @@
 	xmlns:vm="clr-namespace:NTMiner.MinerStudio.Vms;assembly=AppModels"
     Background="White"
 	mc:Ignorable="d" 
-    d:DesignHeight="700" 
+    d:DesignHeight="800" 
     d:DesignWidth="1400"
     d:DataContext="{d:DesignData Source=../Design/MqCountsPageViewModel.xaml}">
     <Grid>
@@ -20,7 +20,7 @@
             <ColumnDefinition Width="2*"></ColumnDefinition>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
-            <RowDefinition Height="Auto"></RowDefinition>
+            <RowDefinition Height="50"></RowDefinition>
             <RowDefinition Height="Auto"></RowDefinition>
             <RowDefinition Height="*"></RowDefinition>
         </Grid.RowDefinitions>

+ 1 - 1
src/AppViews0/MinerStudio/Views/Ucs/MqCountsPage.xaml.cs

@@ -11,7 +11,7 @@ namespace NTMiner.MinerStudio.Views.Ucs {
                 Title = "Mq Counts",
                 IconName = "Icon_RabbitMq",
                 Width = 1400,
-                Height = 700,
+                Height = 800,
                 IsMaskTheParent = false,
                 IsChildWindow = true,
                 CloseVisible = Visibility.Visible,

+ 3 - 3
src/NTMinerClient/Report/ReportDataProvider.cs

@@ -171,9 +171,9 @@ namespace NTMiner.Report {
                     if (ntminerContext.ServerContext.KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel)) {
                         speedDto.Kernel = kernel.GetFullName();
                         if (ntminerContext.ServerContext.KernelOutputSet.TryGetKernelOutput(kernel.KernelOutputId, out IKernelOutput kernelOutput)) {
-                            speedDto.IsFoundOneGpuShare = !string.IsNullOrEmpty(kernelOutput.FoundOneShare);
-                            speedDto.IsGotOneIncorrectGpuShare = !string.IsNullOrEmpty(kernelOutput.GpuGotOneIncorrectShare);
-                            speedDto.IsRejectOneGpuShare = !string.IsNullOrEmpty(kernelOutput.RejectOneShare);
+                            speedDto.IsFoundOneGpuShare = kernelOutput.GetIsFoundOneGpuShare();
+                            speedDto.IsGotOneIncorrectGpuShare = kernelOutput.GetIsGotOneIncorrectGpuShare();
+                            speedDto.IsRejectOneGpuShare = kernelOutput.GetIsRejectOneGpuShare();
                         }
                         ICoinKernelProfile coinKernelProfile = workProfile.GetCoinKernelProfile(coinProfile.CoinKernelId);
                         speedDto.IsDualCoinEnabled = coinKernelProfile.IsDualCoinEnabled;

+ 39 - 0
src/NTMinerDataSchemas/Core/KernelOutputExtensions.cs

@@ -0,0 +1,39 @@
+namespace NTMiner.Core {
+    public static class KernelOutputExtensions {
+        public static bool GetIsRejectOneGpuShare(this IKernelOutput kernelOutput) {
+            if (kernelOutput == null) {
+                return false;
+            }
+            return !string.IsNullOrEmpty(kernelOutput.RejectOneShare) || !string.IsNullOrEmpty(kernelOutput.GpuRejectShare);
+        }
+
+        public static bool GetIsGotOneIncorrectGpuShare(this IKernelOutput kernelOutput) {
+            if (kernelOutput == null) {
+                return false;
+            }
+            if (!string.IsNullOrEmpty(kernelOutput.GpuGotOneIncorrectShare) && kernelOutput.GpuGotOneIncorrectShare.Contains("?<gpu>")) {
+                return true;
+            }
+            if (!string.IsNullOrEmpty(kernelOutput.GpuIncorrectShare) && kernelOutput.GpuIncorrectShare.Contains("?<gpu>")) {
+                return true;
+            }
+            return false;
+        }
+
+        public static bool GetIsFoundOneGpuShare(this IKernelOutput kernelOutput) {
+            if (kernelOutput == null) {
+                return false;
+            }
+            if (!string.IsNullOrEmpty(kernelOutput.FoundOneShare) && kernelOutput.FoundOneShare.Contains("?<gpu>")) {
+                return true;
+            }
+            if (!string.IsNullOrEmpty(kernelOutput.AcceptOneShare) && kernelOutput.AcceptOneShare.Contains("?<gpu>")) {
+                return true;
+            }
+            if (!string.IsNullOrEmpty(kernelOutput.GpuAcceptShare) && kernelOutput.GpuAcceptShare.Contains("?<gpu>")) {
+                return true;
+            }
+            return false;
+        }
+    }
+}

+ 1 - 0
src/NTMinerDataSchemas/NTMinerDataSchemas.csproj

@@ -48,6 +48,7 @@
     <Compile Include="Core\CaptchaData.cs" />
     <Compile Include="Core\AfterTimeRequest.cs" />
     <Compile Include="Core\ConsoleOutLines.cs" />
+    <Compile Include="Core\KernelOutputExtensions.cs" />
     <Compile Include="Core\LocalMessages.cs" />
     <Compile Include="Core\MinerServer\NTMinerFilesRequest.cs" />
     <Compile Include="Core\MinerServer\NTMinerFilesResponse.cs" />

+ 46 - 0
src/UnitTests/UnitTest1.cs

@@ -324,5 +324,51 @@ namespace NTMiner {
             var elapsedMilliseconds = NTStopwatch.Stop();
             Console.WriteLine(elapsedMilliseconds);
         }
+
+        public class ListItem {
+            public ListItem() { }
+
+            public int N { get; set; }
+        }
+        [TestMethod]
+        public void ListSortTest() {
+            List<ListItem> list = new List<ListItem>();
+            var item2 = new ListItem {
+                N = 2
+            };
+            var item3 = new ListItem {
+                N = 3
+            };
+            var item1 = new ListItem {
+                N = 1
+            };
+            list.Add(item2);
+            list.Add(new ListItem {
+                N = 2
+            });
+            list.Add(item3);
+            list.Add(new ListItem {
+                N = 3
+            });
+            list.Add(item1);
+            list.Sort((left, right) => {
+                return right.N - left.N;
+            });
+            Assert.AreEqual(3, list[0].N);
+            Assert.AreEqual(3, list[1].N);
+            Assert.AreEqual(2, list[2].N);
+            Assert.AreEqual(2, list[3].N);
+            Assert.AreEqual(1, list[4].N);
+            list.Remove(item2);
+            Assert.AreEqual(3, list[0].N);
+            Assert.AreEqual(3, list[1].N);
+            Assert.AreEqual(2, list[2].N);
+            Assert.AreEqual(1, list[3].N);
+            list.Remove(item3);
+            list.Remove(item1);
+            Assert.AreEqual(3, list[0].N);
+            Assert.AreEqual(2, list[1].N);
+            // 结论:移除排序后的List中的元素不会改变排序
+        }
     }
 }