public XPathDocument GetXPathDocument(string path) { XPathDocument xpathdocument = null; try { if (path.StartsWith("http")) { HttpWebRequest request = new HTTPConnector().BuildWebRequest(path, "text/xml"); using (WebResponse response = request.GetResponse()) { Stream xmlStream = response.GetResponseStream(); xpathdocument = GetXPathDocument(xmlStream); xmlStream.Close(); response.Close(); } } else { Stream xmlStream = new FileStream(path, FileMode.Open); xpathdocument = GetXPathDocument(xmlStream); xmlStream.Close(); } } catch (Exception exception) { ErrorService.Log("XMLConnector", "GetXPathDocument", path, exception); } return xpathdocument; }
public XmlDocument GetXMLDocument(string path) { XmlDocument xmlDocument = new XmlDocument(); try { if (path.StartsWith("http")) { HttpWebRequest request = new HTTPConnector().BuildWebRequest(path, "text/xml"); using (WebResponse response = request.GetResponse()) { Stream xmlStream = response.GetResponseStream(); xmlDocument.Load(xmlStream); xmlStream.Close(); response.Close(); } } else { xmlDocument.Load(path); } } catch (Exception exception) { ErrorService.Log("XMLConnector", "GetXMLDocument", path, exception); } return xmlDocument; }
public JObject PostJSONObjectWithHeader(string url, string headerName, string headeValue, string data) { JObject jsonObject = null; string json = new HTTPConnector().PostDataWithHeader(url, headerName, headeValue, data); jsonObject = JObject.Parse(json); return jsonObject; }
public JArray GetJSONArrayWithHeader(string url, string headerName, string headerVaue) { JArray jsonArray = null; string json = new HTTPConnector().GetResponseWithHeader(url, headerName, headerVaue, "application/json"); jsonArray = JArray.Parse(json); return jsonArray; }
public JObject GetJSONObjectWithHeader(string url, string headerName, string headerVaue) { JObject jsonObject = null; string json = new HTTPConnector().GetResponseWithHeader(url, headerName, headerVaue, "application/json"); jsonObject = JObject.Parse(json); return jsonObject; }
public JObject GetJSONObject(string url) { JObject jsonObject = null; string json = new HTTPConnector().GetResponse(url, "application/json"); jsonObject = JObject.Parse(json); return jsonObject; }
public static void Send(EventItem eventItem) { string url = string.Format(SPLUNK_URL_TEMPLATE, PROJECT_ID, HOST, eventItem.Source.ToString("f"), eventItem.SourceType.ToString("f")); HTTPConnector HTTPConnector = new HTTPConnector(); string response = HTTPConnector.PostDataWithCredentials(url, "x", ACCESS_TOKEN, eventItem.Data); }
public string GetHTMLDocument(string path) { string htmlDocument = null; try { if (path.StartsWith("http")) { htmlDocument = new HTTPConnector().GetResponse(path, "text/html"); } else { LogService.Warn(typeof(HTMLConnector), "Reading from a file not supported"); } } catch (Exception exception) { ErrorService.Log("HTMLConnector", "GetHTMLDocument", path, exception); } return htmlDocument; }
static private void PreLoadTrendsImage(TrendsList trendsList) { if (trendsList != null) { SearchService searchService = new SearchService(); foreach (TrendItem trendItem in trendsList) { if (trendItem.ImageURL == null) { String query = trendItem.Title; SearchContext searchContext = new SearchContext(query, 1, 1); searchContext.SearchType = SearchTypeEnum.Image; SearchResultList searchResultList = searchService.Search(searchContext); if (searchResultList.Count() > 0) { SearchResultItem item = (SearchResultItem)searchResultList.Item(0); trendItem.ImageURL = item.ImageURL; } } if (trendItem.TileImageURL == null && trendItem.ImageURL != null) { int imageSize; switch (trendItem.Weight) { case 1: imageSize = 150; break; case 2: imageSize = 150; break; case 3: imageSize = 150; break; case 4: imageSize = 150; break; case 5: imageSize = 150; break; default: imageSize = 150; break; } string url = "http://src.sencha.io/" + imageSize + "/" + trendItem.ImageURL; HttpStatusCode status = new HTTPConnector().GetStatus(url, "image/jpeg,image/gif.image/png"); if (status == HttpStatusCode.OK) { trendItem.TileImageURL = url; } } } } }