/// <summary> /// UpdaterThread Thread /// </summary> private void Get(ArchiveInterval interval, URIDelegate URI, ReaderDelegate Reader, Host host, IXenObject xenObject) { if (host == null) { return; } try { Session session = xenObject.Connection.Session; if (session == null) { return; } using (Stream httpstream = HTTPHelper.GET(URI(session, host, interval, xenObject), xenObject.Connection, true)) { using (XmlReader reader = XmlReader.Create(httpstream)) { SetsAdded = new List <DataSet>(); while (reader.Read()) { Reader(reader, xenObject); } } } } catch (WebException) { } catch (Exception e) { log.Debug(string.Format("ArchiveMaintainer: Get updates for {0}: {1} Failed.", xenObject is Host ? "Host" : "VM", xenObject != null ? xenObject.opaque_ref : Helper.NullOpaqueRef), e); } }
private void HttpGet(Uri uri) { int BUFSIZE = 1024; byte[] buf = new byte[BUFSIZE]; using (MemoryStream ms = new MemoryStream()) { using (Stream http = HTTPHelper.GET(uri, Connection, false)) { while (true) { int n = http.Read(buf, 0, BUFSIZE); if (n <= 0) { result = new String(Encoding.UTF8.GetChars(ms.ToArray())); return; } ms.Write(buf, 0, n); if (Cancelling) { return; } } } } }
protected virtual XmlDocument FetchCheckForUpdatesXml(string location) { XmlDocument xdoc; using (Stream xmlstream = HTTPHelper.GET(new Uri(location), Connection, false)) { xdoc = Helpers.LoadXmlDocument(xmlstream); } return(xdoc); }
private void HttpGet(string filename, Uri uri) { using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) { using (Stream http = HTTPHelper.GET(uri, Connection, true, true)) { new Export().verify(http, fs, (Export.cancellingCallback) delegate() { return(Cancelling); }); } } }
private void HttpGet(string filename, Uri uri) { using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) { using (Stream http = HTTPHelper.GET(uri, Connection, true)) { new Export().verify(http, fs, () => Cancelling); } } }
public Db(IXenConnection connection, string url) { _tables = new TableDictionary(this); using (StreamReader stream = url.StartsWith("http") ? new StreamReader(HTTPHelper.GET(new Uri(url), connection, true)) : new StreamReader(url)) { StatusReportXmlDocReader reader = new StatusReportXmlDocReader(); XmlDocument doc = new XmlDocument(); doc.XmlResolver = new BasicXMLResolver(); doc.Load(stream); reader.PopulateDbFromXml(this, doc); } UpdateRelations(); _tables.Changed += TablesChanged; }
protected virtual XmlDocument FetchCheckForUpdatesXml(string location) { var xdoc = new XmlDocument(); var uri = new Uri(location); if (uri.IsFile) { xdoc.Load(location); } else { using (Stream xmlstream = HTTPHelper.GET(new Uri(location), Connection, false, true)) { xdoc = Helpers.LoadXmlDocument(xmlstream); } } return(xdoc); }
private static Dictionary <string, double> ValuesFor(Host host) { if (host.address == null) { return(new Dictionary <string, double>()); } try { Session session = host.Connection.Session; if (session != null) { return(AllValues(HTTPHelper.GET(GetUri(session, host), host.Connection, true))); } } catch (Exception e) { log.Warn(string.Format("Exception getting metrics for {0}", Helpers.GetName(host)), e); } return(new Dictionary <string, double>()); }