Exemplo n.º 1
0
        /// <summary>
        /// This method will call the Event Resource class method to Add the event in the database
        /// And send the email to all admin about the event insertion for all public event
        /// </summary>
        /// <param name="objEvent">An Event Object which contain Event information</param>
        public void SaveEvent(Events objEvent)
        {
            try
            {
                EventResource objEventRes = new EventResource();
                object identity = objEventRes.SaveEvent(objEvent);

                // Send the email to all the adminstrator if event is public that event has been created
                if ((objEvent != null) && (objEvent.CustomError == null) && (identity != null)
                    && (int.Parse(identity.ToString()) != 0) && (objEvent.IsPrivate == false))
                {
                    string EmailSubject = objEvent.FirstName + " " + objEvent.LastName + " added a new event on Your " + WebConfig.ApplicationWordForInternalUse.ToString() + "...";
                    string EmailBody = "<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + objEvent.FirstName + " " + objEvent.LastName + " added a new event in the " + objEvent.TributeName + " " + objEvent.TributeType + " " + WebConfig.ApplicationWordForInternalUse.ToString() + ".</p><p> To view the event, follow the link below: <br/> " + objEvent.ServerURL + " </p>" + "<p>----" + "<br/>" + "Your " + WebConfig.ApplicationWord.ToString() + " Team</p></font>";

                    SendEmail(objEvent.TributeId, EmailSubject, EmailBody.Replace("##", identity.ToString()));
                }

                // If an event name an event type combination already exist in database then
                // return an error message
                if (int.Parse(identity.ToString()) == 0)
                {
                    Errors objError = new Errors();
                    objError.ErrorMessage = "This Event Name '" + objEvent.EventName + "' with this Event Type already exist";
                    objEvent.CustomError = objError;
                }
                else    // otherwise return the eventid
                {
                    objEvent.EventID = int.Parse(identity.ToString());
                }

                SessionValue objSessionValue = null;
                StateManager objStateManager = StateManager.Instance;
                objSessionValue = (SessionValue)objStateManager.Get(PortalEnums.SessionValueEnum.objSessionvalue.ToString(), StateManager.State.Session);
                if ((objEvent != null) && (objEvent.CustomError == null) && (identity != null)
                   && (int.Parse(identity.ToString()) != 0))
                {
                   object value =  objEventRes.SaveRsvpForCreator(objEvent,objSessionValue);
                   if (value != null)
                   {
                       if (int.Parse(value.ToString()) != 0)
                       {
                           //Insert the Hashcode for the Guest
                           string Hashcode = GetHashCode(int.Parse(value.ToString()));
                           objEventRes.InsertHashCodeForGuest(int.Parse(value.ToString()), Hashcode);
                       }
                   }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method will call the Event resource method to invite the guest for the event
        /// </summary>
        /// <param name="objEvent">An Event Object which contain event id and Guest List</param>
        public int InviteGuest(Events objEvent)
        {
            int count = 0;

            try
            {
                StateManager objStateManager = StateManager.Instance;
                SessionValue objSessionValue = (SessionValue)objStateManager.Get(PortalEnums.SessionValueEnum.objSessionvalue.ToString(), StateManager.State.Session);

                StateManager objStateManager_ = StateManager.Instance;
                Tributes objTribute = (Tributes)objStateManager_.Get(PortalEnums.SessionValueEnum.TributeSession.ToString(), StateManager.State.Session);

                TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance;
                string Servername = (string)stateManager.Get("SERVERNAME", TributesPortal.Utilities.StateManager.State.Session);

                EventResource objEventRes = new EventResource();
                Events objEventDetails = objEventRes.GetEventInfo(objEvent);

                //Added by amit
                objEventDetails.EventID = objEvent.EventID;
                objEventDetails.TributeId = objEvent.TributeId;
                objEventDetails.IsActive = true;
                objEventDetails.UserId = objEvent.UserId;
                objEventDetails.ModifiedBy = objEvent.UserId;
                objEventDetails.TributeType = objEvent.TributeType;
                objEventDetails.EventThemeID = objEvent.EventThemeID;
                objEventDetails.EventMessage = objEvent.EventMessage;
                objEventDetails.State = objEvent.State;
               // objEventDetails.IsAskForMeal = objEventRes.IsAskForMeal;
                objEventRes.UpdateEvent(objEventDetails);

                string EmailSubject = objSessionValue.FirstName + " " + objSessionValue.LastName + " invited you to the event \"" + objEventDetails.EventName + "\"";
                for (int i = 0; i < objEvent.EventAwaiting.Count; i++)
                {
                    Events emailEvent = new Events();
                    emailEvent.EventID = objEvent.EventID;
                    emailEvent.EmailId = objEvent.EventAwaiting[i].UserName.ToString();
                    emailEvent.IsAskForMeal = objEventDetails.IsAskForMeal;
                    emailEvent.MealOptions = objEventDetails.MealOptions;
                    object identity = objEventRes.InviteGuest(emailEvent);
                    if (identity != null)
                    {
                        if (int.Parse(identity.ToString()) != 0)
                        {
                            //Insert the Hashcode for the Guest
                            string Hashcode = GetHashCode(int.Parse(identity.ToString()));
                            objEventRes.InsertHashCodeForGuest(int.Parse(identity.ToString()), Hashcode);

                            EmailMessages objEmail = EmailMessages.Instance;

                            EventTheme objTheme = GetEventThemeByID(objEventDetails.EventThemeID);

                            StringBuilder objEmailBody = new StringBuilder();
                            objEmailBody.Append("<html>");
                            objEmailBody.Append("<head>");
                            objEmailBody.Append("<title>Event Invitation Mail</title>");
                            objEmailBody.Append("</head>");
                            objEmailBody.Append("<body text='#000000' link='#000000'>");
                            objEmailBody.Append("<table width='700' border='0' align='center' cellpadding='0' cellspacing='0'>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><table width='100%' border='0' cellspacing='10' cellpadding='0'>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>Having trouble seeing this email? <a href='http://" + objEventDetails.TributeType.Replace("New Baby", "newbaby").ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "/event.aspx?EventID=" + objEventDetails.EventID + "'> Visit our Event webpage.</a></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("</table></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td><table width='520' height='650' border='0' align='center' cellpadding='0' cellspacing='10' bgcolor='" + objTheme.ThemeBackgroundColor + "'>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><img src='" + GetImageURL(objTheme.ThemeFullSizeImage) + "' alt='Invitation Photo' /></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>&nbsp;</font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><strong><font size='4' face='Verdana, Arial, Helvetica, sans-serif'>" + objEventDetails.EventName + " </font></strong></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>" + objEventDetails.EventMessage + " </font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>When:</strong></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>" + DateTime.Parse(objEventDetails.EventDate.ToString()).ToString("MMMM dd, yyyy") + ", " + objEventDetails.EventStartTime + " - " + objEventDetails.EventEndTime + "</font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>Where:</strong></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>" + objEventDetails.EventPlace + "</font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>Website:</strong></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><a href='http://" + objEventDetails.TributeType.Replace("New Baby", "newbaby").ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "/'>http://" + objEventDetails.TributeType.Replace("New Baby", "newbaby").ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "/</a></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>&nbsp;</font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("</table>");
                            objEmailBody.Append("</td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td><table width='100%' border='0' cellspacing='10' cellpadding='0'>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><a href='http://" + objEventDetails.TributeType.Replace("New Baby", "newbaby").ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "/event.aspx?EventID=" + objEventDetails.EventID + "&TributeID=" + objEventDetails.TributeId + "&Hashcode=" + Hashcode + "'><b><font size='4' face='Verdana, Arial, Helvetica, sans-serif'>Please visit our " + objEventDetails.TributeType + " Tribute to RSVP</font></b></a></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("</table>");
                            objEmailBody.Append("</td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td><table width='100%' border='0' cellspacing='5' cellpadding='0'>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font color='#666666' size='1' face='Verdana, Arial, Helvetica, sans-serif'>This email has a unique link just for you, please do not forward it to others.</font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font color='#666666' size='1' face='Verdana, Arial, Helvetica, sans-serif'>Your Tribute respects your privacy. For any privacy concerns please <a href='"+ WebConfig.AppBaseDomain +"privacy.aspx'>click here.</a></font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font color='#666666' size='1' face='Verdana, Arial, Helvetica, sans-serif'>Your Tribute, Inc.</font></td>");
                            objEmailBody.Append("</tr>");
                            objEmailBody.Append("<tr>");
                            objEmailBody.Append("<td align='center'><font color='#666666' size='1' face='Verdana, Arial, Helvetica, sans-serif'>2875 North Lamb Blvd. Bldg 8, Las Vegas, NV 89115</font></td>");
                            objEmailBody.Append("</tr></table></td>");
                            objEmailBody.Append("</tr></table></body></html>");

                            bool val = objEmail.SendMessages("Your Tribute<" + WebConfig.NoreplyEmail + ">", emailEvent.EmailId, EmailSubject, objEmailBody.ToString(), EmailMessages.TextFormat.Html.ToString());
                            count++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return count;
        }