Пример #1
0
        //删除草稿更新原文
        void Add_Click(object sender, EventArgs e)
        {

            try
            {
                if (TextBox2.Text != "")
                    LogId = Convert.ToInt32(TextBox2.Text);
            }
            catch { }
            if (LogId != 0)
            {
                BWeblog_log.DeleteByID(LogId);
            }

            LogTitle = Title.Text;
            LogContext = Editor.Text;


            Weblog_Log WL = BWeblog_log.GetWithDraftByID(blogContext.LogId);
            WL.Log_CateId = Convert.ToInt32(LogCategory.SelectedValue);
            WL.Log_IsDraft = false;
            WL.Log_LastModiTime = DateTime.Now;
            WL.Log_Title = LogTitle;
            WL.Log_Content = LogContext;
            WL.Log_CreateTime = Convert.ToDateTime(CreateTime.Text.Trim());
            WL.Log_IsEnRePly = IsEnReply.Checked;
            WL.Log_IsIndexShow = IsIndexShow.Checked;
            if (AllowPsd.Checked == true && TextBox1.Text.Trim() != "")
            {
                WL.Log_PassWord = TextBox1.Text.Trim();
                WL.Log_IsPasssword = true;
            }
            else
            {
                WL.Log_PassWord = "";
                WL.Log_IsPasssword = false;
            }
            WL.Log_KeyWords = KeyWords.Text.Trim();
            BWeblog_log.Update(WL);
            int TxzID = Convert.ToInt32(BWeblog_User.GetByID(blogContext.BlogUserId).User_TxzId);
            int NewsUrlTypeID = -1;
            if (TxzID < 200000)
            {
                NewsUrlTypeID = 3;
            }
            else NewsUrlTypeID = 13;
            Ncuhome.Blog.Core.clubNewsService.NewsService clubNews = new Ncuhome.Blog.Core.clubNewsService.NewsService();
            try
            {
                clubNews.AddNews(TxzID, -1, WL.Log_Title, WL.Log_Content, NewsUrlTypeID, WL.Log_Id);
            }
            catch
            { }
            BWeblog_log.SetLogCountByUID(blogContext.BlogUserId);
            DateTime PublishTime = Convert.ToDateTime(CreateTime.Text.Trim());
            if (PublishTime < DateTime.Now)
                PageRedirct(true, "操作成功,文章已经发布!");
            else
                PageRedirct(true, "文章将于" + PublishTime.ToString() + "发布");
        }
Пример #2
0
        private void Add_Click(object sender, EventArgs e)
        {
            Add.Enabled = false;
            LogTitle = Title.Text;
            LogContext = Editor.Text;

            //myself:尽量不要使用try catch
            bool blHasLogID = int.TryParse(this.TextBox2.Text.Trim(), out LogId);
            if (!blHasLogID)
            {
                LogId = 0;
            }

            //try
            //{
            //    if(TextBox2.Text!="")
            //    LogId = Convert.ToInt32(TextBox2.Text);
            //}
            //catch { }

            Weblog_Log WL = new Weblog_Log();
            WL.Log_CateId = Convert.ToInt32(LogCategory.SelectedValue);
            WL.Log_CommentCount = 0;
            WL.Log_IsTop = false;
            WL.Log_IsVisible = true;
            WL.Log_ViewCount = 0;
            WL.Log_IP = Globals.IPAddress;
            WL.Log_IsDraft = false;
            WL.Log_LastModiTime = DateTime.Now;
            WL.Log_Title = LogTitle;
            WL.Log_Content = LogContext;
            WL.Log_UserId = blogContext.BlogUserId;
            WL.Log_CreateTime = Convert.ToDateTime(CreateTime.Text.Trim());
            WL.Log_IsEnRePly = IsEnReply.Checked;
            WL.Log_IsIndexShow = IsIndexShow.Checked;
            if (AllowPsd.Checked == true&&TextBox1.Text.Trim()!="")
            {
                WL.Log_PassWord = TextBox1.Text.Trim();
                WL.Log_IsPasssword = true;
            }
            else
            {
                WL.Log_PassWord = "";
                WL.Log_IsPasssword = false;
            }
            WL.Log_KeyWords = KeyWords.Text.Trim();
            int TxzID = Convert.ToInt32(BWeblog_User.GetByID(blogContext.BlogUserId).User_TxzId);
            int NewsUrlTypeID = -1;
            if (TxzID < 200000)
            {
                NewsUrlTypeID = 3;
            }
            else NewsUrlTypeID = 13;
            Ncuhome.Blog.Core.clubNewsService.NewsService clubNews = new Ncuhome.Blog.Core.clubNewsService.NewsService();
            if (LogId == 0)//添加
            {
                BWeblog_log.Insert(WL);
                try   //peng 20081109  webservice 上要有异常处理
                {
                    clubNews.AddNews(TxzID, -1, WL.Log_Title, WL.Log_Content, NewsUrlTypeID, WL.Log_Id);
                }
                catch
                { }
            }
            else//更新
            {
                WL.Log_Id = LogId;
                BWeblog_log.Update(WL);
                try   //peng 20081109
                {
                    clubNews.AddNews(TxzID, -1, WL.Log_Title, WL.Log_Content, NewsUrlTypeID, WL.Log_Id);
                }
                catch
                { }
            }
            BWeblog_log.SetLogCountByUID(blogContext.BlogUserId);

            DateTime PublishTime = Convert.ToDateTime(CreateTime.Text.Trim());
            if (PublishTime < DateTime.Now)
                PageRedirct(true, "操作成功,文章已经发布!");
            else
                PageRedirct(true, "文章将于" + PublishTime.ToString() + "发布");
          }