Esempio n. 1
0
        private void ButtonDiscoverEndpoint_Click(object sender, RoutedEventArgs e)
        {
            var discover = new BlogEndpointDiscovery();

            var url = Model.ActiveWeblogInfo.ApiUrl;

            ShowStatus("Checking Endpoint Url...");

            if (discover.CheckRpcEndpoint(url))
            {
                ShowStatus("The Weblog Endpoint is a valid RPC endpoint.");
                return;
            }

            var blogInfo = discover.DiscoverBlogEndpoint(url, Model.ActiveWeblogInfo.BlogId as string, Model.ActiveWeblogInfo.Type.ToString());

            if (blogInfo.HasError)
            {
                MessageBox.Show(blogInfo.ErrorMessage, "Unable to discover Endpoint Url",MessageBoxButton.OK,MessageBoxImage.Warning);
                ShowStatus("Endpoint discovery failed: " + blogInfo.ErrorMessage, 6000);
                return;
            }

            Model.ActiveWeblogInfo.ApiUrl = blogInfo.ApiUrl;
            Model.ActiveWeblogInfo.BlogId = blogInfo.BlogId;
            if (blogInfo.BlogType == "MetaWeblog" || blogInfo.BlogType == "MetaWeblogApi")
                Model.ActiveWeblogInfo.Type = WeblogTypes.MetaWeblogApi;
            else if (blogInfo.BlogType == "WordPress")
                Model.ActiveWeblogInfo.Type = WeblogTypes.Wordpress;
            else
                Model.ActiveWeblogInfo.Type = WeblogTypes.Unknown;

            ShowStatus("Weblog API Endpoint Url found and updated...", 6000);
        }
Esempio n. 2
0
        private void ButtonDiscoverEndpoint_Click(object sender, RoutedEventArgs e)
        {
            if (Model.ActiveWeblogInfo == null)
            {
                return;
            }

            var discover = new BlogEndpointDiscovery();

            var url = Model.ActiveWeblogInfo.ApiUrl;

            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            StatusBar.ShowStatusProgress("Checking Endpoint Url...");

            if (discover.CheckRpcEndpoint(url))
            {
                StatusBar.ShowStatusSuccess("The Weblog Endpoint is a valid RPC endpoint.", 10000);
                return;
            }

            var blogInfo = discover.DiscoverBlogEndpoint(url, Model.ActiveWeblogInfo.BlogId as string,
                                                         Model.ActiveWeblogInfo.Type.ToString());

            if (blogInfo.HasError)
            {
                if (url.IndexOf("medium.com", StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    Model.ActiveWeblogInfo.ApiUrl = "https://api.medium.com/v1/";
                    Model.ActiveWeblogInfo.Type   = WeblogTypes.Medium;
                    StatusBar.ShowStatusSuccess("Weblog API Endpoint Url found and updated.");
                    return;
                }

                StatusBar.ShowStatusError($"Endpoint Discovery: {blogInfo.ErrorMessage}");
                return;
            }

            Model.ActiveWeblogInfo.ApiUrl = blogInfo.ApiUrl;
            Model.ActiveWeblogInfo.BlogId = blogInfo.BlogId;
            if (blogInfo.BlogType == "MetaWeblog" || blogInfo.BlogType == "MetaWeblogApi")
            {
                Model.ActiveWeblogInfo.Type = WeblogTypes.MetaWeblogApi;
            }
            else if (blogInfo.BlogType == "WordPress")
            {
                Model.ActiveWeblogInfo.Type = WeblogTypes.Wordpress;
            }
            else
            {
                Model.ActiveWeblogInfo.Type = WeblogTypes.Unknown;
            }

            StatusBar.ShowStatusSuccess("Weblog API Endpoint Url found and updated.", 6000);
        }
        private void RsdToUrlTest(string discoveryUrl)
        {
            var             discover = new BlogEndpointDiscovery();
            BlogApiEndpoint ep       = discover.DiscoverBlogEndpoint(discoveryUrl, "1", "MetaWeblog");

            Assert.IsNotNull(ep);
            Console.WriteLine(ep.ApiUrl + " " + ep.BlogType + " - " + ep.BlogId + "\r\n" + ep.Rsd);
            Assert.AreNotEqual(discoveryUrl, ep.ApiUrl);
        }
        public void DiscoverFSharpForWestWindBlogNoRDS()
        {
            // no RDS
            string discoveryUrl = "http://weblog.west-wind.com/metaweblogapi.ashx";

            var             discover = new BlogEndpointDiscovery();
            BlogApiEndpoint ep       = discover.DiscoverBlogEndpoint(discoveryUrl, "1", "MetaWeblog");


            Assert.IsNotNull(ep);
            Console.WriteLine(ep.ApiUrl + " " + ep.BlogType + " - " + ep.BlogId + "\r\n" + ep.Rsd);
            Assert.AreEqual(discoveryUrl, ep.ApiUrl);
        }
        private void ButtonDiscoverEndpoint_Click(object sender, RoutedEventArgs e)
        {
            var discover = new BlogEndpointDiscovery();

            var url = Model.ActiveWeblogInfo.ApiUrl;


            ShowStatus("Checking Endpoint Url...");

            if (discover.CheckRpcEndpoint(url))
            {
                ShowStatus("The Weblog Endpoint is a valid RPC endpoint.");
                return;
            }

            var blogInfo = discover.DiscoverBlogEndpoint(url, Model.ActiveWeblogInfo.BlogId as string, Model.ActiveWeblogInfo.Type.ToString());

            if (blogInfo.HasError)
            {
                if (url.IndexOf("medium.com", StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    Model.ActiveWeblogInfo.ApiUrl = "https://api.medium.com/v1/";
                    Model.ActiveWeblogInfo.Type   = WeblogTypes.Medium;
                    ShowStatus("Weblog API Endpoint Url found and updated", mmApp.Configuration.StatusMessageTimeout);
                    return;
                }

                MessageBox.Show(blogInfo.ErrorMessage, "Unable to discover Endpoint Url", MessageBoxButton.OK, MessageBoxImage.Warning);
                ShowStatus("Endpoint discovery failed: " + blogInfo.ErrorMessage, 6000);
                return;
            }

            Model.ActiveWeblogInfo.ApiUrl = blogInfo.ApiUrl;
            Model.ActiveWeblogInfo.BlogId = blogInfo.BlogId;
            if (blogInfo.BlogType == "MetaWeblog" || blogInfo.BlogType == "MetaWeblogApi")
            {
                Model.ActiveWeblogInfo.Type = WeblogTypes.MetaWeblogApi;
            }
            else if (blogInfo.BlogType == "WordPress")
            {
                Model.ActiveWeblogInfo.Type = WeblogTypes.Wordpress;
            }
            else
            {
                Model.ActiveWeblogInfo.Type = WeblogTypes.Unknown;
            }

            ShowStatus("Weblog API Endpoint Url found and updated...", 6000);
        }