Esempio n. 1
0
        protected void ImageButtonNext_Click(object sender, ImageClickEventArgs e)
        {
            // 生成静态页面和关联页面
            switch (article.Category.ArticleType)
            {
                case 1: // 普通新闻
                    releaseManager.ReleasingArticle(article);
                    break;
                case 2:// 图片新闻
                    Wis.Website.DataManager.ArticlePhotoManager articlePhotoManager = new Wis.Website.DataManager.ArticlePhotoManager();
                    Wis.Website.DataManager.ArticlePhoto articlePhoto = articlePhotoManager.GetArticlePhoto(this.ArticleGuid);
                    releaseManager.ReleasingPhotoArticle(articlePhoto);
                    break;
                case 3:// 视频新闻
                    Wis.Website.DataManager.VideoArticleManager videoArticleManager = new Wis.Website.DataManager.VideoArticleManager();
                    Wis.Website.DataManager.VideoArticle videoArticle = videoArticleManager.GetVideoArticle(this.ArticleGuid);
                    releaseManager.ReleasingVideoArticle(videoArticle);
                    break;
                case 4:// 软件
                    //releaseManager.ReleasingRelatedReleasesByArticle(article);
                    break;
                default:
                    //releaseManager.ReleasingRelatedReleasesByArticle(article);
                    break;
            }

            // 提示操作成功
            Warning.InnerHtml = string.Format("发布静态页成功,<a href='ArticleAddNew.aspx?CategoryGuid={0}'>继续添加新闻</a>,还是<a href='ArticleList.aspx?CategoryGuid={0}'>返回新闻列表页</a>?", article.Category.CategoryGuid);
            #warning TODO:继续添加新闻,返回新闻列表页?在页面上放两个按钮,完成的按钮应隐藏
            //Response.Redirect("ArticleAddNew.aspx?CategoryGuid=" + articlePhoto.Category.CategoryGuid);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string requestArticleGuid = Request.QueryString["ArticleGuid"];
            if (string.IsNullOrEmpty(requestArticleGuid) || !Wis.Toolkit.Validator.IsGuid(requestArticleGuid))
            {
                throw new System.ArgumentNullException("ArticleGuid");
            }
            Guid articleGuid = new Guid(requestArticleGuid);
            if (System.Web.HttpContext.Current.Items["VideoArticle"] == null)
            {
                Response.Redirect(string.Format("ArticleAddVideo.aspx?ArticleGuid={0}", articleGuid));
                return;
            }
            VideoArticle videoArticle = System.Web.HttpContext.Current.Items["VideoArticle"] as VideoArticle;

            // 转换视频格式
            // 输出进度条
            string content;
            using (System.IO.StreamReader reader = new System.IO.StreamReader(Page.MapPath("Progressbar.htm"), System.Text.Encoding.UTF8))
            {
                content = reader.ReadToEnd();
                System.Text.RegularExpressions.Regex.Replace(content, "", this.TotalSeconds.ToString(), System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            }
            Context.Response.Write(content);
            Context.Response.Flush();

            string inFile = Page.MapPath(videoArticle.VideoPath);
            string outFile = Page.MapPath(videoArticle.FlvVideoPath);

            string ffmpegFile = Page.MapPath("Tools/ffmpeg.exe");
            MediaHandler mediaHandler = new MediaHandler();
            this.TotalSeconds = mediaHandler.GetTotalSeconds(ffmpegFile, inFile);

            outFile = Page.MapPath(videoArticle.FlvVideoPath);
            mediaHandler.ConvertingVideo(ffmpegFile, inFile, outFile, new DataReceivedEventHandler(ConvertingVideo_DataReceived));

            System.Threading.Thread.Sleep(1000);
            string flvtool2File = Page.MapPath("Tools/flvtool2.exe");
            mediaHandler.InjectMetadata(flvtool2File, outFile, new DataReceivedEventHandler(ConvertingVideo_DataReceived));

            content = "<script type='text/javascript' language='javascript'>AddLog('转换成功。');SetProgressbar('100');</script>\n";
            Response.Write(content);
            Response.Flush();

            // 视频信息入库
            Wis.Website.DataManager.VideoArticleManager videoArticleManager = new Wis.Website.DataManager.VideoArticleManager();
            int videoArticleCount = videoArticleManager.Count(videoArticle.Article.ArticleGuid);
            if (videoArticleCount == 0)
                videoArticle.VideoArticleId = videoArticleManager.AddNew(videoArticle);
            else
                videoArticle.VideoArticleId = videoArticleManager.Update(videoArticle);

            System.Web.HttpContext.Current.Items.Remove("VideoArticle");

            // 下一步
            Wis.Toolkit.ClientScript.Window.Redirect(string.Format("ArticleRelease.aspx?ArticleGuid={0}", videoArticle.Article.ArticleGuid));
            //Response.Redirect(string.Format("ArticleRelease.aspx?ArticleGuid={0}", this.ArticleGuid));
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            // 1 验证验证码
            if (context.Session[CommentVerifyHttpHandler.ConstCommentVerify] == null)
            {
                return;
            }
            string commentVerify1 = context.Session[CommentVerifyHttpHandler.ConstCommentVerify].ToString();
            string commentVerify2 = context.Request[CommentVerifyHttpHandler.ConstCommentVerify];
            if (string.IsNullOrEmpty(commentVerify1) || string.IsNullOrEmpty(commentVerify2))
            {
                return;
            }
            if (commentVerify1.ToUpper() != commentVerify2.ToUpper())
            {
                return;
            }

            // 验证评论数据,两者不能同时为空
            string title = RequestManager.Request("Title");
            string contentHtml = RequestManager.Request("ContentHtml");
            if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(contentHtml))
            {
                return;
            }

            // 评论标题和内过滤Html脚本
            // TODO:过滤内嵌Script脚本、样式
            title = Regex.Replace(title, "<[^>]*>", "");
            contentHtml = Regex.Replace(contentHtml, "<[^>]*>", "");

            // 2 验证评论数据
            // 获取文章的编号
            if (context.Request.UrlReferrer == null)
            {
                return;
            }

            string rawUrl = context.Request.UrlReferrer.AbsoluteUri;
            int charIndex = rawUrl.LastIndexOf('/');
            if (charIndex == -1)
            {
                return;
            }

            // http://localhost:3419/Web/2/2-13/38.htm
            rawUrl = rawUrl.Substring(charIndex + 1); // 38.htm
            charIndex = rawUrl.IndexOf('.');
            if (charIndex == -1)
            {
                return;
            }
            string requestArticleId = rawUrl.Substring(0, charIndex); // RequestManager.Request("ArticleId");

            // 文章编号是否为数字
            int articleId;
            if (int.TryParse(requestArticleId, out articleId) == false)
            {
                // 提示失败
                return;
            }

            // 文章是否存在
            ArticleManager articleManager = new ArticleManager();
            Article article = articleManager.GetArticle(articleId);
            if (string.IsNullOrEmpty(article.Title))
            {
                // 提示失败
                return;
            }

            // 构造评论实体类
            Comment comment = new Comment();

            // 获得实体类
            // TODO:如果前台支持用户注册和登录,获取用户的昵称(唯一不重复)
            comment.Commentator = string.Empty;

            comment.CommentGuid = Guid.NewGuid();
            //comment.CommentId
            comment.ContentHtml = contentHtml;
            comment.DateCreated = DateTime.Now;
            comment.IPAddress = RequestManager.GetClientIP();
            comment.Original = string.Empty;
            comment.SubmissionGuid = article.ArticleGuid;
            comment.Title = title;

            CommentManager commentManager = new CommentManager();
            commentManager.AddNew(comment);

            // TODO:事务处理
            // 更新Article的评论数
            articleManager.UpdateArticleComments(article.ArticleGuid);

            // 清空评论验证码
            context.Session[CommentVerifyHttpHandler.ConstCommentVerify] = null;

            // 输出评论数
            //context.Response.Write((articlePhoto.Comments + 1).ToString());
            // 重新生成 Article
            ReleaseManager releaseManager = new ReleaseManager();
            switch (article.Category.ArticleType)
            {
                case 1://ArticleType.Normal:
                    releaseManager.ReleasingArticleItem(article);
                    break;
                case 2://ArticleType.Photo:
                    ArticlePhotoManager articlePhotoManager = new ArticlePhotoManager();
                    ArticlePhoto articlePhoto = articlePhotoManager.GetArticlePhoto(article.ArticleGuid);
                    releaseManager.ReleasingPhotoArticleItem(articlePhoto);
                    break;
                case 3://ArticleType.Video:
                    VideoArticleManager videoArticleManager = new VideoArticleManager();
                    VideoArticle videoArticle = videoArticleManager.GetVideoArticle(article.ArticleGuid);
                    releaseManager.ReleasingVideoArticleItem(videoArticle);
                    break;
                //case ArticleType.Soft:
                //    releaseManager.ReleasingSoftArticleItem(article);
                //    break;
                //case ArticleType.Link:
                //    releaseManager.ReleasingLinkArticleItem(article);
                //    break;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 删除文章。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButtonDelete_Click(object sender, CommandEventArgs e)
        {
            int articleId;
            if(int.TryParse(e.CommandName, out articleId) == false)
            {
                MessageBox("错误提示", "文章编号必须为整数");
                return;
            }

            // 添加操作日志
            DataManager.LogManager logManager = new DataManager.LogManager();
            int iExecuteNonQuery = 0;

            Wis.Website.DataManager.ArticleManager articleManager = new Wis.Website.DataManager.ArticleManager();
            Wis.Website.DataManager.Article article = articleManager.GetArticle(articleId);
            #warning 删除与该文章相关的图片、视频、软件

            // 重新生成静态页面和关联页面
            DataManager.ReleaseManager releaseManager = new DataManager.ReleaseManager();
            switch (article.Category.ArticleType)
            {
                case 1://ArticleType.Normal:
                    iExecuteNonQuery = articleManager.Remove(article.ArticleGuid);
                    logManager.AddNew(Guid.NewGuid(), Guid.Empty, "删除新闻", article.ArticleGuid, article.Title, System.DateTime.Now);
                    releaseManager.ReleasingRemovedArticle(article);
                    break;
                case 2://ArticleType.Photo:
                    ArticlePhotoManager articlePhotoManager = new ArticlePhotoManager();
                    ArticlePhoto articlePhoto = articlePhotoManager.GetArticlePhoto(article.ArticleGuid);
                    iExecuteNonQuery = articleManager.Remove(articlePhoto.ArticleGuid);
                    logManager.AddNew(Guid.NewGuid(), Guid.Empty, "删除新闻", articlePhoto.ArticleGuid, articlePhoto.Title, System.DateTime.Now);
                    releaseManager.ReleasingRemovedPhotoArticle(articlePhoto);
                    break;
                case 3://ArticleType.Video:
                    VideoArticleManager videoArticleManager = new VideoArticleManager();
                    VideoArticle videoArticle = videoArticleManager.GetVideoArticle(article.ArticleGuid);
                    iExecuteNonQuery = articleManager.Remove(videoArticle.Article.ArticleGuid);
                    logManager.AddNew(Guid.NewGuid(), Guid.Empty, "删除新闻", videoArticle.Article.ArticleGuid, videoArticle.Article.Title, System.DateTime.Now);
                    releaseManager.ReleasingRemovedVideoArticle(videoArticle);
                    break;
                //case ArticleType.Soft:
                //    releaseManager.ReleasingRemovedSoftArticle(article);
                //    break;
                //case ArticleType.Link:
                //    releaseManager.ReleasingRemovedLinkArticle(article);
                //    break;
            }

            if (iExecuteNonQuery > 0)
            {
                Warning.InnerHtml = "删除成功!";
            }
            else
            {
                Warning.InnerHtml = "删除失败!";
            }

            // 重新绑定新闻列表
            BindRepeater();
        }
Esempio n. 5
0
        /// <summary>
        /// 发布文章。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButtonRelease_Click(object sender, CommandEventArgs e)
        {
            int articleId;
            if (int.TryParse(e.CommandName, out articleId) == false)
            {
                MessageBox("错误提示", "文章编号必须为整数");
                return;
            }
            Wis.Website.DataManager.ArticleManager articleManager = new Wis.Website.DataManager.ArticleManager();
            Wis.Website.DataManager.Article article = articleManager.GetArticle(articleId);

            // 重新生成静态页面和关联页面
            DataManager.ReleaseManager releaseManager = new DataManager.ReleaseManager();
            switch (article.Category.ArticleType)
            {
                case 1://ArticleType.Normal:
                    releaseManager.ReleasingArticle(article);
                    break;
                case 2://ArticleType.Photo:
                    ArticlePhotoManager articlePhotoManager = new ArticlePhotoManager();
                    ArticlePhoto articlePhoto = articlePhotoManager.GetArticlePhoto(article.ArticleGuid);
                    releaseManager.ReleasingPhotoArticle(articlePhoto);
                    break;
                case 3://ArticleType.Video:
                    VideoArticleManager videoArticleManager = new VideoArticleManager();
                    VideoArticle videoArticle = videoArticleManager.GetVideoArticle(article.ArticleGuid);
                    releaseManager.ReleasingVideoArticle(videoArticle);
                    break;
                //case ArticleType.Soft:
                //    releaseManager.ReleasingRemovedSoftArticle(article);
                //    break;
                //case ArticleType.Link:
                //    releaseManager.ReleasingRemovedLinkArticle(article);
                //    break;
            }

            MessageBox("操作提示", "发布成功!");
            //MessageBox("操作提示", "发布失败!");

            // 添加操作日志
            DataManager.LogManager logManager = new DataManager.LogManager();
            logManager.AddNew(Guid.NewGuid(), Guid.Empty, "发布新闻", article.ArticleGuid, article.Title, System.DateTime.Now);
        }
Esempio n. 6
0
 /// <summary>
 /// 发布被引用的页面,比如首页某个栏目引用了该分类,专题引用了改分类,把关联的发布页面重新生成
 /// </summary>
 /// <param name="categoryGuid"></param>
 public void ReleasingRelatedReleases(Guid relatedGuid)
 {
     CategoryManager categoryManager = new CategoryManager();
     List<Release> relatedReleases = GetRelatedReleases(relatedGuid);
     foreach (Release relatedRelease in relatedReleases)
     {
         switch (relatedRelease.Template.TemplateType)
         {
             case TemplateType.Index:
                 ReleasingIndex(relatedRelease);
                 break;
             case TemplateType.ArticleItem: // 发布对应分类下的所有文章
                 ArticleManager articleManager = new ArticleManager();
                 List<Article> relatedArticles = articleManager.GetArticlesByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Article relatedArticle in relatedArticles)
                 {
                     ReleasingArticleItem(relatedArticle, relatedRelease);
                 }
                 break;
             case TemplateType.ArticleList: // 发布对应分类下的所有列表页
                 List<Category> relatedArticleListCategories = categoryManager.GetCategorysByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Category relatedCategory in relatedArticleListCategories)
                 {
                     ReleasingArticleList(relatedCategory, relatedRelease);
                 }
                 break;
             case TemplateType.ArticleIndex: // 发布对应分类下的所有索引页
                 List<Category> relatedArticleIndexCategories = categoryManager.GetCategorysByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Category relatedCategory in relatedArticleIndexCategories)
                 {
                     ReleasingArticleIndex(relatedCategory, relatedRelease);
                 }
                 break;
             case TemplateType.Page: // 发布对应的单页
                 PageManager pageManager = new PageManager();
                 List<Page> relatedPages = pageManager.GetPagesByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Page relatedPage in relatedPages)
                 {
                     ReleasingPage(relatedPage, relatedRelease);
                 }
                 break;
             case TemplateType.PhotoArticleItem: // 发布对应分类下的图片新闻
                 ArticlePhotoManager photoArticleManager = new ArticlePhotoManager();
                 List<ArticlePhoto> photoArticles = photoArticleManager.GetPhotoArticlesByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (ArticlePhoto photoArticle in photoArticles)
                 {
                     ReleasingPhotoArticleItem(photoArticle, relatedRelease);
                 }
                 break;
             case TemplateType.PhotoArticleList: // 发布对应分类下的列表页
                 List<Category> relatedPhotoArticleListCategories = categoryManager.GetCategorysByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Category relatedCategory in relatedPhotoArticleListCategories)
                 {
                     ReleasingPhotoArticleList(relatedCategory, relatedRelease);
                 }
                 break;
             case TemplateType.SpecialList: // 发布专题列表页
                 SpecialManager specialManager = new SpecialManager();
                 List<Special> relatedSpecials = specialManager.GetSpecialsByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Special relatedSpecial in relatedSpecials)
                 {
                     ReleasingSpecial(relatedSpecial, relatedRelease);
                 }
                 break;
             case TemplateType.VideoArticleItem: // 发布对应分类下的所有视频文章详细页
                 VideoArticleManager videoArticleManager = new VideoArticleManager();
                 List<VideoArticle> relatedVideoArticles = videoArticleManager.GetVideoArticlesByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (VideoArticle relatedVideoArticle in relatedVideoArticles)
                 {
                     ReleasingVideoArticleItem(relatedVideoArticle, relatedRelease);
                 }
                 break;
             case TemplateType.VideoArticleList: // 发布对应分类下的所有视频列表页
                 List<Category> relatedVideoArticleListCategories = categoryManager.GetCategorysByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Category relatedCategory in relatedVideoArticleListCategories)
                 {
                     ReleasingVideoArticleList(relatedCategory, relatedRelease);
                 }
                 break;
             case TemplateType.VideoArticleIndex: // 发布对应分类下的所有视频索引页
                 List<Category> relatedVideoArticleIndexCategories = categoryManager.GetCategorysByReleaseGuid(relatedRelease.ReleaseGuid);
                 foreach (Category relatedCategory in relatedVideoArticleIndexCategories)
                 {
                     ReleasingVideoArticleIndex(relatedCategory, relatedRelease);
                 }
                 break;
         }
     }
 }