public static HttpResult CallProgress(string startUrl, string stepUrl = null, bool showUrlOnError = true) { HttpInvoker i = new HttpInvoker(); i.startUrl = startUrl; i.stepUrl = stepUrl; i.showUrlOnError = showUrlOnError; i.doCallProgress(); if (i.ret) { return(i.LastResult); } else { return(null); } }
private HttpResult Navigate(string relativeUrl) { string httpServer = HttpInvoker.GetServer(); if (String.IsNullOrEmpty(httpServer)) { throw new Exception("AppConfig debe incluir HttpServer"); } if (!httpServer.EndsWith("/")) { httpServer += "/"; } string fullurl = httpServer + relativeUrl; string xdebug = ConfigurationGet("HttpXDebugSession"); if (xdebug != null && xdebugCookieAdded == false) { CookieContainer.Add(new Uri(httpServer), new Cookie("XDEBUG_SESSION", xdebug)); xdebugCookieAdded = true; } WebClientEx wc = new WebClientEx(CookieContainer); this.lastUrl = fullurl; HttpResult res = new HttpResult(); string json = wc.DownloadString(fullurl); Dictionary <string, string> htmlAttributes = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); if (htmlAttributes.ContainsKey("key")) { res.Key = htmlAttributes["key"]; } if (htmlAttributes.ContainsKey("status")) { res.Caption = htmlAttributes["status"]; } if (htmlAttributes.ContainsKey("totalSteps")) { res.Total = int.Parse(htmlAttributes["totalSteps"]); } if (htmlAttributes.ContainsKey("step")) { res.Value = int.Parse(htmlAttributes["step"]); } if (htmlAttributes.ContainsKey("totalSlices")) { res.SubTotal = int.Parse(htmlAttributes["totalSlices"]); } if (htmlAttributes.ContainsKey("extra")) { res.Extra = JsonConvert.DeserializeObject <Dictionary <string, string> >(htmlAttributes["extra"]); } if (htmlAttributes.ContainsKey("slice")) { res.SubValue = int.Parse(htmlAttributes["slice"]); } if (htmlAttributes.ContainsKey("done")) { res.Completed = htmlAttributes["done"] == "true"; } return(res); }