Beispiel #1
0
        /// <summary>
        /// Adds a feed to the list of custom feeds.
        /// </summary>
        private void AddCustomFeed(string input)
        {
            FeedUri feedUri;

            try
            {
                feedUri = new FeedUri(input);
            }
            catch (UriFormatException ex)
            {
                Msg.Inform(this, ex.Message, MsgSeverity.Error);
                return;
            }

            if (_interfaceUri.IsFile)
            {
                if (!File.Exists(_interfaceUri.LocalPath))
                {
                    Msg.Inform(this, string.Format(Resources.FileOrDirNotFound, _interfaceUri.LocalPath), MsgSeverity.Warn);
                    return;
                }
            }
            else
            {
                Feed feed = null;
                try
                {
                    using var handler = new DialogTaskHandler(this);
                    handler.RunTask(new SimpleTask(Resources.CheckingFeed,
                                                   delegate
                    {
                        using var webClient = new WebClientTimeout();
                        feed = XmlStorage.FromXmlString <Feed>(webClient.DownloadString(feedUri));
                    }));
                }
        /// <summary>
        /// Performs a feed search query using the <see cref="Config.FeedMirror"/>.
        /// </summary>
        /// <param name="config">The current configuration determining which mirror server to query.</param>
        /// <param name="keywords">The keywords to search for.</param>
        public static SearchQuery Perform([NotNull] Config config, [CanBeNull] string keywords)
        {
            #region Sanity checks
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            #endregion

            if (string.IsNullOrEmpty(keywords))
            {
                return(new SearchQuery());
            }

            var url = new Uri(
                config.FeedMirror.EnsureTrailingSlash(),
                new Uri("search/?q=" + Uri.EscapeUriString(keywords), UriKind.Relative));

            Log.Info("Performing search query: " + url.ToStringRfc());
            using (var webClient = new WebClientTimeout())
            {
                var result = XmlStorage.FromXmlString <SearchQuery>(webClient.DownloadString(url));
                result.Keywords = keywords;
                return(result);
            }
        }
Beispiel #3
0
 private static void CheckOriginXB1()
 {
     try
     {
         var wc = new WebClientTimeout {
             Proxy = null, Timeout = 10000
         };
         var str = wc.DownloadString("http://origin.xb1.warframe.com/index.txt.lzma");
         FlatFile.WriteStatus("originxb1", true);
     }
     catch (Exception ex)
     {
         FlatFile.WriteStatus("originxb1", false);
         Log.ErrorFormat("Origin XB1 check failed: {0}", ex.Message);
     }
 }
Beispiel #4
0
 private static void CheckForums()
 {
     try
     {
         var wc = new WebClientTimeout {
             Proxy = null, Timeout = 10000
         };
         var str = wc.DownloadString("https://forums.warframe.com");
         if (!str.Contains("div"))
         {
             throw new Exception("No div detected in str");
         }
         FlatFile.WriteStatus("forums", true);
     }
     catch (Exception ex)
     {
         FlatFile.WriteStatus("forums", false);
         Log.ErrorFormat("Forums check failed: {0}", ex.Message);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Adds a feed to the list of custom feeds.
        /// </summary>
        private void AddCustomFeed(string input)
        {
            FeedUri feedUri;

            try
            {
                feedUri = new FeedUri(input);
            }
            catch (UriFormatException ex)
            {
                Msg.Inform(this, ex.Message, MsgSeverity.Error);
                return;
            }

            if (_interfaceUri.IsFile)
            {
                if (!File.Exists(_interfaceUri.LocalPath))
                {
                    Msg.Inform(this, string.Format(Resources.FileOrDirNotFound, _interfaceUri.LocalPath), MsgSeverity.Warn);
                    return;
                }
            }
            else
            {
                Feed feed = null;
                try
                {
                    using (var handler = new DialogTaskHandler(this))
                    {
                        handler.RunTask(new SimpleTask(Resources.CheckingFeed,
                                                       delegate
                        {
                            using (var webClient = new WebClientTimeout())
                                feed = XmlStorage.FromXmlString <Feed>(webClient.DownloadString(feedUri));
                        }));
                    }
                }
                #region Error handling
                catch (OperationCanceledException)
                {
                    return;
                }
                catch (IOException ex)
                {
                    Msg.Inform(this, ex.Message, MsgSeverity.Error);
                    return;
                }
                catch (InvalidDataException ex)
                {
                    Msg.Inform(this, ex.Message, MsgSeverity.Error);
                    return;
                }
                catch (WebException ex)
                {
                    Msg.Inform(this, ex.Message, MsgSeverity.Error);
                    return;
                }
                catch (UnauthorizedAccessException ex)
                {
                    Msg.Inform(this, ex.Message, MsgSeverity.Error);
                    return;
                }
                #endregion

                // Ensure a matching <feed-for> is present for online feeds
                if (feed.FeedFor.All(entry => entry.Target != _interfaceUri))
                {
                    if (!Msg.YesNo(this, Resources.IgnoreMissingFeedFor, MsgSeverity.Warn))
                    {
                        return;
                    }
                }
            }

            var reference = new FeedReference {
                Source = feedUri
            };
            if (_interfacePreferences.Feeds.Contains(reference))
            {
                return;
            }
            _interfacePreferences.Feeds.Add(reference);
            listBoxFeeds.Items.Add(reference);
        }
Beispiel #6
0
        public async Task <HDriveData> CollectData(string ipAddress, string mac)
        {
            int    protocolVersion  = 0;
            int    fwVersion        = 0;
            int    serialNumber     = 0;
            int    bootloderVersion = 0;
            int    appId            = 0;
            string guiVersion       = "N/A";

            DebugConsoleText += System.Environment.NewLine + DateTime.Now.TimeOfDay + " reading Web-Gui version of:" + ipAddress;
            DebugConsoleText += System.Environment.NewLine + DateTime.Now.TimeOfDay + " Reading objects from motor:" + ipAddress;

            try
            {
                using (var client = new WebClientTimeout())
                {
                    string downloadString = client.DownloadString("http://" + ipAddress);
                    guiVersion = GetBetween(downloadString, "Web-Gui version", "</p>");
                }

                using (var client = new WebClientTimeout())
                {
                    int    subindex       = 22;
                    int    index          = 4;
                    string downloadString = client.DownloadString("http://" + ipAddress + "/getData.cgi?obj=" + (subindex << 8 | index));
                    int.TryParse(downloadString, out protocolVersion);
                }

                using (var client = new WebClientTimeout())
                {
                    int    subindex       = 0;
                    int    index          = 3;
                    string downloadString = client.DownloadString("http://" + ipAddress + "/getData.cgi?obj=" + (subindex << 8 | index));
                    int.TryParse(downloadString, out fwVersion);
                }

                using (var client = new WebClientTimeout())
                {
                    int    subindex       = 13;
                    int    index          = 3;
                    string downloadString = client.DownloadString("http://" + ipAddress + "/getData.cgi?obj=" + (subindex << 8 | index));
                    int.TryParse(downloadString, out serialNumber);
                }

                using (var client = new WebClientTimeout())
                {
                    int    subindex       = 15;
                    int    index          = 3;
                    string downloadString = client.DownloadString("http://" + ipAddress + "/getData.cgi?obj=" + (subindex << 8 | index));
                    int.TryParse(downloadString, out appId);
                }

                using (var client = new WebClientTimeout())
                {
                    int    subindex       = 16;
                    int    index          = 3;
                    string downloadString = client.DownloadString("http://" + ipAddress + "/getData.cgi?obj=" + (subindex << 8 | index));
                    int.TryParse(downloadString, out bootloderVersion);
                }

                if (guiVersion.Length > 10)
                {
                    guiVersion = "N/A";
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(new HDriveData(ipAddress, mac, protocolVersion, fwVersion, serialNumber, bootloderVersion, appId, guiVersion));
        }