Exemple #1
0
 private static void Login()
 {
     // 本机运行,不验证用户名密码
     SingleUser.LoginName = "CalcConfigUpdater";
     SingleUser.SetPasswordSha1("123");
     Console.WriteLine($"LoginName:CalcConfigUpdater");
     Console.Write($"Password:"******"123");
     Console.ResetColor();
 }
            public void ShutdownWindowsAsync(IClientData client, Action <ResponseBase, Exception> callback)
            {
                SignatureRequest innerRequest = new SignatureRequest {
                    LoginName = SingleUser.LoginName
                };

                innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId));
                WrapperRequest <SignatureRequest> request = new WrapperRequest <SignatureRequest> {
                    ObjectId     = client.GetId(),
                    ClientId     = client.ClientId,
                    LoginName    = SingleUser.LoginName,
                    InnerRequest = innerRequest,
                    ClientIp     = client.MinerIp
                };

                request.SignIt(SingleUser.PasswordSha1);
                PostAsync(SControllerName, nameof(IWrapperMinerClientController.ShutdownWindows), null, request, callback);
            }
            // ReSharper disable once InconsistentNaming
            public void UpgradeNTMinerAsync(IClientData client, string ntminerFileName, Action <ResponseBase, Exception> callback)
            {
                UpgradeNTMinerRequest innerRequest = new UpgradeNTMinerRequest {
                    LoginName       = SingleUser.LoginName,
                    NTMinerFileName = ntminerFileName
                };

                innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId));
                WrapperRequest <UpgradeNTMinerRequest> request = new WrapperRequest <UpgradeNTMinerRequest> {
                    ObjectId     = client.GetId(),
                    ClientId     = client.ClientId,
                    LoginName    = SingleUser.LoginName,
                    InnerRequest = innerRequest,
                    ClientIp     = client.MinerIp
                };

                request.SignIt(SingleUser.PasswordSha1);
                PostAsync(SControllerName, nameof(IWrapperMinerClientController.UpgradeNTMiner), null, request, callback);
            }
            public void SetClientMinerProfilePropertyAsync(IClientData client, string propertyName, object value, Action <ResponseBase, Exception> callback)
            {
                SetClientMinerProfilePropertyRequest innerRequest = new SetClientMinerProfilePropertyRequest {
                    LoginName    = SingleUser.LoginName,
                    PropertyName = propertyName,
                    Value        = value
                };

                innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId));
                WrapperRequest <SetClientMinerProfilePropertyRequest> request = new WrapperRequest <SetClientMinerProfilePropertyRequest> {
                    ObjectId     = client.GetId(),
                    ClientId     = client.ClientId,
                    LoginName    = SingleUser.LoginName,
                    ClientIp     = client.MinerIp,
                    InnerRequest = innerRequest
                };

                request.SignIt(SingleUser.PasswordSha1);
                PostAsync(SControllerName, nameof(IWrapperMinerClientController.SetClientMinerProfileProperty), null, request, callback);
            }
Exemple #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            try {
                appMutex = new Mutex(true, s_appPipName, out createdNew);
            }
            catch (Exception) {
                createdNew = false;
            }

            if (createdNew)
            {
                Vms.AppStatic.IsMinerClient = false;
                SplashWindow splashWindow = new SplashWindow();
                splashWindow.Show();
                NotiCenterWindow.Instance.Show();
                NTMinerRoot.AppName = "开源矿工群控客户端";
                NTMinerServices.NTMinerServicesUtil.RunNTMinerServices();
                NTMinerRoot.Current.Init(() => {
                    NTMinerRoot.KernelDownloader = new KernelDownloader();
                    UIThread.Execute(() => {
                        splashWindow?.Close();
                        bool?result = true;
                        if (Ip.Util.IsInnerIp(NTMinerRegistry.GetControlCenterHost()))
                        {
                            SingleUser.LoginName = "innerip";
                            SingleUser.SetPasswordSha1("123");
                            result = true;
                        }
                        else if (string.IsNullOrEmpty(SingleUser.LoginName) || string.IsNullOrEmpty(SingleUser.PasswordSha1))
                        {
                            LoginWindow loginWindow = new LoginWindow();
                            result = loginWindow.ShowDialog();
                        }
                        if (result.HasValue && result.Value)
                        {
                            ChartsWindow.ShowWindow();
                            System.Drawing.Icon icon = new System.Drawing.Icon(GetResourceStream(new Uri("pack://application:,,,/MinerStudio;component/logo.ico")).Stream);
                            AppHelper.NotifyIcon     = ExtendedNotifyIcon.Create(icon, "群控客户端", isMinerStudio: true);
                            #region 处理显示主界面命令
                            VirtualRoot.Window <ShowMainWindowCommand>("处理显示主界面命令", LogEnum.None,
                                                                       action: message => {
                                Dispatcher.Invoke((ThreadStart)ChartsWindow.ShowWindow);
                            });
                            #endregion
                            HttpServer.Start($"http://localhost:{WebApiConst.MinerStudioPort}");
                            AppHelper.RemoteDesktop = MsRdpRemoteDesktop.OpenRemoteDesktop;
                        }
                    });
                });
                VirtualRoot.Window <CloseNTMinerCommand>("处理关闭群控客户端命令", LogEnum.UserConsole,
                                                         action: message => {
                    UIThread.Execute(() => {
                        if (MainWindow != null)
                        {
                            MainWindow.Close();
                        }
                        Shutdown();
                        Environment.Exit(0);
                    });
                });
            }
            else
            {
                try {
                    AppHelper.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerStudio);
                }
                catch (Exception) {
                    DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "alert", icon: "Icon_Error");
                    Process   currentProcess = Process.GetCurrentProcess();
                    Process[] processes      = Process.GetProcessesByName(currentProcess.ProcessName);
                    foreach (var process in processes)
                    {
                        if (process.Id != currentProcess.Id)
                        {
                            NTMiner.Windows.TaskKill.Kill(process.Id);
                        }
                    }
                }
            }
            base.OnStartup(e);
        }