Пример #1
0
        private void UserLogin(IHavePassword parameter)
        {
            Task.Run(() =>
            {
                if (IsVisitorLogin == true)//游客登录
                {
                    Applicate.URLDATA.data.apiUrl = ConfigurationUtil.GetValue("InitialServer") + "/";
                    VisitorKey = ConfigurationUtil.GetValue("InitialServer_key");

                    int index  = VisitorKey.LastIndexOf("?");
                    VisitorKey = VisitorKey.Substring(index + 1);

                    int index2 = VisitorKey.LastIndexOf("=");
                    VisitorKey = VisitorKey.Substring(index2 + 1);
                    VisitorLogin();
                    return;
                }

                //接收用户名和密码
                string password;
                if (IsRememberPwd &&
                    TruePasswordWhenRemembered != null &&
                    !IsCancelRememberPwdAndTextNewPwd)     //如果当前处于记住有效密码 且 不为加载密码后重新输入的密码
                {
                    password = TruePasswordWhenRemembered; //使用数据库密码
                    //parameter.LoginSecurePassword = TruePasswordWhenRemembered.ToSecureString();
                }
                else//没记住密码 或
                {
                    password = parameter.LoginSecurePassword.UnSecure();//使用文本框内密码
                }
                EnabledLogin = false;//暂时禁用登录
                //获取经纬度
                string Longitude = "0";
                string Latitude  = "0";
                if (Location.IsUnknown != true)
                {
                    Longitude = Location.Longitude.ToString();
                    Latitude  = Location.Latitude.ToString();
                }
                try
                {
                    var client = ShiKuManager.ShiKuLogin(UserId, password, Latitude, Longitude, GobalAreaList[SelectedCountryCode].prefix.ToString());
                    client.UploadDataCompleted += LoginComplete;
                }
                catch (Exception ex)
                {
                    SnackBar.Enqueue("登录失败:" + ex.Message, "重试", () => { LoginCommand.Execute(Applicate.GetWindow <IHavePassword>()); });
                    Console.WriteLine("登录失败:" + ex.Message);
                    EnabledLogin = true;//启用登录
                }
            });
        }