public void grdEnrollment_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            var objEnroll = default(EventSignupsInfo);

            objEnroll = _objCtlEventSignups.EventsSignupsGet(
                Convert.ToInt32(grdEnrollment.DataKeys[e.Item.ItemIndex]), ModuleId, false);

            try
            {
                switch (e.CommandName)
                {
                case "Select":
                    try
                    {
                        var itemID             = objEnroll.EventID;
                        var objEventInfoHelper =
                            new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                        Response.Redirect(
                            objEventInfoHelper.AddSkinContainerControls(
                                EditUrl("ItemID", itemID.ToString(), "Edit"), "?"));
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch (Exception)
                    { }
                    break;

                case "User":
                    var objCtlEvent = new EventController();
                    var objEvent    = objCtlEvent.EventsGet(objEnroll.EventID, objEnroll.ModuleID);

                    var objEventEmailInfo = new EventEmailInfo();
                    var objEventEmail     = new EventEmails(PortalId, ModuleId, LocalResourceFile,
                                                            ((PageBase)Page).PageCulture.Name);
                    objEventEmailInfo.TxtEmailSubject = txtEmailSubject.Text;
                    objEventEmailInfo.TxtEmailBody    = txtEmailMessage.Text;
                    objEventEmailInfo.TxtEmailFrom    = txtEmailFrom.Text;
                    if (objEnroll.UserID > -1)
                    {
                        objEventEmailInfo.UserIDs.Add(objEnroll.UserID);
                    }
                    else
                    {
                        objEventEmailInfo.UserEmails.Add(objEnroll.AnonEmail);
                        objEventEmailInfo.UserLocales.Add(objEnroll.AnonCulture);
                        objEventEmailInfo.UserTimeZoneIds.Add(objEnroll.AnonTimeZoneId);
                    }
                    objEventEmail.SendEmails(objEventEmailInfo, objEvent, objEnroll);
                    break;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
            BindData();
        }
        protected void lnkSelectedDelete_Click(object sender, EventArgs e)
        {
            var item               = default(DataGridItem);
            var objEnroll          = default(EventSignupsInfo);
            var objCtlEventSignups = new EventSignupsController();
            var objEvent           = new EventInfo();
            var objCtlEvent        = new EventController();
            var eventID            = 0;

            foreach (DataGridItem tempLoopVar_item in grdEnrollment.Items)
            {
                item = tempLoopVar_item;
                if (((CheckBox)item.FindControl("chkSelect")).Checked)
                {
                    objEnroll = objCtlEventSignups.EventsSignupsGet(
                        Convert.ToInt32(grdEnrollment.DataKeys[item.ItemIndex]), ModuleId, false);
                    if (eventID != objEnroll.EventID)
                    {
                        objEvent = objCtlEvent.EventsGet(objEnroll.EventID, ModuleId);
                    }
                    eventID = objEnroll.EventID;

                    // Delete Selected Enrollee
                    DeleteEnrollment(Convert.ToInt32(grdEnrollment.DataKeys[item.ItemIndex]),
                                     objEvent.ModuleID, objEvent.EventID);

                    // Mail users
                    if (Settings.SendEnrollMessageDeleted)
                    {
                        var objEventEmailInfo = new EventEmailInfo();
                        var objEventEmail     = new EventEmails(PortalId, ModuleId, LocalResourceFile,
                                                                ((PageBase)Page).PageCulture.Name);
                        objEventEmailInfo.TxtEmailSubject = Settings.Templates.txtEnrollMessageSubject;
                        objEventEmailInfo.TxtEmailBody    = Settings.Templates.txtEnrollMessageDeleted;
                        objEventEmailInfo.TxtEmailFrom    = Settings.StandardEmail;
                        objEventEmailInfo.UserEmails.Add(PortalSettings.UserInfo.Email);
                        objEventEmailInfo.UserLocales.Add(PortalSettings.UserInfo.Profile.PreferredLocale);
                        objEventEmailInfo.UserTimeZoneIds.Add(PortalSettings.UserInfo.Profile.PreferredTimeZone
                                                              .Id);
                        objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                        objEventEmail.SendEmails(objEventEmailInfo, objEvent, objEnroll);
                    }
                }
            }

            BindData();
        }
        protected void cmdUpdateSelected_Click(object sender, EventArgs e)
        {
            var item          = default(DataGridItem);
            var objEventEmail = new EventEmails(this.PortalId, this.ModuleId, this.LocalResourceFile,
                                                ((PageBase)this.Page).PageCulture.Name);

            try
            {
                switch (this.rbModerate.SelectedValue)
                {
                case "Events":
                    var objEventEmailInfo_1 = new EventEmailInfo();
                    objEventEmailInfo_1.TxtEmailSubject = this.txtEmailSubject.Text;
                    objEventEmailInfo_1.TxtEmailBody    = this.txtEmailMessage.Text;
                    objEventEmailInfo_1.TxtEmailFrom    = this.txtEmailFrom.Text;
                    var objCal = new EventInfo();
                    var objEventRecurMaster = default(EventRecurMasterInfo);
                    foreach (DataGridItem tempLoopVar_item in this.grdEvents.Items)
                    {
                        item = tempLoopVar_item;
                        switch (((RadioButtonList)item.FindControl("rbEventAction")).SelectedValue)
                        {
                        case "Approve":
                            objCal = this._objCtlEvent.EventsGet(
                                Convert.ToInt32(this.grdEvents.DataKeys[item.ItemIndex]),
                                this.ModuleId);
                            objCal.Approved = true;
                            var newEventEmailSent = objCal.NewEventEmailSent;
                            objCal.NewEventEmailSent = true;
                            this._objCtlEvent.EventsSave(objCal, true, this.TabId, false);
                            // Only send event emails when event approved for first time
                            if (!newEventEmailSent)
                            {
                                objCal.RRULE = "";
                                this.SendNewEventEmails(objCal);
                                this.CreateNewEventJournal(objCal);
                            }
                            // Email Requesting/Moderated User
                            if (this.chkEmail.Checked)
                            {
                                objCal.RRULE = "";
                                objEventEmailInfo_1.UserIDs.Clear();
                                objEventEmailInfo_1.UserIDs.Add(objCal.OwnerID);
                                objEventEmail.SendEmails(objEventEmailInfo_1, objCal);
                            }
                            break;

                        case "Deny":
                            objCal = this._objCtlEvent.EventsGet(
                                Convert.ToInt32(this.grdEvents.DataKeys[item.ItemIndex]),
                                this.ModuleId);
                            //Don't Allow Delete on Enrolled Event - Only Cancel
                            objEventRecurMaster =
                                this._objCtlEventRecurMaster.EventsRecurMasterGet(
                                    objCal.RecurMasterID, objCal.ModuleID);
                            if (objEventRecurMaster.RRULE != "")
                            {
                                objCal.Cancelled     = true;
                                objCal.LastUpdatedID = this.UserId;
                                objCal = this._objCtlEvent.EventsSave(objCal, false, this.TabId, true);
                            }
                            else
                            {
                                this._objCtlEventRecurMaster.EventsRecurMasterDelete(
                                    objCal.RecurMasterID, objCal.ModuleID);
                            }
                            // Email Requesting/Moderated User
                            if (this.chkEmail.Checked)
                            {
                                objCal.RRULE = "";
                                objEventEmailInfo_1.UserIDs.Clear();
                                objEventEmailInfo_1.UserIDs.Add(objCal.OwnerID);
                                objEventEmail.SendEmails(objEventEmailInfo_1, objCal);
                            }
                            break;
                        }
                    }
                    foreach (DataGridItem tempLoopVar_item in this.grdRecurEvents.Items)
                    {
                        item = tempLoopVar_item;
                        switch (((RadioButtonList)item.FindControl("rbEventRecurAction")).SelectedValue)
                        {
                        case "Approve":
                            objEventRecurMaster =
                                this._objCtlEventRecurMaster.EventsRecurMasterGet(
                                    Convert.ToInt32(this.grdRecurEvents.DataKeys[item.ItemIndex]),
                                    this.ModuleId);
                            objEventRecurMaster.Approved = true;
                            this._objCtlEventRecurMaster.EventsRecurMasterSave(
                                objEventRecurMaster, this.TabId, false);
                            var lstEvents = default(ArrayList);
                            lstEvents = this._objCtlEvent.EventsGetRecurrences(
                                objEventRecurMaster.RecurMasterID,
                                objEventRecurMaster.ModuleID);
                            var blEmailSent = false;
                            foreach (EventInfo tempLoopVar_objCal in lstEvents)
                            {
                                objCal = tempLoopVar_objCal;
                                if (!objCal.Cancelled)
                                {
                                    objCal.Approved = true;
                                    var newEventEmailSent = objCal.NewEventEmailSent;
                                    objCal.NewEventEmailSent = true;
                                    this._objCtlEvent.EventsSave(objCal, true, this.TabId, false);
                                    // Only send event emails when event approved for first time
                                    if (!newEventEmailSent && !blEmailSent)
                                    {
                                        objCal.RRULE = objEventRecurMaster.RRULE;
                                        this.SendNewEventEmails(objCal);
                                        this.CreateNewEventJournal(objCal);
                                        blEmailSent = true;
                                    }
                                }
                            }
                            // Email Requesting/Moderated User
                            if (this.chkEmail.Checked)
                            {
                                objCal.RRULE = objEventRecurMaster.RRULE;
                                objEventEmailInfo_1.UserIDs.Clear();
                                objEventEmailInfo_1.UserIDs.Add(objEventRecurMaster.CreatedByID);
                                objEventEmail.SendEmails(objEventEmailInfo_1, objCal);
                            }
                            break;

                        case "Deny":
                            objEventRecurMaster =
                                this._objCtlEventRecurMaster.EventsRecurMasterGet(
                                    Convert.ToInt32(this.grdRecurEvents.DataKeys[item.ItemIndex]),
                                    this.ModuleId);
                            //Don't Allow Delete on Enrolled Event - Only Cancel
                            this._objCtlEventRecurMaster.EventsRecurMasterDelete(
                                Convert.ToInt32(this.grdRecurEvents.DataKeys[item.ItemIndex]),
                                this.ModuleId);
                            // Email Requesting/Moderated User
                            if (this.chkEmail.Checked)
                            {
                                objCal.RRULE = objEventRecurMaster.RRULE;
                                objEventEmailInfo_1.UserIDs.Clear();
                                objEventEmailInfo_1.UserIDs.Add(objEventRecurMaster.CreatedByID);
                                objEventEmail.SendEmails(objEventEmailInfo_1, objCal);
                            }
                            break;
                        }
                    }
                    break;

                case "Enrollment":
                    // Not moderated
                    var objEnroll = default(EventSignupsInfo);
                    foreach (DataGridItem tempLoopVar_item in this.grdEnrollment.Items)
                    {
                        item = tempLoopVar_item;
                        if (((RadioButtonList)item.FindControl("rbEnrollAction")).SelectedValue != "")
                        {
                            objEnroll = this._objCtlEventSignups.EventsSignupsGet(
                                Convert.ToInt32(this.grdEnrollment.DataKeys[item.ItemIndex]),
                                this.ModuleId, false);
                            var objCtlEvent       = new EventController();
                            var objEvent          = objCtlEvent.EventsGet(objEnroll.EventID, objEnroll.ModuleID);
                            var objEventEmailInfo = new EventEmailInfo();
                            objEventEmailInfo.TxtEmailSubject = this.txtEmailSubject.Text;
                            objEventEmailInfo.TxtEmailFrom    = this.txtEmailFrom.Text;
                            if (this.chkEmail.Checked)
                            {
                                if (objEnroll.UserID > -1)
                                {
                                    objEventEmailInfo.UserIDs.Add(objEnroll.UserID);
                                }
                                else
                                {
                                    objEventEmailInfo.UserEmails.Add(objEnroll.AnonEmail);
                                    objEventEmailInfo.UserLocales.Add(objEnroll.AnonCulture);
                                    objEventEmailInfo.UserTimeZoneIds.Add(objEnroll.AnonTimeZoneId);
                                }
                            }
                            switch (((RadioButtonList)item.FindControl("rbEnrollAction")).SelectedValue)
                            {
                            case "Approve":
                                objEnroll.Approved = true;
                                this.CreateEnrollment(objEnroll, objEvent);

                                // Email Requesting/Moderated User
                                if (this.Settings.SendEnrollMessageApproved)
                                {
                                    objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                                }
                                objEventEmailInfo.TxtEmailBody =
                                    this.txtEmailMessage.Text +
                                    this.Settings.Templates.txtEnrollMessageApproved;
                                objEventEmail.SendEmails(objEventEmailInfo, objEvent, objEnroll);
                                break;

                            case "Deny":
                                this.DeleteEnrollment(
                                    Convert.ToInt32(this.grdEnrollment.DataKeys[item.ItemIndex]),
                                    objEvent.ModuleID, objEvent.EventID);

                                // Email Requesting/Moderated User
                                if (this.Settings.SendEnrollMessageDenied)
                                {
                                    objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                                }
                                objEventEmailInfo.TxtEmailBody =
                                    this.txtEmailMessage.Text + this.Settings.Templates.txtEnrollMessageDenied;
                                objEventEmail.SendEmails(objEventEmailInfo, objEvent, objEnroll);
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
            this.BindData();
        }
Exemple #4
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                double dblTotal    = 0;
                var    strCurrency = "";

                if (!ReferenceEquals(this.Request.Params["ItemID"], null))
                {
                    this._itemID = int.Parse(this.Request.Params["ItemID"]);
                }
                if (!ReferenceEquals(this.Request.Params["AnonEmail"], null))
                {
                    this._anonEmail = HttpUtility.UrlDecode(this.Request.Params["AnonEmail"]);
                }
                if (!ReferenceEquals(this.Request.Params["AnonName"], null))
                {
                    this._anonName = HttpUtility.UrlDecode(this.Request.Params["AnonName"]);
                }
                if (!ReferenceEquals(this.Request.Params["AnonPhone"], null))
                {
                    this._anonTelephone = HttpUtility.UrlDecode(this.Request.Params["AnonPhone"]);
                    if (this._anonTelephone == "0")
                    {
                        this._anonTelephone = "";
                    }
                }

                // Set the selected theme
                this.SetTheme(this.pnlEventsModulePayPal);

                this.divMessage.Attributes.Add("style", "display:none;");

                if (!this.Page.IsPostBack)
                {
                    if (this._itemID != -1)
                    {
                        if (!ReferenceEquals(this.Request.Params["NoEnrol"], null))
                        {
                            this._noEnrol = int.Parse(this.Request.Params["NoEnrol"]);
                        }

                        var objEvent = default(EventInfo);
                        objEvent = this._objCtlEvent.EventsGet(this._itemID, this.ModuleId);

                        //  Compute Dates/Times (for recurring)
                        var startdate = objEvent.EventTimeBegin;
                        this.SelectedDate = startdate.Date;
                        var d = default(DateTime);
                        d = startdate.Date.AddMinutes(objEvent.EventTimeBegin.TimeOfDay.TotalMinutes);
                        this.lblStartDate.Text   = d.ToLongDateString() + " " + d.ToShortTimeString();
                        this.lblEventName.Text   = objEvent.EventName;
                        this.lblDescription.Text = this.Server.HtmlDecode(objEvent.EventDesc);
                        this.lblFee.Text         = string.Format("{0:#0.00}", objEvent.EnrollFee);
                        this.lblNoEnrolees.Text  = Convert.ToString(this._noEnrol);
                        this.lblPurchase.Text    = Localization.GetString("lblPurchase", this.LocalResourceFile);
                        this.lblPurchase.Visible = true;
                    }
                    else if (!ReferenceEquals(this.Request.Params["signupid"], null))
                    {
                        // Get EventSignup
                        this._objEventSignups = new EventSignupsInfo();
                        var signupID = Convert.ToInt32(this.Request.Params["signupid"]);
                        this._objEventSignups =
                            this._objCtlEventSignups.EventsSignupsGet(signupID, this.ModuleId, false);
                        this.lblStartDate.Text = this._objEventSignups.EventTimeBegin.ToLongDateString() + " " +
                                                 this._objEventSignups.EventTimeBegin.ToShortTimeString();
                        this.lblEventName.Text = this._objEventSignups.EventName;
                        // Get Related Event
                        var objEvent = default(EventInfo);
                        objEvent = this._objCtlEvent.EventsGet(this._objEventSignups.EventID,
                                                               this._objEventSignups.ModuleID);
                        this.lblDescription.Text = this.Server.HtmlDecode(objEvent.EventDesc);
                        this.lblFee.Text         = string.Format("{0:#0.00}", objEvent.EnrollFee);
                        this.lblNoEnrolees.Text  = Convert.ToString(this._objEventSignups.NoEnrolees);
                        if (this.Request.Params["status"].ToLower() == "enrolled")
                        {
                            // User has been successfully enrolled for this event (paid enrollment)
                            this.ShowMessage(Localization.GetString("lblComplete", this.LocalResourceFile),
                                             MessageLevel.DNNSuccess);
                            this.lblPurchase.Visible  = false;
                            this.cmdPurchase.Visible  = false;
                            this.cancelButton.Visible = false;
                            this.cmdReturn.Visible    = true;
                        }
                        else if (this.Request.Params["status"].ToLower() == "cancelled")
                        {
                            // User has been cancelled paid enrollment
                            this.ShowMessage(Localization.GetString("lblCancel", this.LocalResourceFile),
                                             MessageLevel.DNNWarning);
                            this.lblPurchase.Visible  = false;
                            this.cmdPurchase.Visible  = false;
                            this.cancelButton.Visible = false;
                            this.cmdReturn.Visible    = true;
                            // Make sure we delete the signup
                            this.DeleteEnrollment(signupID, objEvent.ModuleID, objEvent.EventID);

                            // Mail users
                            if (this.Settings.SendEnrollMessageCancelled)
                            {
                                var objEventEmailInfo = new EventEmailInfo();
                                var objEventEmail     =
                                    new EventEmails(this.PortalId, this.ModuleId, this.LocalResourceFile,
                                                    ((PageBase)this.Page).PageCulture.Name);
                                objEventEmailInfo.TxtEmailSubject = this.Settings.Templates.txtEnrollMessageSubject;
                                objEventEmailInfo.TxtEmailBody    = this.Settings.Templates.txtEnrollMessageCancelled;
                                objEventEmailInfo.TxtEmailFrom    = this.Settings.StandardEmail;
                                if (this._objEventSignups.UserID > -1)
                                {
                                    objEventEmailInfo.UserIDs.Add(this._objEventSignups.UserID);
                                }
                                else
                                {
                                    objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail);
                                    objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture);
                                    objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId);
                                }
                                objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                                objEventEmail.SendEmails(objEventEmailInfo, objEvent, this._objEventSignups);
                            }
                        }
                    }
                    else // security violation attempt to access item not related to this Module
                    {
                        this.Response.Redirect(this.GetSocialNavigateUrl(), true);
                    }
                }

                dblTotal                   = Conversion.Val(this.lblFee.Text) * Conversion.Val(this.lblNoEnrolees.Text);
                this.lblTotal.Text         = Strings.Format(dblTotal, "#,##0.00");
                strCurrency                = this.PortalSettings.Currency;
                this.lblFeeCurrency.Text   = strCurrency;
                this.lblTotalCurrency.Text = strCurrency;
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #5
0
        protected void cmdPurchase_Click(object sender, EventArgs e)
        {
            var objEvent = default(EventInfo);

            try
            {
                if (this.Page.IsValid)
                {
                    objEvent = this._objCtlEvent.EventsGet(this._itemID, this.ModuleId);
                    // User wants to purchase event, create Event Signup Record
                    this._objEventSignups = new EventSignupsInfo();

                    //Just in case the user has clicked back and has now clicked Purchase again!!
                    var objEventSignupsChk = default(EventSignupsInfo);
                    if (string.IsNullOrEmpty(this._anonEmail))
                    {
                        objEventSignupsChk =
                            this._objCtlEventSignups.EventsSignupsGetUser(
                                objEvent.EventID, this.UserId, objEvent.ModuleID);
                    }
                    else
                    {
                        objEventSignupsChk =
                            this._objCtlEventSignups.EventsSignupsGetAnonUser(
                                objEvent.EventID, this._anonEmail, objEvent.ModuleID);
                    }
                    if (!ReferenceEquals(objEventSignupsChk, null))
                    {
                        this._objEventSignups.SignupID = objEventSignupsChk.SignupID;
                    }
                    this._objEventSignups.EventID  = objEvent.EventID;
                    this._objEventSignups.ModuleID = objEvent.ModuleID;
                    if (string.IsNullOrEmpty(this._anonEmail))
                    {
                        this._objEventSignups.UserID         = this.UserId;
                        this._objEventSignups.AnonEmail      = null;
                        this._objEventSignups.AnonName       = null;
                        this._objEventSignups.AnonTelephone  = null;
                        this._objEventSignups.AnonCulture    = null;
                        this._objEventSignups.AnonTimeZoneId = null;
                    }
                    else
                    {
                        var objSecurity = new PortalSecurity();
                        this._objEventSignups.UserID    = -1;
                        this._objEventSignups.AnonEmail =
                            objSecurity.InputFilter(this._anonEmail, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonName =
                            objSecurity.InputFilter(this._anonName, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonTelephone =
                            objSecurity.InputFilter(this._anonTelephone, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonCulture    = Thread.CurrentThread.CurrentCulture.Name;
                        this._objEventSignups.AnonTimeZoneId = this.GetDisplayTimeZoneId();
                    }
                    this._objEventSignups.PayPalStatus      = "none";
                    this._objEventSignups.PayPalReason      = "PayPal call initiated...";
                    this._objEventSignups.PayPalPaymentDate = DateTime.UtcNow;
                    this._objEventSignups.Approved          = false;
                    this._objEventSignups.NoEnrolees        = int.Parse(this.lblNoEnrolees.Text);

                    this._objEventSignups = this.CreateEnrollment(this._objEventSignups, objEvent);

                    if (!ReferenceEquals(objEventSignupsChk, null))
                    {
                        this._objEventSignups =
                            this._objCtlEventSignups.EventsSignupsGet(objEventSignupsChk.SignupID,
                                                                      objEventSignupsChk.ModuleID, false);
                    }

                    // Mail users
                    if (this.Settings.SendEnrollMessagePaying)
                    {
                        var objEventEmailInfo = new EventEmailInfo();
                        var objEventEmail     = new EventEmails(this.PortalId, this.ModuleId, this.LocalResourceFile,
                                                                ((PageBase)this.Page).PageCulture.Name);
                        objEventEmailInfo.TxtEmailSubject = this.Settings.Templates.txtEnrollMessageSubject;
                        objEventEmailInfo.TxtEmailBody    = this.Settings.Templates.txtEnrollMessagePaying;
                        objEventEmailInfo.TxtEmailFrom    = this.Settings.StandardEmail;
                        if (string.IsNullOrEmpty(this._anonEmail))
                        {
                            objEventEmailInfo.UserEmails.Add(this.PortalSettings.UserInfo.Email);
                            objEventEmailInfo.UserLocales.Add(this.PortalSettings.UserInfo.Profile.PreferredLocale);
                            objEventEmailInfo.UserTimeZoneIds.Add(this.PortalSettings.UserInfo.Profile.PreferredTimeZone
                                                                  .Id);
                        }
                        else
                        {
                            objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail);
                            objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture);
                            objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId);
                        }
                        objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                        objEventEmail.SendEmails(objEventEmailInfo, objEvent, this._objEventSignups);
                    }

                    // build PayPal URL
                    var ppurl = this.Settings.Paypalurl + "/cgi-bin/webscr?cmd=_xclick&business=";

                    var socialGroupId = this.GetUrlGroupId();

                    var objEventInfoHelper =
                        new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
                    var returnURL = "";
                    if (socialGroupId > 0)
                    {
                        returnURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=enrolled", "groupid=" + socialGroupId), "?");
                    }
                    else
                    {
                        returnURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=enrolled"), "?");
                    }
                    if (returnURL.IndexOf("://") + 1 == 0)
                    {
                        returnURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + returnURL;
                    }
                    var cancelURL = "";
                    if (socialGroupId > 0)
                    {
                        cancelURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=cancelled", "groupid=" + socialGroupId), "?");
                    }
                    else
                    {
                        cancelURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=cancelled"), "?");
                    }
                    if (cancelURL.IndexOf("://") + 1 == 0)
                    {
                        cancelURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + cancelURL;
                    }
                    var strPayPalURL = "";
                    strPayPalURL = ppurl + Globals.HTTPPOSTEncode(objEvent.PayPalAccount);
                    strPayPalURL = strPayPalURL + "&item_name=" +
                                   Globals.HTTPPOSTEncode(objEvent.ModuleTitle + " - " + this.lblEventName.Text +
                                                          " ( " + this.lblFee.Text + " " + this.lblFeeCurrency.Text +
                                                          " )");
                    strPayPalURL = strPayPalURL + "&item_number=" +
                                   Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.SignupID));
                    strPayPalURL = strPayPalURL + "&quantity=" +
                                   Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.NoEnrolees));
                    strPayPalURL = strPayPalURL + "&custom=" +
                                   Globals.HTTPPOSTEncode(
                        Convert.ToDateTime(this.lblStartDate.Text).ToShortDateString());

                    // Make sure currency is in correct format
                    var dblFee    = double.Parse(this.lblFee.Text);
                    var uiculture = Thread.CurrentThread.CurrentCulture;
                    Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                    strPayPalURL = strPayPalURL + "&amount=" +
                                   Globals.HTTPPOSTEncode(Strings.Format(dblFee, "#,##0.00"));
                    Thread.CurrentThread.CurrentCulture = uiculture;

                    strPayPalURL = strPayPalURL + "&currency_code=" +
                                   Globals.HTTPPOSTEncode(this.lblTotalCurrency.Text);
                    strPayPalURL = strPayPalURL + "&return=" + returnURL;
                    strPayPalURL = strPayPalURL + "&cancel_return=" + cancelURL;
                    strPayPalURL = strPayPalURL + "&notify_url=" +
                                   Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(this.Request)) +
                                                          "/DesktopModules/Events/EventIPN.aspx");
                    strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1";
                    //strPayPalURL = strPayPalURL & "&undefined_quantity=&no_note=1&no_shipping=1&rm=2"

                    // redirect to PayPal
                    this.Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #6
0
        private string SendEventNotifications()
        {
            var objEvents             = new EventController();
            var objEvent              = default(EventInfo);
            var objEventNotifications = new EventNotificationController();
            var notifyEvents          = default(ArrayList);
            var returnStr             = "Event Notification completed.";

            Status = "Sending Event Notifications";

            //***  All Event Notifications are stored in UTC internally.
            notifyEvents = objEventNotifications.EventsNotificationsToSend(DateTime.UtcNow);

            foreach (EventNotificationInfo objNotification in notifyEvents)
            {
                //Get the Associated Event
                objEvent = objEvents.EventsGet(objNotification.EventID, objNotification.ModuleID);

                if (!ReferenceEquals(objEvent, null))
                {
                    // Setup PortalSettings
                    var portalSettings =
                        CreatePortalSettings(objNotification.PortalAliasID, objNotification.TabID);
                    var folderName = DesktopModuleController
                                     .GetDesktopModuleByModuleName("DNN_Events", objEvent.PortalID).FolderName;

                    if (!ReferenceEquals(portalSettings, null))
                    {
                        // Make up the LocalResourceFile value
                        var templateSourceDirectory = Globals.ApplicationPath;
                        var localResourceFile       = templateSourceDirectory + "/DesktopModules/" + folderName + "/" +
                                                      Localization.LocalResourceDirectory + "/EventNotification.ascx.resx";

                        // Send the email
                        var objEventEmailInfo = new EventEmailInfo();
                        var objEventEmail     = new EventEmails(portalSettings.PortalId, objNotification.ModuleID,
                                                                localResourceFile, objNotification.NotifyLanguage);
                        objEventEmailInfo.TxtEmailSubject = objEvent.Notify;
                        objEventEmailInfo.TxtEmailBody    = objEvent.Reminder;
                        objEventEmailInfo.TxtEmailFrom    = objEvent.ReminderFrom;
                        objEventEmailInfo.UserEmails.Add(objNotification.UserEmail);
                        objEventEmailInfo.UserLocales.Add(objNotification.NotifyLanguage);
                        objEventEmailInfo.UserTimeZoneIds.Add(objEvent.EventTimeZoneId);
                        var domainurl = portalSettings.PortalAlias.HTTPAlias;
                        if (domainurl.IndexOf("/", StringComparison.Ordinal) > 0)
                        {
                            domainurl = domainurl.Substring(0, domainurl.IndexOf("/", StringComparison.Ordinal));
                        }

                        objEventEmail.SendEmails(objEventEmailInfo, objEvent, domainurl);
                    }

                    //*** Update Notification (so we don't send again)
                    objNotification.NotificationSent = true;
                    objEventNotifications.EventsNotificationSave(objNotification);
                    returnStr = "Event Notification completed. " + notifyEvents.Count + " Notification(s) sent!";
                }
            }

            //**** Delete Expired EventNotifications (older than 30 days)
            var endDate = DateTime.UtcNow.AddDays(-30);

            objEventNotifications.EventsNotificationDelete(endDate);

            Status = "Event Notifications Sent Successfully";
            ScheduleHistoryItem.Succeeded = true;
            return(returnStr);
        }
Exemple #7
0
        private void MailUsTheOrder(string tagMsg, bool sendToUser = true)
        {
            // ********* RWJS - Seems to add no value, and would have always returned nothing *********
            //			InitializeSettings(Item_number)

            var sMessage   = "";
            var sEmail     = "";
            var strNewLine = Environment.NewLine;

            if (this._settings.HTMLEmail == "html")
            {
                strNewLine = "<br />";
            }
            sMessage = tagMsg + strNewLine
                       + "Transaction ID:   " + this._txnID + strNewLine
                       + "Transaction Type: " + this._txnType + strNewLine
                       + "Payment Type:     " + this._paymentType + strNewLine
                       + "Payment Status:   " + this._paymentStatus + strNewLine
                       + "Pending Reason:   " + this._pendingReason + strNewLine
                       + "Payment Date:     " + this._paymentDate + strNewLine
                       + "Receiver Email:   " + this._receiverEmail + strNewLine
                       + "Invoice:          " + this._invoice + strNewLine
                       + "Item Number:      " + this._itemNumber + strNewLine
                       + "Item Name:        " + this._itemName + strNewLine
                       + "Quantity:         " + this._quantity + strNewLine
                       + "Custom:           " + this._custom + strNewLine
                       + "Payment Currency: " + this._currency + strNewLine
                       + "Payment Gross:    " + this._paymentGross + strNewLine
                       + "Payment Fee:      " + this._paymentFee + strNewLine
                       + "Payer Email:      " + this._payerEmail + strNewLine
                       + "First Name:       " + this._firstName + strNewLine
                       + "Last Name:        " + this._lastName + strNewLine
                       + "Street Address:   " + this._addressStreet + strNewLine
                       + "City:             " + this._addressCity + strNewLine
                       + "State:            " + this._addressState + strNewLine
                       + "Zip Code:         " + this._addressZip + strNewLine
                       + "Country:          " + this._addressCountry + strNewLine
                       + "Address Status:   " + this._addressStatus + strNewLine
                       + "Payer Status:     " + this._payerStatus + strNewLine
                       + "Verify Sign:      " + this._verifySign + strNewLine
                       + "Subscriber Date:  " + this._subscrDate + strNewLine
                       + "Period 1:         " + this._period1 + strNewLine
                       + "Period 2:         " + this._period2 + strNewLine
                       + "Period 3:         " + this._period3 + strNewLine
                       + "Amount 1:         " + this._amount1 + strNewLine
                       + "Amount 2:         " + this._amount2 + strNewLine
                       + "Amount 3:         " + this._amount3 + strNewLine
                       + "Recurring:        " + this._recurring + strNewLine
                       + "Reattempt:        " + this._reattempt + strNewLine
                       + "Retry At:         " + this._retryAt + strNewLine
                       + "Recur Times:      " + this._recurTimes + strNewLine
                       + "UserName:         "******"Password:         "******"Subscriber ID:    " + this._subscrID + strNewLine
                       + "Notify Version:   "
                       + this._notifyVersion + strNewLine;


            var portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            sEmail   = this._settings.StandardEmail.Trim();
            sMessage = sMessage;
            try
            {
                var sSystemPrice = Convert.ToDecimal(this._paymentGross);

                // Also verify that Gross Payment is what we logged as the Fee ("payment_gross" field )
                this._objEventSignups =
                    this._objCtlEventSignups.EventsSignupsGet(Convert.ToInt32(this._itemNumber), 0, true);
                this._objEvent =
                    this._objCtlEventEvent.EventsGet(this._objEventSignups.EventID, this._objEventSignups.ModuleID);
                var sPPPrice = this._objEvent.EnrollFee * this._objEventSignups.NoEnrolees;


                var objEventEmailInfo = new EventEmailInfo();
                var objEventEmail     = new EventEmails(this._objEvent.PortalID, this._objEventSignups.ModuleID,
                                                        this._localResourceFile);
                objEventEmailInfo.TxtEmailSubject = this._settings.Templates.txtEnrollMessageSubject;
                objEventEmailInfo.TxtEmailFrom    = sEmail;
                if (sendToUser)
                {
                    if (this._objEventSignups.UserID > -1)
                    {
                        objEventEmailInfo.UserIDs.Add(this._objEventSignups.UserID);
                    }
                    else
                    {
                        objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail);
                        objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture);
                        objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId);
                    }
                }
                objEventEmailInfo.UserIDs.Add(this._objEvent.OwnerID);
                var objEventEmailInfo2 = new EventEmailInfo();
                objEventEmailInfo2.TxtEmailFrom = sEmail;
                objEventEmailInfo2.UserEmails.Add(this._objEvent.PayPalAccount);
                objEventEmailInfo2.UserLocales.Add("");
                objEventEmailInfo2.UserTimeZoneIds.Add("");

                if (sPPPrice == sSystemPrice)
                {
                    //we're ok
                    objEventEmailInfo2.TxtEmailSubject =
                        "Sale of: " + this._itemName + " from " + portalSettings.PortalName;
                    objEventEmailInfo2.TxtEmailBody = sMessage;
                    if (this._paymentStatus.ToUpper() == "COMPLETED")
                    {
                        this.SavePayPalInfo(true, this._objEvent);

                        // Mail users
                        if (this._settings.SendEnrollMessagePaid)
                        {
                            objEventEmailInfo.TxtEmailBody = this._settings.Templates.txtEnrollMessagePaid;
                            objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true);
                        }
                    }
                    else
                    {
                        this.SavePayPalInfo(false, this._objEvent);

                        // Mail users
                        if (this._settings.SendEnrollMessagePending)
                        {
                            objEventEmailInfo.TxtEmailBody = this._settings.Templates.txtEnrollMessagePending;
                            objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true);
                        }
                    }
                }
                else
                {
                    //someone is trying to rip us off.
                    objEventEmailInfo2.TxtEmailSubject = "Failed Price Matchup Check: " + this._itemName + " from " +
                                                         portalSettings.PortalName;
                    objEventEmailInfo2.TxtEmailBody =
                        "There was an incorrect match between actual price and price paid. The following transaction information is provided below:" +
                        strNewLine +
                        strNewLine + "The purchasing email is: " + this._payerEmail + strNewLine +
                        "User ID: " + this._custom + strNewLine +
                        "Transaction Type: " + this._txnType + strNewLine +
                        "Transaction ID: " + this._txnID + strNewLine +
                        "Item Number: " + this._itemNumber + strNewLine +
                        "PayPal Paid: " + sSystemPrice + strNewLine +
                        "Actual Price: " + sPPPrice + strNewLine +
                        strNewLine + "TRANSACTION DETAILS: " + strNewLine + strNewLine + sMessage;

                    this.SavePayPalErrorLogInfo();

                    // Mail users
                    if (this._settings.SendEnrollMessageIncorrect)
                    {
                        objEventEmailInfo.TxtEmailBody = this._settings.Templates.txtEnrollMessageIncorrect;
                        objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true);
                    }
                }
                objEventEmail.SendEmails(objEventEmailInfo2, this._objEvent, this._objEventSignups, true);
            }
            catch (Exception exc)
            {
                Exceptions.LogException(
                    new ModuleLoadException("EventIPN, Paypal Exception: " + exc.Message + " at: " + exc.Source));
                Exceptions.ProcessModuleLoadException(this, exc);
                var localResourceFile = this.TemplateSourceDirectory + "/" + Localization.LocalResourceDirectory +
                                        "/EventIPN.resx";
                var objEventEmailInfo = new EventEmailInfo();
                var objEventEmail     = new EventEmails(this._objEvent.PortalID, this._objEventSignups.ModuleID,
                                                        localResourceFile);
                objEventEmailInfo.TxtEmailSubject = "Sale of: " + this._itemName + " from " + portalSettings.PortalName;
                objEventEmailInfo.TxtEmailFrom    = this._settings.StandardEmail.Trim();
                objEventEmailInfo.UserEmails.Add(this._objEvent.PayPalAccount);
                objEventEmailInfo.UserLocales.Add("");
                objEventEmailInfo.UserTimeZoneIds.Add("");

                objEventEmailInfo.TxtEmailBody =
                    "There was a failure of the item purchase module. The following transaction information is provided below:" +
                    strNewLine +
                    strNewLine + "The purchasing email is: " + this._payerEmail + strNewLine +
                    strNewLine + "User ID: " + this._custom + strNewLine +
                    strNewLine + "Transaction Type: " + this._txnType + strNewLine +
                    strNewLine + "Transaction ID: " + this._txnID + strNewLine +
                    strNewLine + "Error Code: " + exc.Message + strNewLine + exc.Source;

                objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true);
            }
        }