private void DoArticleEdit(MainDataSet.ArticleRow articleRow) { ShowArticleEdit(); TreeViewParentArticle.Nodes.Clear(); TreeViewParentArticle.Nodes.Add(new Telerik.Web.UI.RadTreeNode(" ", string.Empty)); TreeViewParentArticle.DataBind(); CustomLinksDataBind(UserContext.Current.SelectedInstance.InstanceId); if (articleRow != null) { HtmlEditorBody.ImageManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.ImageManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.ImageDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.MediaManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.MediaManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.VideoDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.FlashManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.FlashManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.FlashDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.DocumentManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.DocumentManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.FileDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.Content = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid); ImageAdminListCtrl.ArticleGuid = articleRow.ArticleGuid; FileAdminListCtrl.ArticleGuid = articleRow.ArticleGuid; ImageAdminListCtrl.DataBind(); FileAdminListCtrl.DataBind(); Master.CustomName = articleRow.Subject; TextBoxSubject.Text = articleRow.Subject; SearchDescriptionTextBox.Text = articleRow.SearchDesc; if (!articleRow.IsParentArticleGuidNull()) { Telerik.Web.UI.RadTreeNode node = TreeViewParentArticle.FindNodeByValue(articleRow.ParentArticleGuid.ToString()); if (node != null) { node.Selected = true; node.ExpandParentNodes(); } } if (articleRow.Type == ArticleType.Request.ToString()) { TextBoxAlternateIds.Text = articleRow.Subject; } else { using (MainDataSetTableAdapters.AlternateIdTableAdapter altAdapter = new MainDataSetTableAdapters.AlternateIdTableAdapter()) { TextBoxAlternateIds.Text = string.Empty; MainDataSet.AlternateIdDataTable dtAlt = altAdapter.GetDataByArticleGuid(articleRow.ArticleGuid); foreach (MainDataSet.AlternateIdRow row in dtAlt) { TextBoxAlternateIds.Text += row.AlternateId + Environment.NewLine; } } } } else { Master.CustomName = (string)this.GetLocalResourceObject("AddNewArticle"); } }
protected void PostCommentCtrl_CommentPosted(object sender, ArticleEventArgs e) { if (e.IsNew) { using (MainDataSetTableAdapters.AlternateIdTableAdapter taAlternateId = new MainDataSetTableAdapters.AlternateIdTableAdapter()) { taAlternateId.InsertAlt(this.Master.InstanceGuid, e.ArticleGuid, this.AlternateId); } PanelArticle.Visible = false; PanelSuccess.Visible = true; //LabelCommentPosted.Text = string.Format(LabelCommentPosted.Text, PostCommentCtrl.ReceiverName); //Response.Redirect(string.Format("~/?i={0}&t={1}#comments", this.Master.InstanceGuid.ToString("N"), e.ArticleGuid.ToString("N")), false); } else { CommentsListCtrl.DataBind(); CommentsListCtrl.RegisterGoAnchor(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (UserContext.Current != null && UserContext.Current.SelectedInstance != null && this.ArticleGuid != Guid.Empty && !IsPopup) { Response.Redirect("ArticleViewAdmin.aspx?id=" + this.ArticleGuid.ToString("N"), false); return; } else if (UserContext.Current != null && UserContext.Current.SelectedInstance != null && !IsPopup) { Response.Redirect("InstanceHomeAdmin.aspx", false); return; } //// todo: popup case //if (IsPopup) //{ //} string loginUrl = Micajah.Common.Application.WebApplication.LoginProvider.GetLoginUrl(); string pageUrl = Request.Url.AbsolutePath.ToLowerInvariant().Replace("default.aspx", string.Empty); int indexUrl = Request.Url.AbsoluteUri.IndexOf(":" + Request.Url.Port.ToString()); if (indexUrl <= 0) indexUrl = Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath); string siteUrl = Request.Url.AbsoluteUri.Substring(0, indexUrl) + Request.ApplicationPath; if (this.CurrentInstance != null) { string orgInstName = string.Format(CultureInfo.CurrentCulture, "{0} {1}", this.CurrentInstance.Organization.Name, this.CurrentInstance.Name); string instanceUrl = pageUrl + (UserContext.SelectedInstanceId == Guid.Empty ? "?i=" + this.InstanceGuid.ToString("N") : string.Empty); string breadcrumbs = string.Format("<a href=\"{1}\">{0}</a>", (string)this.GetLocalResourceObject("Home"), instanceUrl); #region Load Article MainDataSet.ArticleDataTable dtArticle = null; MainDataSet.ArticleRow articleRow = null; StringBuilder textHeader = new StringBuilder((string)this.GetLocalResourceObject("Header")); StringBuilder textFooter = new StringBuilder((string)this.GetLocalResourceObject("Footer")); if (this.ArticleGuid != Guid.Empty) { dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(this.ArticleGuid); if (dtArticle.Count > 0) articleRow = dtArticle[0]; if (articleRow == null || articleRow.Deleted) Response.Redirect(instanceUrl, false); } else if (this.AlternateId != string.Empty) { string strAltId = this.AlternateId; MainDataSetTableAdapters.AlternateIdTableAdapter taAlternateId = new MainDataSetTableAdapters.AlternateIdTableAdapter(); Guid? articleGuid = null; articleGuid = taAlternateId.GetArticleGuid(strAltId, this.InstanceGuid); int idx = 0; if (!articleGuid.HasValue) { idx = strAltId.LastIndexOf('/'); if (idx > 0) { strAltId = strAltId.Substring(0, idx + 1); articleGuid = taAlternateId.GetArticleGuid(strAltId, this.InstanceGuid); } } if (articleGuid.HasValue) { dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid.Value); if (dtArticle.Count > 0) articleRow = dtArticle[0]; if (articleRow == null || articleRow.Deleted) Response.Redirect(instanceUrl, false); } } //else //{ //Response.Redirect(instanceUrl, false); //return; //} #endregion #region Post Comment // before write a comment we has to chek a new posted comment if (!string.IsNullOrEmpty(Request.Form["Name"]) && !string.IsNullOrEmpty(Request.Form["Comment"])) { using (MainDataSetTableAdapters.CommentTableAdapter taComment = new MainDataSetTableAdapters.CommentTableAdapter()) { string postName = Request.Form["Name"]; string postEmail = Request.Form["Email"]; if (postEmail == null) postEmail = string.Empty; string postComment = Request.Form["Comment"]; string honeyPot = Request.Form["hpot"]; DateTime dtNow = DateTime.Now; if (honeyPot == "micajah@@kb") // honeypot protection { if (articleRow == null) { Guid newId = Guid.NewGuid(); // create a request if (this.ArticleTableAdapter.Insert(newId, this.InstanceGuid, new Guid?(), ArticleType.Request.ToString(), (this.AlternateId != string.Empty) ? this.AlternateId : HttpUtility.HtmlEncode(Utils.ShortCommentText(postComment, 50)), (string)this.GetLocalResourceObject("BodyNotArticle"), string.Empty, 0, 0, 0, false, new DateTime?(), new DateTime?(), new DateTime?(), new Guid?(), new Guid?(), new Guid?()) > 0) { dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(newId); if (dtArticle.Count > 0) articleRow = dtArticle[0]; MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(newId, postName, postEmail, string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress), HttpUtility.HtmlEncode(Utils.ShortCommentText(postComment, 50)), HttpUtility.HtmlEncode(postComment), false, true, DateTime.Now, true); if (commentDataTable != null && commentDataTable.Rows.Count > 0) { string subj; subj = (this.AlternateId != string.Empty) ? this.AlternateId : HttpUtility.HtmlEncode(Utils.ShortCommentText(postComment, 50)); ArrayList SendTo = new ArrayList(); SendTo.AddRange(this.InputListAdmin); SendTo.AddRange(InstanceAdminEmails); MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter(); foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows) { if (!SendTo.Contains(row["UserEmail"].ToString())) SendTo.Add(row["UserEmail"].ToString()); } foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(ArticleGuid, this.InstanceGuid).Rows) SendTo.Remove(row["UserEmail"].ToString()); string SendToList = string.Empty; bool separated = false; for (int i = 0; i < SendTo.Count; i++) { if (!separated && !InputListAdmin.Contains(SendTo[i].ToString()) && !InstanceAdminEmails.Contains(SendTo[i].ToString())) { SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString(); separated = true; } else SendToList += ", " + SendTo[i].ToString(); } SendToList = SendToList.Remove(0, 1); if (SendTo.Count > 0) { for (int i = 0; i < SendTo.Count; i++) { StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_Request")); body.Replace("{OrgName}", this.CurrentInstance.Organization.Name); body.Replace("{InstName}", this.CurrentInstance.Name); body.Replace("{ArticleName}", subj); body.Replace("{ArticleUrl}", siteUrl + (UserContext.SelectedInstanceId != Guid.Empty ? "?" : string.Format(CultureInfo.CurrentCulture, "?i={0}&", this.InstanceGuid.ToString("N"))) + string.Format(CultureInfo.CurrentCulture, "t={0}", newId.ToString("N"))); body.Replace("{ArticleText}", HttpUtility.HtmlEncode(postComment)); body.Replace("{AuthorName}", postName); body.Replace("{AuthorEmail}", string.IsNullOrEmpty(postEmail) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", postEmail)); body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl); if (InputListAdmin.Contains(SendTo[i]) || InstanceAdminEmails.Contains(SendTo[i])) body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList); else body.Replace("{SendToList}", string.Empty); if (body.Length > 0) { string encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 1, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256); string url = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted); body.Replace("{UnsubscribeFromArticleUrl}", url); encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 2, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256); url = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted); body.Replace("{UnsubscribeFromAllUrl}", url); Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), string.Format((string)this.GetLocalResourceObject("EmailSubjectRequest"), subj), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true); } } } } } } else { // post to article MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(this.ArticleGuid, postName, postEmail, string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress), HttpUtility.HtmlEncode(Utils.ShortCommentText(postComment, 50)), HttpUtility.HtmlEncode(postComment), false, true, dtNow, true); if (commentDataTable != null && commentDataTable.Rows.Count > 0) { ArrayList SendTo = new ArrayList(); SendTo.AddRange(this.InputListAdmin); SendTo.AddRange(InstanceAdminEmails); MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter(); foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows) { if (!SendTo.Contains(row["UserEmail"].ToString())) SendTo.Add(row["UserEmail"].ToString()); } foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(ArticleGuid, this.InstanceGuid).Rows) SendTo.Remove(row["UserEmail"].ToString()); string SendToList = string.Empty; bool separated = false; for (int i = 0; i < SendTo.Count; i++) { if (!separated && !InputListAdmin.Contains(SendTo[i].ToString()) && !InstanceAdminEmails.Contains(SendTo[i].ToString())) { SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString(); separated = true; } else SendToList += ", " + SendTo[i].ToString(); } SendToList = SendToList.Remove(0, 1); if (SendTo.Count > 0) { if (!articleRow.IsUpdatedByNull()) { string subj = String.Empty; subj = string.Format((string)this.GetLocalResourceObject("EmailSubjectComment"), articleRow.Subject); for (int i = 0; i < SendTo.Count; i++) { StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_PostToArticle")); body.Replace("{OrgName}", this.CurrentInstance.Organization.Name); body.Replace("{InstName}", this.CurrentInstance.Name); body.Replace("{ArticleName}", articleRow.Subject); body.Replace("{ArticleUrl}", siteUrl + (UserContext.SelectedInstanceId != Guid.Empty ? "?" : string.Format(CultureInfo.CurrentCulture, "?i={0}&", this.InstanceGuid.ToString("N"))) + string.Format(CultureInfo.CurrentCulture, "t={0}", articleRow.ArticleGuid.ToString("N"))); body.Replace("{ArticleText}", HttpUtility.HtmlEncode(postComment)); body.Replace("{AuthorName}", postName); body.Replace("{AuthorEmail}", string.IsNullOrEmpty(postEmail) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", postEmail)); body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl); if (InputListAdmin.Contains(SendTo[i]) || InstanceAdminEmails.Contains(SendTo[i])) body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList); else body.Replace("{SendToList}", string.Empty); if (body.Length > 0) { string encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 1, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256); string url = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted); body.Replace("{UnsubscribeFromArticleUrl}", url); encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 2, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256); url = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted); body.Replace("{UnsubscribeFromAllUrl}", url); Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), subj, body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true); } } } } } } } } } #endregion #region Generate an Article if (articleRow != null) { if (!articleRow.Deleted) { //Response.Redirect(instanceUrl, false); //return; textHeader = textHeader.Replace("{title}", string.Format(CultureInfo.CurrentCulture, "{2}{0} {1}", this.CurrentInstance.Organization.Name, this.CurrentInstance.Name, string.IsNullOrEmpty(articleRow.Subject) ? string.Empty : articleRow.Subject + " - ")); //textHeader = textHeader.Replace("{metakeywords}", articleRow.SearchDesc); textHeader = textHeader.Replace("{metadescription}", articleRow.SearchDesc); textHeader = textHeader.Replace("{canonical}", Canonical); Response.Write(textHeader.ToString()); if (!this.IsPopup) { Response.Write(" <div id=\"header\"><div id=\"breadcrumbs\"><span>" + Environment.NewLine); MainDataSet.ArticleDataTable dtBreadcrumbs = this.ArticleTableAdapter.GetRecursiveAllByArticleGuid(articleRow.ArticleGuid); for (int i = dtBreadcrumbs.Count - 1; i >= 0; i--) { if (dtBreadcrumbs[i].ArticleGuid == articleRow.ArticleGuid) breadcrumbs += string.Format(" > {0}", dtBreadcrumbs[i].Subject); else breadcrumbs += string.Format(" > <a href=\"{1}\">{0}</a>", dtBreadcrumbs[i].Subject, pageUrl + (UserContext.SelectedInstanceId != Guid.Empty ? "?" : "?i=" + this.InstanceGuid.ToString("N") + "&") + "t=" + dtBreadcrumbs[i].ArticleGuid.ToString("N")); } Response.Write(breadcrumbs); Response.Write("</span></div><div id=\"search\">" + Environment.NewLine); Response.Write(string.Format("<form action=\"{0}\" method=\"post\"><input type=\"text\" name=\"search\" size=\"40\" />{1}<input type=\"submit\" value=\"Search\" /></form>{1}", "SearchResult.aspx" + (UserContext.SelectedInstanceId == Guid.Empty ? "?i=" + this.InstanceGuid.ToString("N") : string.Empty), Environment.NewLine)); Response.Write("</div></div>"); } // write a header // write a body Response.Write(" <div id=\"title\">" + Environment.NewLine); Response.Write(string.Format(" <h1>{0}</h1>{1}", articleRow.Subject, Environment.NewLine)); Response.Write(" </div>" + Environment.NewLine); if (articleRow.Type == ArticleType.Request.ToString()) { //Response.Write(" <hr />" + Environment.NewLine); Response.Write(" <div id=\"article\">" + Environment.NewLine); Response.Write((string)this.GetLocalResourceObject("ArticleDoesNotExist")); Response.Write(" </div>" + Environment.NewLine); } else { this.ArticleTableAdapter.IncReview(articleRow.ArticleGuid); string body = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid); if (body.Replace("<p>", string.Empty).Replace("</p>", string.Empty).Trim().Length > 0) { body = body.Replace("<h2>", "<h2><span>"); body = body.Replace("<H2>", "<H2><span>"); body = body.Replace("</h2>", "</span></h2>"); body = body.Replace("</H2>", "</span></H2>"); //Response.Write(" <hr />" + Environment.NewLine); Response.Write(" <div id=\"article\">" + Environment.NewLine); Response.Write(body); Response.Write(" </div>" + Environment.NewLine); } } // write a attachments using (Micajah.FileService.Client.Dal.MetaDataSetTableAdapters.FileTableAdapter taFile = new Micajah.FileService.Client.Dal.MetaDataSetTableAdapters.FileTableAdapter()) { Micajah.FileService.Client.Dal.MetaDataSet.FileDataTable dtFiles = taFile.GetFiles(this.CurrentInstance.OrganizationId, this.CurrentInstance.InstanceId, "Article", articleRow.ArticleGuid.ToString("N"), false); StringBuilder stringAttachments = new StringBuilder(); foreach (Micajah.FileService.Client.Dal.MetaDataSet.FileRow frow in dtFiles) { string ext = Path.GetExtension(frow.Name); string mimeType = Micajah.FileService.Client.MimeType.GetMimeType(ext); if (!Micajah.FileService.Client.MimeType.IsImageType(mimeType) && !Micajah.FileService.Client.MimeType.IsFlash(mimeType)) stringAttachments = stringAttachments.AppendFormat(" <li><a href=\"{1}\">{0}</a></li>", frow.Name, Access.GetFileUrl(frow.FileUniqueId, frow.OrganizationId, frow.DepartmentId)); } if (stringAttachments.Length > 0) { stringAttachments = stringAttachments.Insert(0, " <div id=\"attachments\">" + Environment.NewLine + " <ol>" + Environment.NewLine); stringAttachments = stringAttachments.AppendLine(" </ol>" + Environment.NewLine + " </div>"); //Response.Write(" <hr />" + Environment.NewLine); Response.Write(stringAttachments.ToString()); } } // write a child article list MainDataSet.ArticleDataTable dtList = this.ArticleTableAdapter.GetChildArticles(new Guid?(articleRow.ArticleGuid), 1024); //if (dtList.Count > 0) Response.Write(" <div id=\"related\">" + Environment.NewLine + " <ol>" + Environment.NewLine); foreach (MainDataSet.ArticleRow arow in dtList.OrderBy(x => x.Subject)) { Response.Write(this.GetRelatedString(arow, pageUrl)); } if (articleRow.IsParentArticleGuidNull()) { //this.CurrentInstance.Name Response.Write(string.Format(" <li><a style='color:gray' href=\"{0}\">{1}</a>{2} <span style=\"display:block;\">{3}</span>{2} </li>", pageUrl + (UserContext.SelectedInstanceId == Guid.Empty ? "?i=" + this.InstanceGuid.ToString("N") : string.Empty), "< " + (string)this.GetLocalResourceObject("BackTo") + " " + this.CurrentInstance.Name + " " + (string)this.GetLocalResourceObject("Home"), Environment.NewLine, string.Empty)); //this.CurrentInstance.Description)); } else { dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleRow.ParentArticleGuid); if (dtArticle.Count > 0) { MainDataSet.ArticleRow row = dtArticle[0]; row.Subject = "< " + (string)this.GetLocalResourceObject("BackTo") + " " + row.Subject; Response.Write(this.GetRelatedString(row, pageUrl, true)); } } //if (dtList.Count > 0) Response.Write(" </ol>" + Environment.NewLine + " </div>" + Environment.NewLine); // write a comments using (MainDataSetTableAdapters.CommentTableAdapter taComments = new MainDataSetTableAdapters.CommentTableAdapter()) { MainDataSet.CommentDataTable dtComments = taComments.GetDataByArticleGuid(articleRow.ArticleGuid); if (dtComments.Count > 0) { //Response.Write(" <hr />" + Environment.NewLine); Response.Write(" <div id=\"comments\">" + Environment.NewLine + " <ol>" + Environment.NewLine); foreach (MainDataSet.CommentRow crow in dtComments) { Response.Write(string.Format(" <li><a name=\"{0}\">{1}</a>{2} <span style=\"display:block;\">{3}</span></li>", crow.CommentId.ToString(), crow.UserName, Environment.NewLine, crow.Body.Replace(Environment.NewLine, "<br>"))); } Response.Write(" </ol>" + Environment.NewLine + " </div>" + Environment.NewLine); } } // write a footer string commentaction = "default.aspx?"; if (UserContext.SelectedInstanceId == Guid.Empty) commentaction += "i=" + this.InstanceGuid.ToString("N") + "&"; commentaction += "t=" + articleRow.ArticleGuid.ToString("N"); if (this.InputUserName.Length > 0) commentaction += "&un=" + this.InputUserName; if (this.InputUserEmail.Length > 0) commentaction += "&ue=" + this.InputUserEmail; if (this.InputListAdmin.Length > 0) commentaction += "&la=" + string.Join(";", this.InputListAdmin); textFooter = textFooter.Replace("{username}", this.InputUserName); textFooter = textFooter.Replace("{useremail}", this.InputUserEmail); textFooter = textFooter.Replace("{homeurl}", instanceUrl); if (articleRow != null) textFooter = textFooter.Replace("{editurl}", string.Format("<a href=\"ArticleViewAdmin.aspx?id={0}&mode=edit\">Edit</a>", articleRow.ArticleGuid.ToString())); else textFooter = textFooter.Replace("{editurl}", string.Empty); textFooter = textFooter.Replace("{micajahurl}", loginUrl); textFooter = textFooter.Replace("{currentyear}", DateTime.Now.Year.ToString(CultureInfo.InvariantCulture)); textFooter = textFooter.Replace("{commentaction}", commentaction); //textFooter = textFooter.Replace("{trackingcode}", string.Empty); string trackingcode = string.Empty; Setting trackCode = this.CurrentInstance.Settings.FindByShortName("TrackingCode"); if (trackCode != null && !string.IsNullOrEmpty(trackCode.Value)) trackingcode = trackCode.Value; textFooter = textFooter.Replace("{trackingcode}", trackingcode + (string)this.GetLocalResourceObject("GlobalTrackingCode")); Response.Write(textFooter); return; } } else if (this.AlternateId != string.Empty) { // add new article mode textHeader = textHeader.Replace("{title}", (string)this.GetLocalResourceObject("NewArticle")); textHeader = textHeader.Replace("{metadescription}", string.Empty); // write a header Response.Write(textHeader.ToString()); if (!this.IsPopup) { Response.Write(" <div id=\"header\"><div id=\"breadcrumbs\"><span>" + Environment.NewLine); breadcrumbs += " > " + this.AlternateId; //breadcrumbs += " > " + (string)this.GetLocalResourceObject("NewArticle"); Response.Write(breadcrumbs); Response.Write("</span></div><div id=\"search\">" + Environment.NewLine); Response.Write(string.Format("<form action=\"{0}\" method=\"post\"><input type=\"text\" name=\"search\" size=\"40\" /><input type=\"submit\" value=\"Search\" /></form>{1}", "SearchResult.aspx" + (UserContext.SelectedInstanceId == Guid.Empty ? "?i=" + this.InstanceGuid.ToString("N") : string.Empty), Environment.NewLine)); Response.Write("</div></div>"); } // write a body Response.Write(" <div id=\"title\">" + Environment.NewLine); Response.Write(string.Format(" <H1>{0}</H1>{1}", (string)this.GetLocalResourceObject("ArticleIsNotFoundTitle"), Environment.NewLine)); Response.Write(" </div>" + Environment.NewLine); //Response.Write(" <hr />" + Environment.NewLine); Response.Write(" <div id=\"article\">" + Environment.NewLine); Response.Write(string.Format(" <P>{0}</P>{1}", (string)this.GetLocalResourceObject("ArticleDoesNotExist"), Environment.NewLine)); Response.Write(" </div>" + Environment.NewLine); // = (string)this.GetLocalResourceObject("ArticleDoesNotExist"); // write a footer string commentaction = "default.aspx?"; if (UserContext.SelectedInstanceId == Guid.Empty) commentaction += "i=" + this.InstanceGuid.ToString("N") + "&"; commentaction += "a=" + this.AlternateId; if (this.InputUserName.Length > 0) commentaction += "&un=" + this.InputUserName; if (this.InputUserEmail.Length > 0) commentaction += "&ue=" + this.InputUserEmail; if (this.InputListAdmin.Length > 0) commentaction += "&la=" + string.Join(";", this.InputListAdmin); textFooter = textFooter.Replace("{username}", this.InputUserName); textFooter = textFooter.Replace("{useremail}", this.InputUserEmail); textFooter = textFooter.Replace("{homeurl}", instanceUrl); if (articleRow != null) textFooter = textFooter.Replace("{editurl}", string.Format("<a href=\"ArticleViewAdmin.aspx?id={0}&mode=edit\">Edit</a>", articleRow.ArticleGuid.ToString())); else textFooter = textFooter.Replace("{editurl}", string.Empty); textFooter = textFooter.Replace("{micajahurl}", loginUrl); textFooter = textFooter.Replace("{currentyear}", DateTime.Now.Year.ToString(CultureInfo.InvariantCulture)); textFooter = textFooter.Replace("{commentaction}", commentaction); //textFooter = textFooter.Replace("{trackingcode}", string.Empty); string trackingcode = string.Empty; Setting trackCode = this.CurrentInstance.Settings.FindByShortName("TrackingCode"); if (trackCode != null && !string.IsNullOrEmpty(trackCode.Value)) trackingcode = trackCode.Value; textFooter = textFooter.Replace("{trackingcode}", trackingcode + (string)this.GetLocalResourceObject("GlobalTrackingCode")); Response.Write(textFooter); return; } #endregion #region Generate the Instance Home page StringBuilder textHeaderInst = new StringBuilder((string)this.GetLocalResourceObject("Header_Inst")); StringBuilder textFooterInst = new StringBuilder((string)this.GetLocalResourceObject("Footer_Inst")); textHeaderInst = textHeaderInst.Replace("{title}", orgInstName + " - Home"); textHeaderInst = textHeaderInst.Replace("{metadescription}", "KB Home Page"); textHeaderInst = textHeaderInst.Replace("{searchaction}", "SearchResult.aspx" + (UserContext.SelectedInstanceId == Guid.Empty ? "?i=" + this.InstanceGuid.ToString("N") : string.Empty)); textHeaderInst = textHeaderInst.Replace("{orgInstName}", orgInstName); textHeaderInst = textHeaderInst.Replace("{orgUrl}", instanceUrl); textHeaderInst = textHeaderInst.Replace("{canonical}", Canonical); //textHeaderInst = textHeaderInst.Replace("{orgUrl}", this.CurrentInstance.Organization.WebsiteUrl); Response.Write(textHeaderInst.ToString()); string listTreeView = string.Empty; MainDataSet.ArticleDataTable articleTable = this.ArticleTableAdapter.GetRecursiveByDepartmentGuid(this.InstanceGuid); this.SortRecursiveTable(ref listTreeView, ref articleTable, null, pageUrl); Response.Write(listTreeView); textFooterInst = textFooterInst.Replace("{micajahurl}", loginUrl); textFooterInst = textFooterInst.Replace("{currentyear}", DateTime.Now.Year.ToString(CultureInfo.InvariantCulture)); //textFooterInst = textFooterInst.Replace("{trackingcode}", string.Empty); string trackingcode2 = string.Empty; Setting trackCode2 = this.CurrentInstance.Settings.FindByShortName("TrackingCode"); if (trackCode2 != null && !string.IsNullOrEmpty(trackCode2.Value)) trackingcode2 = trackCode2.Value; textFooterInst = textFooterInst.Replace("{trackingcode}", trackingcode2 + (string)this.GetLocalResourceObject("GlobalTrackingCode")); Response.Write(textFooterInst); #endregion } else if (UserContext.SelectedOrganizationId != Guid.Empty && UserContext.SelectedInstanceId == Guid.Empty) { Response.Redirect("OrganizationHome.aspx", false); return; } else Response.Redirect(loginUrl, false); } }
private void DoArticleEdit(MainDataSet.ArticleRow articleRow) { ShowArticleEdit(); TreeViewParentArticle.Nodes.Clear(); TreeViewParentArticle.Nodes.Add(new Telerik.Web.UI.RadTreeNode(" ", string.Empty)); TreeViewParentArticle.DataBind(); CustomLinksDataBind(UserContext.Current.SelectedInstance.InstanceId); if (articleRow != null) { HtmlEditorBody.ImageManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.ImageManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.ImageDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.MediaManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.MediaManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.VideoDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.FlashManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.FlashManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.FlashDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.DocumentManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") }; HtmlEditorBody.DocumentManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.FileDBContentProvider).AssemblyQualifiedName; HtmlEditorBody.Content = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid); ImageAdminListCtrl.ArticleGuid = articleRow.ArticleGuid; FileAdminListCtrl.ArticleGuid = articleRow.ArticleGuid; ImageAdminListCtrl.DataBind(); FileAdminListCtrl.DataBind(); Master.CustomName = articleRow.Subject; TextBoxSubject.Text = articleRow.Subject; SearchDescriptionTextBox.Text = articleRow.SearchDesc; if (!articleRow.IsParentArticleGuidNull()) { Telerik.Web.UI.RadTreeNode node = TreeViewParentArticle.FindNodeByValue(articleRow.ParentArticleGuid.ToString()); if (node != null) { node.Selected = true; node.ExpandParentNodes(); } } if (articleRow.Type == ArticleType.Request.ToString()) TextBoxAlternateIds.Text = articleRow.Subject; else { using (MainDataSetTableAdapters.AlternateIdTableAdapter altAdapter = new MainDataSetTableAdapters.AlternateIdTableAdapter()) { TextBoxAlternateIds.Text = string.Empty; MainDataSet.AlternateIdDataTable dtAlt = altAdapter.GetDataByArticleGuid(articleRow.ArticleGuid); foreach (MainDataSet.AlternateIdRow row in dtAlt) TextBoxAlternateIds.Text += row.AlternateId + Environment.NewLine; } } } else { Master.CustomName = (string)this.GetLocalResourceObject("AddNewArticle"); } }
protected void ButtonUpload_Click(object sender, EventArgs e) { using (MainDataSetTableAdapters.AlternateIdTableAdapter altAdapter = new MainDataSetTableAdapters.AlternateIdTableAdapter()) { articleGuid = this.ArticleGuid; foreach (string str in TextBoxAlternateIds.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if ((int)altAdapter.CheckAlternateId(UserContext.Current.SelectedInstance.InstanceId, articleGuid, str) == 1) { Master.ErrorMessage = string.Format((string)this.GetLocalResourceObject("ErrorMsg_AlternateId"), str); return; } } //string htmlBody = HtmlEditorBody.Content; if (!HtmlEditorBody.Content.EndsWith("<p></p>\r\n") && !HtmlEditorBody.Content.EndsWith("<p>nbsp;</p>\r\n") && !HtmlEditorBody.Content.EndsWith("<p> </p>\r\n") && !HtmlEditorBody.Content.EndsWith("<p></p>") && !HtmlEditorBody.Content.EndsWith("<p> </p>") && !HtmlEditorBody.Content.EndsWith("<p>nbsp;</p>")) HtmlEditorBody.Content += "<p></p>\r\n"; if (articleGuid.Equals(Guid.Empty)) { articleGuid = Guid.NewGuid(); this.ArticleTableAdapter.Insert( articleGuid, UserContext.Current.SelectedInstance.InstanceId, ((this.ParntArticleGuid != Guid.Empty) ? this.ParntArticleGuid : new Guid?()), ArticleType.Article.ToString(), TextBoxSubject.Text, HtmlEditorBody.Content, SearchDescriptionTextBox.Text, 0, 0, 0, false, new DateTime?(DateTime.Now), new DateTime?(), new DateTime?(), new Guid?(UserContext.Current.UserId), new Guid?(), new Guid?()); if (!articleGuid.Equals(Guid.Empty)) { DoUploadFile(articleGuid); if (this.ArticleGuid.Equals(Guid.Empty)) Response.Redirect("~/ArticleViewAdmin.aspx?mode=edit&id=" + articleGuid.ToString("N"), false); } } else { MainDataSet.ArticleRow articleRow = this.GetCurrentArticle(); string oldType = articleRow.Type; articleRow.Type = ArticleType.Article.ToString(); articleRow.Body = HtmlEditorBody.Content;//HttpUtility.HtmlEncode(htmlBody); articleRow.Subject = TextBoxSubject.Text; articleRow.SearchDesc = SearchDescriptionTextBox.Text; if (this.ParntArticleGuid != Guid.Empty) articleRow.ParentArticleGuid = this.ParntArticleGuid; else articleRow.SetParentArticleGuidNull(); articleRow.UpdatedBy = UserContext.Current.UserId; articleRow.UpdatedTime = DateTime.Now; this.ArticleTableAdapter.Update(articleRow); if (oldType == ArticleType.Request.ToString()) { string siteUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath)) + Request.ApplicationPath + "/"; Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers( UserContext.Current.SelectedOrganization.OrganizationId, UserContext.Current.SelectedInstance.InstanceId, new string[] { "InstAdmin" }); ArrayList admins = new ArrayList(); ArrayList SendTo = new ArrayList(); foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users) admins.Add(row.Email); SendTo.AddRange(admins); MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter(); foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows) { if (!SendTo.Contains(row["UserEmail"].ToString())) SendTo.Add(row["UserEmail"].ToString()); } foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(articleRow.ArticleGuid, UserContext.Current.SelectedInstance.InstanceId).Rows) SendTo.Remove(row["UserEmail"].ToString()); string SendToList = string.Empty; bool separated = false; for (int i = 0; i < SendTo.Count; i++) { if (!separated && !admins.Contains(SendTo[i].ToString())) { SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString(); separated = true; } else SendToList += ", " + SendTo[i].ToString(); } SendToList = SendToList.Remove(0,1); if (SendTo.Count > 0) { for (int i = 0; i < SendTo.Count; i++) { StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_ArticleCreated")); body.Replace("{OrgName}", UserContext.Current.SelectedOrganization.Name); body.Replace("{InstName}", UserContext.Current.SelectedInstance.Name); body.Replace("{ArticleName}", articleRow.Subject); body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", articleRow.DepartmentGuid.ToString("N"), articleRow.ArticleGuid.ToString("N"))); body.Replace("{ArticleText}", HtmlEditorBody.Content); body.Replace("{AuthorName}", UserContext.Current.FirstName + " " + UserContext.Current.LastName); body.Replace("{AuthorEmail}", string.IsNullOrEmpty(UserContext.Current.Email) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", UserContext.Current.Email)); body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl); if (admins.Contains(SendTo[i])) body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList); else body.Replace("{SendToList}", string.Empty); Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), new string[] { }, string.Format((string)this.GetLocalResourceObject("EmailSubjectNewArticle"), articleRow.Subject), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true); } } } altAdapter.DeleteByArticleGuid(articleGuid); foreach (string str in TextBoxAlternateIds.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) altAdapter.InsertAlt(UserContext.Current.SelectedInstance.InstanceId, articleGuid, str); if (!articleGuid.Equals(Guid.Empty)) { DoUploadFile(articleGuid); if (this.ArticleGuid.Equals(Guid.Empty)) Response.Redirect("~/ArticleViewAdmin.aspx?mode=edit&id=" + articleGuid.ToString("N"), false); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (IsPopup) { Master.VisibleBreadcrumbs = false; Master.VisibleHeader = false; Master.VisibleHelpLink = false; Master.VisibleFooter = false; //divBody.Visible = false; PostCommentCtrl.VisibleLine = false; } Master.AutoGenerateBreadcrumbs = false; //Master.VisiblePageTitle = false; UserContext.Breadcrumbs.Clear(); MainDataSet.ArticleDataTable dtArticle = null; if (UserContext.Current != null && UserContext.Current.SelectedInstance != null && this.ArticleGuid != Guid.Empty && !IsPopup) { Response.Redirect("ArticleViewAdmin.aspx?id=" + this.ArticleGuid.ToString("N"), false); return; } if (this.Master.InstanceGuid != Guid.Empty) { string instName = (string)this.ArticleTableAdapter.GetInstanceName(this.Master.InstanceGuid); if (!string.IsNullOrEmpty(instName)) { //UploadControlSettings.DepartmentName = instName; //UploadControlSettings.DepartmentId = this.Master.InstanceGuid; //MainDataSetTableAdapters.Mc_InstanceTableAdapter instance = new MainDataSetTableAdapters.Mc_InstanceTableAdapter(); //UploadControlSettings.OrganizationId = instance.GetDataByInstanceId(this.Master.InstanceGuid)[0].OrganizationId; if (!IsPopup) UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("Home"), "~/InstanceHome.aspx?i=" + this.Master.InstanceGuid.ToString("N"), string.Empty, false); //SearchArticleCtrl.InstanceGuid = this.InstanceGuid; if (this.ArticleGuid != Guid.Empty) { //if (UserContext.Current != null) //{ // Response.Redirect("ArticleViewAdmin.aspx?id=" + this.ArticleGuid.ToString("N"), true); // return; //} // view mode dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(this.ArticleGuid); if (dtArticle.Count > 0) { this.DoArticleView(dtArticle[0]); AttachmentListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //ImageListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //FileListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //VideoListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; return; } } else if (this.AlternateId != string.Empty) { // view mode string strAltId = this.AlternateId; MainDataSetTableAdapters.AlternateIdTableAdapter taAlternateId = new MainDataSetTableAdapters.AlternateIdTableAdapter(); Guid? articleGuid = null; articleGuid = taAlternateId.GetArticleGuid(strAltId, this.Master.InstanceGuid); int idx = 0; //if (!articleGuid.HasValue) //{ // idx = strAltId.LastIndexOf('?'); // if (idx > 0) // { // strAltId = strAltId.Substring(0, idx); // articleGuid = taAlternateId.GetArticleGuid(strAltId, this.Master.InstanceGuid); // } //} if (!articleGuid.HasValue) { idx = strAltId.LastIndexOf('/'); if (idx > 0) { strAltId = strAltId.Substring(0, idx + 1); articleGuid = taAlternateId.GetArticleGuid(strAltId, this.Master.InstanceGuid); } } if (articleGuid.HasValue) { dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid.Value); if (dtArticle.Count > 0) { AttachmentListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //ImageListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //FileListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //VideoListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; this.DoArticleView(dtArticle[0]); return; } } else { // add new article mode if (!IsPopup) { UserContext.Breadcrumbs.Add(this.AlternateId, string.Empty, string.Empty, false); divBody.InnerHtml = (string)this.GetLocalResourceObject("ArticleDoesNotExist"); } PanelArticle.Visible = true; Master.CustomName = (string)this.GetLocalResourceObject("NewArticle"); litSubject.Text = (string)this.GetLocalResourceObject("ArticleIsNotFoundTitle"); ArticlesListCtrl.Visible = false; CommentsListCtrl.Visible = false; //PostCommentCtrl.ReceiverName = Utils.GetInstanceUserName(this.Master.InstanceGuid); PostCommentCtrl.InstanceGuid = this.Master.InstanceGuid; PostCommentCtrl.ArticleGuid = Guid.Empty; return; } } else { Response.Redirect("InstanceHome.aspx?i=" + this.Master.InstanceGuid.ToString("N"), false); return; } } } PanelArticle.Visible = false; Response.Redirect(Micajah.Common.Application.WebApplication.LoginProvider.GetLoginUrl(), false); //Master.ErrorMessage = (string)this.GetLocalResourceObject("ArticleIsNotFound"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (IsPopup) { Master.VisibleBreadcrumbs = false; Master.VisibleHeader = false; Master.VisibleHelpLink = false; Master.VisibleFooter = false; //divBody.Visible = false; PostCommentCtrl.VisibleLine = false; } Master.AutoGenerateBreadcrumbs = false; //Master.VisiblePageTitle = false; UserContext.Breadcrumbs.Clear(); MainDataSet.ArticleDataTable dtArticle = null; if (UserContext.Current != null && UserContext.Current.SelectedInstance != null && this.ArticleGuid != Guid.Empty && !IsPopup) { Response.Redirect("ArticleViewAdmin.aspx?id=" + this.ArticleGuid.ToString("N"), false); return; } if (this.Master.InstanceGuid != Guid.Empty) { string instName = (string)this.ArticleTableAdapter.GetInstanceName(this.Master.InstanceGuid); if (!string.IsNullOrEmpty(instName)) { //UploadControlSettings.DepartmentName = instName; //UploadControlSettings.DepartmentId = this.Master.InstanceGuid; //MainDataSetTableAdapters.Mc_InstanceTableAdapter instance = new MainDataSetTableAdapters.Mc_InstanceTableAdapter(); //UploadControlSettings.OrganizationId = instance.GetDataByInstanceId(this.Master.InstanceGuid)[0].OrganizationId; if (!IsPopup) { UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("Home"), "~/InstanceHome.aspx?i=" + this.Master.InstanceGuid.ToString("N"), string.Empty, false); } //SearchArticleCtrl.InstanceGuid = this.InstanceGuid; if (this.ArticleGuid != Guid.Empty) { //if (UserContext.Current != null) //{ // Response.Redirect("ArticleViewAdmin.aspx?id=" + this.ArticleGuid.ToString("N"), true); // return; //} // view mode dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(this.ArticleGuid); if (dtArticle.Count > 0) { this.DoArticleView(dtArticle[0]); AttachmentListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //ImageListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //FileListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //VideoListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; return; } } else if (this.AlternateId != string.Empty) { // view mode string strAltId = this.AlternateId; MainDataSetTableAdapters.AlternateIdTableAdapter taAlternateId = new MainDataSetTableAdapters.AlternateIdTableAdapter(); Guid?articleGuid = null; articleGuid = taAlternateId.GetArticleGuid(strAltId, this.Master.InstanceGuid); int idx = 0; //if (!articleGuid.HasValue) //{ // idx = strAltId.LastIndexOf('?'); // if (idx > 0) // { // strAltId = strAltId.Substring(0, idx); // articleGuid = taAlternateId.GetArticleGuid(strAltId, this.Master.InstanceGuid); // } //} if (!articleGuid.HasValue) { idx = strAltId.LastIndexOf('/'); if (idx > 0) { strAltId = strAltId.Substring(0, idx + 1); articleGuid = taAlternateId.GetArticleGuid(strAltId, this.Master.InstanceGuid); } } if (articleGuid.HasValue) { dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid.Value); if (dtArticle.Count > 0) { AttachmentListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //ImageListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //FileListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; //VideoListCtrl.ArticleGuid = dtArticle[0].ArticleGuid; this.DoArticleView(dtArticle[0]); return; } } else { // add new article mode if (!IsPopup) { UserContext.Breadcrumbs.Add(this.AlternateId, string.Empty, string.Empty, false); divBody.InnerHtml = (string)this.GetLocalResourceObject("ArticleDoesNotExist"); } PanelArticle.Visible = true; Master.CustomName = (string)this.GetLocalResourceObject("NewArticle"); litSubject.Text = (string)this.GetLocalResourceObject("ArticleIsNotFoundTitle"); ArticlesListCtrl.Visible = false; CommentsListCtrl.Visible = false; //PostCommentCtrl.ReceiverName = Utils.GetInstanceUserName(this.Master.InstanceGuid); PostCommentCtrl.InstanceGuid = this.Master.InstanceGuid; PostCommentCtrl.ArticleGuid = Guid.Empty; return; } } else { Response.Redirect("InstanceHome.aspx?i=" + this.Master.InstanceGuid.ToString("N"), false); return; } } } PanelArticle.Visible = false; Response.Redirect(Micajah.Common.Application.WebApplication.LoginProvider.GetLoginUrl(), false); //Master.ErrorMessage = (string)this.GetLocalResourceObject("ArticleIsNotFound"); } }
protected void ButtonUpload_Click(object sender, EventArgs e) { using (MainDataSetTableAdapters.AlternateIdTableAdapter altAdapter = new MainDataSetTableAdapters.AlternateIdTableAdapter()) { articleGuid = this.ArticleGuid; foreach (string str in TextBoxAlternateIds.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if ((int)altAdapter.CheckAlternateId(UserContext.Current.SelectedInstance.InstanceId, articleGuid, str) == 1) { Master.ErrorMessage = string.Format((string)this.GetLocalResourceObject("ErrorMsg_AlternateId"), str); return; } } //string htmlBody = HtmlEditorBody.Content; if (!HtmlEditorBody.Content.EndsWith("<p></p>\r\n") && !HtmlEditorBody.Content.EndsWith("<p>nbsp;</p>\r\n") && !HtmlEditorBody.Content.EndsWith("<p> </p>\r\n") && !HtmlEditorBody.Content.EndsWith("<p></p>") && !HtmlEditorBody.Content.EndsWith("<p> </p>") && !HtmlEditorBody.Content.EndsWith("<p>nbsp;</p>")) { HtmlEditorBody.Content += "<p></p>\r\n"; } if (articleGuid.Equals(Guid.Empty)) { articleGuid = Guid.NewGuid(); this.ArticleTableAdapter.Insert( articleGuid, UserContext.Current.SelectedInstance.InstanceId, ((this.ParntArticleGuid != Guid.Empty) ? this.ParntArticleGuid : new Guid?()), ArticleType.Article.ToString(), TextBoxSubject.Text, HtmlEditorBody.Content, SearchDescriptionTextBox.Text, 0, 0, 0, false, new DateTime?(DateTime.Now), new DateTime?(), new DateTime?(), new Guid?(UserContext.Current.UserId), new Guid?(), new Guid?()); if (!articleGuid.Equals(Guid.Empty)) { DoUploadFile(articleGuid); if (this.ArticleGuid.Equals(Guid.Empty)) { Response.Redirect("~/ArticleViewAdmin.aspx?mode=edit&id=" + articleGuid.ToString("N"), false); } } } else { MainDataSet.ArticleRow articleRow = this.GetCurrentArticle(); string oldType = articleRow.Type; articleRow.Type = ArticleType.Article.ToString(); articleRow.Body = HtmlEditorBody.Content;//HttpUtility.HtmlEncode(htmlBody); articleRow.Subject = TextBoxSubject.Text; articleRow.SearchDesc = SearchDescriptionTextBox.Text; if (this.ParntArticleGuid != Guid.Empty) { articleRow.ParentArticleGuid = this.ParntArticleGuid; } else { articleRow.SetParentArticleGuidNull(); } articleRow.UpdatedBy = UserContext.Current.UserId; articleRow.UpdatedTime = DateTime.Now; this.ArticleTableAdapter.Update(articleRow); if (oldType == ArticleType.Request.ToString()) { string siteUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath)) + Request.ApplicationPath + "/"; Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers( UserContext.Current.SelectedOrganization.OrganizationId, UserContext.Current.SelectedInstance.InstanceId, new string[] { "InstAdmin" }); ArrayList admins = new ArrayList(); ArrayList SendTo = new ArrayList(); foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users) { admins.Add(row.Email); } SendTo.AddRange(admins); MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter(); foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows) { if (!SendTo.Contains(row["UserEmail"].ToString())) { SendTo.Add(row["UserEmail"].ToString()); } } foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(articleRow.ArticleGuid, UserContext.Current.SelectedInstance.InstanceId).Rows) { SendTo.Remove(row["UserEmail"].ToString()); } string SendToList = string.Empty; bool separated = false; for (int i = 0; i < SendTo.Count; i++) { if (!separated && !admins.Contains(SendTo[i].ToString())) { SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString(); separated = true; } else { SendToList += ", " + SendTo[i].ToString(); } } SendToList = SendToList.Remove(0, 1); if (SendTo.Count > 0) { for (int i = 0; i < SendTo.Count; i++) { StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_ArticleCreated")); body.Replace("{OrgName}", UserContext.Current.SelectedOrganization.Name); body.Replace("{InstName}", UserContext.Current.SelectedInstance.Name); body.Replace("{ArticleName}", articleRow.Subject); body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", articleRow.DepartmentGuid.ToString("N"), articleRow.ArticleGuid.ToString("N"))); body.Replace("{ArticleText}", HtmlEditorBody.Content); body.Replace("{AuthorName}", UserContext.Current.FirstName + " " + UserContext.Current.LastName); body.Replace("{AuthorEmail}", string.IsNullOrEmpty(UserContext.Current.Email) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", UserContext.Current.Email)); body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl); if (admins.Contains(SendTo[i])) { body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList); } else { body.Replace("{SendToList}", string.Empty); } Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), new string[] { }, string.Format((string)this.GetLocalResourceObject("EmailSubjectNewArticle"), articleRow.Subject), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true); } } } altAdapter.DeleteByArticleGuid(articleGuid); foreach (string str in TextBoxAlternateIds.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { altAdapter.InsertAlt(UserContext.Current.SelectedInstance.InstanceId, articleGuid, str); } if (!articleGuid.Equals(Guid.Empty)) { DoUploadFile(articleGuid); if (this.ArticleGuid.Equals(Guid.Empty)) { Response.Redirect("~/ArticleViewAdmin.aspx?mode=edit&id=" + articleGuid.ToString("N"), false); } } } } }