예제 #1
0
        /// <summary>
        /// Checks the update via RSS.
        /// </summary>
        /// <param name="uri">The URI.</param>
        private void CheckUpdateViaRss(Uri uri)
        {
            _updateList = new UpdateInfoList();
            XmlDocument doc = new XmlDocument();

            try {
                Stream strm = GetRssStream(uri);
                using ( strm ) {
                    doc.Load(strm);
                }
            } catch { throw; }
            XmlNamespaceManager nsm = CreateXmlNamespaceManager(doc);

            XmlNodeList updateInfoNodes = doc.SelectNodes(string.Format(Properties.Strings.UpdateInfoRootXPath, Properties.Strings.UpdateInfoNamespacePrefix), nsm);

            // Console.WriteLine ( "{0} Update info items found", updateInfoNodes.Count );

            foreach (XmlElement uie in updateInfoNodes)
            {
                try {
                    XmlParserContext xpc    = new XmlParserContext(doc.NameTable, nsm, string.Empty, XmlSpace.Preserve);
                    XmlTextReader    reader = new XmlTextReader(uie.OuterXml, XmlNodeType.Element, xpc);

                    XmlSerializer serializer = new XmlSerializer(typeof(UpdateInfo), nsm.LookupNamespace(Properties.Strings.UpdateInfoNamespacePrefix));
                    _updateList.Add(serializer.Deserialize(reader) as UpdateInfo);
                } catch (Exception ex) {
                    Console.WriteLine(ex.ToString());
                }
            }

            _updateList.Sort(new UpdateInfoVersionComparer());
            if (_updateList.Count > 0)
            {
                UpdateInfo _updateInfo = UpdateInfoList[UpdateInfoList.GetLatestVersion(  )];
                foreach (UpdateFile uf in _updateInfo.Files)
                {
                    if (uf.Version.CompareTo(this.Version) > 0)
                    {
                        _updatesAvailable = true;
                    }
                }
                if (_updatesAvailable || _updateInfo.Version.CompareTo(this.Version) > 0)
                {
                    OnUpdateAvailable(new UpdatesAvailableEventArgs(_updateInfo.Version));
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationUpdater"/> class.
 /// </summary>
 public ApplicationUpdater()
 {
     try {
         XmlDocument doc         = new XmlDocument();
         string      startUpPath = this.GetType().Assembly.Location;
         startUpPath = startUpPath.Substring(0, startUpPath.LastIndexOf("\\"));
         doc.Load(Path.Combine(startUpPath, Properties.Strings.UpdaterConfigurationFile));
         UpdaterConfigurationSectionHandler ucsh = new UpdaterConfigurationSectionHandler();
         _configuration  = ucsh.Create(null, null, doc.DocumentElement);
         this.UpdateName = "CCNetConfig";
     } catch (Exception ex) {
         throw new ApplicationException(Properties.Strings.UpdaterConfigLoadErrorMessage, ex);
     }
     _updateList = new UpdateInfoList();
     _serializer = new XmlSerializer(typeof(UpdateInfo));
     _tempFiles  = new List <FileInfo> ();
 }
예제 #3
0
 /// <summary>
 /// Gets the updates.
 /// </summary>
 /// <param name="version">The version.</param>
 public void GetUpdates(Version version)
 {
     if (_updatesAvailable && UpdateInfoList.Contains(version))
     {
         UpdateInfo ui = UpdateInfoList[version];
         foreach (UpdateFile uf in ui.Files)
         {
             if (Version.CompareTo(uf.Version) < 0)
             {
                 DownloadFile(uf);
             }
         }
         OnUpdateDownloadsCompleted(EventArgs.Empty);
         buildScript(ui);
         OnUpdateScriptCreated(EventArgs.Empty);
     }
 }
예제 #4
0
 /// <summary>
 /// Gets the updates.
 /// </summary>
 public void GetUpdates()
 {
     GetUpdates(UpdateInfoList.GetLatestVersion());
 }
예제 #5
0
 internal UpdateState(UpdateStates t)
 {
     state          = t;
     list           = new UpdateInfoList();
     updatedplugins = false;
 }