Beispiel #1
0
        public void DoubleAdd()
        {
            var xps = new XmlRpcStruct();

            xps.Add("foo", "123456");
            Assert.That(() => xps.Add("foo", "abcdef"), Throws.ArgumentException);
        }
Beispiel #2
0
        public void OrderingEnumerator()
        {
            var xps = new XmlRpcStruct();

            xps.Add("1", "a");
            xps.Add("3", "c");
            xps.Add("2", "b");
            IDictionaryEnumerator enumerator = xps.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("1", enumerator.Key);
            Assert.AreEqual("a", enumerator.Value);
            Assert.IsInstanceOf(typeof(DictionaryEntry), enumerator.Current);
            DictionaryEntry de = (DictionaryEntry)enumerator.Current;

            Assert.AreEqual("1", de.Key);
            Assert.AreEqual("a", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("3", enumerator.Key);
            Assert.AreEqual("c", enumerator.Value);
            Assert.IsInstanceOf(typeof(DictionaryEntry), enumerator.Current);
            de = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("3", de.Key);
            Assert.AreEqual("c", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("2", enumerator.Key);
            Assert.AreEqual("b", enumerator.Value);
            Assert.IsInstanceOf(typeof(DictionaryEntry), enumerator.Current);
            de = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("2", de.Key);
            Assert.AreEqual("b", de.Value);
        }
Beispiel #3
0
        public static bool admin_save_oar(string password, string nomeRegiao, string oarfile)
        {
            XmlRpcStruct saveAccept = new XmlRpcStruct();
            XmlRpcStruct saveParms  = new XmlRpcStruct();

            saveParms.Add("password", password);
            saveParms.Add("region_name", nomeRegiao);
            saveParms.Add("filename", oarfile);

            RemoteOpensim admin = XmlRpcProxyGen.Create <RemoteOpensim>();

            try
            {
                saveAccept = admin.admin_save_oar(saveParms);
            }
            catch
            {
                return(false);
            }

            bool retShut = true;

            /*
             * foreach (DictionaryEntry ReturnResults in saveAccept)
             * {
             *  if ((ReturnResults.Key.ToString() == "success") && ((bool)ReturnResults.Value))
             *  {
             *      retShut = true;
             *      break;
             *  }
             * }
             */

            return(retShut);
        }
        /// <summary>
        /// 下载磁链接文件
        /// </summary>
        /// <param name="metalink">磁链接文件</param>
        /// <param name="dir">下载目录</param>
        /// <returns>成功返回任务标识符数组,失败返回空数组</returns>
        public static string[] AddMetalink(ref string strSHA1Hex, string metalink, string fileName = "", string dir = "")
        {
            FileStream fs = File.Open(metalink, FileMode.Open, FileAccess.Read);

            byte[] bytes = new byte[fs.Length];
            fs.Seek(0, SeekOrigin.Begin);
            fs.Read(bytes, 0, bytes.Length);
            fs.Dispose();

            string[]     gids;
            XmlRpcStruct option = new XmlRpcStruct();

            if (dir != "")
            {
                option.Add("dir", dir);
            }

            if (fileName != "")
            {
                option.Add("out", fileName);
            }

            if (option.Count > 0)
            {
                gids = aria2c.AddMetalink(Aria2cRpcSecret, bytes, option);
            }
            else
            {
                gids = aria2c.AddMetalink(Aria2cRpcSecret, bytes);
            }

            strSHA1Hex = GetSHA1HexStrOfMetadata(bytes);

            return(gids);
        }
Beispiel #5
0
        public XmlRpcStruct RunKeyword(string keywordName, string[] arguments)
        {
            var result = new XmlRpcStruct();

            Keyword keyword;

            if (!keywordManager.TryGetKeyword(keywordName, out keyword))
            {
                throw new XmlRpcFaultException(1, string.Format("Keyword \"{0}\" not found", keywordName));
            }

            try
            {
                var keywordResult = keyword.Execute(arguments);
                if (keywordResult != null)
                {
                    result.Add(KeywordResultValue, keywordResult.ToString());
                }
                result.Add(KeywordResultStatus, KeywordResultPass);
            }
            catch (Exception e)
            {
                result.Clear();

                result.Add(KeywordResultStatus, KeywordResultFail);
                result.Add(KeywordResultError, BuildRecursiveErrorMessage(e));
                result.Add(KeywordResultTraceback, e.StackTrace);
            }

            return(result);
        }
Beispiel #6
0
        public XmlRpcStruct RunKeyword(string keywordName, string[] arguments)
        {
            var result = new XmlRpcStruct();

            KeywordManager.KeywordLookupResult lookupResult = default(KeywordManager.KeywordLookupResult);
            try
            {
                lookupResult = keywordManager.TryExecuteKeyword(keywordName, arguments, out var keywordResult);
                if (lookupResult == KeywordManager.KeywordLookupResult.Success)
                {
                    if (keywordResult != null)
                    {
                        result.Add(KeywordResultValue, keywordResult);
                    }
                    result.Add(KeywordResultStatus, KeywordResultPass);
                }
            }
            catch (Exception e)
            {
                result.Clear();

                result.Add(KeywordResultStatus, KeywordResultFail);
                result.Add(KeywordResultError, BuildRecursiveValueFromException(e, ex => ex.Message).StripNonSafeCharacters());
                result.Add(KeywordResultTraceback, BuildRecursiveValueFromException(e, ex => ex.StackTrace).StripNonSafeCharacters());
            }
            if (lookupResult == KeywordManager.KeywordLookupResult.KeywordNotFound)
            {
                throw new XmlRpcFaultException(1, string.Format("Keyword \"{0}\" not found", keywordName));
            }
            if (lookupResult == KeywordManager.KeywordLookupResult.ArgumentsNotMatched)
            {
                throw new XmlRpcFaultException(2, string.Format("Arguments types do not match any available keyword \"{0}\" : [{1}]", keywordName, string.Join(", ", arguments)));
            }
            return(result);
        }
        /// <summary>
        /// 添加下载任务
        /// </summary>
        /// <param name="uri">下载地址</param>
        /// <param name="fileName">输出文件名</param>
        /// <param name="dir">下载文件夹</param>
        /// <returns>成功返回任务标识符,失败返回空</returns>
        public static string AddUri(string uri, string fileName = "", string dir = "")
        {
            string[]     uris = new string[] { uri };
            string       gid;
            XmlRpcStruct option = new XmlRpcStruct();

            if (dir != "")
            {
                option.Add("dir", dir);
            }

            if (fileName != "")
            {
                option.Add("out", fileName);
            }

            if (option.Count > 0)
            {
                gid = aria2c.AddUri(uris, option);
            }
            else
            {
                gid = aria2c.AddUri(uris);
            }

            return(gid);
        }
        /// <summary>
        /// 下载磁链接文件
        /// </summary>
        /// <param name="metalink">磁链接文件</param>
        /// <param name="dir">下载目录</param>
        /// <returns>成功返回任务标识符,失败返回空</returns>
        public static string AddMetalink(string metalink, string fileName = "", string dir = "")
        {
            FileStream fs = File.Open(metalink, FileMode.Open);

            byte[] bytes = new byte[fs.Length];
            fs.Close();

            string       gid;
            XmlRpcStruct option = new XmlRpcStruct();

            if (dir != "")
            {
                option.Add("dir", dir);
            }

            if (fileName != "")
            {
                option.Add("out", fileName);
            }

            if (option.Count > 0)
            {
                gid = aria2c.AddMetalink(bytes, option);
            }
            else
            {
                gid = aria2c.AddMetalink(bytes);
            }

            return(gid);
        }
Beispiel #9
0
        [Ignore("Unsupported due to migration")] // [ExpectedException(typeof(ArgumentException))]
        public void DoubleAdd()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps.Add("foo", "123456");
            xps.Add("foo", "abcdef");
        }
        /// <summary>
        /// 添加下载任务
        /// </summary>
        /// <param name="uri">下载地址</param>
        /// <param name="fileName">输出文件名</param>
        /// <param name="dir">下载文件夹</param>
        /// <returns>成功返回任务标识符,失败返回空</returns>
        public static string AddUri(string uri, string fileName = "", string dir = "", string userAgent = null)
        {
            string[]     uris = new string[] { uri };
            string       gid;
            XmlRpcStruct option = new XmlRpcStruct();

            if (dir != "")
            {
                option.Add("dir", dir);
            }

            if (fileName != "")
            {
                option.Add("out", fileName);
            }

            if (!string.IsNullOrWhiteSpace(userAgent))
            {
                option.Add("user-agent", userAgent);
            }

            if (option.Count > 0)
            {
                gid = aria2c.AddUri(Aria2cRpcSecret, uris, option);
            }
            else
            {
                gid = aria2c.AddUri(Aria2cRpcSecret, uris);
            }

            return(gid);
        }
        public string PostEmployee([FromBody] Employee employee)
        {
            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>();

            rpcClientLogin.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

            //login
            int userId = rpcClientLogin.Login(db, username, password);

            //Add Contacts(Customers)
            IOpenErpAddFields rpcField      = XmlRpcProxyGen.Create <IOpenErpAddFields>();
            XmlRpcStruct      addPairFields = new XmlRpcStruct();

            addPairFields.Add("x_UUID", employee.UUID);
            addPairFields.Add("name", employee.Name);
            addPairFields.Add("email", employee.Email);
            addPairFields.Add("x_timestamp", employee.Timestamp);
            addPairFields.Add("x_version", employee.Version);
            addPairFields.Add("active", employee.Active);
            addPairFields.Add("employee", true);
            addPairFields.Add("login", employee.Email);
            addPairFields.Add("sel_groups_1_9_10", 1);
            addPairFields.Add("sel_groups_38_39", 38);

            int resAdd = rpcField.Create(db, userId, password, "res.users", "create", addPairFields);

            return("Employee created with id = " + resAdd);
        }
Beispiel #12
0
        /// <summary>
        /// Creates a <code>SSXManager</code> from the cleaned HTML of a local editing page.
        /// </summary>
        /// <param name="pageConverter">An instance of the <code>ConversionManager</code> for this page.</param>
        /// <param name="cleanHTML">Cleaned HTML of the local page.</param>
        /// <returns>An instance of a <code>SSXManager</code>.</returns>
        public static SSXManager BuildFromLocalHTML(ConversionManager pageConverter, string cleanHTML)
        {
            SSXManager  ssxManager = new SSXManager();
            XmlDocument xmlDoc     = new XmlDocument();

            xmlDoc.LoadXml(cleanHTML);
            XmlNodeList styleNodes     = xmlDoc.GetElementsByTagName("style");
            string      pageCSSContent = "";

            foreach (XmlNode styleNode in styleNodes)
            {
                pageCSSContent += styleNode.InnerText;
            }

            XmlRpcStruct dictionary = new XmlRpcStruct();

            dictionary.Add("code", pageCSSContent);
            dictionary.Add("name", "XOfficeStyle");
            dictionary.Add("use", "currentPage");
            dictionary.Add("parse", "0");
            dictionary.Add("cache", "forbid");

            XWikiObject ssxObject = new XWikiObject();

            ssxObject.className        = SSX_CLASS_NAME;
            ssxObject.pageId           = pageConverter.States.PageFullName;
            ssxObject.objectDictionary = dictionary;

            ssxManager.pageFullName             = pageConverter.States.PageFullName;
            ssxManager.pageCSSContent           = pageCSSContent;
            ssxManager.pageStyleSheetExtensions = new List <XWikiObject>();
            ssxManager.pageStyleSheetExtensions.Add(ssxObject);
            ssxManager.pageConverter = pageConverter;
            return(ssxManager);
        }
Beispiel #13
0
        public XmlRpcStruct[] getCategories(string blogid, string username, string password)
        {
            int ii = 0;

            Authenticate(username, password);

            var blog = ContentHelper.GetContentDatabase().GetItem(blogid);

            if (blog != null)
            {
                var categoryList = ManagerFactory.CategoryManagerInstance.GetCategories(blog);

                XmlRpcStruct[] categories = new XmlRpcStruct[categoryList.Length];

                foreach (CategoryItem category in categoryList)
                {
                    XmlRpcStruct rpcstruct = new XmlRpcStruct();
                    rpcstruct.Add("categoryid", category.ID.ToString());          // Category ID
                    rpcstruct.Add("title", category.Title.Raw);                   // Category Title
                    rpcstruct.Add("description", "Description is not available"); // Category Description
                    categories[ii] = rpcstruct;
                    ii++;
                }

                return(categories);
            }

            return(new XmlRpcStruct[0]);
        }
Beispiel #14
0
        public void NewPost_ValidUser()
        {
            var entryContent = new XmlRpcStruct();

            entryContent.Add("title", "the title");
            entryContent.Add("description", "the description");

            var newId = m_api.newPost(m_blog1.ID.ToString(), m_userAuthor.Name, PASSWORD, entryContent, false);

            Assert.IsNotNullOrEmpty(newId);

            var newItem = m_blog1.Database.GetItem(newId);

            try
            {
                Assert.AreEqual("the title", newItem["title"]);
                Assert.AreEqual("the description", newItem["content"]);
            }
            finally
            {
                using (new SecurityDisabler())
                {
                    newItem.Delete();
                }
            }
        }
        /// <summary>
        /// 下载种子链接文件
        /// </summary>
        /// <param name="torrent">种子文件</param>
        /// <param name="fileName">输出文件名</param>
        /// <param name="dir">下载目录</param>
        /// <returns>成功返回任务标识符,失败返回空</returns>
        public static string AddTorrent(string torrent, string fileName = "", string dir = "")
        {
            FileStream fs = File.Open(torrent, FileMode.Open);
            byte[] bytes = new byte[fs.Length];
            fs.Close();

            string gid;
            XmlRpcStruct option = new XmlRpcStruct();

            if (dir != "")
            {
                option.Add("dir", dir);
            }

            if (fileName != "")
            {
                option.Add("out", fileName);
            }

            if (option.Count > 0)
            {
                gid = aria2c.AddTorrent(bytes, new string[] { "" }, option);
            }
            else
            {
                gid = aria2c.AddTorrent(bytes);
            }

            return gid;
        }
Beispiel #16
0
        public void NewPost_ValidUserFuturePublish()
        {
            var publishDate = new DateTime(2020, 10, 10, 13, 12, 12);

            var entryContent = new XmlRpcStruct();

            entryContent.Add("title", "the title");
            entryContent.Add("description", "the description");
            entryContent.Add("dateCreated", publishDate);

            var newId = m_api.newPost(m_blog1.ID.ToString(), m_userAuthor.Name, PASSWORD, entryContent, false);

            Assert.IsNotNullOrEmpty(newId);

            var newItem = m_blog1.Database.GetItem(newId);

            try
            {
                Assert.AreEqual(publishDate, newItem.Publishing.PublishDate);
            }
            finally
            {
                using (new SecurityDisabler())
                {
                    newItem.Delete();
                }
            }
        }
Beispiel #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ImdbId"></param>
        /// <param name="query"></param>
        /// <param name="languages"></param>
        /// <returns></returns>
        public List <SearchSubtitleResult> SearchByImdbIdThenQuery(string ImdbId, string query, OSLanguage languages)
        {
            XmlRpcStruct SearchParamsStruct = new XmlRpcStruct();

            if (languages != null)
            {
                SearchParamsStruct.Add("sublanguageid", languages.IdSubLanguage);
            }
            else
            {
                SearchParamsStruct.Add("sublanguageid", "all");
            }
            if (!String.IsNullOrEmpty(ImdbId))
            {
                SearchParamsStruct.Add("imdbid", ImdbId);
            }
            if (!String.IsNullOrEmpty(query))
            {
                SearchParamsStruct.Add("query", query);
            }
            XmlRpcStruct ResponseStruct = proxy.SearchSubtitles(Token, new object[1] {
                new XmlRpcStruct[1] {
                    SearchParamsStruct
                }
            });
            List <SearchSubtitleResult> SearchResultList = DoSearchRequest(ResponseStruct);

            return(SearchResultList);
        }
Beispiel #18
0
 public List <SearchSubtitleResult> SearchByFile(FileInfo VideoFile, OSLanguage languages)
 {
     if (VideoFile != null && VideoFile.Exists)
     {
         XmlRpcStruct SearchParamsStruct = new XmlRpcStruct();
         XmlRpcStruct Limit = new XmlRpcStruct();
         Limit.Add("limit", 10);
         if (languages != null)
         {
             SearchParamsStruct.Add("sublanguageid", languages.IdSubLanguage);
         }
         else
         {
             SearchParamsStruct.Add("sublanguageid", "all");
         }
         byte[] hash = GetHash.Main.ComputeHash(VideoFile.FullName);
         SearchParamsStruct.Add("moviehash", GetHash.Main.ToHexadecimal(hash));
         SearchParamsStruct.Add("moviebytesize", Convert.ToDouble(VideoFile.Length));
         XmlRpcStruct ResponseStruct = proxy.SearchSubtitles(Token, new object[2] {
             new XmlRpcStruct[1] {
                 SearchParamsStruct
             }, new XmlRpcStruct[1] {
                 Limit
             }
         });
         List <SearchSubtitleResult> SearchResultList = DoSearchRequest(ResponseStruct);
         return(SearchResultList);
     }
     return(new List <SearchSubtitleResult>());
 }
Beispiel #19
0
        public void DoubleAdd()
        {
            XmlRpcStruct xps = new XmlRpcStruct();

            xps.Add("foo", "123456");
            xps.Add("foo", "abcdef");
            Assert.Fail("Test should throw ArgumentException");
        }
Beispiel #20
0
        public static TestPlanTotal GetTestPlanTotal(
            string name,
            string type,
            int total_tc)
        {
//        /// <summary>
//        /// category name
//        /// </summary>
//        public readonly string Type = "";
//        /// <summary>
//        /// category value
//        /// </summary>
//        public readonly string Name = "";
//        /// <summary>
//        /// total test cases that are covered in this test plan
//        /// </summary>
//        public readonly int Total_tc;
//        /// <summary>
//        /// Dictionary with execution totals
//        /// </summary>
//        public readonly Dictionary<string, int> Details = new Dictionary<string, int>();
//
////        internal TestPlanTotal(XmlRpcStruct data)
////        {
//            Total_tc = toInt(data, "total_tc");
//            if (data.ContainsKey("type"))
//                Type = (string)data["type"];
//            if (data.ContainsKey("name"))
//                Name = (string)data["name"];
//
//            XmlRpcStruct xdetails = data["details"] as XmlRpcStruct;
//
//            foreach (string key in xdetails.Keys)
//            {
//                XmlRpcStruct val = xdetails[key] as XmlRpcStruct;
//                int qty = toInt(val,"qty");
//                Details.Add(key, qty);
//            }
////        }


            int id = generator.Next(1000000);

            XmlRpcStruct data = new XmlRpcStruct();

            data.Add("name", name);
            data.Add("type", type);
            data.Add("total_tc", total_tc);

            XmlRpcStruct details = new XmlRpcStruct();

            data.Add("details", details);

            var testPlanTotal = new Mock <TestPlanTotal>(data);

            return(testPlanTotal.Object);
        }
Beispiel #21
0
        /// <summary>
        /// Add an already upload file to cck file field, without saving the node
        /// </summary>
        /// <param name="fileFieldName">CCK field name</param>
        /// <param name="fid">File ID to attach</param>
        /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
        /// <param name="node">Node to attach file to (alresdy load with node load)</param>
        public bool AttachFileToNode(string fileFieldName, int fid, int fileIndex, XmlRpcStruct node)
        {
            XmlRpcStruct filenode = this.FileGet(fid);

            if (filenode == null)
            {
                return(false);
            }
            else
            {
                if (node[fileFieldName] == null)
                {
                    node[fileFieldName] = new object[1];
                }
                // Index is not within range of lenght + 1
                if ((node[fileFieldName] as object[]).Length < fileIndex)
                {
                    handleExeption(new IndexOutOfRangeException(), "Attach file to Node");
                    return(false);
                }
                else
                {
                    // index is one bigger than existing array, we need to add one object manually
                    List <object> objectList = new List <object>();
                    if ((node[fileFieldName] as object[]).Length == fileIndex)
                    {
                        foreach (object ob in (node[fileFieldName] as object[]))
                        {
                            objectList.Add(ob);
                        }
                        objectList.Add(new object());
                        node[fileFieldName] = objectList.ToArray();
                        // Add index list required for multiple files.
                        filenode.Add("list", (fileIndex + 1).ToString());
                    }
                    else
                    // Case a file was removed form the node, we need to reformat the object
                    if (((node[fileFieldName] as object[]).Length == 1) &&
                        ((node[fileFieldName] as object[])[0] is string))
                    {
                        objectList.Add(new object());
                        node[fileFieldName] = objectList.ToArray();
                        filenode.Add("list", (fileIndex + 1).ToString());
                    }
                    else
                    {
                        filenode.Add("list", (fileIndex + 1).ToString());
                    }

                    (node[fileFieldName] as object[])[fileIndex] = filenode;
                    return(true);
                }
            }
        }
Beispiel #22
0
        private XmlRpcStruct CreateSearchStructure(List <string> languages, string hashString, long videoSize)
        {
            var searchStructure    = new XmlRpcStruct();
            var preferredLanguages = this.GetSubtitleString(languages);

            searchStructure.Add("sublanguageid", preferredLanguages);
            searchStructure.Add("moviehash", hashString);
            searchStructure.Add("moviebytesize", videoSize.ToString());
            searchStructure.Add("imdbid", "");
            return(searchStructure);
        }
Beispiel #23
0
        public void NewPost_InvalidUser()
        {
            var entryContent = new XmlRpcStruct();

            entryContent.Add("title", "the title");
            entryContent.Add("description", "the description");

            var newId = m_api.newPost(m_blog1.ID.ToString(), "sitecore\\a", "a", entryContent, false);

            Assert.IsNullOrEmpty(newId);
        }
            public string GetDescription(string strUPC)
            {
                var request  = new XmlRpcStruct();
                var response = new XmlRpcStruct();


                request.Add("rpc_key", RPCKEY);
                request.Add("upc", strUPC);

                response = _proxy.Lookup(request);
                return(response["description"] + " " + response["size"]);
            }
Beispiel #25
0
        public void OrderingKeys2()
        {
            var xps = new XmlRpcStruct();

            xps.Add("member_1", "a");
            xps.Add("member_4", "c");

            IEnumerator enumerator = xps.Keys.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("member_1", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("member_4", enumerator.Current);
        }
        /// <summary>
        /// 添加下载任务
        /// </summary>
        /// <param name="uri">下载地址</param>
        /// <param name="fileName">输出文件名</param>
        /// <param name="dir">下载文件夹</param>
        /// <param name="taskOptions">下载任务选项(需要拆分)</param>
        /// <returns>成功返回任务标识符,失败返回空</returns>
        public static string AddUri(string uri, string fileName = "", string dir = "", List <Dictionary <string, string> > taskOptions = null)
        {
            string[]     uris = new string[] { uri };
            string       gid;
            XmlRpcStruct option = new XmlRpcStruct();

            if (dir != "")
            {
                option.Add("dir", dir);
            }

            if (fileName != "")
            {
                option.Add("out", fileName);
            }

            if (taskOptions != null && taskOptions.Count > 0)
            {
                string header = "";
                foreach (Dictionary <string, string> dicElement in taskOptions)
                {
                    foreach (KeyValuePair <string, string> item in dicElement)
                    {
                        if (item.Key == "header")
                        {
                            header += item.Value + Environment.NewLine;
                        }
                        else
                        {
                            option.Add(item.Key, item.Value);
                        }
                    }
                }
                if (header != "")
                {
                    option.Add("header", header.Trim(Environment.NewLine.ToCharArray()));
                }
            }

            if (option.Count > 0)
            {
                gid = aria2c.AddUri(Aria2cRpcSecret, uris, option);
            }
            else
            {
                gid = aria2c.AddUri(Aria2cRpcSecret, uris);
            }

            return(gid);
        }
Beispiel #27
0
        public XmlRpcStruct[] getRecentPosts(string blogid, string username, string password, int numberOfPosts)
        {
            int ii = 0;

            Authenticate(username, password);

            var blog = ContentHelper.GetContentDatabase().GetItem(blogid);

            if (blog != null)
            {
                var entryList = ManagerFactory.EntryManagerInstance.GetBlogEntries(blog, numberOfPosts, null, null, (DateTime?)null);

                XmlRpcStruct[] posts = new XmlRpcStruct[entryList.Length];

                //Populate structure with post entities
                foreach (EntryItem entry in entryList)
                {
                    XmlRpcStruct rpcstruct = new XmlRpcStruct();
                    rpcstruct.Add("title", entry.Title.Raw);
                    rpcstruct.Add("link", entry.AbsoluteUrl);
                    rpcstruct.Add("description", entry.Content.Text);
                    rpcstruct.Add("pubDate", entry.EntryDate.DateTime);
                    rpcstruct.Add("guid", entry.ID.ToString());
                    rpcstruct.Add("postid", entry.ID.ToString());
                    rpcstruct.Add("keywords", entry.Tags.Raw);
                    rpcstruct.Add("author", entry.InnerItem.Statistics.CreatedBy);
                    posts[ii] = rpcstruct;
                    ii++;
                }
                return(posts);
            }

            return(new XmlRpcStruct[0]);
        }
Beispiel #28
0
        public List <SearchSubtitleResult> SearchOnlyByQuery(string query, OSLanguage languages)
        {
            XmlRpcStruct SearchParamsStruct = new XmlRpcStruct();

            SearchParamsStruct.Add("sublanguageid", languages.IdSubLanguage);
            SearchParamsStruct.Add("query", query);
            XmlRpcStruct ResponseStruct = proxy.SearchSubtitles(Token, new object[1] {
                new XmlRpcStruct[1] {
                    SearchParamsStruct
                }
            });
            List <SearchSubtitleResult> SearchResultList = DoSearchRequest(ResponseStruct);

            return(SearchResultList);
        }
        public static XmlRpcStruct GetFieldNamesXmlRpcStruct(object[] fieldNames, Nullable <int> paginationOffset, Nullable <int> paginationLimit)
        {
            XmlRpcStruct result = new XmlRpcStruct();

            result.Add("fields", fieldNames);
            if (paginationOffset.HasValue)
            {
                result.Add("offset", paginationOffset.Value);
            }
            if (paginationLimit.HasValue)
            {
                result.Add("limit", paginationLimit.Value);
            }
            return(result);
        }
Beispiel #30
0
        //- @Ping -//
        public static void Ping(String name, Uri uri)
        {
            ITechnoratiPing proxy = XmlRpcProxyGen.Create <ITechnoratiPing>();
            XmlRpcStruct    call  = new XmlRpcStruct();

            call.Add("name", name);
            call.Add("url", uri.AbsoluteUri);
            XmlRpcStruct response = proxy.Ping(call);

            //+
            if (response["flerror"].ToString() == "1")
            {
                throw new ApplicationException(response["message"].ToString());
            }
        }