private async Task <string> PostUserAccountAsync(string responseString) { _viewStatePrimary = responseString.Substring(responseString.LastIndexOf("![CDATA[") + 8); _viewStateSecundary = _viewStatePrimary.Substring(_viewStatePrimary.IndexOf(":") + 1); _viewStateSecundary = _viewStateSecundary.Remove(_viewStateSecundary.IndexOf("]")); _viewStatePrimary = _viewStatePrimary.Remove(_viewStatePrimary.IndexOf(":")); _webNavigator.AditionalHeaders.Add("Faces-Request", "partial/ajax"); _webNavigator.AditionalHeaders.Add("Origin", $"{BASE_URL}"); _webNavigator.ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; _webNavigator.Referer = $"{BASE_URL}/login.jsf"; _webNavigator.Method = "POST"; _webNavigator.Accept = "*/*"; _webNavigator.PostData = $"frmLogin=frmLogin&javax.faces.ViewState={_viewStatePrimary}%3A{_viewStateSecundary}" + $"&j_idt21=CLIENTE_RENDA_FIXA&loginv20170605={_userAccount}" + "&javax.faces.source=loginv20170605&javax.faces.partial.event=change" + "&javax.faces.partial.execute=loginv20170605%20loginv20170605&javax.faces.partial.render=loginv20170605" + "&javax.faces.behavior.event=valueChange&javax.faces.partial.ajax=true"; responseString = await _webNavigator.NavigateAsync($"{BASE_URL}/login.jsf"); _htmlDocument.LoadHtml(await WebNavigator.GetHtmlFrom(BASE_URL)); var collection = _htmlDocument.DocumentNode.Descendants("input"); var button = collection.FirstOrDefault( node => node.GetAttributeValue("value", string.Empty) .EqualsIgnoreCase("Avançar")) .GetAttributeValue("name", string.Empty); var comboBox = _htmlDocument.DocumentNode.Descendants() .FirstOrDefault(descendant => descendant.Name.EqualsIgnoreCase("select")); _viewStatePrimary = responseString.Substring(responseString.LastIndexOf("![CDATA[") + 8); _viewStateSecundary = _viewStatePrimary.Substring(_viewStatePrimary.IndexOf(":") + 1); _viewStateSecundary = _viewStateSecundary.Remove(_viewStateSecundary.IndexOf("]")); _viewStatePrimary = _viewStatePrimary.Remove(_viewStatePrimary.IndexOf(":")); _webNavigator.PostData = $"frmLogin=frmLogin&javax.faces.ViewState={_viewStatePrimary}%3A{_viewStateSecundary}" + $"&{comboBox.Id}=CLIENTE_RENDA_FIXA&loginv20170605={_userAccount}&{button}=Aguarde..."; _webNavigator.AditionalHeaders.Add("Cache-Control", "max-age=0"); _webNavigator.AditionalHeaders.Add("Upgrade-Insecure-Requests", "1"); _webNavigator.AditionalHeaders.Add("Origin", BASE_URL); _webNavigator.Method = "POST"; _webNavigator.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; _webNavigator.ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; _webNavigator.Referer = $"{BASE_URL}/login.jsf"; return(await _webNavigator.NavigateAsync($"{BASE_URL}/login.jsf")); }
/// <summary> /// Returns a redirect url string that points to the /// <see cref="Spring.Web.Support.Result.TargetPage"/> defined by this /// result evaluated using this Page for expression /// </summary> /// <param name="resultName">Name of the result.</param> /// <param name="context">The context to use for evaluating the SpEL expression in the Result</param> /// <returns>A redirect url string.</returns> protected string GetResultUrl(string resultName, object context) { return(ResolveUrl(WebNavigator.GetResultUri(resultName, this, context))); }
/// <summary> /// Returns a redirect url string that points to the /// <see cref="Spring.Web.Support.Result.TargetPage"/> defined by this /// result evaluated using this Page for expression /// </summary> /// <param name="resultName">Name of the result.</param> /// <returns>A redirect url string.</returns> protected string GetResultUrl(string resultName) { return(ResolveUrl(WebNavigator.GetResultUri(resultName, this, null))); }
/// <summary> /// Redirects user to a URL mapped to specified result name. /// </summary> /// <param name="resultName">Name of the result.</param> /// <param name="context">The context to use for evaluating the SpEL expression in the Result.</param> protected void SetResult(string resultName, object context) { WebNavigator.NavigateTo(resultName, this, context); }
/// <summary> /// Redirects user to a URL mapped to specified result name. /// </summary> /// <param name="resultName">Result name.</param> protected void SetResult(string resultName) { WebNavigator.NavigateTo(resultName, this, null); }
static WebNavigator() { mInstance = new WebNavigator(); }
public Intermedium() { _htmlDocument = new HtmlDocument(); _webNavigator = new WebNavigator(); }