Example #1
0
 public void TestMethod1()
 {
     Rdp.SetRdpEnabled(true);
     Assert.IsTrue(Rdp.GetRdpEnabled());
     Rdp.SetRdpEnabled(false);
     Assert.IsFalse(Rdp.GetRdpEnabled());
 }
Example #2
0
 public ResponseBase EnableWindowsRemoteDesktop()
 {
     try {
         Rdp.SetRdpEnabled(true, true);
         Firewall.AddRemoteDesktopRule();
         return(ResponseBase.Ok());
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError(e.Message));
     }
 }
Example #3
0
        static bool ConsoleEventCallback(int eventType)
        {
            //Console is being forcefully closed. Make sure that remote desktop is disabled
            if (eventType == 2 && disableOnClose)
            {
                Console.WriteLine("Attempting to disable remote desktop connections.");

                Rdp.SetRdpEnabled(false);
                Firewall.RemoveRemoteDesktopRule();

                Console.Write("Remote desktop connections disabled.");
            }
            return(false);
        }
Example #4
0
        private void TemporarelyEnableRemoteDesktop(int seconds)
        {
            Rdp.SetRdpEnabled(true);
            ShowRdpStatus();

            Console.WriteLine();

            Firewall.AddRemoteDesktopRule();
            ShowFirewallStatus();

            Console.WriteLine();

            System.Threading.Thread.Sleep(seconds * 1000);

            Rdp.SetRdpEnabled(false);
            ShowRdpStatus();

            Console.WriteLine();
        }
Example #5
0
 private void Link()
 {
     VirtualRoot.Window <CloseNTMinerCommand>("处理关闭NTMiner客户端命令", LogEnum.UserConsole,
                                              action: message => {
         UIThread.Execute(() => {
             try {
                 if (MainWindow != null)
                 {
                     MainWindow.Close();
                 }
                 Shutdown();
             }
             catch (Exception e) {
                 Logger.ErrorDebugLine(e);
                 Environment.Exit(0);
             }
         });
     });
     VirtualRoot.Window <CloseMainWindowCommand>("处理关闭主界面命令", LogEnum.DevConsole,
                                                 action: message => {
         UIThread.Execute(() => {
             if (NTMinerRoot.GetIsCloseMeanExit())
             {
                 VirtualRoot.Execute(new CloseNTMinerCommand());
                 return;
             }
             MainWindow = NotiCenterWindow.Instance;
             foreach (Window window in Windows)
             {
                 if (window != MainWindow)
                 {
                     window.Close();
                 }
             }
             NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage(message.Message, "开源矿工");
         });
     });
     #region 周期确保守护进程在运行
     VirtualRoot.On <Per1MinuteEvent>("周期确保守护进程在运行", LogEnum.DevConsole,
                                      action: message => {
         Daemon.DaemonUtil.RunNTMinerDaemon();
     });
     #endregion
     #region 1080小药丸
     VirtualRoot.On <MineStartedEvent>("开始挖矿后启动1080ti小药丸、挖矿开始后如果需要启动DevConsole则启动DevConsole", LogEnum.DevConsole,
                                       action: message => {
         // 启动DevConsole
         if (NTMinerRoot.IsUseDevConsole)
         {
             var mineContext     = message.MineContext;
             string poolIp       = mineContext.MainCoinPool.GetIp();
             string consoleTitle = mineContext.MainCoinPool.Server;
             Daemon.DaemonUtil.RunDevConsoleAsync(poolIp, consoleTitle);
         }
         OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Start();
     });
     VirtualRoot.On <MineStopedEvent>("停止挖矿后停止1080ti小药丸", LogEnum.DevConsole,
                                      action: message => {
         OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Stop();
     });
     #endregion
     #region 处理禁用win10系统更新
     VirtualRoot.Window <BlockWAUCommand>("处理禁用win10系统更新命令", LogEnum.DevConsole,
                                          action: message => {
         NTMiner.Windows.WindowsUtil.BlockWAU();
     });
     #endregion
     #region 优化windows
     VirtualRoot.Window <Win10OptimizeCommand>("处理优化windows命令", LogEnum.DevConsole,
                                               action: message => {
         NTMiner.Windows.WindowsUtil.Win10Optimize();
     });
     #endregion
     #region 处理开启A卡计算模式
     VirtualRoot.Window <SwitchRadeonGpuCommand>("处理开启A卡计算模式命令", LogEnum.DevConsole,
                                                 action: message => {
         if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD)
         {
             SwitchRadeonGpuMode();
         }
     });
     #endregion
     #region 处理A卡驱动签名
     VirtualRoot.Window <AtikmdagPatcherCommand>("处理A卡驱动签名命令", LogEnum.DevConsole,
                                                 action: message => {
         if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD)
         {
             AtikmdagPatcher.AtikmdagPatcherUtil.Run();
         }
     });
     #endregion
     #region 启用或禁用windows远程桌面
     VirtualRoot.Window <EnableWindowsRemoteDesktopCommand>("处理启用或禁用Windows远程桌面命令", LogEnum.DevConsole,
                                                            action: message => {
         if (NTMinerRoot.GetIsRemoteDesktopEnabled())
         {
             return;
         }
         string msg = "确定启用Windows远程桌面吗?";
         DialogWindow.ShowDialog(message: msg, title: "确认", onYes: () => {
             Rdp.SetRdpEnabled(true, true);
             Firewall.AddRemoteDesktopRule();
         }, icon: IconConst.IconConfirm);
     });
     #endregion
     #region 启用或禁用windows开机自动登录
     VirtualRoot.Window <EnableOrDisableWindowsAutoLoginCommand>("处理启用或禁用Windows开机自动登录命令", LogEnum.DevConsole,
                                                                 action: message => {
         if (NTMiner.Windows.OS.Instance.IsAutoAdminLogon)
         {
             return;
         }
         NTMiner.Windows.Cmd.RunClose("control", "userpasswords2");
     });
     #endregion
 }
Example #6
0
 private void Link()
 {
     VirtualRoot.BuildEventPath <StartingMineFailedEvent>("开始挖矿失败", LogEnum.DevConsole,
                                                          action: message => {
         AppContext.Instance.MinerProfileVm.IsMining = false;
         VirtualRoot.Out.ShowError(message.Message);
     });
     #region 处理显示主界面命令
     VirtualRoot.BuildCmdPath <ShowMainWindowCommand>(action: message => {
         ShowMainWindow(message.IsToggle);
     });
     #endregion
     VirtualRoot.BuildCmdPath <CloseNTMinerCommand>(action: message => {
         // 不能推迟这个日志记录的时机,因为推迟会有windows异常日志
         VirtualRoot.ThisLocalWarn(nameof(NTMinerRoot), $"退出{VirtualRoot.AppName}。原因:{message.Reason}");
         UIThread.Execute(() => {
             try {
                 Shutdown();
             }
             catch (Exception e) {
                 Logger.ErrorDebugLine(e);
                 Environment.Exit(0);
             }
         });
     });
     #region 周期确保守护进程在运行
     VirtualRoot.BuildEventPath <Per1MinuteEvent>("周期确保守护进程在运行", LogEnum.DevConsole,
                                                  action: message => {
         Daemon.DaemonUtil.RunNTMinerDaemon();
     });
     #endregion
     #region 开始和停止挖矿后
     VirtualRoot.BuildEventPath <MineStartedEvent>("启动1080ti小药丸、启动DevConsole? 更新挖矿按钮状态", LogEnum.DevConsole,
                                                   action: message => {
         AppContext.Instance.MinerProfileVm.IsMining       = true;
         StartStopMineButtonViewModel.Instance.BtnStopText = "正在挖矿";
         // 启动DevConsole
         if (NTMinerRoot.IsUseDevConsole)
         {
             var mineContext     = message.MineContext;
             string poolIp       = mineContext.MainCoinPool.GetIp();
             string consoleTitle = mineContext.MainCoinPool.Server;
             Daemon.DaemonUtil.RunDevConsoleAsync(poolIp, consoleTitle);
         }
         OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Start();
     });
     VirtualRoot.BuildEventPath <MineStopedEvent>("停止挖矿后停止1080ti小药丸 挖矿停止后更新界面挖矿状态", LogEnum.DevConsole,
                                                  action: message => {
         AppContext.Instance.MinerProfileVm.IsMining       = false;
         StartStopMineButtonViewModel.Instance.BtnStopText = "尚未开始";
         OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Stop();
     });
     #endregion
     #region 处理禁用win10系统更新
     VirtualRoot.BuildCmdPath <BlockWAUCommand>(action: message => {
         NTMiner.Windows.WindowsUtil.BlockWAU();
     });
     #endregion
     #region 优化windows
     VirtualRoot.BuildCmdPath <Win10OptimizeCommand>(action: message => {
         NTMiner.Windows.WindowsUtil.Win10Optimize();
     });
     #endregion
     #region 处理开启A卡计算模式
     VirtualRoot.BuildCmdPath <SwitchRadeonGpuCommand>(action: message => {
         if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD)
         {
             SwitchRadeonGpuMode(message.On);
         }
     });
     #endregion
     #region 处理A卡驱动签名
     VirtualRoot.BuildCmdPath <AtikmdagPatcherCommand>(action: message => {
         if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.AMD)
         {
             AtikmdagPatcher.AtikmdagPatcherUtil.Run();
         }
     });
     #endregion
     #region 启用或禁用windows远程桌面
     VirtualRoot.BuildCmdPath <EnableWindowsRemoteDesktopCommand>(action: message => {
         if (NTMinerRegistry.GetIsRemoteDesktopEnabled())
         {
             return;
         }
         string msg = "确定启用Windows远程桌面吗?";
         DialogWindow.ShowSoftDialog(new DialogWindowViewModel(
                                         message: msg,
                                         title: "确认",
                                         onYes: () => {
             Rdp.SetRdpEnabled(true);
             Firewall.AddRdpRule();
         }));
     });
     #endregion
     #region 启用或禁用windows开机自动登录
     VirtualRoot.BuildCmdPath <EnableOrDisableWindowsAutoLoginCommand>(action: message => {
         if (NTMiner.Windows.OS.Instance.IsAutoAdminLogon)
         {
             return;
         }
         NTMiner.Windows.Cmd.RunClose("control", "userpasswords2");
     });
     #endregion
 }
Example #7
0
 private void ForceRdpDisable()
 {
     Rdp.SetRdpEnabled(false, true);
     ShowRdpStatus();
 }