Exemple #1
0
        /// <summary>
        /// Actual code performed when action is executed in Do
        /// </summary>
        /// <param name="items">
        /// Items. ITextItem <see cref="IItem"/>
        /// </param>
        /// <param name="modItems">
        /// Modifier Items. None <see cref="IItem"/>
        /// </param>
        /// <returns>
        /// Array of Bookmark Items. URLs to search results <see cref="IItem"/>
        /// </returns>
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            try
            {
                ConfluenceSoapServiceService soapService = new ConfluenceSoapServiceService(_config.BaseUrl);

                // Only login if username AND password were provided in the config.
                // Otherwise, use anonymous access with a null token.
                String token = null;
                if (_config.Username != null && _config.Username.Trim().Length != 0 &&
                    _config.Password != null && _config.Password.Trim().Length != 0)
                {
                    token = soapService.login(_config.Username, _config.Password);
                }

                string query = (items.First() as ITextItem).Text;
                RemoteSearchResult[] results = soapService.search(token, query, _config.MaxSearchResults);

                List <Item> retItems = new List <Item> ();
                foreach (RemoteSearchResult result in results)
                {
                    retItems.Add(new BookmarkItem(result.title, result.url));
                }

                return(retItems.ToArray());
            }
            catch (Exception e)
            {
                Log("Unable to search Confluence: {0}", e);
                return(null);
            }
        }
Exemple #2
0
        public string RunCommand()
        {
            IBitlyService bitlyService = new BitlyService("vhytyk", "R_5d31d4dc7a364cf6af291c7533655e55");

            string result = null;

            if (!string.IsNullOrEmpty(_searchPhrase))
            {
                var wikiService = new ConfluenceSoapServiceService();
                if (null == wikiToken)
                {
                    wikiToken = wikiService.login("vhytyk", "");
                }

                var resultList = new List <string>();
                var searchList = wikiService.search(wikiToken, _searchPhrase, 20)
                                 .Where(r => r.type == "page")
                                 .Take(3)
                                 .ToList();

                searchList.ForEach(s =>
                {
                    resultList.Add(string.Format("{1} ({0})",
                                                 bitlyService.Shorten(s.url.Replace("wiki/", "wiki.justanswer.local/")), s.title));
                });



                result = string.Join("\r", resultList);
            }

            return(result);
        }
Exemple #3
0
 public IEnumerable <Page> SearchPages(string query, string space)
 {
     CheckCredentials();
     foreach (var searchResult in _confluence.search(_credentials, query, 20))
     {
         Log.DebugFormat("Got result of type {0}", searchResult.type);
         if ("page".Equals(searchResult.type))
         {
             yield return(new Page(searchResult, space));
         }
     }
 }
        public List <Page> searchPages(string query, string space)
        {
            checkCredentials();
            List <Page> results = new List <Page>();

            foreach (RemoteSearchResult searchResult in confluence.search(credentials, query, 20))
            {
                LOG.DebugFormat("Got result of type {0}", searchResult.type);
                if ("page".Equals(searchResult.type))
                {
                    results.Add(new Page(searchResult, space));
                }
            }
            return(results);
        }
        /// <summary>
        /// Actual code performed when action is executed in Do
        /// </summary>
        /// <param name="items">
        /// Items. ITextItem <see cref="IItem"/>
        /// </param>
        /// <param name="modItems">
        /// Modifier Items. None <see cref="IItem"/>
        /// </param>
        /// <returns>
        /// Array of Bookmark Items. URLs to search results <see cref="IItem"/>
        /// </returns>
        public override IEnumerable<Item> Perform(IEnumerable<Item> items, IEnumerable<Item> modItems)
        {
            try
            {
                ConfluenceSoapServiceService soapService = new ConfluenceSoapServiceService(_config.BaseUrl);

                // Only login if username AND password were provided in the config.
                // Otherwise, use anonymous access with a null token.
                String token = null;
                if (_config.Username != null && _config.Username.Trim().Length != 0 &&
                      _config.Password != null && _config.Password.Trim().Length != 0)
                {
                    token = soapService.login(_config.Username, _config.Password);
                }

                string query = (items.First () as ITextItem).Text;
                RemoteSearchResult[] results = soapService.search(token, query, _config.MaxSearchResults);

                List<Item> retItems = new List<Item> ();
                foreach (RemoteSearchResult result in results)
                {
                    retItems.Add(new BookmarkItem(result.title, result.url));
                }

                return retItems.ToArray();
            }
            catch( Exception e )
            {
                Log( "Unable to search Confluence: {0}", e );
                return null;
            }
        }