/// <summary> /// 保存缩略图源文件名到数据库 /// </summary> /// <param name="thumbnailFile"></param> void SaveImageToDB(string thumbnailFile) { string rootPath = Server.MapPath("/"); thumbnailFile = thumbnailFile.Remove(0, rootPath.Length); thumbnailFile = string.Format("/{0}", thumbnailFile.Replace("\\", "/")); Article a = new Article(); a.ID = ArticleID; a.Thumbnail = thumbnailFile; a.IsImage = 1; if (a.ID == null) { Article article = ArticleHelper.AddArticles(a); } else { string[] fields = new string[] { "Thumbnail", "WapImage", "OriginalImage", "IsImage" }; ArticleHelper.UpdateArticle(a, fields); } }
void SaveArticle() { try { if (CDHelper.Config.EnableLoginAuhenCode == "true" && this.ValidateTextBox.Text != Request.Cookies["AreYouHuman"].Value) { Messages.ShowError("错误:您输入的验证码不正确,请重新输入!"); // Clear the input and create a new random code. this.ValidateTextBox.Text = ""; Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode(); return; } string ownerId = OwnerID; if (ownerId == null) { ownerId = ChannelDropDownList.SelectedValue; } if (String.IsNullOrEmpty(ownerId)) { Messages.ShowError("文章栏目不能为空!"); return; } Article a = ThisArticle; a.Description = DescriptionTextBox.Value; a.Title = TitleTextBox.Value; a.SubTitle = SubTitleTextBox.Value; a.Color = ddlColor.SelectedValue; a.FontStyle = chkItalic.Checked ? "Italic" : ""; a.FontWeight = chkBold.Checked ? "Bold" : ""; //a.ID = ArticleID; if (IndexTextBox.Value.Trim() == "") { a.Index = 0; } else { a.Index = Convert.ToInt32(IndexTextBox.Value); } a.Source = SourceTextBox.Value; a.AllowComments = AllowCommentsCheckBox.Checked ? 1 : 0; //if (IsShowCheckBox.Checked) //{ // a.EnumState = StateMgr.StateInitialize(); // a.EnumState = StateMgr.StateProcess(a.EnumState, EnumLibrary.Business.HomeRecommend, 1); //} //a.IsShow = IsShowCheckBox.Checked ? 1 : 0; a.Author = AuthorTextBox.Value; a.State = Convert.ToInt32(StateDropDownList.SelectedValue); a.ContentType = Convert.ToInt32(ActicleTypeDropDownList.SelectedValue); //a.IsImage = (TypeOfArticle)a.ContentType == TypeOfArticle.QuoteArticle || (TypeOfArticle)a.ContentType == TypeOfArticle.ShareArticle ? 1 : 0; a.ContentUrl = ContentUrlTextBox.Value; a.Content = We7Helper.ConvertPageBreakFromVisualToChar(ContentTextBox.Value); a.KeyWord = KeywordTextBox.Value; a.DescriptionKey = DescriptionKeyTextBox.Value; if (GeneralConfigs.GetConfig().AllowParentArticle&& !string.IsNullOrEmpty(ParentArticleID.Value)) { a.ParentID = ParentArticleID.Value; } else { a.ParentID = We7Helper.EmptyGUID; } if (UpdatedTextBox.Value.Trim() == "") { a.Updated = DateTime.Now; } else { a.Updated = Convert.ToDateTime(UpdatedTextBox.Value); } if (txtInvalidDate.Value != "") { a.Overdue = Convert.ToDateTime(txtInvalidDate.Value.Trim()); } else { GeneralConfigInfo si = GeneralConfigs.GetConfig(); int OverdueDateTime = si.OverdueDateTime; a.Overdue = a.Updated.AddDays(OverdueDateTime); } if (ArticleID == null) { a.AccountID = AccountID; a.OwnerID = ownerId; Channel ch = ChannelHelper.GetChannel(ownerId, null); if (ch.FullUrl != null && ch.FullUrl != "") { a.ChannelFullUrl = ch.FullUrl; } if (ch.Process != null && ch.Process == "1") { a.State = 2; } //a.ChannelName = ch.ChannelName; /*这儿把上面一句注了,改成了下面的。上面一句与老系统不兼容*/ a.ChannelName = ch.Name; a.FullChannelPath = ch.FullPath; //int type = StateMgr.GetStateValue(ch.EnumState, EnumLibrary.Business.ChannelContentType); //a.EnumState = StateMgr.StateProcess(a.EnumState, EnumLibrary.Business.ArticleType, type); // a.State = 0; //如果禁用 if (StateDropDownList.SelectedValue == "0") { a.state = 0; } Article article = ArticleHelper.AddArticles(a); // 往全文检索里插入数据 ArticleIndexHelper.InsertData(article.ID, 0); #region 自动提交一审(mxy2011-10-18) if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0") { Processing ap = ArticleProcessHelper.GetArticleProcess(article); if (ap.ArticleState != ArticleStates.Checking) { string accName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName; ap.ProcessState = ProcessStates.FirstAudit; ap.ProcessDirection = ((int)ProcessAction.Next).ToString(); ap.ProcessAccountID = AccountID; ap.ApproveName = accName; ArticleProcessHelper.SaveFlowInfoToDB(article, ap); } } #endregion //记录日志 string content = string.Format("新建文章:“{0}”", a.Title); AddLog("新建文章", content); } else { Channel ch = ChannelHelper.GetChannel(ownerId, null); string[] fields = new string[] { "Description", "Title", "Content", "Updated", "Index", "Source", "AllowComments", "Author", "State", "IsShow", "IsImage", "SubTitle", "ContentUrl", "ContentType", "IsDeleted", "Overdue", "KeyWord", "DescriptionKey", "ParentID", "FullChannelPath", "ChannelFullUrl", "Color", "FontWeight", "FontStyle" }; ArticleHelper.UpdateArticle(a, fields); // 往全文检索里更新数据 ArticleIndexHelper.InsertData(a.ID, 0); if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0") { Processing ap = ArticleProcessHelper.GetArticleProcess(a); if (ap.ArticleState != ArticleStates.Checking && ap.ProcessState != ProcessStates.EndAudit) { //编辑审核启用 if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0") { a.State = 2; ArticleHelper.UpdateArticle(a, new string[] { "State" }); } string accName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName; ap.ProcessState = ProcessStates.FirstAudit; ap.ProcessDirection = ((int)ProcessAction.Next).ToString(); ap.ProcessAccountID = AccountID; ap.ApproveName = accName; ArticleProcessHelper.SaveFlowInfoToDB(a, ap); } } //记录日志 string content = string.Format("修改了文章“{0}”", a.Title); AddLog("编辑文章", content); } string rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "saved"); if (!String.IsNullOrEmpty(ArticleID)) { rawurl = We7Helper.AddParamToUrl(rawurl, "saved", "1"); rawurl = We7Helper.AddParamToUrl(rawurl, "Submit", "1"); } else { rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "oid"); rawurl = We7Helper.RemoveParamFromUrl(rawurl, "ParentID"); rawurl = We7Helper.AddParamToUrl(rawurl, "id", a.ID); rawurl = We7Helper.AddParamToUrl(rawurl, "Submit", "0"); } Response.Redirect(rawurl); } catch (FormatException) { Messages.ShowError("无法保存文章信息:可能是文章排序或修改日期格式不正确。"); return; } catch (Exception ex) { Messages.ShowError("无法保存文章信息:" + ex.Message); } }