/// <summary>
    /// On btnRegister click.
    /// </summary>
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string currentSiteName = SiteContext.CurrentSiteName;
        // Check banned IPs
        if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text = GetString("General.BannedIP");
            return;
        }

        // Exit if problem occurs
        if (errorOccurs)
        {
            return;
        }

        string result = null;
        Validator val = new Validator();
        // Check name fields if required
        if (RequireName)
        {
            result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired"))
                .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result;
        }
        // Check e-mail field
        if (string.IsNullOrEmpty(result))
        {
            result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result;
        }
        // Check phone field if required
        if (RequirePhone && string.IsNullOrEmpty(result))
        {
            result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result;
        }

        if (string.IsNullOrEmpty(result))
        {
            // Allow registration if opened
            if (IsRegistrationOpened)
            {
                if (EventNode != null)
                {
                    if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim()))
                    {
                        // Add new attendant to the event
                        EventAttendeeInfo eai = AddAttendantToEvent();

                        if (eai != null)
                        {
                            // Log activity
                            Activity activity = new ActivityEventBooking(EventNode, EventNode.GetDocumentName(), eai, AnalyticsContext.ActivityEnvironmentVariables);
                            activity.Log();

                            // Send invitation e-mail
                            TimeZoneInfo tzi;
                            TimeZoneMethods.GetDateTimeForControl(this, DateTime.Now, out tzi);
                            EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi);

                            lblRegInfo.Text = GetString("eventmanager.registrationsucceeded");
                            lblRegInfo.Visible = true;
                            // Hide registration form
                            pnlReg.Visible = false;
                        }
                    }
                    else
                    {
                        // User is already registered
                        lblError.Text = GetString("eventmanager.attendeeregistered");
                        lblError.Visible = true;
                    }
                }
                else
                {
                    // Event does not exist
                    lblError.Text = GetString("eventmanager.eventnotexist");
                    lblError.Visible = true;
                    // Hide registration form
                    pnlReg.Visible = false;
                }
            }
            else
            {
                // Event registration is not opened
                lblError.Text = GetString("eventmanager.notopened");
                lblError.Visible = true;
                // Hide registration form
                pnlReg.Visible = false;
            }
        }
        else
        {
            // Display error message
            lblError.Text = result;
            lblError.Visible = true;
        }
    }
예제 #2
0
    /// <summary>
    /// On btnRegister click.
    /// </summary>
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string currentSiteName = SiteContext.CurrentSiteName;

        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("General.BannedIP");
            return;
        }

        // Exit if problem occurs
        if (errorOccurs)
        {
            return;
        }

        string    result = null;
        Validator val    = new Validator();

        // Check name fields if required
        if (RequireName)
        {
            result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired"))
                     .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result;
        }
        // Check e-mail field
        if (string.IsNullOrEmpty(result))
        {
            result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result;
        }
        // Check phone field if required
        if (RequirePhone && string.IsNullOrEmpty(result))
        {
            result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result;
        }

        if (string.IsNullOrEmpty(result))
        {
            DateTime now = DateTime.Now;
            // Allow registration if opened
            if ((openFrom == DateTimeHelper.ZERO_TIME || openFrom < now) && (openTo == DateTimeHelper.ZERO_TIME || now <= openTo) && (now <= eventDate))
            {
                if (EventNode != null)
                {
                    if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim()))
                    {
                        // Add new attendant to the event
                        EventAttendeeInfo eai = AddAttendantToEvent();

                        if (eai != null)
                        {
                            // Log activity
                            Activity activity = new ActivityEventBooking(EventNode, EventNode.GetDocumentName(), eai, AnalyticsContext.ActivityEnvironmentVariables);
                            activity.Log();

                            // Send invitation e-mail
                            TimeZoneInfo tzi = null;
                            TimeZoneMethods.GetDateTimeForControl(this, DateTime.Now, out tzi);
                            EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi);

                            lblRegInfo.Text    = GetString("eventmanager.registrationsucceeded");
                            lblRegInfo.Visible = true;
                            // Hide registration form
                            pnlReg.Visible = false;
                        }
                    }
                    else
                    {
                        // User is already registered
                        lblError.Text    = GetString("eventmanager.attendeeregistered");
                        lblError.Visible = true;
                    }
                }
                else
                {
                    // Event does not exist
                    lblError.Text    = GetString("eventmanager.eventnotexist");
                    lblError.Visible = true;
                    // Hide registration form
                    pnlReg.Visible = false;
                }
            }
            else
            {
                // Event registration is not opened
                lblError.Text    = GetString("eventmanager.notopened");
                lblError.Visible = true;
                // Hide registration form
                pnlReg.Visible = false;
            }
        }
        else
        {
            // Display error message
            lblError.Text    = result;
            lblError.Visible = true;
        }
    }