/// <summary> /// Checks that the custom module data exists. If the custom module /// object cannot be retrieved (e.g., this is the initial creation of /// the module), then a new module object is created using the module /// id assigned by the CMS. /// </summary> private void EnsureModule() { FormBuilder.FormBuilderDataContext dc = new FormBuilderDataContext(); FormBuilder_Module formBuilderModule = (from m in dc.FormBuilder_Modules where m.ModuleId == this.ModuleId select m).FirstOrDefault(); if (formBuilderModule == null) { formBuilderModule = new FormBuilder_Module(); formBuilderModule.ModuleId = this.ModuleId; dc.FormBuilder_Modules.InsertOnSubmit(formBuilderModule); dc.SubmitChanges(); } }
/// <summary> /// Gets the current object and fills its with the form input values. /// If input is not valid, returns null. /// </summary> public void GetInput_FormBuilderModule(FormBuilderDataContext dc, out FormBuilder_Module module) { module = (from m in dc.FormBuilder_Modules where m.ModuleId == this.ModuleId select m).Single(); module.NotifyEmail = NotifyEmailCtl.Text.Trim(); module.ConfirmationPageId = ConfirmationPageIdCtl.SelectedNavigationId > 0 ? (int?)ConfirmationPageIdCtl.SelectedNavigationId : null; module.StyleName = StyleDropDown.SelectedValue; module.SubmitButtonText = tbSubmitButtonText.Text.Trim(); module.Ack_Enabled = chkAcknowledgementEnabled.Checked; module.Ack_Body = txtAcknowledgementBody.Text.Length > 4000 ? txtAcknowledgementBody.Text.Trim().Substring(0, 4000) : txtAcknowledgementBody.Text.Trim(); module.Ack_EmailAddressFieldLabel = txtAcknowledgementEmailField.Text.Trim(); module.Ack_FromEmailAddress = txtAcknowledgementFromEmail.Text.Trim(); module.Ack_Subject = txtAcknowledgementSubject.Text.Trim(); }
private void LoadModule() { FormBuilder.FormBuilderDataContext dc = new FormBuilderDataContext(); FormBuilder_Module FormBuilderModule = (from m in dc.FormBuilder_Modules where m.ModuleId == this.ModuleId select m).Single(); NotifyEmailCtl.Text = FormBuilderModule.NotifyEmail; ConfirmationPageIdCtl.SelectedNavigationId = FormBuilderModule.ConfirmationPageId.HasValue ? FormBuilderModule.ConfirmationPageId.Value : -1; StyleDropDown.SelectedValue = FormBuilderModule.StyleName; tbSubmitButtonText.Text = FormBuilderModule.SubmitButtonText; FormBuilderField_edit1.ModuleId = this.ModuleId; chkAcknowledgementEnabled.Checked = pnlEmailAcknowledgement.Visible = FormBuilderModule.Ack_Enabled; txtAcknowledgementBody.Text = FormBuilderModule.Ack_Body; txtAcknowledgementEmailField.Text = FormBuilderModule.Ack_EmailAddressFieldLabel; txtAcknowledgementFromEmail.Text = FormBuilderModule.Ack_FromEmailAddress; txtAcknowledgementSubject.Text = FormBuilderModule.Ack_Subject; LoadFields(); }
public BaseValidator GetInputValidator() { BaseValidator validator = null; switch ((FieldType)this.Type) { case FieldType.CheckBox: validator = new CheckBoxListValidator(); break; default: validator = new RequiredFieldValidator(); break; } validator.ControlToValidate = this.GetInputControlId(); validator.ValidationGroup = FormBuilder_Module.GetValidationGroup(this.TemplateId); validator.Text = "Required"; validator.Display = ValidatorDisplay.None; validator.ErrorMessage = string.Format("{0} input is required.", this.Name); validator.Visible = true; return(validator); }
public void EmailAcknowledgement() { try { var dc = new FormBuilderDataContext(); FormBuilder_Module form = FormBuilder_Module; if (form.Ack_Enabled) { var message = new MailMessage(); string strNotifyEmails = this.FormBuilder_Module.NotifyEmail; string[] astrNotifyEmails = strNotifyEmails.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); if (astrNotifyEmails.Length > 0) { foreach (string strNotifyEmail in astrNotifyEmails) { MailAddress address = new MailAddress(strNotifyEmail.Trim()); message.Bcc.Add(address); } } if (!string.IsNullOrEmpty(form.Ack_FromEmailAddress)) { message.From = new MailAddress(form.Ack_FromEmailAddress); } List <FormBuilder_FieldInput> inputs = (from fi in dc.FormBuilder_FieldInputs where fi.ResponseId == Id select fi).ToList(); //sort by SortOrder. inputs.Sort(delegate(FormBuilder_FieldInput a, FormBuilder_FieldInput b) { return(a.FormBuilder_Field.SortOrder.CompareTo(b.FormBuilder_Field.SortOrder)); }); var sbSubject = new StringBuilder(form.Ack_Subject); var sbBody = new StringBuilder(form.Ack_Body); foreach (FormBuilder_FieldInput input in inputs) { if (string.Compare(input.FormBuilder_Field.Name, form.Ack_EmailAddressFieldLabel, true) == 0) { message.To.Add(new MailAddress(input.InputValue)); } string strToken = string.Format("##{0}##", input.FormBuilder_Field.Name); sbSubject = sbSubject.Replace(strToken, input.InputValue); sbSubject = sbSubject.Replace(strToken.ToLower(), input.InputValue); sbSubject = sbSubject.Replace(strToken.ToUpper(), input.InputValue); sbBody = sbBody.Replace(strToken, input.InputValue); sbBody = sbBody.Replace(strToken.ToLower(), input.InputValue); sbBody = sbBody.Replace(strToken.ToUpper(), input.InputValue); } if (message.To.Count > 0) { message.Subject = sbSubject.ToString(); message.Body = sbBody.ToString(); message.IsBodyHtml = true; var smtpClient = new SmtpClient(); smtpClient.Send(message); } } } catch (Exception ex) { WebModulesAuditEvent.Raise("Failed sending acknowledgement email", this, ex); } }