Example #1
0
    //===============================================================
    // Function: alertsRepeater_ItemCommand
    //===============================================================
    protected void alertsRepeater_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        int eventAlertID = int.Parse(e.CommandArgument.ToString());

        EventAlert eventAlert = new EventAlert(Session["loggedInUserFullName"].ToString(), eventAlertID);

        if (e.CommandName == "clearAlertButton")
        {
            EventAlert alertToDelete = new EventAlert(Session["loggedInUserFullName"].ToString(), eventAlertID);
            alertToDelete.Delete();
        }

        int userID = int.Parse(Session["loggedInUserID"].ToString());
        PopulateAlertsList(userID);
    }
Example #2
0
    //===============================================================
    // Function: addReminderLink_click
    //===============================================================
    protected void addReminderLink_click(object sender, EventArgs e)
    {
        int eventID = int.Parse(Request.QueryString["EID"]);

        DateTime alertDate = CalendarAlertDate.SelectedDate;
        string alertText = newAlertTextBox.Text;

        EventAlert eventAlert = new EventAlert((string)Application["connectionString"]);
        eventAlert.alertDate = alertDate;
        eventAlert.eventID = eventID;
        eventAlert.alertText = alertText;
        eventAlert.Add();

        newAlertTextBox.Text = "";
        CalendarAlertDate.SelectedDate = DateTime.Now;
        PickerAlertDate.SelectedDate = DateTime.Now;

        Response.Redirect("viewEvent.aspx?EID=" + eventID.ToString());
    }
Example #3
0
    //===============================================================
    // Function: saveChangesButton_click
    //===============================================================
    protected void saveChangesButton_click(object sender, EventArgs e)
    {
        int eventID = int.Parse(Request.QueryString["EID"]);

        if (eventPicFileUpload.PostedFile.ContentLength != 0)
        {
            int fileSizeBytes = eventPicFileUpload.PostedFile.ContentLength;

            GlobalData gd = new GlobalData((string)Session["loggedInUserFullName"]);
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder") + @"\temp";

            string originalFileName = Path.GetFileName(eventPicFileUpload.PostedFile.FileName);
            string destPath = Path.Combine(fileStoreFolder, originalFileName);
            if ((eventPicFileUpload.PostedFile.ContentType == "image/jpeg"
                || eventPicFileUpload.PostedFile.ContentType == "image/gif"
                || eventPicFileUpload.PostedFile.ContentType == "image/png")
                && Path.GetExtension(destPath) != ""
                )
            {
                destPath = destPath.Replace(" ", "_");
                destPath = MiscUtils.GetUniqueFileName(destPath);
                string savedFilename = Path.GetFileName(destPath);

                eventPicFileUpload.PostedFile.SaveAs(destPath);

                MiscUtils.CreateEventPicPreviews(Path.GetFileName(destPath), eventID);
            }
        }

        DateTime alertDate = CalendarAlertDate.SelectedDate;
        string alertText = newAlertTextBox.Text.Trim();

        if (alertText != "")
        {
            EventAlert eventAlert = new EventAlert((string)Application["connectionString"]);
            eventAlert.alertDate = alertDate;
            eventAlert.eventID = eventID;
            eventAlert.alertText = alertText;
            eventAlert.Add();

            newAlertTextBox.Text = "";
            CalendarAlertDate.SelectedDate = DateTime.Now;
            PickerAlertDate.SelectedDate = DateTime.Now;
        }

        SedogoEvent sedogoEvent = new SedogoEvent((string)Session["loggedInUserFullName"], eventID);
        sedogoEvent.Update();

        Response.Redirect("addEventInvites.aspx?EID=" + eventID.ToString());
    }
Example #4
0
    //===============================================================
    // Function: createAlertLink_click
    //===============================================================
    protected void createAlertLink_click(object sender, EventArgs e)
    {
        int eventID = int.Parse(Request.QueryString["EID"]);

        DateTime alertDate = CalendarAlertDate.SelectedDate;
        string alertText = newAlertTextBox.Text;

        EventAlert eventAlert = new EventAlert(Session["loggedInUserFullName"].ToString());
        eventAlert.alertDate = alertDate;
        eventAlert.eventID = eventID;
        eventAlert.alertText = alertText;
        eventAlert.Add();

        newAlertTextBox.Text = "";
        CalendarAlertDate.SelectedDate = DateTime.Now;
        PickerAlertDate.SelectedDate = DateTime.Now;

        PopulateAlerts(eventID);
    }
Example #5
0
    //===============================================================
    // Function: Page_Load
    //===============================================================
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int eventID = int.Parse(Request.QueryString["EID"]);
            string action = "";
            int eventAlertID = -1;
            if (Request.QueryString["A"] != null && Request.QueryString["EAID"] != null)
            {
                action = Request.QueryString["A"].ToString();
                eventAlertID = int.Parse(Request.QueryString["EAID"]);

                if (action == "Delete")
                {
                    try
                    {
                        EventAlert alertToDelete = new EventAlert(Session["loggedInUserFullName"].ToString(), eventAlertID);
                        alertToDelete.Delete();
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                            "alert(\"Error: " + ex.Message + "\");", true);
                    }
                }
            }

            SedogoEvent sedogoEvent = new SedogoEvent(Session["loggedInUserFullName"].ToString(), eventID);
            SedogoUser eventOwner = new SedogoUser("", sedogoEvent.userID);

            string dateString = "";
            DateTime startDate = sedogoEvent.startDate;
            MiscUtils.GetDateStringStartDate(eventOwner, sedogoEvent.dateType, sedogoEvent.rangeStartDate,
                sedogoEvent.rangeEndDate, sedogoEvent.beforeBirthday, ref dateString, ref startDate);

            eventTitleLabel.Text = sedogoEvent.eventName;
            eventOwnersNameLabel.Text = eventOwner.firstName + " " + eventOwner.lastName;
            eventDateLabel.Text = dateString;
            eventDescriptionLabel.Text = sedogoEvent.eventDescription.Replace("\n", "<br/>");

            CalendarAlertDate.SelectedDate = DateTime.Now;
            PickerAlertDate.SelectedDate = DateTime.Now;

            PopulateAlerts(eventID);
        }
    }
Example #6
0
    //===============================================================
    // Function: createAlertLink_click
    //===============================================================
    protected void createAlertLink_click(object sender, EventArgs e)
    {
        int eventID = int.Parse(Request.QueryString["EID"]);

        DateTime alertDate = CalendarAlertDate.SelectedDate;
        string alertText = newAlertTextBox.Text;

        EventAlert eventAlert = new EventAlert((string)Application["connectionString"]);
        eventAlert.alertDate = alertDate;
        eventAlert.eventID = eventID;
        eventAlert.alertText = alertText;
        eventAlert.Add();

        newAlertTextBox.Text = "";
        CalendarAlertDate.SelectedDate = DateTime.Now;
        PickerAlertDate.SelectedDate = DateTime.Now;

        PopulateAlerts(eventID);
    }
Example #7
0
        //===============================================================
        // Function: SendAlertEmails
        //===============================================================
        public static void SendAlertEmails()
        {
            GlobalData gd = new GlobalData("");
            string SMTPServer = gd.GetStringValue("SMTPServer");
            string mailFromAddress = gd.GetStringValue("MailFromAddress");
            string mailFromUsername = gd.GetStringValue("MailFromUsername");
            string mailFromPassword = gd.GetStringValue("MailFromPassword");

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectAlertsToSendByEmail";
                DbDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    int eventAlertID = int.Parse(rdr["EventAlertID"].ToString());

                    // Send the email
                    EventAlert eventAlert = new EventAlert("", eventAlertID);
                    SedogoEvent sedogoEvent = new SedogoEvent("", eventAlert.eventID);
                    SedogoUser user = new SedogoUser("", sedogoEvent.userID);
                    string dateString = "";
                    DateTime startDate = sedogoEvent.startDate;

                    string emailSubject = "Sedogo reminder for " + sedogoEvent.eventName;

                    MiscUtils.GetDateStringStartDate(user, sedogoEvent.dateType, sedogoEvent.rangeStartDate,
                        sedogoEvent.rangeEndDate, sedogoEvent.beforeBirthday, ref dateString, ref startDate);

                    string inviteURL = gd.GetStringValue("SiteBaseURL");
                    inviteURL = inviteURL + "/viewEvent.aspx?EID=" + eventAlert.eventID.ToString();

                    StringBuilder emailBodyCopy = new StringBuilder();
                    emailBodyCopy.AppendLine("<html>");
                    emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
                    emailBodyCopy.AppendLine("<style type=\"text/css\">");
                    emailBodyCopy.AppendLine("	body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }");
                    emailBodyCopy.AppendLine("	p { margin: 0 }");
                    emailBodyCopy.AppendLine("	h1 { color: #00ccff; font-size: 18px; font-weight: bold; }");
                    emailBodyCopy.AppendLine("	a, .blue { color: #00ccff; text-decoration: none; }");
                    emailBodyCopy.AppendLine("	img { border: 0; }");
                    emailBodyCopy.AppendLine("</style></head>");
                    emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">");
                    emailBodyCopy.AppendLine("  <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
                    //emailBodyCopy.AppendLine("	<tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>");
                    emailBodyCopy.AppendLine("	<tr><td style=\"background: #fff\" width=\"30\"></td>");
                    emailBodyCopy.AppendLine("		<td style=\"background: #fff\" width=\"632\">");
                    emailBodyCopy.AppendLine("			<h1>You asked to be reminded about:</h1>");
                    emailBodyCopy.AppendLine("			<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">");
                    emailBodyCopy.AppendLine("				<tr>");
                    emailBodyCopy.AppendLine("					<td width=\"60\">What:</td>");
                    emailBodyCopy.AppendLine("					<td width=\"10\" rowspan=\"5\">&nbsp;</td>");
                    emailBodyCopy.AppendLine("					<td width=\"530\"><a href=\"" + inviteURL + "\">" + sedogoEvent.eventName + "</a></td>");
                    emailBodyCopy.AppendLine("				</tr>");
                    emailBodyCopy.AppendLine("				<tr>");
                    emailBodyCopy.AppendLine("					<td valign=\"top\">Where:</td>");
                    emailBodyCopy.AppendLine("					<td>" + sedogoEvent.eventVenue + "</td>");
                    emailBodyCopy.AppendLine("				</tr>");
                    emailBodyCopy.AppendLine("				<tr>");
                    emailBodyCopy.AppendLine("					<td valign=\"top\">Who:</td>");
                    emailBodyCopy.AppendLine("					<td>" + user.firstName + " " + user.lastName + "</td>");
                    emailBodyCopy.AppendLine("				</tr>");
                    emailBodyCopy.AppendLine("				<tr>");
                    emailBodyCopy.AppendLine("					<td valign=\"top\">When:</td>");
                    emailBodyCopy.AppendLine("					<td>" + dateString + "</td>");
                    emailBodyCopy.AppendLine("				</tr>");
                    emailBodyCopy.AppendLine("				<tr>");
                    emailBodyCopy.AppendLine("					<td valign=\"top\">Message:</td>");
                    emailBodyCopy.AppendLine("					<td><p style=\"color:black\">" + eventAlert.alertText.Replace("\n", "<br/>") + "</p></td>");
                    emailBodyCopy.AppendLine("				</tr>");
                    emailBodyCopy.AppendLine("			</table>");
                    emailBodyCopy.AppendLine("			<p>To view this event, <a href=\"" + inviteURL + "\"><u>click here</u></a>.</p>");
                    emailBodyCopy.AppendLine("			<br /><br />");
                    emailBodyCopy.AppendLine("			<p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />");
                    emailBodyCopy.AppendLine("			<br /><br /><br /><a href=\"http://www.sedogo.com\">");
                    //emailBodyCopy.AppendLine("			<img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />");
                    emailBodyCopy.AppendLine("			</a></td>");
                    emailBodyCopy.AppendLine("		<td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">");
                    //emailBodyCopy.AppendLine("			<img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">");
                    emailBodyCopy.AppendLine("		</td></tr><tr><td colspan=\"3\"><small>This message was intended for " + user.emailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>");
                    emailBodyCopy.AppendLine("		</td></tr></table></body></html>");

                    if (user.enableSendEmails == true)
                    {
                        try
                        {
                            MailMessage message = new MailMessage(mailFromAddress, user.emailAddress);
                            message.ReplyTo = new MailAddress("*****@*****.**");

                            message.Subject = emailSubject;
                            message.Body = emailBodyCopy.ToString();
                            message.IsBodyHtml = true;
                            SmtpClient smtp = new SmtpClient();
                            smtp.Host = SMTPServer;
                            if (mailFromPassword != "")
                            {
                                // If the password is blank, assume mail relay is permitted
                                smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword);
                            }
                            smtp.Send(message);

                            SentEmailHistory emailHistory = new SentEmailHistory("");
                            emailHistory.subject = emailSubject;
                            emailHistory.body = emailBodyCopy.ToString();
                            emailHistory.sentFrom = mailFromAddress;
                            emailHistory.sentTo = user.emailAddress;
                            emailHistory.Add();
                        }
                        catch (Exception ex)
                        {
                            SentEmailHistory emailHistory = new SentEmailHistory("");
                            emailHistory.subject = emailSubject;
                            emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString();
                            emailHistory.sentFrom = mailFromAddress;
                            emailHistory.sentTo = user.emailAddress;
                            emailHistory.Add();
                        }

                        eventAlert.reminderEmailSent = true;
                        eventAlert.Update();
                    }
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventAlert", "SendAlertEmails", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }