コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        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;
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected virtual XmlDocument FetchCheckForUpdatesXml(string location)
        {
            XmlDocument xdoc;

            using (Stream xmlstream = HTTPHelper.GET(new Uri(location), Connection, false))
            {
                xdoc = Helpers.LoadXmlDocument(xmlstream);
            }
            return(xdoc);
        }
コード例 #4
0
 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); });
         }
     }
 }
コード例 #5
0
 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);
         }
     }
 }
コード例 #6
0
        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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: MetricUpdater.cs プロジェクト: wranders/xenadmin
        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>());
        }