private void Login(object obj) { this.ErrorInfo = string.Empty; if (string.IsNullOrEmpty(this.SelectedLogin.User.PhoneNumber)) { this.ErrorInfo = "账号不能为空"; return; } if (string.IsNullOrEmpty(this.SelectedLogin.Password)) { this.ErrorInfo = "密码不能为空"; return; } //var runs = System.Diagnostics.Process.GetProcessesByName("IMUI"); //foreach (var run in runs) //{ // if (run.MainWindowTitle.Contains(this.SelectedLogin.User.PhoneNumber)) // { // //System.Windows.MessageBox.Show("已经有一个账号登录"); // //return; // this.ErrorInfo = "此账号已登录"; // return; // } //} //if (!SDKClient.SDKClient.Instance.IsConnected) //{ // this.ErrorInfo = "网络未连接"; // return; //} System.Threading.Mutex temp; #if RELEASE if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber, out temp)) { this.ErrorInfo = "此账号已登录"; return; } else { App.MUTEX = new System.Threading.Mutex(true, this.SelectedLogin.User.PhoneNumber); } //if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber, out temp)) //{ // this.ErrorInfo = "此账号已登录"; // return; //} //else //{ // MUTEX = new System.Threading.Mutex(true, this.SelectedLogin.User.PhoneNumber); //} #else if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber + "cs", out temp)) { this.ErrorInfo = "此账号已登录"; return; } else { App.MUTEX = new System.Threading.Mutex(true, this.SelectedLogin.User.PhoneNumber + "cs"); } #endif this.IsWaitForLogin = false; Task.Run(() => { SDKClient.Model.LoginMode mode = this.SelectedLogin.IsSavePassword ? SDKClient.Model.LoginMode.Save : SDKClient.Model.LoginMode.None; //this.LoginButtonEnabled = false; var t = Util.Helpers.Async.Run(async() => await SDKClient.SDKClient.Instance.StartAsync(this.SelectedLogin.User.PhoneNumber, this.SelectedLogin.Password, mode, SDKClient.SDKProperty.userType.customserver)); if (t) { return; } this.ErrorInfo = "无网络连接"; this.IsWaitForLogin = true; App.MUTEX?.Close(); App.MUTEX = null; }); }
private void Login(object obj) { if (historyAccountDB == null) { return; } this.ErrorInfo = string.Empty; //if (string.IsNullOrEmpty(this.SelectedLogin.User.PhoneNumber)) //{ // this.IsErrorShow = true; // this.ErrorInfo = "账号不能为空"; // return; //} //if (string.IsNullOrEmpty(this.SelectedLogin.Password)) //{ // this.IsErrorShow = true; // this.ErrorInfo = "密码不能为空"; // return; //} System.Threading.Mutex temp; #if RELEASE if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber, out temp)) { this.IsErrorShow = true; this.ErrorInfo = "此账号已登录"; return; } #elif CHECK if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber + "cs", out temp)) { this.IsErrorShow = true; this.ErrorInfo = "此账号已登录"; return; } #elif DEBUG if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber + "kf", out temp)) { this.IsErrorShow = true; this.ErrorInfo = "此账号已登录"; return; } #elif HUIDU if (System.Threading.Mutex.TryOpenExisting(this.SelectedLogin.User.PhoneNumber + "hd", out temp)) { this.IsErrorShow = true; this.ErrorInfo = "此账号已登录"; return; } #endif this.IsWaitForLogin = false; IsLogin = true; Task.Run(async() => { SDKClient.Model.LoginMode mode = this.SelectedLogin.IsSavePassword ? SDKClient.Model.LoginMode.Save : SDKClient.Model.LoginMode.None; _timer?.Start(); //this.LoginButtonEnabled = false; SDKClient.SDKClient.Instance.NewDataRecv -= Instance_NewDataRecv; SDKClient.SDKClient.Instance.ConnState -= Instance_ConnState; SDKClient.SDKClient.Instance.NewDataRecv += Instance_NewDataRecv; SDKClient.SDKClient.Instance.ConnState += Instance_ConnState; var t = await SDKClient.SDKClient.Instance.StartQRLoginAsync(true, historyAccountDB?.token); if (t) { //IsLogin = false; this.ErrorInfo = string.Empty; this.IsWaitForLogin = false; IsWaitPhoneConfirm = true; return; } //this.IsConnecting = false; IsLogin = false; this.IsErrorShow = true; this.ErrorInfo = "当前网络无法使用\n请检查后重新尝试"; this.IsWaitForLogin = true; App.MUTEX?.Close(); App.MUTEX = null; }); }