예제 #1
0
 public static string GetInstanceName(Guid instanceGuid)
 {
     MainDataSetTableAdapters.Mc_InstanceTableAdapter taDepartment = new MainDataSetTableAdapters.Mc_InstanceTableAdapter();
     MainDataSet.Mc_InstanceDataTable departmentTable = taDepartment.GetDataByInstanceId(instanceGuid);
     if (departmentTable != null && departmentTable.Rows.Count > 0)
     {
         return(((MainDataSet.Mc_InstanceRow)departmentTable.Rows[0]).Name);
     }
     else
     {
         return(string.Empty);
     }
 }
예제 #2
0
        public static string GetInstanceUserName(Guid instanceGuid)
        {
            string userName = string.Empty;

            MainDataSetTableAdapters.Mc_InstanceTableAdapter taDepartment = new MainDataSetTableAdapters.Mc_InstanceTableAdapter();
            object obj = taDepartment.GetDepartmentAdministrator(instanceGuid);

            if (obj != null)
            {
                userName = (string)obj;
            }
            else
            {
                obj = taDepartment.GetOrganizationAdministrator(instanceGuid);
                if (obj != null)
                {
                    userName = (string)obj;
                }
            }
            return(userName);
        }
예제 #3
0
        protected void ButtonPostComment_Click(object sender, EventArgs e)
        {
            // check the Honeypot
            if (TextBoxPhone.Text == string.Empty && this.InstanceGuid != Guid.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 + "/";
                using (MainDataSetTableAdapters.CommentTableAdapter taComment = new MainDataSetTableAdapters.CommentTableAdapter())
                {
                    Organization currOrganization = null;
                    MainDataSet.Mc_InstanceRow currInstance = null;
                    using (MainDataSetTableAdapters.Mc_InstanceTableAdapter taInstance = new MainDataSetTableAdapters.Mc_InstanceTableAdapter())
                    {
                        MainDataSet.Mc_InstanceDataTable instances = taInstance.GetDataByInstanceId(this.InstanceGuid);
                        if (instances.Count > 0)
                        {
                            currInstance = instances[0];
                            currOrganization = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganization(currInstance.OrganizationId);
                        }
                    }
                    DateTime dtNow = DateTime.Now;
                    if (this.ArticleGuid == Guid.Empty)
                    {
                        // create a reqest
                        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(TextBoxComment.Text, 50)),
                            (string)this.GetLocalResourceObject("BodyNotArticle"),
                            string.Empty,
                            0,
                            0,
                            0,
                            false,
                            new DateTime?(),
                            new DateTime?(),
                            new DateTime?(),
                            new Guid?(),
                            new Guid?(),
                            new Guid?()) > 0)
                        {
                            MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(newId,
                                TextBoxName.Text,
                                TextBoxEmail.Text,
                                string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress),
                                HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                                HttpUtility.HtmlEncode(TextBoxComment.Text),
                                false,
                                true,
                                DateTime.Now, true);
                            if (commentDataTable != null && commentDataTable.Rows.Count > 0)
                            {
                                if (CommentPosted != null) CommentPosted(this, new ArticleEventArgs(newId, true));
                                if (currOrganization != null && currInstance != null)
                                {
                                    string subj;
                                    Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                                        currOrganization.OrganizationId,
                                        this.InstanceGuid,
                                        new string[] { "InstAdmin" });

                                    ArrayList admins = new ArrayList();
                                    ArrayList SendTo = new ArrayList();

                                    admins.AddRange(this.InputListAdmin);

                                    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(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 && !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++)
                                        {
                                            subj = (this.AlternateId != string.Empty) ? this.AlternateId : HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50));
                                            StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_Request"));
                                            body.Replace("{OrgName}", currOrganization.Name);
                                            body.Replace("{InstName}", currInstance.Name);
                                            body.Replace("{ArticleName}", subj);
                                            body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", this.InstanceGuid.ToString("N"), newId.ToString("N")));
                                            body.Replace("{ArticleText}", HttpUtility.HtmlEncode(TextBoxComment.Text));
                                            body.Replace("{AuthorName}", TextBoxName.Text);
                                            body.Replace("{AuthorEmail}", string.IsNullOrEmpty(TextBoxEmail.Text) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", TextBoxEmail.Text));
                                            body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                                            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);
                                                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(), string.Format((string)this.GetLocalResourceObject("EmailSubjectRequest"), subj), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true);
                                            }
                                        }
                                    }
                                }
                                ResetData();
                            }
                        }
                    }
                    else
                    {
                        // post to article
                        MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(this.ArticleGuid,
                            TextBoxName.Text,
                            TextBoxEmail.Text,
                            string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress),
                            HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                            HttpUtility.HtmlEncode(TextBoxComment.Text),
                            false,
                            true,
                            dtNow, true);
                        if (commentDataTable != null && commentDataTable.Rows.Count > 0)
                        {
                            if (CommentPosted != null) CommentPosted(this, new ArticleEventArgs(this.ArticleGuid, false));
                            MainDataSet.ArticleRow articleRow = this.GetCurrentArticle();
                            if (currOrganization != null && articleRow != null && !articleRow.IsUpdatedByNull() && currInstance != null)
                            {
                                string author = string.Empty, subj;
                                subj = string.Format((string)this.GetLocalResourceObject("EmailSubjectComment"), articleRow.Subject);

                                System.Data.DataRow mcuser = Micajah.Common.Bll.Providers.UserProvider.GetUserRow(articleRow.UpdatedBy, currOrganization.OrganizationId);
                                if (mcuser != null)
                                    author = (string)mcuser["Email"];

                                Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                                        currOrganization.OrganizationId,
                                        this.InstanceGuid,
                                        new string[] { "InstAdmin" });

                                ArrayList admins = new ArrayList();
                                ArrayList SendTo = new ArrayList();

                                admins.AddRange(this.InputListAdmin);
                                foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users)
                                    admins.Add(row.Email);
                                SendTo.AddRange(admins);

                                if (!string.IsNullOrEmpty(author) && !SendTo.Contains(author))
                                    SendTo.Add(author);

                                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 && !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_PostToArticle"));
                                        body.Replace("{OrgName}", currOrganization.Name);
                                        body.Replace("{InstName}", currInstance.Name);
                                        body.Replace("{ArticleName}", articleRow.Subject);
                                        body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", this.InstanceGuid.ToString("N"), this.ArticleGuid.ToString("N")));
                                        body.Replace("{ArticleText}", HttpUtility.HtmlEncode(TextBoxComment.Text));
                                        body.Replace("{AuthorName}", TextBoxName.Text);
                                        body.Replace("{AuthorEmail}", string.IsNullOrEmpty(TextBoxEmail.Text) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", TextBoxEmail.Text));
                                        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);

                                        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);
                                        }
                                    }
                                }
                            }
                            ResetData();
                        }
                    }
                }
            }
        }
예제 #4
0
        protected void ButtonPostComment_Click(object sender, EventArgs e)
        {
            // check the Honeypot
            if (TextBoxPhone.Text == string.Empty && this.InstanceGuid != Guid.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 + "/";
                using (MainDataSetTableAdapters.CommentTableAdapter taComment = new MainDataSetTableAdapters.CommentTableAdapter())
                {
                    Organization currOrganization           = null;
                    MainDataSet.Mc_InstanceRow currInstance = null;
                    using (MainDataSetTableAdapters.Mc_InstanceTableAdapter taInstance = new MainDataSetTableAdapters.Mc_InstanceTableAdapter())
                    {
                        MainDataSet.Mc_InstanceDataTable instances = taInstance.GetDataByInstanceId(this.InstanceGuid);
                        if (instances.Count > 0)
                        {
                            currInstance     = instances[0];
                            currOrganization = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganization(currInstance.OrganizationId);
                        }
                    }
                    DateTime dtNow = DateTime.Now;
                    if (this.ArticleGuid == Guid.Empty)
                    {
                        // create a reqest
                        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(TextBoxComment.Text, 50)),
                                                            (string)this.GetLocalResourceObject("BodyNotArticle"),
                                                            string.Empty,
                                                            0,
                                                            0,
                                                            0,
                                                            false,
                                                            new DateTime?(),
                                                            new DateTime?(),
                                                            new DateTime?(),
                                                            new Guid?(),
                                                            new Guid?(),
                                                            new Guid?()) > 0)
                        {
                            MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(newId,
                                                                                                    TextBoxName.Text,
                                                                                                    TextBoxEmail.Text,
                                                                                                    string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress),
                                                                                                    HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                                                                                                    HttpUtility.HtmlEncode(TextBoxComment.Text),
                                                                                                    false,
                                                                                                    true,
                                                                                                    DateTime.Now, true);
                            if (commentDataTable != null && commentDataTable.Rows.Count > 0)
                            {
                                if (CommentPosted != null)
                                {
                                    CommentPosted(this, new ArticleEventArgs(newId, true));
                                }
                                if (currOrganization != null && currInstance != null)
                                {
                                    string subj;
                                    Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                                        currOrganization.OrganizationId,
                                        this.InstanceGuid,
                                        new string[] { "InstAdmin" });

                                    ArrayList admins = new ArrayList();
                                    ArrayList SendTo = new ArrayList();

                                    admins.AddRange(this.InputListAdmin);

                                    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(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 && !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++)
                                        {
                                            subj = (this.AlternateId != string.Empty) ? this.AlternateId : HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50));
                                            StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_Request"));
                                            body.Replace("{OrgName}", currOrganization.Name);
                                            body.Replace("{InstName}", currInstance.Name);
                                            body.Replace("{ArticleName}", subj);
                                            body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", this.InstanceGuid.ToString("N"), newId.ToString("N")));
                                            body.Replace("{ArticleText}", HttpUtility.HtmlEncode(TextBoxComment.Text));
                                            body.Replace("{AuthorName}", TextBoxName.Text);
                                            body.Replace("{AuthorEmail}", string.IsNullOrEmpty(TextBoxEmail.Text) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", TextBoxEmail.Text));
                                            body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                                            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);
                                                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(), string.Format((string)this.GetLocalResourceObject("EmailSubjectRequest"), subj), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true);
                                            }
                                        }
                                    }
                                }
                                ResetData();
                            }
                        }
                    }
                    else
                    {
                        // post to article
                        MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(this.ArticleGuid,
                                                                                                TextBoxName.Text,
                                                                                                TextBoxEmail.Text,
                                                                                                string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress),
                                                                                                HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                                                                                                HttpUtility.HtmlEncode(TextBoxComment.Text),
                                                                                                false,
                                                                                                true,
                                                                                                dtNow, true);
                        if (commentDataTable != null && commentDataTable.Rows.Count > 0)
                        {
                            if (CommentPosted != null)
                            {
                                CommentPosted(this, new ArticleEventArgs(this.ArticleGuid, false));
                            }
                            MainDataSet.ArticleRow articleRow = this.GetCurrentArticle();
                            if (currOrganization != null && articleRow != null && !articleRow.IsUpdatedByNull() && currInstance != null)
                            {
                                string author = string.Empty, subj;
                                subj = string.Format((string)this.GetLocalResourceObject("EmailSubjectComment"), articleRow.Subject);

                                System.Data.DataRow mcuser = Micajah.Common.Bll.Providers.UserProvider.GetUserRow(articleRow.UpdatedBy, currOrganization.OrganizationId);
                                if (mcuser != null)
                                {
                                    author = (string)mcuser["Email"];
                                }

                                Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                                    currOrganization.OrganizationId,
                                    this.InstanceGuid,
                                    new string[] { "InstAdmin" });

                                ArrayList admins           = new ArrayList();
                                ArrayList SendTo           = new ArrayList();

                                admins.AddRange(this.InputListAdmin);
                                foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users)
                                {
                                    admins.Add(row.Email);
                                }
                                SendTo.AddRange(admins);

                                if (!string.IsNullOrEmpty(author) && !SendTo.Contains(author))
                                {
                                    SendTo.Add(author);
                                }

                                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 && !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_PostToArticle"));
                                        body.Replace("{OrgName}", currOrganization.Name);
                                        body.Replace("{InstName}", currInstance.Name);
                                        body.Replace("{ArticleName}", articleRow.Subject);
                                        body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", this.InstanceGuid.ToString("N"), this.ArticleGuid.ToString("N")));
                                        body.Replace("{ArticleText}", HttpUtility.HtmlEncode(TextBoxComment.Text));
                                        body.Replace("{AuthorName}", TextBoxName.Text);
                                        body.Replace("{AuthorEmail}", string.IsNullOrEmpty(TextBoxEmail.Text) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", TextBoxEmail.Text));
                                        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);
                                        }

                                        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);
                                        }
                                    }
                                }
                            }
                            ResetData();
                        }
                    }
                }
            }
        }
예제 #5
0
파일: Utils.cs 프로젝트: bigWebApps/KB-Old
 public static string GetInstanceUserName(Guid instanceGuid)
 {
     string userName = string.Empty;
     MainDataSetTableAdapters.Mc_InstanceTableAdapter taDepartment = new MainDataSetTableAdapters.Mc_InstanceTableAdapter();
     object obj = taDepartment.GetDepartmentAdministrator(instanceGuid);
     if (obj != null)
         userName = (string)obj;
     else
     {
         obj = taDepartment.GetOrganizationAdministrator(instanceGuid);
         if (obj != null)
             userName = (string)obj;
     }
     return userName;
 }
예제 #6
0
파일: Utils.cs 프로젝트: bigWebApps/KB-Old
 public static string GetInstanceName(Guid instanceGuid)
 {
     MainDataSetTableAdapters.Mc_InstanceTableAdapter taDepartment = new MainDataSetTableAdapters.Mc_InstanceTableAdapter();
     MainDataSet.Mc_InstanceDataTable departmentTable = taDepartment.GetDataByInstanceId(instanceGuid);
     if (departmentTable != null && departmentTable.Rows.Count > 0)
         return ((MainDataSet.Mc_InstanceRow)departmentTable.Rows[0]).Name;
     else
         return string.Empty;
 }