/// <summary> /// UniGrid external data bound. /// </summary> object gridDocs_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLower(); 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 = CMSContext.GetDateTimeForControl(this, ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME), out tzi).ToString(); // Display time zone shift if needed if ((tzi != null) && TimeZoneHelper.TimeZonesEnabled()) { if (sourceName.EndsWith("tooltip")) { result = TimeZoneHelper.GetGMTLongStringOffset(tzi); } else { result += TimeZoneHelper.GetGMTStringOffset(" (GMT{0:+00.00;-00.00})", 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); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing || CMSContext.CurrentDocument == null || CMSContext.CurrentDocument.NodeClassName.ToLower() != "cms.bookingevent") { // Do nothing this.Visible = false; } else { // Get current event document EventNode = CMSContext.CurrentDocument; // Get event date, open from/to, capacity and possibility to register over capacity information eventDate = ValidationHelper.GetDateTime(EventNode.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED); openFrom = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenFrom"), DataHelper.DATETIME_NOT_SELECTED); openTo = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenTo"), DataHelper.DATETIME_NOT_SELECTED); capacity = ValidationHelper.GetInteger(EventNode.GetValue("EventCapacity"), 0); allowRegistrationOverCapacity = ValidationHelper.GetBoolean(EventNode.GetValue("EventAllowRegistrationOverCapacity"), false); // Display registration section DisplayRegistration(); // Display link to iCalendar file which adds this event to users Outlook if (this.AllowExportToOutlook) { TimeZoneInfo tzi = null; CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi); string timeZoneId = string.Empty; if (tzi != null) { timeZoneId = "&timezoneid=" + tzi.TimeZoneID; } lnkOutlook.NavigateUrl = "~/CMSModules/EventManager/CMSPages/AddToOutlook.aspx?eventid=" + EventNode.NodeID.ToString() + timeZoneId; lnkOutlook.Target = "_blank"; lnkOutlook.Text = GetString("eventmanager.exporttooutlook"); lnkOutlook.Visible = true; } } }
/// <summary> /// On btnRegister click. /// </summary> protected void btnRegister_Click(object sender, EventArgs e) { string currentSiteName = CMSContext.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 == DataHelper.DATETIME_NOT_SELECTED || openFrom < now) && (openTo == DataHelper.DATETIME_NOT_SELECTED || 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, CMSContext.ActivityEnvironmentVariables); activity.Log(); // Send invitation e-mail TimeZoneInfo tzi = null; CMSContext.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; } }
/// <summary> /// On btnRegister click. /// </summary> protected void btnRegister_Click(object sender, EventArgs e) { string currentSiteName = CMSContext.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 (this.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 (this.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 == DataHelper.DATETIME_NOT_SELECTED || openFrom < now) && (openTo == DataHelper.DATETIME_NOT_SELECTED || 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 if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.EventBookingEnabled(currentSiteName)) { if (ValidationHelper.GetBoolean(EventNode.GetValue("EventLogActivity"), false)) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.EVENT_BOOKING, TitleData = EventNode.DocumentName, ItemID = eai.AttendeeID, URL = URLHelper.CurrentRelativePath, ItemDetailID = EventNode.DocumentID, NodeID = EventNode.NodeID, Culture = EventNode.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } // Send invitation e-mail TimeZoneInfo tzi = null; CMSContext.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; } }