示例#1
0
        //===============================================================
        // Function: BuildBroadcastEmail
        //===============================================================
        public static string BuildBroadcastEmail(string broadcastEmailContent)
        {
            string emailBody = "";

            GlobalData gd = new GlobalData("");
            string linkURL = gd.GetStringValue("SiteBaseURL");

            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("			<p>" + broadcastEmailContent.Replace("\n", "<br/>") + "</p>");

            emailBodyCopy.AppendLine("			<p>To log into Sedogo, <a href=\"" + linkURL + "\"><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 <<RECIPIENT>>. 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>");

            emailBody = emailBodyCopy.ToString();

            return emailBody;
        }
示例#2
0
        //===============================================================
        // Function: CheckChangePassword
        //
        // This function checks the password is valid for this contact
        // It does NOT change the password in the database
        // The following rules can be checked depending on system settings
        // - Min password length
        // - Max password length
        // - Mixed case
        // - Force alphanumeric (password must have letters and numbers)
        // - Force non-alphanumerix (password must have punctuation characters in it)
        // - Password history check, cannot re-use any of the last x passwords
        //===============================================================
        public Boolean CheckChangePassword(string password, out Byte reason)
        {
            // passwordChangeResults { passwordOK, passwordTooShort, passwordTooLong, passwordMixedCase,
            // passwordNeedsDigit, passwordSpecialCharacter, passwordReused }
            Boolean returnStatus = true;
            reason = 0;

            string pwdCheckMinLengthEnabled = "N";
            int pwdCheckMinLength = 1;
            string pwdCheckMaxLengthEnabled = "N";
            int pwdCheckMaxLength = 999;
            string pwdCheckMixedCaseEnabled = "N";
            string pwdCheckNeedsDigitEnabled = "N";
            string pwdCheckSpecialCharacterEnabled = "N";
            string pwdCheckNeedsReusedEnabled = "N";
            int pwdCheckReusedNumber = 1;

            const string lower = "abcdefghijklmnopqrstuvwxyz";
            const string upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            const string digits = "0123456789";
            string allChars = lower + upper + digits;

            try
            {
                GlobalData globalData = new GlobalData(m_loggedInUser);
                pwdCheckMinLengthEnabled = globalData.GetStringValue("PwdCheckMinLengthEnabled");
                pwdCheckMinLength = globalData.GetIntegerValue("PwdCheckMinLength");
                pwdCheckMaxLengthEnabled = globalData.GetStringValue("PwdCheckMaxLengthEnabled");
                pwdCheckMaxLength = globalData.GetIntegerValue("PwdCheckMaxLength");
                pwdCheckMixedCaseEnabled = globalData.GetStringValue("PwdCheckMixedCaseEnabled");
                pwdCheckNeedsDigitEnabled = globalData.GetStringValue("PwdCheckNeedsDigitEnabled");
                pwdCheckSpecialCharacterEnabled = globalData.GetStringValue("PwdCheckSpecialCharacterEnabled");
                pwdCheckNeedsReusedEnabled = globalData.GetStringValue("PwdCheckNeedsReusedEnabled");
                pwdCheckReusedNumber = globalData.GetIntegerValue("PwdCheckReusedNumber");
            }
            catch (Exception)
            {
                throw (new Exception("Error getting global data values for password checks"));
            }

            if (pwdCheckMinLengthEnabled == "Y")
            {
                if (password.Length < pwdCheckMinLength)
                {
                    reason = reason |= (int)passwordChangeResults.passwordTooShort;
                    returnStatus = false;
                }
            }
            if (pwdCheckMaxLengthEnabled == "Y")
            {
                if (password.Length > pwdCheckMaxLength)
                {
                    reason = reason |= (int)passwordChangeResults.passwordTooLong;
                    returnStatus = false;
                }
            }
            if (pwdCheckMixedCaseEnabled == "Y")
            {
                if (!((password.IndexOfAny(lower.ToCharArray()) >= 0) && (password.IndexOfAny(upper.ToCharArray()) >= 0)))
                {
                    reason = reason |= (int)passwordChangeResults.passwordMixedCase;
                    returnStatus = false;
                }
            }
            if (pwdCheckNeedsDigitEnabled == "Y")
            {
                if (!(password.IndexOfAny(digits.ToCharArray()) >= 0))
                {
                    reason = reason |= (int)passwordChangeResults.passwordNeedsDigit;
                    returnStatus = false;
                }
            }
            if (pwdCheckSpecialCharacterEnabled == "Y")
            {
                if (!(password.Trim(allChars.ToCharArray()).Length > 0))
                {
                    reason = reason |= (int)passwordChangeResults.passwordSpecialCharacter;
                    returnStatus = false;
                }
            }
            if (pwdCheckNeedsReusedEnabled == "Y")
            {
                // pwdCheckReusedNumber
            }

            return returnStatus;
        }
示例#3
0
        //===============================================================
        // Function: GetInviteCount
        //===============================================================
        public void SendInviteAcceptedEmail()
        {
            GlobalData gd = new GlobalData("");
            string SMTPServer = gd.GetStringValue("SMTPServer");
            string mailFromAddress = gd.GetStringValue("MailFromAddress");
            string mailFromUsername = gd.GetStringValue("MailFromUsername");
            string mailFromPassword = gd.GetStringValue("MailFromPassword");

            string invitedUserFullName = m_emailAddress;
            if( m_userID > 0 )
            {
                SedogoUser invitedUser = new SedogoUser(m_loggedInUser, m_userID);
                invitedUserFullName = invitedUser.fullName;
            }
            SedogoEvent sedogoEvent = new SedogoEvent(m_loggedInUser, m_eventID);
            SedogoUser eventOwner = new SedogoUser(m_loggedInUser, sedogoEvent.userID);

            string emailSubject = "Sedogo invitation to " + sedogoEvent.eventName + " has been accepted by "
                + invitedUserFullName;

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

            string inviteURL = gd.GetStringValue("SiteBaseURL");
            inviteURL = inviteURL + "/viewEvent.aspx?EID=" + m_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>" + invitedUserFullName + " has accepted your invitation:</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=\"4\">&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>" + eventOwner.firstName + " " + eventOwner.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("			</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 " + eventOwner.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 (eventOwner.enableSendEmails == true)
            {
                try
                {
                    MailMessage message = new MailMessage(mailFromAddress, eventOwner.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 = eventOwner.emailAddress;
                    emailHistory.Add();
                }
                catch (Exception ex)
                {
                    SentEmailHistory emailHistory = new SentEmailHistory("");
                    emailHistory.subject = emailSubject;
                    emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString();
                    emailHistory.sentFrom = mailFromAddress;
                    emailHistory.sentTo = eventOwner.emailAddress;
                    emailHistory.Add();
                }
            }
        }
示例#4
0
        //===============================================================
        // Function: SendEventUpdateEmail
        //===============================================================
        public void SendEventUpdateEmail(int updatingUserID)
        {
            StringBuilder emailBodyCopy = new StringBuilder();
            GlobalData gd = new GlobalData("");

            string dateString = "";
            DateTime startDate = m_startDate;
            SedogoUser eventOwner = new SedogoUser(m_loggedInUser, m_userID);
            SedogoUser updatingUser = new SedogoUser(m_loggedInUser, updatingUserID);
            MiscUtils.GetDateStringStartDate(eventOwner, m_dateType, m_rangeStartDate,
                m_rangeEndDate, m_beforeBirthday, ref dateString, ref startDate);

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

            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>" + updatingUser.firstName + " " + updatingUser.lastName + " has updated the following goal:</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=\"4\">&nbsp;</td>");
            emailBodyCopy.AppendLine("					<td width=\"530\">" + m_eventName + "</td>");
            emailBodyCopy.AppendLine("				</tr>");
            emailBodyCopy.AppendLine("				<tr>");
            emailBodyCopy.AppendLine("					<td valign=\"top\">Owner:</td>");
            emailBodyCopy.AppendLine("					<td>" + eventOwner.firstName + " " + eventOwner.lastName + "</td>");
            emailBodyCopy.AppendLine("				</tr>");
            emailBodyCopy.AppendLine("				<tr>");
            emailBodyCopy.AppendLine("					<td valign=\"top\">Where:</td>");
            emailBodyCopy.AppendLine("					<td>" + m_eventVenue + "</td>");
            emailBodyCopy.AppendLine("				</tr>");
            emailBodyCopy.AppendLine("				<tr>");
            emailBodyCopy.AppendLine("					<td valign=\"top\">When:</td>");
            emailBodyCopy.AppendLine("					<td>" + dateString + "</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 <<RECIPIENT>>. 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>");

            string emailSubject = m_eventName + " on " + dateString + " has been updated";

            string SMTPServer = gd.GetStringValue("SMTPServer");
            string mailFromAddress = gd.GetStringValue("MailFromAddress");
            string mailFromUsername = gd.GetStringValue("MailFromUsername");
            string mailFromPassword = gd.GetStringValue("MailFromPassword");

            // Sent the message to the event owner as well as the trackers
            if (updatingUserID != m_userID)
            {
                if (eventOwner.enableSendEmails == true)
                {
                    try
                    {
                        MailMessage message = new MailMessage(mailFromAddress, eventOwner.emailAddress);
                        message.ReplyTo = new MailAddress("*****@*****.**");

                        message.Subject = emailSubject;
                        message.Body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", eventOwner.emailAddress);
                        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().Replace("<<RECIPIENT>>", eventOwner.emailAddress);
                        emailHistory.sentFrom = mailFromAddress;
                        emailHistory.sentTo = eventOwner.emailAddress;
                        emailHistory.Add();
                    }
                    catch (Exception ex)
                    {
                        SentEmailHistory emailHistory = new SentEmailHistory("");
                        emailHistory.subject = emailSubject;
                        emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", eventOwner.emailAddress);
                        emailHistory.sentFrom = mailFromAddress;
                        emailHistory.sentTo = eventOwner.emailAddress;
                        emailHistory.Add();
                    }
                }
            }

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

                SqlCommand cmd = new SqlCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectTrackingUsersByEventID";
                cmd.Parameters.Add("@EventID", SqlDbType.Int).Value = m_eventID;
                DbDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    //int trackedEventID = int.Parse(rdr["TrackedEventID"].ToString());
                    int userID = int.Parse(rdr["UserID"].ToString());
                    string firstName = (string)rdr["FirstName"];
                    string lastName = (string)rdr["LastName"];
                    //string gender = (string)rdr["Gender"];
                    //string homeTown = (string)rdr["HomeTown"];
                    string emailAddress = (string)rdr["EmailAddress"];

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

                                message.Subject = emailSubject;
                                message.Body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress);
                                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().Replace("<<RECIPIENT>>", emailAddress);
                                emailHistory.sentFrom = mailFromAddress;
                                emailHistory.sentTo = emailAddress;
                                emailHistory.Add();
                            }
                            catch (Exception ex)
                            {
                                SentEmailHistory emailHistory = new SentEmailHistory("");
                                emailHistory.subject = emailSubject;
                                emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress);
                                emailHistory.sentFrom = mailFromAddress;
                                emailHistory.sentTo = emailAddress;
                                emailHistory.Add();
                            }
                        }
                    }
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoEvent", "SendEventUpdateEmail", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#5
0
        //===============================================================
        // Function: SendBroadcastTestEmail
        //===============================================================
        public static void SendBroadcastTestEmail(string recipientEmailAddress)
        {
            GlobalData gd = new GlobalData("");

            string broadcastEmailSubject = gd.GetStringValue("BroadcastEmailSubject");
            string broadcastEmailContent = gd.GetStringValue("BroadcastEmailContent");

            string emailBodyCopy = BuildBroadcastEmail(broadcastEmailContent);

            string SMTPServer = gd.GetStringValue("SMTPServer");
            string mailFromAddress = gd.GetStringValue("MailFromAddress");
            string mailFromUsername = gd.GetStringValue("MailFromUsername");
            string mailFromPassword = gd.GetStringValue("MailFromPassword");

            try
            {
                MailMessage message = new MailMessage(mailFromAddress, recipientEmailAddress);
                message.ReplyTo = new MailAddress("*****@*****.**");

                message.Subject = broadcastEmailSubject;
                message.Body = emailBodyCopy.Replace("<<RECIPIENT>>", recipientEmailAddress);
                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 = broadcastEmailSubject;
                emailHistory.body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", recipientEmailAddress);
                emailHistory.sentFrom = mailFromAddress;
                emailHistory.sentTo = recipientEmailAddress;
                emailHistory.Add();
            }
            catch (Exception ex)
            {
                SentEmailHistory emailHistory = new SentEmailHistory("");
                emailHistory.subject = broadcastEmailSubject;
                emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", recipientEmailAddress);
                emailHistory.sentFrom = mailFromAddress;
                emailHistory.sentTo = recipientEmailAddress;
                emailHistory.Add();
            }
        }
示例#6
0
        //===============================================================
        // Function: SendBroadcastEmail
        //===============================================================
        public static void SendBroadcastEmail()
        {
            GlobalData gd = new GlobalData("");
            string broadcastEmailWaiting = gd.GetStringValue("BroadcastEmailWaiting");
            if (broadcastEmailWaiting == "Y")
            {
                // update this straight away - if the broadcast fails then it will not send again to all users
                gd.UpdateStringValue("BroadcastEmailWaiting", "N");

                string broadcastEmailSubject = gd.GetStringValue("BroadcastEmailSubject");
                string broadcastEmailContent = gd.GetStringValue("BroadcastEmailContent");

                string emailBodyCopy = BuildBroadcastEmail(broadcastEmailContent);

                string SMTPServer = gd.GetStringValue("SMTPServer");
                string mailFromAddress = gd.GetStringValue("MailFromAddress");
                string mailFromUsername = gd.GetStringValue("MailFromUsername");
                string mailFromPassword = gd.GetStringValue("MailFromPassword");

                // Get a list of all users
                SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
                try
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand("", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "spSelectUserList";
                    DbDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        string emailAddress = "";
                        string firstName = "";
                        string lastName = "";

                        int userID = int.Parse(rdr["UserID"].ToString());
                        if (!rdr.IsDBNull(rdr.GetOrdinal("EmailAddress")))
                        {
                            emailAddress = (string)rdr["EmailAddress"];
                        }
                        if (!rdr.IsDBNull(rdr.GetOrdinal("FirstName")))
                        {
                            firstName = (string)rdr["FirstName"];
                        }
                        if (!rdr.IsDBNull(rdr.GetOrdinal("LastName")))
                        {
                            lastName = (string)rdr["LastName"];
                        }
                        Boolean enableSendEmails = (Boolean)rdr["EnableSendEmails"];

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

                                message.Subject = broadcastEmailSubject;
                                message.Body = emailBodyCopy.Replace("<<RECIPIENT>>", emailAddress);
                                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 = broadcastEmailSubject;
                                emailHistory.body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress);
                                emailHistory.sentFrom = mailFromAddress;
                                emailHistory.sentTo = emailAddress;
                                emailHistory.Add();
                            }
                            catch (Exception ex)
                            {
                                SentEmailHistory emailHistory = new SentEmailHistory("");
                                emailHistory.subject = broadcastEmailSubject;
                                emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress);
                                emailHistory.sentFrom = mailFromAddress;
                                emailHistory.sentTo = emailAddress;
                                emailHistory.Add();
                            }
                        }
                    }
                    rdr.Close();
                }
                catch (Exception ex)
                {
                    ErrorLog errorLog = new ErrorLog();
                    errorLog.WriteLog("MiscUtils", "SendBroadcastEmail", ex.Message, logMessageLevel.errorMessage);
                    throw ex;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
示例#7
0
        //===============================================================
        // Function: CreatePreviews
        // Description:
        //===============================================================
        public static int CreatePreviews(string fullFileName)
        {
            int returnStatus = -1;
            string filename = Path.GetFileName(fullFileName);
            string filePath = Path.GetFullPath(fullFileName);
            GlobalData gd = new GlobalData("");
            int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
            int previewSize = gd.GetIntegerValue("PreviewSize");
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\profilePics";
            string thumbnailFileName = "";
            string previewFileName = "";
             //           File.Copy(fullFileName, Path.Combine(fileStoreFolderTemp, filename));
            int thumbnailStatus = GenerateThumbnail(filePath,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(filePath, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(filePath, previewFileName));

                //File.Move(Path.Combine(fileStoreFolderTemp, filename), destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);
                returnStatus = 0;
            }

            return returnStatus;
        }
示例#8
0
        //===============================================================
        // Function: CreatePreviews
        // Description:
        //===============================================================
        public static int CreatePreviews(string filename, int userID)
        {
            int returnStatus = -1;

            GlobalData gd = new GlobalData("");
            int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
            int previewSize = gd.GetIntegerValue("PreviewSize");
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\profilePics";
            string thumbnailFileName = "";
            string previewFileName = "";

            int thumbnailStatus = GenerateThumbnail(fileStoreFolderTemp,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, previewFileName));

                File.Move(Path.Combine(fileStoreFolderTemp, filename),
                    destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);

                SedogoUser user = new SedogoUser("", userID);
                user.profilePicFilename = filename;
                user.profilePicPreview = previewFileName;
                user.profilePicThumbnail = thumbnailFileName;
                user.UpdateUserProfilePic();

                returnStatus = 0;
            }

            return returnStatus;
        }
示例#9
0
        //===============================================================
        // Function: CreateGoalPicPreviews
        // Description:
        //===============================================================
        public static int CreateGoalPicPreviews(string filename, int eventID, string loggedInContactName,
            int postedByUserID, string caption)
        {
            int returnStatus = -1;

            GlobalData gd = new GlobalData("");
            int thumbnailSize =  gd.GetIntegerValue("ThumbnailSize");//100;
            int previewSize =  gd.GetIntegerValue("PreviewSize");//500;
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\eventPics";

            string thumbnailFileName = "";
            string previewFileName = "";
            int thumbnailStatus = GenerateThumbnail(fileStoreFolderTemp,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, previewFileName));

                File.Move(Path.Combine(fileStoreFolderTemp, filename),
                    destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);

                SedogoEventPicture pic = new SedogoEventPicture(loggedInContactName);
                pic.eventID = eventID;
                pic.postedByUserID = postedByUserID;
                pic.eventImageFilename = Path.GetFileName(destFilename);
                pic.eventImagePreview = Path.GetFileName(destPreviewFilename);
                pic.eventImageThumbnail = Path.GetFileName(destThumbnailFilename);
                pic.caption = caption;
                pic.Add();

                returnStatus = pic.eventPictureID;
            }

            return returnStatus;
        }
示例#10
0
        //===============================================================
        // Function: CreateEventCommentImagePreviews
        // Description:
        //===============================================================
        public static int CreateEventCommentImagePreviews(string filename,
            out string savedFileName, out string thumbnailFileName, out string previewFileName)
        {
            int returnStatus = -1;

            GlobalData gd = new GlobalData("");
            int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
            int previewSize = 500;  // gd.GetIntegerValue("PreviewSize");
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\eventPics";
            savedFileName = "";
            thumbnailFileName = "";
            previewFileName = "";

            // Just for the goal comments, if the image is smaller than 500, leave it at its
            // original size
            System.Drawing.Image sourceImagePreview = System.Drawing.Image.FromFile(fileStoreFolderTemp + @"\" + filename);
            if (sourceImagePreview.Width < previewSize)
            {
                previewSize = sourceImagePreview.Width;
            }
            sourceImagePreview.Dispose();

            int thumbnailStatus = GenerateThumbnail(fileStoreFolderTemp,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, previewFileName));

                File.Move(Path.Combine(fileStoreFolderTemp, filename),
                    destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);

                savedFileName = destFilename;
                thumbnailFileName = destThumbnailFilename;
                previewFileName = destPreviewFilename;

                returnStatus = 0;
            }

            return returnStatus;
        }