コード例 #1
0
 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();
     }
 }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
ファイル: Default2.aspx.cs プロジェクト: bigWebApps/KB-Old
 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();
     }
 }
コード例 #4
0
        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);
                        }
                    }
                }
            }
        }