Beispiel #1
0
        private async Task <LoginState> LoginInternal(int accoutType, string user, string pwd, string vc, int question, string answer)
        {
            await HookScript(WebBrowser, "/Assets/Json.js");
            await HookScript(WebBrowser, "/Assets/Login.js");

            int accoutTypeValue = 0;

            switch (accoutType)
            {
            case 1:
                accoutTypeValue = 2;
                break;

            case 2:
                accoutTypeValue = 1;
                break;
            }

            var resultData = WebBrowser.Document.InvokeScript("Login", new object[] { accoutTypeValue, user, pwd, vc, question, answer });

            var result = JsonConvert.DeserializeObject <ErrorObject>(resultData.ToString());

            if (result.ErrorCode != ErrorCode.Ok)
            {
                throw new Exception($"{result.ErrorCode}");
            }

            NavigateWaitHandle handle = new NavigateWaitHandle(MainPage);

            _waitHandles.Add(handle);
            await handle.Wait(5000);

            return(await GetUserInformation());
        }
Beispiel #2
0
        private async Task Navigate(String url)
        {
            NavigateWaitHandle handle = new NavigateWaitHandle(url);

            _waitHandles.Add(handle);
            WebBrowser.Navigate(url);
            await handle.Wait();
        }