예제 #1
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            IRepositoryController repositoryController = new RepositoryController();
            System.Collections.Generic.IList<Blog> allBlogs = repositoryController.LoadAllBlogEntries();

            String[] blogIds = txtBlogs.Text.Split(',');

            System.Collections.Generic.IEnumerable<Blog> technicalBlogs =
                allBlogs.Where((b) => blogIds.Contains(b.Id.ToString())).ToList();

            RSSOperator rssOperator = new RSSOperator();
            rssOperator.GenerateCodeProjectFeed(technicalBlogs);
        }
예제 #2
0
        private bool Validation()
        {
            string title = txtTitle.Text.Trim();
            string permalink = txtPermalink.Text.Trim();
            string tags = txtTag.Text.Trim();
            string content = txtContent.Text.Trim();
            string postTime = txtPostTime.Text;

            List<string> errs = new List<string>();

            if (!WebUtil.CheckLength(title, 50))
                errs.Add("标题超过限制长度50.");
            if (!WebUtil.CheckLength(permalink, 100))
                errs.Add("Permalink超过限制长度100.");
            if (!WebUtil.CheckLength(tags, 500))
                errs.Add("Tag超过限制长度500.");
            if (!WebUtil.CheckLength(content, 200000))
                errs.Add("内容超过限制长度200000.");
            if (!WebUtil.CheckDateTime(postTime))
                errs.Add("发表时间不对.");
            if (!String.IsNullOrEmpty(permalink))
            {
                IRepositoryController iRepositoryController = new RepositoryController();
                bool permlinkExists =
                    iRepositoryController.LoadAllBlogEntries().Any((b) => b.Permalink.Equals(permalink));

                if (permlinkExists)
                {
                    if (toBeEditBlogId == 0) // Create new blog
                        errs.Add("Permalink已经存在了!");
                    else if (permalink != curBlog.Permalink)
                        errs.Add("Permalink已经存在了!");
                }
            }

            if (errs.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<tr><td bgcolor=\"#FFFFFF\" colspan=\"2\"><dd style=\"color:#FF0000;\">出现下列错误:");

                foreach (string err in errs)
                    sb.AppendFormat("<dl>->{0}</dl>", err);

                sb.Append("</dd></td></tr>");

                ltrErrInfo.Text = sb.ToString();

                return false;
            }
            else
                return true;
        }