Пример #1
0
        /// <summary>
        /// Handles OnUpdate event
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnUpdate(EventArgs e)
        {
            string   email;
            Label    lblEMail;
            CheckBox chkSelect;

            foreach (RepeaterItem SelectItem in repListItem.Items)
            {
                lblEMail  = (Label)SelectItem.FindControl("lblEMail");
                email     = lblEMail.Text;
                chkSelect = (CheckBox)SelectItem.FindControl("chkSelect");

                if (chkSelect.Checked)
                {
                    //BlacklistDB.AddToBlackList(this.portalSettings.PortalID, email, "Blacklisted by " +  Context.User.Identity.Name);
                    // Added EsperantusKeys for Localization
                    // Mario Endara [email protected] june-1-2004
                    BlacklistDB.AddToBlackList(this.PortalSettings.PortalID, email,
                                               General.GetString("NEWSLETTER_BLACKLISTED") +
                                               PortalSettings.CurrentUser.Identity.Email);
                }
                else
                {
                    BlacklistDB.DeleteFromBlackList(this.PortalSettings.PortalID, email);
                }
            }

            // Redirect back to the portal home page
            RedirectBackToReferringPage();
        }
Пример #2
0
 public RPCResult DelBlacklist(List <string> numbers)
 {
     try
     {
         if (numbers.Count == 0)
         {
             return(new RPCResult(false, "黑名单不能为空"));
         }
         if (BlacklistDB.Del(numbers))
         {
             string message = "Dec" + (char)2;
             foreach (var number in numbers)
             {
                 message += number + (char)2;
             }
             BlacklistSend.Instance.Send(message.Substring(0, message.Length - 1));
             return(new RPCResult(true, ""));
         }
         LogHelper.LogWarn("SMSService", "SMSService.DelBlacklist", "黑名单数据库删除失败");
         return(new RPCResult(false, "删除黑名单失败"));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("SMSService", "SMSService.DelBlacklist", ex.ToString());
         return(new RPCResult(false, "删除黑名单出现错误"));
     }
 }
Пример #3
0
 public RPCResult AddBlacklist(List <string> numbers)
 {
     try
     {
         if (numbers.Count == 0)
         {
             return(new RPCResult(false, "黑名单不能为空"));
         }
         if (BlacklistDB.Add(numbers))
         {
             string message = "Add" + (char)2;
             foreach (var number in numbers)
             {
                 message += number + (char)2;
             }
             BlacklistSend.Instance.Send(message.Substring(0, message.Length - 1));
             return(new RPCResult(true, ""));
         }
         LogHelper.LogWarn("Pretreatment", "PretreatmentService.AddBlacklist", "黑名单添加数据库失败");
         return(new RPCResult(false, "添加黑名单失败"));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("Pretreatment", "PretreatmentService.AddBlacklist", ex.ToString());
         return(new RPCResult(false, "添加黑名单出现错误"));
     }
 }
Пример #4
0
        /// <summary>
        /// Binds the list item.
        /// </summary>
        public void BindListItem()
        {
            BlacklistDB blacklist = new BlacklistDB();
            DataSet     blist     = blacklist.GetBlacklist(this.PortalSettings.PortalID, true, false);

            repListItem.DataSource = blist;
            repListItem.DataBind();
        }
Пример #5
0
        void LoadNumber()
        {
            List <string> phones = BlacklistDB.GetNumbers();

            foreach (var phone in phones)
            {
                if (!ContainsNumber(phone))
                {
                    numbers.Add(phone);
                }
            }
        }
Пример #6
0
 public RPCResult <List <string> > GetBlacklist()
 {
     try
     {
         List <string> list = BlacklistDB.GetNumbers();
         return(new RPCResult <List <string> >(true, list, ""));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("SMSService", "SMSService.GetBlacklist", ex.ToString());
         return(new RPCResult <List <string> >(false, null, "获取黑名单失败"));
     }
 }
Пример #7
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of blacklist information from the Users
        /// table, and then databind the results to a templated DataList
        /// server control. It uses the Rainbow.BlacklistDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            showColumnName           = "True" == Settings["BLACKLIST_SHOWCOLUMNNAME"].ToString();
            showColumnEmail          = "True" == Settings["BLACKLIST_SHOWCOLUMNEMAIL"].ToString();
            showColumnSendNewsletter = "True" == Settings["BLACKLIST_SHOWCOLUMNSENDNEWSLETTER"].ToString();
            showColumnReason         = "True" == Settings["BLACKLIST_SHOWCOLUMNREASON"].ToString();
            showColumnDate           = "True" == Settings["BLACKLIST_SHOWCOLUMNDATE"].ToString();
            showColumnLastSend       = "True" == Settings["BLACKLIST_SHOWCOLUMNLASTSEND"].ToString();
            showAllUsers             = "True" == Settings["BLACKLIST_SHOWALLUSERS"].ToString();
            showSubscribersOnly      = "True" == Settings["BLACKLIST_SHOWSUBSCRIBERSONLY"].ToString();

            if (Page.IsPostBack == false)
            {
                sortField     = Settings["BLACKLIST_SORTFIELD"].ToString();
                sortDirection = "ASC";
                if (sortField == "LastSend" || sortField == "Date")
                {
                    sortDirection = "DESC";
                }
                ViewState["SortField"]     = sortField;
                ViewState["sortDirection"] = sortDirection;
            }
            else
            {
                sortField     = (string)ViewState["SortField"];
                sortDirection = (string)ViewState["sortDirection"];
            }


            BlacklistDB blacklist = new BlacklistDB();
            DataSet     blist     = blacklist.GetBlacklist(PortalID, showAllUsers, showSubscribersOnly);

            myDataView = new DataView();
            myDataView = blist.Tables[0].DefaultView;

            if (!Page.IsPostBack)
            {
                myDataView.Sort = sortField + " " + sortDirection;
            }

            BindGrid();
        }
Пример #8
0
        public void Test()
        {
            List <string> black = new List <string>()
            {
                "123456", "234567", "345678"
            };
            var b = BlacklistDB.Add(black);

            Assert.IsTrue(b);
            var list = BlacklistDB.GetNumbers();

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Contains("123456"));
            Assert.IsTrue(list.Contains("234567"));
            Assert.IsTrue(list.Contains("345678"));
            b    = BlacklistDB.Del(black);
            list = BlacklistDB.GetNumbers();
            Assert.IsNotNull(list);
            Assert.IsTrue(!list.Contains("123456"));
            Assert.IsTrue(!list.Contains("234567"));
            Assert.IsTrue(!list.Contains("345678"));
        }
Пример #9
0
        /// <summary>
        /// The SubmitBtn_Click server event handler on this page is used
        /// to handle the scenario where a user clicks the "send"
        /// button after entering a response to a message post.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void submitButton_Click(object sender, EventArgs e)
        {
            string message;
            int    cnt = 0;

            EditPanel.Visible    = false;
            PrewiewPanel.Visible = true;
            UsersPanel.Visible   = false;

            SmtpMail.SmtpServer = Config.SmtpServer;

            message = General.GetString("NEWSLETTER_SENDTO", "<b>Message:</b> sent to:<br>");

            try
            {
                NewsletterDB newsletter = new NewsletterDB();
                if (!bool.Parse(Settings["TestMode"].ToString()))
                {
                    // Get Newsletter Users from DB
                    SqlDataReader dReader =
                        newsletter.GetUsersNewsletter(portalSettings.PortalID,
                                                      Int32.Parse(Settings["NEWSLETTER_USERBLOCK"].ToString()),
                                                      Int32.Parse(Settings["NEWSLETTER_DONOTRESENDWITHIN"].ToString()));
                    try
                    {
                        while (dReader.Read())
                        {
                            cnt++;
                            message += dReader["Email"].ToString() + ", ";
                            try
                            {
                                //Send the email
                                newsletter.SendMessage(txtEMail.Text, dReader["Email"].ToString(),
                                                       dReader["Name"].ToString(), dReader["Password"].ToString(),
                                                       Settings["NEWSLETTER_LOGINHOMEPAGE"].ToString(), txtSubject.Text,
                                                       txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked);
                                //Update db
                                newsletter.SendNewsletterTo(portalSettings.PortalID, dReader["Email"].ToString());
                            }
                            catch (Exception ex)
                            {
                                InvalidRecipients += dReader["Email"].ToString() + "<br>";
                                BlacklistDB.AddToBlackList(portalSettings.PortalID, dReader["Email"].ToString(),
                                                           ex.Message);
                            }
                        }
                    }
                    finally
                    {
                        dReader.Close(); //by Manu, fixed bug 807858
                    }
                    lblMessage.Text =
                        General.GetString("NEWSLETTER_SENDINGTO", "Message has been sent to {1} registered users.").
                        Replace("{1}", cnt.ToString());
                }
                else
                {
                    newsletter.SendMessage(txtEMail.Text, txtEMail.Text, txtName.Text, "******",
                                           Settings["NEWSLETTER_LOGINHOMEPAGE"].ToString(), txtSubject.Text,
                                           txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked);
                    lblMessage.Text = General.GetString("NEWSLETTER_TESTSENDTO", "Test message sent to: ") +
                                      txtName.Text + " [" + txtEMail.Text + "]";
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = General.GetString("NEWSLETTER_ERROR", "An error occurred: ") + ex.Message;
            }

            CreatedDate.Text = General.GetString("NEWSLETTER_SENDDATE", "Message sent: ") +
                               DateTime.Now.ToLongDateString() + "<br>";

            if (InvalidRecipients.Length > 0)
            {
                CreatedDate.Text += General.GetString("NEWSLETTER_INVALID_RECIPIENTS", "Invalid recipients:<br>") +
                                    InvalidRecipients;
            }

            //Hides commands
            submitButton.Visible  = false;
            cancelButton2.Visible = false;
        }
Пример #10
0
        /// <summary>
        /// The SubmitBtn_Click server event handler on this page is used
        /// to handle the scenario where a user clicks the "send"
        /// button after entering a response to a message post.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void submitButton_Click(object sender, EventArgs e)
        {
            string message;
            int    cnt = 0;

            EditPanel.Visible    = false;
            PrewiewPanel.Visible = true;
            UsersPanel.Visible   = false;

            message = General.GetString("NEWSLETTER_SENDTO", "<b>Message:</b> sent to:<br>");

            try
            {
                NewsletterDB newsletter = new NewsletterDB();
                if (!bool.Parse(Settings["TestMode"].ToString()))
                {
                    // Get Newsletter Users from DB
                    var users = newsletter.GetUsersNewsletter(this.PortalSettings.PortalID);
                    foreach (dynamic user in users)
                    {
                        cnt++;
                        message += user.Email + ", ";
                        try
                        {
                            //Send the email
                            newsletter.SendMessage(txtEMail.Text, user.Email, user.Name, txtSubject.Text,
                                                   txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked);
                            // Here the systems used to notify the DB that an email was sent to the user.
                            // Since we implemented the MembershipProvider for Appleseed, we doesn't have a place to store this info,
                            // thus, now the fact that an email was sent won't be persisted in the DB. However this should change in future releases.
                        }
                        catch (Exception ex)
                        {
                            InvalidRecipients += user.Email + "<br/>";
                            BlacklistDB.AddToBlackList(this.PortalSettings.PortalID, user.Email, ex.Message);
                        }
                    }
                    lblMessage.Text =
                        General.GetString("NEWSLETTER_SENDINGTO", "Message has been sent to {1} registered users.").
                        Replace("{1}", cnt.ToString());
                }
                else
                {
                    newsletter.SendMessage(txtEMail.Text, txtEMail.Text, txtName.Text, txtSubject.Text,
                                           txtBody.Text, true, HtmlMode.Checked, InsertBreakLines.Checked);
                    lblMessage.Text = General.GetString("NEWSLETTER_TESTSENDTO", "Test message sent to: ") +
                                      txtName.Text + " [" + txtEMail.Text + "]";
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = General.GetString("NEWSLETTER_ERROR", "An error occurred: ") + ex.Message;
            }

            CreatedDate.Text = General.GetString("NEWSLETTER_SENDDATE", "Message sent: ") +
                               DateTime.Now.ToLongDateString() + "<br>";

            if (InvalidRecipients.Length > 0)
            {
                CreatedDate.Text += General.GetString("NEWSLETTER_INVALID_RECIPIENTS", "Invalid recipients:<br>") +
                                    InvalidRecipients;
            }

            //Hides commands
            submitButton.Visible  = false;
            cancelButton2.Visible = false;
        }