protected void AttendButton_Click(object sender, EventArgs e) { IParticipant participant; if (!string.IsNullOrEmpty(HiddenEmail.Value)) { participant = AttendRegistrationEngine.GetParticipant(HiddenEmail.Value, HiddenCode.Value); if (participant != null) { participant = (participant as ParticipantBlock).CreateWritableClone() as ParticipantBlock; } } else { string participantEmail = ""; foreach (var fragment in DetailsXFormControl.ExtractXFormControls()) { if (fragment.ID == "epost" || fragment.ID == "email") { participantEmail = fragment.Value; } } if (string.IsNullOrEmpty(participantEmail) || Business.Email.Validation.IsEmail(participantEmail) == false) { return; } participant = AttendRegistrationEngine.GenerateParticipation(CurrentData.ContentLink, participantEmail, true, DetailsXFormControl.Data.Data.OuterXml, "Participant submitted form"); } if (participant != null) { participant.XForm = DetailsXFormControl.Data.Data.OuterXml; participant.Sessions = new ContentArea(); foreach (ContentReference item in GetChosenSessions()) { participant.Sessions.Items.Add(new ContentAreaItem() { ContentLink = item }); } Locate.ContentRepository().Save(participant as IContent, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess); string propertyName = ""; if (participant.AttendStatus == AttendStatus.Confirmed.ToString()) { propertyName = "CompleteContent"; } if (participant.AttendStatus == AttendStatus.Submitted.ToString()) { propertyName = "SubmittedContent"; } ContentProperty.PropertyName = propertyName; ContentProperty.DataBind(); DetailsXFormControl.Visible = false; AttendButton.Visible = false; } }
protected void CreateParticipant(string participantString, ContentReference EventPageBase) { IParticipant NewParticipant = null; foreach (string ParticipantData in DelimitContent(participantString, "[PARTICIPANTFIELDDELIMITER]")) { string[] ParticipantDataValues = DelimitContent(ParticipantData, "[PARTICIPANTVALUEDELIMITER]"); switch (ParticipantDataValues[0]) { case "Email": NewParticipant = AttendRegistrationEngine.GenerateParticipation(EventPageBase, ParticipantDataValues[1], false, string.Empty, "Imported participant"); break; } } if (NewParticipant != null) { StatusLiteral.Text += "<br><ul>"; foreach (string ParticipantData in DelimitContent(participantString, "[PARTICIPANTFIELDDELIMITER]")) { string[] ParticipantDataValues = DelimitContent(ParticipantData, "[PARTICIPANTVALUEDELIMITER]"); if (ParticipantDataValues.Length > 1) { string dataKey = ParticipantDataValues[0]; string dataValue = ParticipantDataValues[1]; StatusLiteral.Text += "<li>" + dataKey + ": " + dataValue + "</li>"; switch (ParticipantDataValues[0]) { case "Email": break; case "Status": NewParticipant.AttendStatus = dataValue; break; case "XForm": NewParticipant.XForm = dataValue; break; case "Code": NewParticipant.Code = dataValue; break; case "Submitted": NewParticipant.DateSubmitted = GetDateSafe(dataValue); break; case "Username": NewParticipant.Username = dataValue; break; } } } StatusLiteral.Text += "</ul>"; EPiServer.DataFactory.Instance.Save(NewParticipant as IContent, EPiServer.DataAccess.SaveAction.Publish); } }
protected void CreateParticipant_Click(object sender, EventArgs e) { IParticipant newParticipant = null; EmailPlaceHolder.Visible = false; if (Business.Email.Validation.IsEmail(EMailTextBox.Text) == false) { EmailPlaceHolder.Visible = true; } else { newParticipant = AttendRegistrationEngine.GenerateParticipation(CurrentPage.ContentLink, EMailTextBox.Text, string.Empty); Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptid", "window.parent.location.href='" + EPiServer.Editor.PageEditing.GetEditUrl((newParticipant as IContent).ContentLink) + "'", true); } }
protected void ImportParticipant(EventPageBase ep, string[] participantFields, string[] keys) { string email = ""; Hashtable fieldsHashtable = new Hashtable(); if (participantFields.Count() == keys.Count()) { for (int i = 0; i < keys.Count(); i++) { if (!fieldsHashtable.ContainsKey(keys[i])) { fieldsHashtable.Add(keys[i].ToLower(), participantFields[i]); } } } if (fieldsHashtable.ContainsKey("email")) { email = fieldsHashtable["email"].ToString(); } else { return; } if (string.IsNullOrEmpty(email)) { return; } XForm xform = ep.RegistrationForm; XFormData xFormData = xform.CreateFormData(); PopulateChildNodeRecursive(fieldsHashtable, xFormData.Data.ChildNodes); string xformstring = xFormData.Data.InnerXml; StatusLiteral.Text += "Adding participant: " + email + "<br/>"; AttendRegistrationEngine.GenerateParticipation(ep.ContentLink, email, false, xformstring, "Imported participant from text"); }
public virtual ActionResult Index(EventPageBase currentPage, XFormPostedData xFormPostedData, string contentLink) { var model = CreateEventRegistrationModel(currentPage, contentLink); var id = (currentPage as IContent).ContentLink.ID; var viewDataKey = string.Format("TempViewData_{0}", id); this.ViewData["XFormFragments"] = (object)xFormPostedData.Fragments; this.ControllerContext.Controller.ViewData["XFormFragments"] = (object)xFormPostedData.Fragments; this.TempData[viewDataKey] = this.ViewData; model.ViewData = this.ViewData; model.ViewDataKey = viewDataKey; string participantEmail = ""; foreach (var fragment in xFormPostedData.Fragments) { if (fragment as EPiServer.XForms.Parsing.InputFragment != null) { string fragmentReference = (fragment as EPiServer.XForms.Parsing.InputFragment).Reference.ToLower(); if (fragmentReference == "epost" || fragmentReference == "email" || fragmentReference == BVNetwork.Attend.Business.Settings.Settings.GetSetting("emailFieldName")) { participantEmail = (fragment as EPiServer.XForms.Parsing.InputFragment).Value; } } } string xformdata = new EPiServer.Web.Mvc.XForms.XFormPageHelper().GetXFormData(this, xFormPostedData).Data.InnerXml; var metadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(XFormPostedData)); var validationResult = new XFormValidator(metadata, this.ControllerContext).Validate(xFormPostedData); model.Messages = new List <string>(); foreach (var a in validationResult) { if (!string.IsNullOrEmpty(a.Message)) { model.Messages.Add(a.Message); } } if (Business.Email.Validation.IsEmail(participantEmail) == false) { model.Messages.Add(EPiServer.Framework.Localization.LocalizationService.Current.GetString("/attend/edit/emailmissing")); } if (Business.Email.Validation.IsEmail(participantEmail) == false || model.Messages.Count > 0) { model.PostedData = xFormPostedData; _xformHandler.HandleAction(this); return(PartialView("~/modules/BVNetwork.Attend/Views/Pages/Partials/EventPagePartial.cshtml", model)); } IParticipant participant = AttendRegistrationEngine.GenerateParticipation(model.EventPageBase.ContentLink, participantEmail, true, xformdata, "Participant submitted form"); participant.XForm = xformdata; //Add sessions to participant participant.Sessions = new ContentArea(); foreach (var key in Request.Form.AllKeys) { if (key.StartsWith("Session")) { var sessionContentReference = new ContentReference(Request[key]); participant.Sessions.Items.Add(new ContentAreaItem() { ContentLink = sessionContentReference }); } } _contentRepository.Save(participant as IContent, SaveAction.Publish, AccessLevel.NoAccess); model.Submitted = participant.AttendStatus.ToLower() == "submitted"; ViewBag.Participant = participant; return(PartialView("~/modules/BVNetwork.Attend/Views/Pages/Partials/EventPagePartialSuccess.cshtml", model)); }