/// <summary>
        /// The previewButton_Click server event handler on this page is used
        /// to handle the scenario where a user clicks the "preview"
        /// button to see a preview of the message.
        /// </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 previewButton_Click(object sender, EventArgs e)
        {
            CreatedDate.Text = General.GetString("NEWSLETTER_LOCALTIME", "Local time: ") +
                               DateTime.Now.ToLongDateString();

            NewsletterDB newsletter = new NewsletterDB();

            string email;
            string name;

            if (!bool.Parse(Settings["TestMode"].ToString()))
            {
                var users = newsletter.GetUsersNewsletter(this.PortalSettings.PortalID);
                if (users.Count > 0)
                {
                    email = users[0].Email;
                    name  = users[0].Name;
                }
                else
                {
                    lblMessage.Text = General.GetString("NEWSLETTER_NORECIPIENTS", "No recipients");
                    return; //nothing more to do here
                }
            }
            else
            {
                email = txtEMail.Text;
                name  = txtName.Text;
            }

            EditPanel.Visible    = false;
            PrewiewPanel.Visible = true;
            UsersPanel.Visible   = false;
            lblFrom.Text         = txtName.Text + " (" + txtEMail.Text + ")";
            lblTo.Text           = name + " (" + email + ")";
            lblSubject.Text      = txtSubject.Text;
            string body =
                newsletter.SendMessage(txtEMail.Text, email, name, txtSubject.Text, txtBody.Text,
                                       false, HtmlMode.Checked, InsertBreakLines.Checked);

            if (HtmlMode.Checked)
            {
                lblBody.Text = body;
            }
            else
            {
                lblBody.Text = "<PRE>" + body + "</PRE>";
            }
        }
示例#2
0
        public JsonResult Newsletter(string email)
        {
            NewsletterDB db = new NewsletterDB();

            Biblioteca.Entidades.Newsletter news = db.Buscar(email);
            if (news == null)
            {
                new Newsletter()
                {
                    email = email
                }.Salvar();
                news = db.Buscar(email);
            }

            new Newsletter_navegacao(news, Cookies_ga(), DateTime.Now).Salvar();

            return(Json(new Retorno()));
        }
示例#3
0
        public JsonResult Ligamos(string nome, string email, string telefone)
        {
            new Envio_email()
            {
                para = "*****@*****.**", assunto = "Solicitou ligação - Cenbrap", texto = "Nome: " + nome + "<BR>E-mail: " + email + "<BR>Telefone: " + telefone + "<BR><BR>Solicitou entrar em contato por telefone."
            }.Salvar();

            NewsletterDB db = new NewsletterDB();

            Biblioteca.Entidades.Newsletter news = db.Buscar(email);
            if (news == null)
            {
                new Newsletter()
                {
                    email = email, nome = nome, telefone = telefone
                }.Salvar();
                news = db.Buscar(email);
            }

            new Newsletter_navegacao(news, Cookies_ga(), DateTime.Now).Salvar();

            return(Json(new Retorno()));
        }
示例#4
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </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 Page_Load(object sender, EventArgs e)
        {
            // Added EsperantusKeys for Localization
            // Mario Endara [email protected] 11/05/2004
            Titulo = General.GetString("NEWSLETTER_TITLE");

            if (!Page.IsPostBack)
            {
                CreatedDate.Text = DateTime.Now.ToLongDateString();

                //Set default
                txtName.Text  = Settings["NEWSLETTER_DEFAULTNAME"].ToString();
                txtEMail.Text = Settings["NEWSLETTER_DEFAULTEMAIL"].ToString();
                if (txtEMail.Text == string.Empty)
                {
                    txtEMail.Text = PortalSettings.CurrentUser.Identity.Email;
                }

                //create a DataTable
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("StringValue"));

                NewsletterDB newsletter = new NewsletterDB();

                if (!bool.Parse(Settings["TestMode"].ToString()))
                {
                    SqlDataReader dReader =
                        newsletter.GetUsersNewsletter(portalSettings.PortalID,
                                                      Int32.Parse(Settings["NEWSLETTER_USERBLOCK"].ToString()),
                                                      Int32.Parse(Settings["NEWSLETTER_DONOTRESENDWITHIN"].ToString()));
                    try
                    {
                        while (dReader.Read())
                        {
                            DataRow dr = dt.NewRow();
                            dr[0] = "<b>" + dReader["Name"].ToString() + ":</b> " + dReader["EMail"].ToString();
                            dt.Rows.Add(dr);
                        }
                    }
                    finally
                    {
                        dReader.Close(); //by Manu, fixed bug 807858
                    }

                    DataList1.DataSource      = new DataView(dt);
                    DataList1.RepeatDirection = RepeatDirection.Vertical;
                    DataList1.RepeatLayout    = RepeatLayout.Table;
                    DataList1.BorderWidth     = Unit.Pixel(1);
                    DataList1.GridLines       = GridLines.Both;
                    DataList1.RepeatColumns   = 3;
                    DataList1.DataBind();
                    DataList1.Visible = true;

                    int cnt =
                        newsletter.GetUsersNewsletterCount(portalSettings.PortalID,
                                                           Int32.Parse(Settings["NEWSLETTER_USERBLOCK"].ToString()),
                                                           Int32.Parse(
                                                               Settings["NEWSLETTER_DONOTRESENDWITHIN"].ToString()));
                    // Added EsperantusKeys for Localization
                    // Mario Endara [email protected] 11/05/2004
                    lblMessage.Text = General.GetString("NEWSLETTER_MSG").Replace("{1}", cnt.ToString());
                }
                else
                {
                    // Added EsperantusKeys for Localization
                    // Mario Endara [email protected] 11/05/2004
                    lblMessage.Text =
                        General.GetString("NEWSLETTER_MSG_TEST").Replace("{1}", txtName.Text).Replace("{2}",
                                                                                                      txtEMail.Text);
                }

                //Try to get template
                int HTMLModID = int.Parse(Settings["NEWSLETTER_HTMLTEMPLATE"].ToString());
                if (HTMLModID > 0)
                {
                    // Obtain the selected item from the HtmlText table
                    NewsletterHtmlTextDB text = new NewsletterHtmlTextDB();
                    SqlDataReader        dr   = text.GetHtmlText(HTMLModID, WorkFlowVersion.Staging);
                    try
                    {
                        if (dr.Read())
                        {
                            string buffer = (string)dr["DesktopHtml"];
                            // Replace relative path to absolute path. [email protected] 19/07/2004
                            buffer = buffer.Replace(Path.ApplicationFullPath, Path.ApplicationRoot);
                            if (Path.ApplicationRoot.Length > 0)
                            {
                                //by Manu... on root PortalSettings.ApplicationPath is empty
                                buffer = buffer.Replace(Path.ApplicationRoot, Path.ApplicationFullPath);
                            }

                            txtBody.Text     = Server.HtmlDecode(buffer);
                            HtmlMode.Checked = true;
                        }
                        else
                        {
                            HtmlMode.Checked = false;
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }
                }
            }
            EditPanel.Visible    = true;
            PrewiewPanel.Visible = false;
            UsersPanel.Visible   = true;
        }
示例#5
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;
        }
        /// <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;
        }
示例#7
0
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
            string _ga           = Cookies_ga();
            string identificador = "";

            if (Request.QueryString["identificador"] != null)
            {
                if (Request.QueryString["identificador"] != "")
                {
                    identificador = Request.QueryString["identificador"];
                }
            }
            if (Request.QueryString["_identificador"] != null)
            {
                if (Request.QueryString["_identificador"] != "")
                {
                    identificador = Request.QueryString["_identificador"];
                }
            }
            if (Request.QueryString["_id"] != null)
            {
                if (Request.QueryString["_id"] != "")
                {
                    identificador = Request.QueryString["_id"];
                }
            }

            if (identificador != "")
            {
                //Verifica se já tem Mídia
                MidiaDB midiaDB = new MidiaDB();
                if (!midiaDB.Existe(identificador))
                {
                    new Midia(0, new Midia_tipo(8, ""), new Painel(0), DateTime.Now, "Identificador " + identificador, "", 0, "", 0, 0, 0, 0, 0, 0, false, identificador).Salvar();
                }
            }

            //Se teve url de origem
            Uri uri = Request.UrlReferrer;

            if (uri != null)
            {
                new UrlOrigem(uri.Host, uri.PathAndQuery, Request.Url.OriginalString, Request.UserHostAddress, _ga, identificador).Salvar();
            }

            //Se recebeu o Cartaz
            string cartaz = Request.QueryString["cartaz"];

            if (cartaz != null)
            {
                if (cartaz != "")
                {
                    new MarcarCartaz().Marcar(cartaz, Request.UserHostAddress);
                }
            }

            //Se veio por email
            int idenviado   = 0;
            int i_idenviado = 0;

            if (Request.QueryString["idenviado"] != null)
            {
                if (Request.QueryString["idenviado"] != "")
                {
                    if (int.TryParse(Request.QueryString["idenviado"], out i_idenviado))
                    {
                        idenviado = i_idenviado;
                    }

                    int cont   = 0;
                    int i_cont = 0;
                    if (Request.QueryString["cont"] != null)
                    {
                        if (int.TryParse(Request.QueryString["cont"], out i_cont))
                        {
                            cont = i_cont;
                        }
                    }

                    if (idenviado != 0)
                    {
                        new Clicou(idenviado, cont);

                        //retorna o email do envio
                        if (_ga != null && _ga != "")
                        {
                            string email = new EnviadoDB().Email(idenviado);
                            if (email != "")
                            {
                                //Verifica se já é aluno e se o _ga está salvo para o aluno_navegacao
                                Aluno aluno = new AlunoDB().Email(email);
                                if (aluno != null)
                                {
                                    new Aluno_navegacaoDB().Existe(aluno, _ga);
                                }
                            }
                            else
                            {
                                Newsletter newsletter = new NewsletterDB().Buscar(email);
                                if (newsletter != null)
                                {
                                    new Newsletter_navegacaoDB().Existe(newsletter, _ga);
                                }
                            }
                        }
                    }
                }
            }

            //se _ga for diferente de ""
            if (_ga != null && _ga != "")
            {
                new Navegacao(Request.Url.AbsoluteUri, _ga, DateTime.Now);
            }

            return(base.BeginExecuteCore(callback, state));
        }