/// <summary>
    /// UniGrid external data bound.
    /// </summary>
    private object gridDocs_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        sourceName = sourceName.ToLowerCSafe();
        switch (sourceName)
        {
        // Column 'DocumentWorkflowStepID'
        case "documentworkflowstepid":
            int stepId = ValidationHelper.GetInteger(parameter, 0);
            if (stepId > 0)
            {
                // Get workflow step display name
                WorkflowStepInfo wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(stepId);
                if (wsi != null)
                {
                    return(ResHelper.LocalizeString(wsi.StepDisplayName));
                }
            }
            break;

        // Column 'Published'
        case "published":
            bool published = ValidationHelper.GetBoolean(parameter, true);
            return(published ? GetString("General.Yes") : GetString("General.No"));

        case "documentmodifiedwhen":
        case "documentmodifiedwhentooltip":

            TimeZoneInfo tzi = null;

            // Get current time for user contribution list on live site
            string result = TimeZoneMethods.GetDateTimeForControl(this, ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME), out tzi).ToString();

            // Display time zone shift if needed
            if ((tzi != null) && TimeZoneHelper.TimeZonesEnabled)
            {
                if (sourceName.EndsWithCSafe("tooltip"))
                {
                    result = TimeZoneHelper.GetUTCLongStringOffset(tzi);
                }
                else
                {
                    result += TimeZoneHelper.GetUTCStringOffset(tzi);
                }
            }
            return(result);

        // Action 'edit'
        case "edit":
            ((Control)sender).Visible = AllowEdit && CheckGroupPermission("editpages");
            break;

        // Action 'delete'
        case "delete":
            ((Control)sender).Visible = AllowDelete && CheckGroupPermission("deletepages");
            break;
        }

        return(parameter);
    }
Beispiel #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;
        }
    }