Example #1
0
        //显示百分比   0:未完成 1:未通过审核  2:投标中 3:还款中 4:已流标  6:完成(完成还款)7:完成(下架)
        public static string GetProcessStr(WXSubMyLoanList_Info item)
        {
            if (item.IsOverdue)
            {
                return(item.Progress);
            }
            else
            {
                switch (item.Status)
                {
                case 0:
                case 1:
                    return("0");

                case 2:
                    return(item.Progress);

                case 3:
                    return(WebFormHandler.ProcessBar(item.RefundedMonths, item.TotalRefundMonths, 1));

                case 4:
                case 7:
                    return(item.Progress);

                case 6:
                    return(item.Progress);
                }
                return("0");
            }
        }
        /// <summary>
        /// Login to the website with credentials.
        /// </summary>
        async Task Login()
        {
            Log.Trace("Logging in...");

            var request = MyHttpWebRequest.Create(loginPageUrl);

            request.CookieContainer = CookieContainer;
            request.Method          = "GET";

            await ThrottleBeforeRequestAsync();

            var response = await request.GetResponseAsync();

            var html      = response.HtmlDocument;
            var loginForm = html.GetElementbyId("aspnetForm");

            var form = new WebFormHandler(loginPageUrl, loginForm, CookieContainer);

            form.FillInput("ctl00$bcr$ctl03$ctl07$username", username);
            form.FillInput("ctl00$bcr$ctl03$ctl07$password", password);
            form.FillInput("ctl00$bcr$ctl03$ctl07$loginButton", "Sign in »");
            response = form.SubmitForm();

            if (IsLoggedIn(response.ResponseText))
            {
                Log.Trace("Successfully logged in...");
            }
            else
            {
                Log.Warn("Failed to log in...");
                Log.Trace("Resetting registry stored user details.");
                var registry = Registry.CurrentUser.CreateSubKey(this.GetType().FullName);
                registry.SetValue("username", "");
                registry.SetValue("password", "");
            }
        }