Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // list of object that can be add to editor
                bindDropdownlistModules();
                //js.Text = "<script>window.addEventListener?window.addEventListener('onload',loadContent,false):window.attachevent('onload',loadContent);</script>";
                //js.Text = "<script>addLoadEvent(loadContent); saveViewstate(); //__doPostBack('LinkButton1', '');</script>";
                NewsContent.AssetManagerWidth  = "750";
                NewsContent.AssetManagerHeight = "530";

                NewsContent.AssetManager = "/AssetManager/assetmanager.asp?user="******"Select News_Title From News Where News_Id=" + newsId.ToString());
                    if (objTitleNews != null)
                    {
                        lblTitleNews.Text = objTitleNews.ToString();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static bool UpdateNews(long _news_id, int _cat_id, string _news_subtitle, string _news_title, string _news_image, string _news_source, string _news_init, string _news_content, bool _news_isfocus, int _news_status, int _news_type, string _related_news, string _other_cat, DateTime _switchtime, bool _isSend, bool _isShowComment, bool _isShowRate, int _template, string _obj_media, string _news_title_image, string _news_icon, string _thread_id)
        {
            bool   toReturn        = false;
            int    old_news_status = -1;
            MainDB objDb           = new MainDB();

            objDb.BeginTransaction();
            NewsRow objrow;


            if (_news_init != null)
            {
                _news_init = _news_init.Replace(System.Environment.NewLine, "<br/>");
            }

            try {
                #region Gan Thread vao bai
                // Gan Thread vao bai

                Threaddetails objThread = new Threaddetails();
                objDb.SelectScalar("Delete ThreadDetail Where News_ID = '" + _news_id + "'");

                if (_thread_id != null)
                {
                    string[] strArThread = _thread_id.Split(',');
                    foreach (string str in strArThread)
                    {
                        objThread.AddnewsThread(_news_id.ToString(), int.Parse(str), objDb);
                    }
                }
                #endregion

                objrow          = objDb.NewsCollection.GetByPrimaryKey(_news_id);
                old_news_status = objrow.News_Status;

                if (objrow != null)
                {
                    #region Gan cac gia tri cho bang News
                    objrow.Cat_ID              = _cat_id;
                    objrow.News_Subtitle       = _news_subtitle;
                    objrow.News_Title          = _news_title;
                    objrow.News_Image          = _news_image;
                    objrow.News_Source         = _news_source;
                    objrow.News_InitialContent = _news_init;
                    objrow.News_Content        = _news_content;
                    objrow.WordCount           = NewsHelper.WordCount(objrow.News_Content);
                    //objrow.User_ID = _poster;
                    //objrow.News_Author = _news_author;
                    objrow.News_isFocus = _news_isfocus;
                    //Trang thai cua tin tuy thuoc vao nguoi bien tap.
                    if (_news_status != -1)
                    {
                        objrow.News_Status = _news_status;
                    }
                    objrow.News_Mode = _news_type;
                    //tin lien quan
                    objrow.News_Relation = _related_news;
                    //if (_news_imgfocus != "" && _news_imgfocus!=null)
                    //objrow.News_FocusImage = _news_imgfocus;
                    if (_other_cat != "")
                    {
                        objrow.News_OtherCat = _other_cat;
                    }

                    DateTime dtPublish = _switchtime;
                    if (objrow.News_Status == 3)
                    {
                        if (dtPublish.Year != 9999)
                        {
                            // Neu khong phai la news da published ma khong chon ngay Xuat ban thi update lai ngay gio
                            if (dtPublish.Year != 2000)
                            {
                                objrow.News_PublishDate = dtPublish;
                            }
                            else
                            {
                                objrow.News_PublishDate = DateTime.Now;
                            }
                        }
                    }

                    objrow.Template       = _template;
                    objrow.News_ImageNote = _news_title_image;

                    objrow.isComment  = _isShowComment;
                    objrow.isUserRate = _isShowRate;
                    objrow.Icon       = _news_icon;


                    objrow.News_ModifiedDate = DateTime.Now;
                    #endregion

                    #region Gan cac gia tri cho bang Action
                    //thuc hien luu thong tin vao action.
                    ActionRow objArow = new ActionRow();
                    objArow.Sender_ID = HttpContext.Current.User.Identity.Name;
                    //Gui len. Neu la xoa tam thi khong luu action - Cho nay can phai xem la gui len hay luu lai?
                    string cpMode = HttpContext.Current.Request.QueryString["cpmode"].Replace("add,", string.Empty);
                    switch (objrow.News_Status)
                    {
                    case 1:
                        if (old_news_status != 1)
                        {
                            objArow.Comment_Title = HttpContext.Current.User.Identity.Name + " gửi bài chờ biên tập";
                        }
                        else
                        {
                            objArow.Comment_Title = HttpContext.Current.User.Identity.Name + " nhận biên tập";
                            objArow.Reciver_ID    = HttpContext.Current.User.Identity.Name;
                            ActionRow tem = new ActionRow();
                            tem = getLastestAction(_news_id);
                            objArow.Sender_ID = tem.Sender_ID;
                        }
                        break;

                    case 2:
                        if (old_news_status != 2)
                        {
                            objArow.Comment_Title = HttpContext.Current.User.Identity.Name + " gửi bài chờ duyệt";
                        }
                        else
                        {
                            objArow.Comment_Title = HttpContext.Current.User.Identity.Name + " nhận duyệt";
                            objArow.Reciver_ID    = HttpContext.Current.User.Identity.Name;
                            ActionRow tem = new ActionRow();
                            tem = getLastestAction(_news_id);
                            objArow.Sender_ID = tem.Sender_ID;
                        }
                        break;

                    case 3: objArow.Comment_Title = HttpContext.Current.User.Identity.Name + " xuất bản bài"; break;
                    }
                    objArow.ActionType = objrow.News_Status;
                    objArow.News_ID    = _news_id;

                    objArow.CreateDate = DateTime.Now;
                    // chỉ khi tin đổi trạng thái
                    // hoặc
                    // không phải tin ở trong danh sách nhận duyệt, nhận biên tập
                    // thì mới lưu action
                    // [bacth, 11:00 AM 5/31/2008]
                    if (old_news_status != objrow.News_Status || (cpMode.ToLower().Equals("approvalwaitlist") || cpMode.ToLower().Equals("editwaitlist")))
                    {
                        if (objrow.News_Status == 1 || objrow.News_Status == 2 || objrow.News_Status == 3)
                        {
                            objDb.ActionCollection.Insert(objArow);
                        }
                    }

                    #endregion

                    #region Gan cac gia tri cho bang NewsPublished
                    NewsPublishedRow objpublishRow;

                    // Get lai nhung gia tri cua cua News Published
                    objpublishRow = objDb.NewsPublishedCollection.GetByPrimaryKey(_news_id);

                    // Neu khong ton tai news_id trong NewsPUblished thi khoi tao lai
                    if (objpublishRow == null)
                    {
                        objpublishRow = new NewsPublishedRow();
                    }

                    // Gan cac gia tri cho News Published
                    if (_news_status == 3)
                    {
                        objrow.News_Approver = HttpContext.Current.User.Identity.Name;

                        objArow.Comment_Title = HttpContext.Current.User.Identity.Name + " xuất bản bài";
                        objArow.ActionType    = 3;

                        //thuc hien chuyen du lieu qua bang newspublished
                        objpublishRow.Icon          = _news_icon;
                        objpublishRow.News_ID       = _news_id;
                        objpublishRow.Cat_ID        = _cat_id;
                        objpublishRow.News_Subtitle = _news_subtitle;
                        objpublishRow.News_Title    = _news_title;
                        if (_news_image != "" && _news_image != null)
                        {
                            objpublishRow.News_Image = _news_image;
                        }
                        else
                        {
                            objpublishRow.News_Image = objrow.News_Image;
                        }
                        objpublishRow.News_Source      = _news_source;
                        objpublishRow.News_InitContent = objrow.News_InitialContent;
                        objpublishRow.News_Content     = _news_content;
                        objpublishRow.News_Athor       = objrow.News_Author;
                        objpublishRow.News_Approver    = HttpContext.Current.User.Identity.Name;
                        objpublishRow.News_Status      = 3;

                        if (dtPublish.Year != 9999)
                        {
                            // Neu khong phai la news da published ma khong chon ngay Xuat ban thi update lai ngay gio
                            if (dtPublish.Year != 2000)
                            {
                                objpublishRow.News_PublishDate = dtPublish;
                            }
                            else
                            {
                                objpublishRow.News_PublishDate = DateTime.Now;
                            }
                        }

                        objpublishRow.News_isFocus = _news_isfocus;
                        objpublishRow.News_Mode    = _news_type;
                        if (_related_news != "" && _related_news != null)
                        {
                            objpublishRow.News_Relation = objrow.News_Relation;
                        }
                        else
                        {
                            objpublishRow.News_Relation = _related_news;
                        }
                        if (_other_cat != "" && _other_cat != null)
                        {
                            objpublishRow.News_OtherCat = objrow.News_OtherCat;
                        }
                        else
                        {
                            objpublishRow.News_OtherCat = _other_cat;
                        }

                        objpublishRow.Template       = _template;
                        objpublishRow.isComment      = _isShowComment;
                        objpublishRow.isUserRate     = _isShowRate;
                        objpublishRow.News_ImageNote = _news_title_image;
                    }

                    #endregion

                    if (!objDb.NewsCollection.Update(objrow))
                    {
                        throw new Exception("Không cập nhật được bản tin");
                    }

                    #region Cap nhap vao bang News, Action va  NewsPublished
                    NewsPublishedRow objCurrRow;
                    //neu la send thi moi cap nhat Action



                    if (objrow.News_Status == 3)
                    {
                        //thuc hien xoa neu ton tai tin do va chen moi vao bang xuat ban
                        objCurrRow = objDb.NewsPublishedCollection.GetByPrimaryKey(_news_id);
                        if (objCurrRow != null)
                        {
                            objDb.NewsPublishedCollection.DeleteByPrimaryKey(_news_id);
                        }
                        objDb.NewsPublishedCollection.Insert(objpublishRow);
                    }
                    #endregion

                    #region Cap nhap vao bang MediaObject
                    // Xoa tat ca News_Media cu theo NewsID
                    string strObjectId = NewsMediaHelper.Get_ObjectId_By_NewsId(_news_id);
                    if (strObjectId != null && strObjectId != "")
                    {
                        string[] mediaIds = strObjectId.Split(",".ToCharArray());
                        foreach (string strMediaId in mediaIds)
                        {
                            NewsMediaHelper.Delete_News_Media_ByNewsIdAndObjectId(_news_id, strMediaId, objDb);
                        }
                    }

                    //truong hop co media object
                    if (_obj_media != null && _obj_media != "")
                    {
                        News_MediaRow objMrow  = null;
                        string[]      mediaIds = _obj_media.Split(",".ToCharArray());
                        foreach (string strMediaId in mediaIds)
                        {
                            objMrow           = new News_MediaRow();
                            objMrow.News_ID   = _news_id;
                            objMrow.Object_ID = int.Parse(strMediaId);
                            objDb.News_MediaCollection.Insert(objMrow);
                        }
                    }

                    #endregion

                    objDb.CommitTransaction();
                    toReturn = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally {
                if (HttpContext.Current.Session["newsid"] != null)
                {
                    HttpContext.Current.Session.Remove("newsid");
                }
                objDb.Close();
            }



            return(toReturn);;
        }