Пример #1
0
        public SignInResult SignIn(NetworkCredential credential, DateTime dateTime, out string message)
        {
            try
            {
                if (ApplyDateRestriction && !IsDateAllowed(dateTime))
                {
                    throw new ArgumentOutOfRangeException(nameof(dateTime));
                }

                string result = client.Get(Url);
                if (result == null)
                {
                    throw new ArgumentException();
                }

                var token = GetWebPageToken(result);
                result = client.Post(Url, GetDataToBePosted(credential, dateTime, token));
                return(GetSignInResult(result, out message));
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(SignInResult.Other);
            }
        }
        // ログイン
        async Task <string> LogOn(string userId, string password, string companyCode)
        {
            return(await Task.Run(() =>
            {
                // トップページの取得
                var html = wc.Get(AttendanceProURLs.LogOn);

                // ログイン実行
                var query = QueryCreator.QueryForLogOnPage(html, userId, password, companyCode);
                html = wc.Post(AttendanceProURLs.LogOn, query);

                // ログインが正常に完了しているかのチェック
                ResponseValidator.ValidateLoggedIn(html);

                return html;
            }));
        }
Пример #3
0
        public void PostTest()
        {
            var client = new CookieAwareWebClient
            {
                UserAgent = UserAgent
            };

            client.Post("https://example.com", new NameValueCollection()
            {
                { "key1", "value1" },
                { "key2", "value2" },
            });
        }