/// <summary> /// wp.getPage /// </summary> /// <param name="blogID">blogID in string format</param> /// <param name="pageID">page guid in string format</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <returns>struct with post details</returns> internal MWAPage GetPage(string blogID, string pageID, string userName, string password) { ValidateRequest(userName, password); var sendPage = new MWAPage(); var repository = Ioc.Resolve <IRepository>(); var page = repository.Get <Page>(x => x.Id == pageID.ToInt()); sendPage.pageID = page.Id.ToString(); sendPage.title = page.Title; sendPage.description = page.Content; sendPage.mt_keywords = page.Keywords; sendPage.pageDate = page.DateCreated; //sendPage.link = page.AbsoluteLink.AbsoluteUri; sendPage.mt_convert_breaks = "__default__"; return(sendPage); }
/// <summary> /// wp.getPages /// </summary> /// <param name="blogID">blogID in string format</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <returns></returns> internal List <MWAPage> GetPages(string blogID, string userName, string password) { ValidateRequest(userName, password); var pages = Ioc.Resolve <IRepository>() .Find <Page>() .OrderByDescending(x => x.Id); var mwaPages = new List <MWAPage>(); foreach (Page page in pages) { var mwaPage = new MWAPage(); mwaPage.pageID = page.Id.ToString(); mwaPage.title = page.Title; mwaPage.pageDate = page.DateCreated; //mwaPage.link = page.AbsoluteLink.AbsoluteUri; mwaPages.Add(mwaPage); } return(mwaPages); //return Ioc.Resolve<IRepository>() // .Find<Page>() // .OrderByDescending(x => x.Id) // .Select(page => new MWAPage() // { // pageID = page.Id.ToString(), // title = page.Title, // description = page.Content, // mt_keywords = page.Keywords, // pageDate = page.DateCreated, // link = page.AbsoluteLink.AbsoluteUri, // mt_convert_breaks = "__default__", // pageParentID = page.Parent.ToString() // }) // .ToList(); }
/// <summary> /// wp.newPage /// </summary> /// <param name="blogID">blogID in string format</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <param name="mPage"></param> /// <param name="publish"></param> /// <returns></returns> internal string NewPage(string blogID, string userName, string password, MWAPage mPage, bool publish) { ValidateRequest(userName, password); var repository = Ioc.Resolve <IRepository>(); var page = new Page(); page.Title = mPage.title; page.Content = mPage.description; page.Description = ""; // Can not be set from WLW page.Keywords = mPage.mt_keywords; if (mPage.pageDate != new DateTime()) { page.DateCreated = mPage.pageDate; } page.ShowInList = publish; page.IsPublished = publish; repository.Save(page); return(page.Id.ToString()); }
private void LoadXMLRequest(string xml) { var request = new XmlDocument(); try { if (!(xml.StartsWith("<?xml") || xml.StartsWith("<method"))) xml = xml.Substring(xml.IndexOf("<?xml")); request.LoadXml(xml); } catch (Exception ex) { throw new MetaWeblogException("01", "Invalid XMLRPC Request. (" + ex.Message + ")"); } // Method name is always first _methodName = request.DocumentElement.ChildNodes[0].InnerText; // Parameters are next (and last) _inputParams = new List<XmlNode>(); foreach (XmlNode node in request.SelectNodes("/methodCall/params/param")) _inputParams.Add(node); // Determine what params are what by method name switch (_methodName) { case "metaWeblog.newPost": _blogID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; _post = GetPost(_inputParams[3]); if (_inputParams[4].InnerText == "0" || _inputParams[4].InnerText == "false") _publish = false; else _publish = true; break; case "metaWeblog.editPost": _postID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; _post = GetPost(_inputParams[3]); if (_inputParams[4].InnerText == "0" || _inputParams[4].InnerText == "false") _publish = false; else _publish = true; break; case "metaWeblog.getPost": _postID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; break; case "metaWeblog.newMediaObject": _blogID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; _media = GetMediaObject(_inputParams[3]); break; case "metaWeblog.getCategories": case "wp.getAuthors": case "wp.getPageList": case "wp.getPages": case "wp.getTags": _blogID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; break; case "metaWeblog.getRecentPosts": _blogID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; _numberOfPosts = Int32.Parse(_inputParams[3].InnerText, CultureInfo.InvariantCulture); break; case "blogger.getUsersBlogs": case "metaWeblog.getUsersBlogs": _appKey = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; break; case "blogger.deletePost": _appKey = _inputParams[0].InnerText; _postID = _inputParams[1].InnerText; _userName = _inputParams[2].InnerText; _password = _inputParams[3].InnerText; if (_inputParams[4].InnerText == "0" || _inputParams[4].InnerText == "false") _publish = false; else _publish = true; break; case "blogger.getUserInfo": _appKey = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; break; case "wp.newPage": _blogID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; _page = GetPage(_inputParams[3]); if (_inputParams[4].InnerText == "0" || _inputParams[4].InnerText == "false") _publish = false; else _publish = true; break; case "wp.getPage": _blogID = _inputParams[0].InnerText; _pageID = _inputParams[1].InnerText; _userName = _inputParams[2].InnerText; _password = _inputParams[3].InnerText; break; case "wp.editPage": _blogID = _inputParams[0].InnerText; _pageID = _inputParams[1].InnerText; _userName = _inputParams[2].InnerText; _password = _inputParams[3].InnerText; _page = GetPage(_inputParams[4]); if (_inputParams[5].InnerText == "0" || _inputParams[5].InnerText == "false") _publish = false; else _publish = true; break; case "wp.deletePage": _blogID = _inputParams[0].InnerText; _userName = _inputParams[1].InnerText; _password = _inputParams[2].InnerText; _pageID = _inputParams[3].InnerText; break; default: throw new MetaWeblogException("02", "Unknown Method. (" + _methodName + ")"); } }
private MWAPage GetPage(XmlNode node) { var temp = new MWAPage(); // Require Title and Description try { temp.title = node.SelectSingleNode("value/struct/member[name='title']").LastChild.InnerText; temp.description = node.SelectSingleNode("value/struct/member[name='description']").LastChild.InnerText; } catch (Exception ex) { throw new MetaWeblogException("06", "Page Struct Element, Title or Description, not Sent. (" + ex.Message + ")"); } if (node.SelectSingleNode("value/struct/member[name='link']") == null) temp.link = ""; else temp.link = node.SelectSingleNode("value/struct/member[name='link']").LastChild.InnerText; if (node.SelectSingleNode("value/struct/member[name='dateCreated']") != null) { try { string tempDate = node.SelectSingleNode("value/struct/member[name='dateCreated']").LastChild.InnerText; temp.pageDate = DateTime.ParseExact(tempDate, "yyyyMMdd'T'HH':'mm':'ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); } catch { // Ignore PubDate Error } } //Keywords if (node.SelectSingleNode("value/struct/member[name='mt_keywords']") == null) temp.mt_keywords = ""; else temp.mt_keywords = node.SelectSingleNode("value/struct/member[name='mt_keywords']").LastChild.InnerText; if (node.SelectSingleNode("value/struct/member[name='wp_page_parent_id']") != null) temp.pageParentID = node.SelectSingleNode("value/struct/member[name='wp_page_parent_id']").LastChild.InnerText; return temp; }
internal bool EditPage(string blogID, string pageID, string userName, string password, MWAPage mPage, bool publish) { ValidateRequest(userName, password); var repository = Ioc.Resolve <IRepository>(); var page = repository.Get <Page>(pageID.ToInt()); page.Title = mPage.title; page.Content = mPage.description; page.Keywords = mPage.mt_keywords; page.ShowInList = publish; page.IsPublished = publish; repository.Save(page); return(true); }
/// <summary> /// wp.newPage /// </summary> /// <param name="blogID">blogID in string format</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <param name="mPage"></param> /// <param name="publish"></param> /// <returns></returns> internal string NewPage(string blogID, string userName, string password, MWAPage mPage, bool publish) { ValidateRequest(userName, password); var repository = Ioc.Resolve<IRepository>(); var page = new Page(); page.Title = mPage.title; page.Content = mPage.description; page.Description = ""; // Can not be set from WLW page.Keywords = mPage.mt_keywords; if (mPage.pageDate != new DateTime()) page.DateCreated = mPage.pageDate; page.ShowInList = publish; page.IsPublished = publish; repository.Save(page); return page.Id.ToString(); }
/// <summary> /// wp.getPages /// </summary> /// <param name="blogID">blogID in string format</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <returns></returns> internal List<MWAPage> GetPages(string blogID, string userName, string password) { ValidateRequest(userName, password); var pages = Ioc.Resolve<IRepository>() .Find<Page>() .OrderByDescending(x => x.Id); var mwaPages = new List<MWAPage>(); foreach (Page page in pages) { var mwaPage = new MWAPage(); mwaPage.pageID = page.Id.ToString(); mwaPage.title = page.Title; mwaPage.pageDate = page.DateCreated; //mwaPage.link = page.AbsoluteLink.AbsoluteUri; mwaPages.Add(mwaPage); } return mwaPages; //return Ioc.Resolve<IRepository>() // .Find<Page>() // .OrderByDescending(x => x.Id) // .Select(page => new MWAPage() // { // pageID = page.Id.ToString(), // title = page.Title, // description = page.Content, // mt_keywords = page.Keywords, // pageDate = page.DateCreated, // link = page.AbsoluteLink.AbsoluteUri, // mt_convert_breaks = "__default__", // pageParentID = page.Parent.ToString() // }) // .ToList(); }
/// <summary> /// wp.getPage /// </summary> /// <param name="blogID">blogID in string format</param> /// <param name="pageID">page guid in string format</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <returns>struct with post details</returns> internal MWAPage GetPage(string blogID, string pageID, string userName, string password) { ValidateRequest(userName, password); var sendPage = new MWAPage(); var repository = Ioc.Resolve<IRepository>(); var page = repository.Get<Page>(x => x.Id == pageID.ToInt()); sendPage.pageID = page.Id.ToString(); sendPage.title = page.Title; sendPage.description = page.Content; sendPage.mt_keywords = page.Keywords; sendPage.pageDate = page.DateCreated; //sendPage.link = page.AbsoluteLink.AbsoluteUri; sendPage.mt_convert_breaks = "__default__"; return sendPage; }
internal bool EditPage(string blogID, string pageID, string userName, string password, MWAPage mPage, bool publish) { ValidateRequest(userName, password); var repository = Ioc.Resolve<IRepository>(); var page = repository.Get<Page>(pageID.ToInt()); page.Title = mPage.title; page.Content = mPage.description; page.Keywords = mPage.mt_keywords; page.ShowInList = publish; page.IsPublished = publish; repository.Save(page); return true; }