private void init(string url)
 {
     this.url         = url;
     confluence       = new ConfluenceSoapServiceService();
     confluence.Url   = url;
     confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
 }
示例#2
0
        private void ExecuteLoggedIn(Action <ConfluenceSoapServiceService, string> code)
        {
            ConfluenceSoapServiceService confluence = null;
            var token = string.Empty;

            try
            {
                confluence = new ConfluenceSoapServiceService
                {
                    Url = this.Url
                };
                token = confluence.login(this.UserName, this.Password);

                code(confluence, token);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                if (confluence != null)
                {
                    confluence.logout(token);
                }
            }
        }
示例#3
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);
            }
        }
示例#4
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);
        }
 public string Reconnect()
 {
     _confluenceService     = new ConfluenceSoapServiceService();
     _confluenceService.Url = _confluenceApiUrl;
     _token = _confluenceService.login(_userName, _password);
     return(_token);
 }
示例#6
0
        public ConfluenceServiceWrapper(string serviceUrl, string authToken)
        {
            _authToken = authToken;

            _service = new ConfluenceSoapServiceService
            {
                Url = serviceUrl
            };
        }
示例#7
0
 private void Init(string url)
 {
     _url        = url;
     _confluence = new ConfluenceSoapServiceService
     {
         Url   = url,
         Proxy = NetworkHelper.CreateProxy(new Uri(url))
     };
 }
 protected virtual void Dispose(bool disposing)
 {
     if (confluence != null)
     {
         logout();
     }
     if (disposing)
     {
         if (confluence != null)
         {
             confluence.Dispose();
             confluence = null;
         }
     }
 }
        public ConfluenceClient(string user, string password)
        {
            if (String.IsNullOrEmpty(user))
            {
                throw new ArgumentNullException("user");
            }

            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            m_client = new ConfluenceSoapServiceService();
            m_token  = m_client.login(user, password);
        }
示例#10
0
 protected void Dispose(bool disposing)
 {
     if (_confluence != null)
     {
         Logout();
     }
     if (disposing)
     {
         if (_confluence != null)
         {
             _confluence.Dispose();
             _confluence = null;
         }
     }
 }
示例#11
0
 public ConfluenceService(LogData logData)
 {
     m_soapService = new ConfluenceSoapServiceService();
     m_logData     = logData;
     m_username    = "";
 }
        /// <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;
            }
        }