//- @PostNewComment -// public static String PostNewComment(String blogEntryGuid, String text, String author, String email, String website, DateTime dateTime, String emailBodyTemplate, String emailSubject) { using (CommentClient commentClient = new CommentClient(BlogSection.GetConfigSection().Service.Endpoint.Comment)) { commentClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; commentClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(commentClient.PostNewComment(blogEntryGuid, text, author, email, website, dateTime, emailBodyTemplate, emailSubject)); } }
//- @GetCommentList -// public static List <Comment> GetCommentList(String blogEntryGuid, Boolean showEveryComment) { using (CommentClient commentClient = new CommentClient(BlogSection.GetConfigSection().Service.Endpoint.Comment)) { commentClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; commentClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(commentClient.GetCommentList(blogEntryGuid, showEveryComment)); } }
//- @GetBlogListForAssociatedAuthor -// public static List <BlogMetaData> GetBlogListForAssociatedAuthor(String emailAddress, String password) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = emailAddress; blogClient.ClientCredentials.UserName.Password = password; //+ return(blogClient.GetBlogListForAssociatedAuthor(emailAddress)); } }
public static Label GetLabelByNetTitle(String friendlyTitle, String username, String password) { using (LabelClient labelClient = new LabelClient(BlogSection.GetConfigSection().Service.Endpoint.Label)) { labelClient.ClientCredentials.UserName.UserName = username; labelClient.ClientCredentials.UserName.Password = password; //+ return(labelClient.GetLabelByNetTitle(friendlyTitle)); } }
//- @SaveImage -// public static BlogImage GetImage(String blogImageGuid) { using (ImageClient imageClient = new ImageClient(BlogSection.GetConfigSection().Service.Endpoint.Image)) { imageClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; imageClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(imageClient.GetImage(blogImageGuid)); } }
//- @AuthorizeComment -// public static void AuthorizeComment(String commentGuid) { using (CommentClient commentClient = new CommentClient(BlogSection.GetConfigSection().Service.Endpoint.Comment)) { commentClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; commentClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ commentClient.AuthorizeComment(commentGuid); } }
public static void ApplyLabel(String blogEntryGuid, String labelGuid, String username, String password) { using (LabelClient labelClient = new LabelClient(BlogSection.GetConfigSection().Service.Endpoint.Label)) { labelClient.ClientCredentials.UserName.UserName = username; labelClient.ClientCredentials.UserName.Password = password; //+ labelClient.ApplyLabel(blogEntryGuid, labelGuid); } }
//- @GetBlogEntryListByDateRange -// public static List <BlogEntry> GetBlogEntryListByDateRange(string blogGuid, DateTime startDateTime, DateTime endDateTime, Boolean ignoreFooter, Boolean metaDataOnly) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(blogClient.GetBlogEntryListByDateRange(blogGuid, startDateTime, endDateTime, ignoreFooter, metaDataOnly)); } }
public static void UpdateBlogEntry(String blogEntryGuid, String title, String content, String blogEntryTypeGuid, List <Label> labelList, DateTime dateTime, Boolean publish, String username, String password) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = username; blogClient.ClientCredentials.UserName.Password = password; //+ blogClient.UpdateBlogEntry(blogEntryGuid, title, content, blogEntryTypeGuid, labelList, dateTime, publish); } }
//- @GetNetBlogEntryList -// public static List <BlogEntry> GetNetBlogEntryList(String blogGuid, String label, String archive, String link, Int32 maxBlogEntryCount, Boolean ignoreFooter) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(blogClient.GetNetBlogEntryList(blogGuid, label, archive, link, maxBlogEntryCount, ignoreFooter)); } }
//- @GetBlogEntryTypeList -// public static List <BlogEntryType> GetBlogEntryTypeList(String blogGuid, List <String> guidList) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(blogClient.GetBlogEntryTypeList(blogGuid, guidList)); } }
//- @GetBlogMetaData -// public static BlogMetaData GetBlogMetaData(String blogGuid) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(blogClient.GetBlogMetaData(blogGuid)); } }
//- @GetArchivedEntryList -// public static List <ArchiveCount> GetArchivedEntryList(String blogGuid) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(blogClient.GetArchivedEntryList(blogGuid)); } }
public static String PostBlogEntry(String blogGuid, List <Author> authorList, String title, String content, DateTime dateTime, String blogEntryTypeGuid, List <Label> labelList, Boolean publish, String username, String password) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = username; blogClient.ClientCredentials.UserName.Password = password; //+ return(blogClient.PostBlogEntry(blogGuid, authorList, title, content, dateTime, blogEntryTypeGuid, labelList, publish)); } }
public static List <BlogEntry> GetBlogEntryList(String blogGuid, Int32 maxEntryCount, Boolean ignoreFooter, BlogEntryRetreivalType blogEntryRetreivalType, String username, String password) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = username; blogClient.ClientCredentials.UserName.Password = password; //+ return(blogClient.GetBlogEntryList(blogGuid, maxEntryCount, true, ignoreFooter, blogEntryRetreivalType)); } }
public static List <Label> GetBlogLabelList(String blogGuid, String username, String password) { using (LabelClient labelClient = new LabelClient(BlogSection.GetConfigSection().Service.Endpoint.Label)) { labelClient.ClientCredentials.UserName.UserName = username; labelClient.ClientCredentials.UserName.Password = password; //+ return(labelClient.GetBlogLabelList(blogGuid)); } }
public static BlogEntry GetSingleBlogEntryByLink(String blogGuid, String link, Boolean ignoreFooter, Boolean metaDataOnly, String username, String password) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = username; blogClient.ClientCredentials.UserName.Password = password; //+ return(blogClient.GetSingleBlogEntryByLink(blogGuid, link, ignoreFooter, metaDataOnly)); } }
public static void DisableBlogEntry(String blogEntryGuid, String username, String password) { using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = username; blogClient.ClientCredentials.UserName.Password = password; //+ blogClient.DisableBlogEntry(blogEntryGuid); } }
//+ //- #GetDataSource -// protected override Object GetDataSource() { Int32 maxEntryCount = BlogSection.GetConfigSection().EntriesToShow; if (this.MaxEntryCount > 0) { maxEntryCount = this.MaxEntryCount; } List <BlogEntry> blogEntryList = BlogAgent.GetBlogEntryList(this.BlogGuid, maxEntryCount, false, BlogEntryRetreivalType.Full); //+ return(blogEntryList.Select(p => new { Url = "/" + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.First()), Title = p.Title })); }
//- $SetPageTitle -// private void SetPageTitle( ) { //+ title String pageTitle = String.Empty; switch (this.AccessType) { case AccessType.Index: pageTitle = String.Format("{0} {1}", this.Index, BlogSection.GetConfigSection().Suffix.Index); break; case AccessType.Link: if (this.DataSource != null && this.DataSource.Count == 1) { String blogEntryTitle = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogEntryTitle); pageTitle = blogEntryTitle; } else { pageTitle = GetDefaultHeader(); } break; case AccessType.Label: String labelName = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.LabelTitle); pageTitle = String.Format("{0} {1}", labelName, BlogSection.GetConfigSection().Suffix.Label); break; case AccessType.Archive: String monthName = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.ArchiveMonth); Int32 year = Themelia.Web.HttpData.GetScopedItem <Int32>(Info.Scope, Info.ArchiveYear); pageTitle = String.Format("{0} {1} {2}", monthName, year, BlogSection.GetConfigSection().Suffix.Archive); break; default: pageTitle = GetDefaultHeader(); break; } if (!String.IsNullOrEmpty(pageTitle)) { Themelia.Web.HttpData.SetScopedItem <String>(Info.Scope, Info.PageTitle, pageTitle); } }
//- @PostNewComment -// public Int32 PostNewComment(Int32 captchaValue, String blogEntryGuid, String author, String email, String website, String text) { Int32 returnStatus; //+ if (captchaValue == HttpData.GetScopedSessionItem <Int32>("Captcha", "ExpectedValue")) { CommentReportCreator creator = new CommentReportCreator(); creator.Formatter = new Themelia.Reporting.HtmlFormatter(); Themelia.Map map = new Themelia.Map(); map.Add("BlogEntryTitle", "{BlogEntryTitle}"); map.Add("Guid", blogEntryGuid); map.Add("Author", author); map.Add("Email", email); map.Add("WebSite", website); map.Add("DateTime", DateTime.Now.ToString()); map.Add("Text", text); map.Add("Link", UrlCleaner.FixWebPathTail(Minima.Configuration.BlogSection.GetConfigSection().Domain) + @"/services/comment/{CommentGuid}"); String emailBodyTemplate = creator.Create(map); Themelia.Configuration.SystemSection systemSection = Themelia.Configuration.SystemSection.GetConfigSection(); String emailSubject = String.Format("{0} ({1})", BlogSection.GetConfigSection().Comment.Subject, systemSection.AppInfo.Name); //+ String commentGuid = String.Empty; returnStatus = 0; try { commentGuid = CommentAgent.PostNewComment(blogEntryGuid, text, author, email, website, DateTime.Now, emailBodyTemplate, emailSubject); } catch (Exception ex) { if (ex.Message != "Failure sending mail.") { returnStatus = 1; } } } else { returnStatus = 2; } //+ return(returnStatus); }
//- @GetBlogEntryAuthorSeries -// public static String GetBlogEntryAuthorSeries(BlogEntry blogEntry) { StringBuilder authorSeries = new StringBuilder(); if (blogEntry.AuthorList != null) { Boolean first = true; if (blogEntry.AuthorList.Count < 1) { return(String.Empty); } else if (blogEntry.AuthorList.Count > 1) { authorSeries.Append("{"); } foreach (Author author in blogEntry.AuthorList) { if (blogEntry.AuthorList.Count > 1 && !first) { authorSeries.Append(", "); } if (BlogSection.GetConfigSection().Display.LinkAuthorsToEmail) { authorSeries.Append(String.Format("<a href=\"mailto:{1}\">{0}</a>", author.Name, author.Email)); } else { authorSeries.Append(author.Name); } first = false; } if (blogEntry.AuthorList.Count > 1) { authorSeries.Append("}"); } } //+ return(authorSeries.ToString()); }
//- @GetLabelByNetTitle -// public static Label GetLabelByNetTitle(String friendlyTitle) { return(GetLabelByNetTitle(friendlyTitle, BlogSection.GetConfigSection().Service.Authentication.DefaultUserName, BlogSection.GetConfigSection().Service.Authentication.DefaultPassword)); }
//- @GetBlogLabelList -// public static List <Label> GetBlogLabelList(String blogGuid) { return(GetBlogLabelList(blogGuid, BlogSection.GetConfigSection().Service.Authentication.DefaultUserName, BlogSection.GetConfigSection().Service.Authentication.DefaultPassword)); }
//- @DisableBlogEntry -// public static void DisableBlogEntry(String blogEntryGuid) { DisableBlogEntry(blogEntryGuid, BlogSection.GetConfigSection().Service.Authentication.DefaultUserName, BlogSection.GetConfigSection().Service.Authentication.DefaultPassword); }
//- @ApplyLabel -// public static void ApplyLabel(String blogEntryGuid, String labelGuid) { ApplyLabel(blogEntryGuid, labelGuid, BlogSection.GetConfigSection().Service.Authentication.DefaultUserName, BlogSection.GetConfigSection().Service.Authentication.DefaultPassword); }
//- #OnLoad -// protected override void OnLoad(EventArgs e) { List <BlogEntry> blogEntryList = this.DataSource; if (this.AccessType != AccessType.Index) { //+ were there any entries at all? if (blogEntryList == null || blogEntryList.Count < 1) { rptPosts.Visible = false; phNoEntries.Visible = true; litNoEntriesMessage.Text = BlogSection.GetConfigSection().Display.BlankMessage; } else { rptPosts.DataSource = blogEntryList.Select(p => new { Url = Themelia.Web.WebDomain.GetUrl() + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.First()), // BlogEntryHelper.BuildBlogEntryLink(p.PostDateTime, p.MappingNameList.First(), Themelia.Web.WebDomain.Current), Content = this.CodeParserSeries.ParseCode(p.Content), Title = p.Title, AuthorList = p.AuthorList, AllowCommentStatus = p.AllowCommentStatus, CommentList = p.CommentList, Guid = p.Guid, LabelList = p.LabelList, AuthorSeries = SeriesHelper.GetBlogEntryAuthorSeries(p), LabelSeries = SeriesHelper.GetBlogEntryLabelSeries(p), ViewableCommentCount = p.CommentList != null ? p.CommentList.Count : 0, DateTimeString = String.Format("{0}, {1} {2}, {3}", p.PostDateTime.DayOfWeek, p.PostDateTime.ToString("MMMM"), p.PostDateTime.Day, p.PostDateTime.Year), DateTimeDisplay = String.Format("{0}/{1}/{2} {3}", p.PostDateTime.Month, p.PostDateTime.Day, p.PostDateTime.Year, p.PostDateTime.ToShortTimeString()) }); rptPosts.DataBind(); //+ if (this.AccessType == AccessType.Link && this.SupportCommenting) { BlogEntry blogEntry = blogEntryList[0]; if (blogEntry.AllowCommentStatus == AllowCommentStatus.Disabled) { mvCommentContent.SetActiveView(vCommentsDisabled); } else { mvCommentContent.SetActiveView(vShowComments); List <Comment> commentList = CommentAgent.GetCommentList(this.BlogEntryGuid, false); if (commentList.Count > 0) { htmlCommentListHeader.Visible = true; litCommentCount.Text = commentList.Count.ToString(); } rptComments.DataSource = commentList; rptComments.DataBind(); //+ CommentInputBase commentInput = vCommentForm.FindControl("CommentInput") as CommentInputBase; if (commentInput != null) { HiddenField hfBlogEntryGuid = commentInput.FindControl("hfBlogEntryGuid") as HiddenField; if (hfBlogEntryGuid != null) { hfBlogEntryGuid.Value = this.BlogEntryGuid; } } //+ if (blogEntry.AllowCommentStatus == AllowCommentStatus.Closed) { mvCommentInput.SetActiveView(vCommentClosed); } else { mvCommentInput.SetActiveView(vCommentForm); } } } } } //+ SetPageTitle(); //+ base.OnLoad(e); }
//+ //- #OnInit -// protected override void OnInit(EventArgs e) { Func <BlogEntry, IndexEntry> indexTransformation = p => new IndexEntry { Url = Themelia.Web.WebDomain.GetUrl() + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.FirstOrDefault()), Title = p.Title, TypeGuid = p.BlogEntryTypeGuid, PostDateTime = p.PostDateTime, LabelList = p.LabelList, DateTimeString = String.Format("{0}, {1} {2}, {3}", p.PostDateTime.DayOfWeek, p.PostDateTime.ToString("MMMM"), p.PostDateTime.Day, p.PostDateTime.Year), DateTimeDisplay = String.Format("{0}/{1}/{2} {3}", p.PostDateTime.Month, p.PostDateTime.Day, p.PostDateTime.Year, p.PostDateTime.ToShortTimeString()) }; List <IndexEntry> indexDataSource; //+ index if (this.Index > 0) { String blogGuid = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid); DateTime startDateTime = new DateTime(this.Index, 1, 1, 0, 0, 0); DateTime endDateTime = new DateTime(this.Index, 12, 31, 23, 59, 59); //+ indexDataSource = BlogAgent.GetBlogEntryListByDateRange(blogGuid, startDateTime, endDateTime, false, true).Select(indexTransformation).ToList(); List <Int32> yearDataSource = BlogAgent.GetBlogEntryList(blogGuid, 0, false, BlogEntryRetreivalType.VeryBasic) .Where(p => p.PostDateTime.Year != this.Index) .Select(p => p.PostDateTime.Year) .Distinct() .OrderByDescending(p => p) .ToList(); indexListSeries = new IndexListSeries() { HeadingSuffix = BlogSection.GetConfigSection().Suffix.Index, BlogEntryDataSource = indexDataSource, YearDataSource = yearDataSource, Year = this.Index }; indexListSeries.ID = "indexListSeries"; this.Controls.Add(indexListSeries); } //+ blog else { if (this.AccessType == AccessType.Archive || this.AccessType == AccessType.Label) { if (this.DataSource != null && this.DataSource.Count > 0) { indexDataSource = this.DataSource.Select(indexTransformation).ToList(); indexEntryList = new IndexEntryList(this.AccessType, indexDataSource); indexEntryList.ID = "indexEntryList"; this.Controls.Add(indexEntryList); } } //+ phNoEntries = __BuildNoEntryPlaceHolderControl(); phNoEntries.ID = "phNoEntries"; this.Controls.Add(phNoEntries); //+ rptPosts = this.__BuildPostRepeaterControl(); rptPosts.ID = "rptPosts"; this.Controls.Add(rptPosts); //+ if (this.SupportCommenting) { mvCommentContent = this.__BuildCommentMultiViewControl(); this.Controls.Add(mvCommentContent); } } //+ base.OnInit(e); }
//- @GetRssFeed -// public Rss20FeedFormatter GetRssFeed(String blogGuid, String maxCount) { Int32 maxCountInt32; if (!Int32.TryParse(maxCount, out maxCountInt32)) { return(null); } using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; List <BlogEntry> blogEntryList = null; try { blogEntryList = blogClient.GetBlogEntryList(blogGuid, maxCountInt32, true, false, BlogEntryRetreivalType.MetaDataOnly); } catch (FaultException <ArgumentException> ) { return(null); } catch (FaultException <SecurityException> ) { return(null); } catch { return(null); } if (blogEntryList.Count == 0) { return(null); } BlogMetaData blogMetaData = blogClient.GetBlogMetaData(blogGuid); //+ blog SyndicationFeed syndicationFeed = new SyndicationFeed(); syndicationFeed.Description = new TextSyndicationContent(blogMetaData.Description); foreach (Label label in blogMetaData.LabelList) { syndicationFeed.Categories.Add(new SyndicationCategory(label.Title)); } //+ blog entry list List <SyndicationItem> itemList = new List <SyndicationItem>(); foreach (BlogEntry blogEntry in blogEntryList) { SyndicationItem syndicationItem = new SyndicationItem { Title = new TextSyndicationContent(blogEntry.Title), Summary = new TextSyndicationContent(blogEntry.Content), PublishDate = new DateTimeOffset(blogEntry.PostDateTime), }; syndicationItem.Links.Add(new SyndicationLink(new Uri(Themelia.Web.Http.Root + "/" + Themelia.Web.UrlCleaner.FixWebPathHead(blogEntry.MappingNameList.First())))); foreach (Author author in blogEntry.AuthorList) { syndicationItem.Authors.Add(new SyndicationPerson(author.Email)); } foreach (Label label in blogEntry.LabelList) { syndicationItem.Categories.Add(new SyndicationCategory(label.Title)); } //+ itemList.Add(syndicationItem); } syndicationFeed.Items = itemList; //+ return(new Rss20FeedFormatter(syndicationFeed)); } }
public static BlogEntry GetSingleBlogEntryByLink(String blogGuid, String link, Boolean ignoreFooter, Boolean metaDataOnly) { return(GetSingleBlogEntryByLink(blogGuid, link, ignoreFooter, metaDataOnly, BlogSection.GetConfigSection().Service.Authentication.DefaultUserName, BlogSection.GetConfigSection().Service.Authentication.DefaultPassword)); }