public int UpdateArticle(BusinessLogic b, int ArticleId) { int updateExecuted = -1; StringBuilder formParamString = new StringBuilder(); formParamString.Append("IsArticlePaging=" + Convert.ToInt32(b.IsPagingEnable) + " "); string updateString = "update crossarticle_article set " + formParamString.ToString() + "where id = " + ArticleId; try { using (SqlCommand comUpdateArticle = new SqlCommand(updateString, ConnectDatabase)) { ConnectDatabase.Open(); updateExecuted = comUpdateArticle.ExecuteNonQuery(); } } catch { } finally { ConnectDatabase.Close(); } return updateExecuted; }
private void BindArticle(int articleId) { lblInvalidCategory.Visible = false; ArticleInfo objArticle = ArticleController.Get(articleId); if (objArticle == null) { return; } //Response.Write(objArticle.ctlima); txtTitle.Text = objArticle.Title; txtAuthor.Text = objArticle.Author; chkPublish.Checked = objArticle.Authed; /* txtSource.Text = objArticle.Source; chkQuote.Checked = objArticle.Quote; txtPinOrder.Text = Convert.ToString(objArticle.PinOrder); chkDraft.Checked = objArticle.Draft; ctlLinkUrl.Url = objArticle.LinkUrl; chkFeatured.Checked = objArticle.Featured; chkAuthed.Checked = objArticle.Authed; chkActive.Checked = objArticle.Active; */ //bool returns = (objArticle.TopStoriesImage == "") ? true : false; //Page.ClientScript.RegisterStartupScript(this.GetType(), "mKey", "alert('" + objArticle.Image + "')", true); //Response.Write(objArticle.TopStoriesImage); txtKeywords.Text = objArticle.Keywords; txtImage.Text=objArticle.Image; /*if (!string.IsNullOrEmpty(objArticle.Image)) { foreach (ListItem m in drpThumbnailImage.Items) { if (m.Text == objArticle.Image.Remove(0, objArticle.Image.LastIndexOf("/") + 1)) { drpThumbnailImage.SelectedValue = drpThumbnailImage.Items.FindByText(objArticle.Image.Remove(0, objArticle.Image.LastIndexOf("/") + 1)).Value; break; } } }*/ /* if (!string.IsNullOrEmpty(objArticle.TopStoriesImage)) { foreach (ListItem m in d1.Items) { if (m.Text == objArticle.TopStoriesImage.Remove(0, objArticle.TopStoriesImage.LastIndexOf("/") + 1)) { d1.SelectedValue = d1.Items.FindByText(objArticle.TopStoriesImage.Remove(0, objArticle.TopStoriesImage.LastIndexOf("/") + 1)).Value; break; } } } else { d1.SelectedIndex = 0; }*/ if (!Null.IsNull(objArticle.PublishDate.ToString())) { string time = Convert.ToDateTime(objArticle.PublishDate).ToString("hh:mm:tt"); string[] splitTime = time.Split(':'); // Response.Write("Welcome"); // Response.Write(time.Substring(0, 2) + " " + time.Substring(3, 2) + " " + time.Substring(6, 2) + " " + objArticle.Id); PublishHour.SelectedIndex = PublishHour.Items.IndexOf(PublishHour.Items.FindByText(splitTime[0])); PublishMinute.SelectedIndex = PublishMinute.Items.IndexOf(PublishMinute.Items.FindByText(splitTime[1])); PublishAMPM.SelectedIndex = PublishAMPM.Items.IndexOf(PublishAMPM.Items.FindByText(splitTime[2])); } else { /*int hour1 = DateTime.Now.Hour; if (DateTime.Now.Hour > 12) { hour1 = DateTime.Now.Hour - 12; }*/ string currentTime = DateTime.Now.ToString("hh:mm:tt"); string[] splitCurrentTime = currentTime.Split(':'); PublishHour.SelectedIndex = PublishHour.Items.IndexOf(PublishHour.Items.FindByText(splitCurrentTime[0])); PublishMinute.SelectedIndex = PublishMinute.Items.IndexOf(PublishMinute.Items.FindByText(splitCurrentTime[1])); PublishAMPM.SelectedIndex = PublishAMPM.Items.IndexOf(PublishAMPM.Items.FindByText(splitCurrentTime[2])); /* string hour2 = hour1 < 10 ? ("0" + Convert.ToString(hour1)) : Convert.ToString(hour1); PublishHour.SelectedIndex = PublishHour.Items.IndexOf(PublishHour.Items.FindByText((Convert.ToString(hour2)))); int minute = DateTime.Now.Minute; if (minute % 10 == 1) minute = minute - 1; else if (minute % 10 == 2) minute = minute - 2; else if (minute % 10 == 3) minute = minute + 2; else if (minute % 10 == 4) minute = minute + 1; else if (minute % 10 == 6) minute = minute - 1; else if (minute % 10 == 7) minute = minute - 2; else if (minute % 10 == 8) minute = minute + 2; else if (minute % 10 == 9) minute = minute + 1; string minutes = minute < 10 ? ("0" + Convert.ToString(minute)) : Convert.ToString(minute); //Response.Write(minutes); PublishMinute.SelectedIndex = PublishMinute.Items.IndexOf(PublishMinute.Items.FindByText(minutes)); string ampm = DateTime.Now.ToString().Contains("AM") ? "AM" : "PM"; PublishAMPM.SelectedIndex = PublishAMPM.Items.IndexOf(PublishAMPM.Items.FindByText(ampm)); //Response.Write(hour2+" "+minutes+" "+ampm);*/ } /* */ //if (objArticle.TopStoriesImage != "") //{ // drpTopStoriesPosition.SelectedValue = drpTopStoriesPosition.Items.FindByText(objArticle.TopStoriesImage.Remove(0, objArticle.TopStoriesImage.LastIndexOf("/") + 1)).Value; //} //Image /* SqlCommand cmd1 = new SqlCommand("Select ca.Image from CrossArticle_Article ca where ca.Id=@article", con.Set_Connection()); cmd1.Parameters.AddWithValue("@article", articleId); SqlDataAdapter adap2 = new SqlDataAdapter(cmd1); DataTable dtt1 = new DataTable(); adap2.Fill(dtt1); if (dtt1.Rows[0][0].ToString() != "") { if (UserInfo.IsInRole(PortalSettings.AdministratorRoleName)) { //ctlImage.Url = objArticle.Image; i = cboFiles.Items.IndexOf(cboFiles.Items.FindByValue(Convert.ToString(dtt1.Rows[0][0].ToString()))); cboFiles.SelectedIndex = i; } else { i = cboFiles.Items.IndexOf(cboFiles.Items.FindByValue(Convert.ToString(dtt1.Rows[0][0].ToString()))); cboFiles.SelectedIndex = i; //URL1.Url = objArticle.Image; //ctlUserImage.Url = objArticle.Image; } } */ //txtImageDescription.Text = objArticle.ImageDescription; RecursiveHelper.FillAspNetTreeCheckBox(ref tvCategory, objArticle.Categories, true); List<ArticleToTagInfo> tags = (from t in ArticleToTagController.ListByArticle(articleId) select t).ToList(); SqlCommand cmd = new SqlCommand("Select a2t.TagId from CrossArticle_ArticleToTag a2t where a2t.ArticleId=@article", new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString)); cmd.Parameters.AddWithValue("@article", articleId); foreach (ListItem i in CheckBoxList1.Items) { i.Selected = false; } SqlDataAdapter adap1 = new SqlDataAdapter(cmd); DataTable dtt = new DataTable(); adap1.Fill(dtt); foreach (DataRow r in dtt.Rows) { //Response.Write(r[0].ToString()); CheckBoxList1.Items[(Convert.ToInt32(r[0].ToString())) - 1].Selected = true; } //Date if (!Null.IsNull(objArticle.PublishDate)) txtPublishDate.Text = objArticle.PublishDate.ToShortDateString(); if (!Null.IsNull(objArticle.ExpireDate)) txtExpireDate.Text = objArticle.ExpireDate.ToShortDateString(); cblViewRoles = Utils.FillRolesCheckBox(cblViewRoles, objArticle.ViewRoles, PortalSettings.AdministratorRoleId, PortalId); //rating chkAllowRating.Checked = objArticle.AllowRating; cblRatingRoles = Utils.FillRolesCheckBox(cblRatingRoles, objArticle.RatingRoles, PortalSettings.AdministratorRoleId, PortalId); //Comment value chkAllowComment.Checked = objArticle.AllowComment; chkAutoAuthComment.Checked = objArticle.AutoAuthComment; cblCommentRoles = Utils.FillRolesCheckBox(cblCommentRoles, objArticle.CommentRoles, PortalSettings.AdministratorRoleId, PortalId); // chkAllowRecommend.Checked = objArticle.AllowRecommend; cblRecommendRoles = Utils.FillRolesCheckBox(cblRecommendRoles, objArticle.RecommendRoles, PortalSettings.AdministratorRoleId, PortalId); cblDownloadRoles = Utils.FillRolesCheckBox(cblDownloadRoles, objArticle.DownloadRoles, PortalSettings.AdministratorRoleId, PortalId); BusinessLogic bConstructor = new BusinessLogic(Convert.ToInt32(ArticleId)); chkPaging.Checked = bConstructor.IsPagingEnable; txtSummary.Text = objArticle.Summary; Editor1.Text = Server.HtmlDecode(objArticle.Article); AttachmentList = new List<AttachmentInfo>(); List<AttachmentInfo> aiList = AttachmentController.ListByArticle(articleId); for (int i = 0; i < aiList.Count; i++) { AttachmentInfo ai = new AttachmentInfo(); ai.Id = i; ai.ArticleId = articleId; ai.FilePath = aiList[i].FilePath; AttachmentList.Add(ai); } gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }
private void UpdateArticle() { ArticleInfo objArticle = ArticleController.Get(ArticleId); //Normal objArticle.Title = txtTitle.Text; objArticle.Author = txtAuthor.Text; objArticle.Keywords = txtKeywords.Text; /* objArticle.Source = txtSource.Text; objArticle.Quote = chkQuote.Checked; objArticle.Draft = chkDraft.Checked; objArticle.LinkUrl = ctlLinkUrl.Url; objArticle.PinOrder = Convert.ToInt32(txtPinOrder.Text); //other if (ArticlePortalSettings.General.Portal_ArticleRequireApproval == true) { objArticle.Authed = chkAuthed.Checked; } else { objArticle.Authed = true; } objArticle.Featured = chkFeatured.Checked; objArticle.Active = chkActive.Checked; */ objArticle.Image = txtImage.Text; objArticle.Thumbnail = txtImage.Text; //objArticle.TopStoriesImage = "/Portals/0/" + drpTopStoriesPosition.SelectedItem.Text; objArticle.TopStoriesImage = null; /* if (drpTopStoriesPosition.SelectedItem.Text != "") { objArticle.TopStoriesImage = "/Portals/0/" + drpTopStoriesPosition.SelectedItem.Text; } else { objArticle.TopStoriesImage = null; }*/ objArticle.PublishTime = PublishHour.SelectedItem.Text + ":" + PublishMinute.SelectedItem.Text + " " + PublishAMPM.SelectedItem.Text; //if (objArticle.Image.StartsWith("FileID=")) //{ // FileController fc = new FileController(); // DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); // DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); // DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); // fi = GetFileInfoById(objArticle.Image); // if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) // { // objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; // System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); // if (!fi.FileName.ToLower().StartsWith("thumb_"))//文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 // { // if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name))//存在该文件,则自动指向 // { // objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; // } // else//不存在,则生成该文件,然后指向 // { // if (ArticlePortalSettings.General.Portal_ArticleGenerateThumb) // { // Utils.ResizeImage(fi.PhysicalPath, ArticlePortalSettings.General.Portal_ArticleThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); // objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; // } // } // } // } //} //Add Categories objArticle.Categories = RecursiveHelper.GetAspNetTreeCheckList(tvCategory); //Add Tags objArticle.Tags = ""; TagInfo objTag = new TagInfo(); List<int> tagList = new List<int>(); foreach (ListItem li in CheckBoxList1.Items) { if (li.Selected) { if (listData.InnerText == "") { objTag = TagController.GetByTag(li.Value.Trim()); tagList.Add(objTag.Id); } } } var newTaglist = (from p in tagList select p).Distinct();//remove the repeated tag item. foreach (int item in newTaglist) { objArticle.Tags += item.ToString() + ","; } objArticle.Tags = Utils.RemoveSeperator(objArticle.Tags, ","); //Tags end //date if ((txtPublishDate.Text != null) && (txtPublishDate.Text != "")) { objArticle.PublishDate = Convert.ToDateTime(txtPublishDate.Text); } else { objArticle.PublishDate = DateTime.Now; } if (txtExpireDate.Text != "") { objArticle.ExpireDate = Convert.ToDateTime(txtExpireDate.Text); } objArticle.ViewRoles = Utils.GetCheckedItems(cblViewRoles, PortalSettings.AdministratorRoleId); //Rating objArticle.AllowRating = chkAllowRating.Checked; objArticle.RatingRoles = Utils.GetCheckedItems(cblRatingRoles, PortalSettings.AdministratorRoleId); //Recommend objArticle.AllowRecommend = chkAllowRecommend.Checked; objArticle.RecommendRoles = Utils.GetCheckedItems(cblRecommendRoles, PortalSettings.AdministratorRoleId); //Comment objArticle.AllowComment = chkAllowComment.Checked; objArticle.CommentRoles = Utils.GetCheckedItems(cblCommentRoles, PortalSettings.AdministratorRoleId); objArticle.AutoAuthComment = chkAutoAuthComment.Checked; //Download roles objArticle.DownloadRoles = Utils.GetCheckedItems(cblDownloadRoles, PortalSettings.AdministratorRoleId); objArticle.Summary = LocalUtils.RemoveAllHtmlTags(txtSummary.Text); objArticle.Article = Editor1.Text.Replace("src="Portals", "src="/Portals"); objArticle.Authed = chkPublish.Checked; BusinessLogic b = new BusinessLogic(); //Response.Redirect("http://www.google.co.in?b=" + b.ArticleID.ToString(),false); b.ArticleID = ArticleId; b.IsPagingEnable = chkPaging.Checked; b.UpdateExtraFieldArticle(); ArticleController.Update(objArticle); //Now processing attachment AttachmentController.DeleteByArticle(ArticleId); //delete attachment first. AttachmentInfo ai = new AttachmentInfo(); foreach (AttachmentInfo item in AttachmentList) { ai.ArticleId = ArticleId; ai.FilePath = item.FilePath; AttachmentController.Add(ai); } //Reset all // ArticleId = -1; AttachmentList = new List<AttachmentInfo>(); gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); if (Session["ArticlePageEdit"] != null) { urlReferrer = Session["ArticlePageEdit"].ToString(); Response.Write("URL: "+urlReferrer); Session.Clear(); Response.Redirect(urlReferrer); } }
private void BindArticle(int articleId) { lblInvalidCategory.Visible = false; ArticleInfo objArticle = ArticleController.Get(articleId); if (objArticle == null) { return; } txtTitle.Text = objArticle.Title; txtAuthor.Text = objArticle.Author; chkPublish.Checked = objArticle.Authed; txtKeywords.Text = objArticle.Keywords; txtImage.Text=objArticle.Image; /* txtSource.Text = objArticle.Source; chkQuote.Checked = objArticle.Quote; txtPinOrder.Text = Convert.ToString(objArticle.PinOrder); chkDraft.Checked = objArticle.Draft; ctlLinkUrl.Url = objArticle.LinkUrl; chkFeatured.Checked = objArticle.Featured; chkAuthed.Checked = objArticle.Authed; chkActive.Checked = objArticle.Active; */ //ctlImage.Url = objArticle.Image; //foreach (ListItem l in drpThumbnailImage.Items) { Response.Write(l.Text + "<br>"); } /*if (objArticle.Image != "") { foreach (ListItem m in drpThumbnailImage.Items) { if (m.Text == objArticle.Image.Remove(0, objArticle.Image.LastIndexOf("/") + 1)) { drpThumbnailImage.SelectedValue = drpThumbnailImage.Items.FindByText(objArticle.Image.Remove(0, objArticle.Image.LastIndexOf("/") + 1)).Value; break; } } }*/ /* if (objArticle.TopStoriesImage != "") { foreach (ListItem m in drpTopStoriesPosition.Items) { if (m.Text == objArticle.TopStoriesImage.Remove(0, objArticle.TopStoriesImage.LastIndexOf("/") + 1)) { drpTopStoriesPosition.SelectedValue = drpTopStoriesPosition.Items.FindByText(objArticle.TopStoriesImage.Remove(0, objArticle.TopStoriesImage.LastIndexOf("/") + 1)).Value; break; } } } */ if (!Null.IsNull(objArticle.PublishDate.ToString())) { string time = Convert.ToDateTime(objArticle.PublishDate).ToString("hh:mm:tt"); string[] splitTime = time.Split(':'); // Response.Write("Welcome"); // Response.Write(time.Substring(0, 2) + " " + time.Substring(3, 2) + " " + time.Substring(6, 2) + " " + objArticle.Id); PublishHour.SelectedIndex = PublishHour.Items.IndexOf(PublishHour.Items.FindByText(splitTime[0])); PublishMinute.SelectedIndex = PublishMinute.Items.IndexOf(PublishMinute.Items.FindByText(splitTime[1])); PublishAMPM.SelectedIndex = PublishAMPM.Items.IndexOf(PublishAMPM.Items.FindByText(splitTime[2])); } else { /*int hour1 = DateTime.Now.Hour; if (DateTime.Now.Hour > 12) { hour1 = DateTime.Now.Hour - 12; }*/ string currentTime = DateTime.Now.ToString("hh:mm:tt"); string[] splitCurrentTime = currentTime.Split(':'); PublishHour.SelectedIndex = PublishHour.Items.IndexOf(PublishHour.Items.FindByText(splitCurrentTime[0])); PublishMinute.SelectedIndex = PublishMinute.Items.IndexOf(PublishMinute.Items.FindByText(splitCurrentTime[1])); PublishAMPM.SelectedIndex = PublishAMPM.Items.IndexOf(PublishAMPM.Items.FindByText(splitCurrentTime[2])); /* string hour2 = hour1 < 10 ? ("0" + Convert.ToString(hour1)) : Convert.ToString(hour1); PublishHour.SelectedIndex = PublishHour.Items.IndexOf(PublishHour.Items.FindByText((Convert.ToString(hour2)))); int minute = DateTime.Now.Minute; if (minute % 10 == 1) minute = minute - 1; else if (minute % 10 == 2) minute = minute - 2; else if (minute % 10 == 3) minute = minute + 2; else if (minute % 10 == 4) minute = minute + 1; else if (minute % 10 == 6) minute = minute - 1; else if (minute % 10 == 7) minute = minute - 2; else if (minute % 10 == 8) minute = minute + 2; else if (minute % 10 == 9) minute = minute + 1; string minutes = minute < 10 ? ("0" + Convert.ToString(minute)) : Convert.ToString(minute); //Response.Write(minutes); PublishMinute.SelectedIndex = PublishMinute.Items.IndexOf(PublishMinute.Items.FindByText(minutes)); string ampm = DateTime.Now.ToString().Contains("AM") ? "AM" : "PM"; PublishAMPM.SelectedIndex = PublishAMPM.Items.IndexOf(PublishAMPM.Items.FindByText(ampm)); //Response.Write(hour2+" "+minutes+" "+ampm);*/ } RecursiveHelper.FillAspNetTreeCheckBox(ref tvCategory, objArticle.Categories, true); List<ArticleToTagInfo> tags = (from t in ArticleToTagController.ListByArticle(articleId) select t).ToList(); //Date if (!Null.IsNull(objArticle.PublishDate)) txtPublishDate.Text = objArticle.PublishDate.ToShortDateString(); if (!Null.IsNull(objArticle.ExpireDate)) txtExpireDate.Text = objArticle.ExpireDate.ToShortDateString(); cblViewRoles = Utils.FillRolesCheckBox(cblViewRoles, objArticle.ViewRoles, PortalSettings.AdministratorRoleId, PortalId); //rating chkAllowRating.Checked = objArticle.AllowRating; cblRatingRoles = Utils.FillRolesCheckBox(cblRatingRoles, objArticle.RatingRoles, PortalSettings.AdministratorRoleId, PortalId); //Comment value chkAllowComment.Checked = objArticle.AllowComment; chkAutoAuthComment.Checked = objArticle.AutoAuthComment; cblCommentRoles = Utils.FillRolesCheckBox(cblCommentRoles, objArticle.CommentRoles, PortalSettings.AdministratorRoleId, PortalId); // chkAllowRecommend.Checked = objArticle.AllowRecommend; cblRecommendRoles = Utils.FillRolesCheckBox(cblRecommendRoles, objArticle.RecommendRoles, PortalSettings.AdministratorRoleId, PortalId); cblDownloadRoles = Utils.FillRolesCheckBox(cblDownloadRoles, objArticle.DownloadRoles, PortalSettings.AdministratorRoleId, PortalId); txtSummary.Text = objArticle.Summary; Editor1.Text = Server.HtmlDecode(objArticle.Article); BusinessLogic bConstructor = new BusinessLogic(articleId); //Response.Redirect("http://www.google.co.in?s=" + bConstructor.ArticleID.ToString(),false); chkPaging.Checked = bConstructor.IsPagingEnable; //chkPagination.Checked=false; AttachmentList = new List<AttachmentInfo>(); List<AttachmentInfo> aiList = AttachmentController.ListByArticle(articleId); for (int i = 0; i < aiList.Count; i++) { AttachmentInfo ai = new AttachmentInfo(); ai.Id = i; ai.ArticleId = articleId; ai.FilePath = aiList[i].FilePath; AttachmentList.Add(ai); } gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }