public void Submit(IForm form) { try { var formInfo = BizFormInfoProvider.GetBizFormInfo(form.Name, SiteContext.CurrentSiteID); if (formInfo == null) { throw new InvalidOperationException("The requested checkin form does not exist."); } var dataClassInfo = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID); var item = new BizFormItem(dataClassInfo.ClassName); SetFormValues(form, item); item.SetValue("FormInserted", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); item.SetValue("FormUpdated", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); BizFormItemProvider.SetItem(item); BizFormInfoProvider.RefreshDataCount(formInfo.FormName, formInfo.FormSiteID); if (form.Notification != null) { SendNotificationEmail(formInfo, form, item); } if (!String.IsNullOrEmpty(form.Autoresponder?.Sender)) { SendAcknowledgementEmail(formInfo, item, form.Controls); } } catch (Exception ex) { throw new Exception("There was a problem saving the form. Please contact our support team.", ex); } }
private GeneralResultDTO SubmitRequestAccessFormInternal(string email) { var requestAccessForm = BizFormInfoProvider.GetBizFormInfo(_RequestAccessFormCodeName, SiteContext.CurrentSiteID); if (requestAccessForm != null) { var requestAccessFormClass = DataClassInfoProvider.GetDataClassInfo(requestAccessForm.FormClassID); string requestAccessFormClassName = requestAccessFormClass.ClassName; BizFormItem newFormItem = BizFormItem.New(requestAccessFormClassName); newFormItem.SetValue("Email", email); newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName); newFormItem.SetValue("FormInserted", DateTime.Now); newFormItem.SetValue("FormUpdated", DateTime.Now); newFormItem.Insert(); SendFormEmail(newFormItem); return(new GeneralResultDTO { success = true }); } else { return(new GeneralResultDTO { success = false, errorMessage = ResHelper.GetString("Kadena.ForgottenPassword.ForgottenPasswordRepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode) }); } }
private void SetFormSpecificData(string formName, ContactInfo contact, BizFormItem formItem) { if (formName == COFFEE_SAMPLE_LIST_FORM_CODE_NAME) { formItem.SetValue("Country", CountryInfo.Provider.Get(contact.ContactCountryID).CountryThreeLetterCode); var state = StateInfo.Provider.Get(contact.ContactStateID); var stateName = state != null ? state.StateDisplayName : string.Empty; formItem.SetValue("State", stateName); } if (formName == CONTACT_US_FORM_CODE_NAME) { formItem.SetValue("UserMessage", "Message"); } }
private GeneralResultDTO SubmitContactUsFormInternal(string fullName, string companyName, string email, string phone, string message, List <HttpPostedFile> files) { var contactUsForm = BizFormInfoProvider.GetBizFormInfo(_ContactUsFormCodeName, SiteContext.CurrentSiteID); if (contactUsForm != null) { var contactUsFormClass = DataClassInfoProvider.GetDataClassInfo(contactUsForm.FormClassID); string contactUsFormClassName = contactUsFormClass.ClassName; BizFormItem newFormItem = BizFormItem.New(contactUsFormClassName); newFormItem.SetValue("FullName", fullName); newFormItem.SetValue("CompanyName", companyName); newFormItem.SetValue("Email", email); newFormItem.SetValue("Phone", phone); newFormItem.SetValue("Message", message); newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName); newFormItem.SetValue("User", MembershipContext.AuthenticatedUser.UserName); newFormItem.SetValue("FormInserted", DateTime.Now); newFormItem.SetValue("FormUpdated", DateTime.Now); if (files.Count > 0) { for (int i = 0; files.Count > i; i++) { string extension = System.IO.Path.GetExtension(files[i].FileName); string fileName = new FormsHelper().GetNewGuidName(extension); string formFilesFolderPath = FormHelper.GetBizFormFilesFolderPath(SiteContext.CurrentSiteName); string fileNameString = fileName + "/" + Path.GetFileName(files[i].FileName); new FormsHelper().SaveFileToDisk(files[i], fileName, formFilesFolderPath); newFormItem.SetValue(string.Format("File{0}", i + 1), (object)fileNameString); } } newFormItem.Insert(); new FormsHelper().SendFormEmail(newFormItem, files.Count); return(new GeneralResultDTO { success = true }); } else { return(new GeneralResultDTO { success = false, errorMessage = ResHelper.GetString("Kadena.ContactForm.ContactFormRepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode) }); } }
private void CopyDataFromContactToForm(ContactInfo contact, DataClassInfo classInfo, BizFormItem formItem) { var mapInfo = new FormInfo(classInfo.ClassContactMapping); var fields = mapInfo.GetFields(true, true); foreach (FormFieldInfo ffi in fields) { formItem.SetValue(ffi.MappedToField, contact.GetStringValue(ffi.Name, string.Empty)); } }
private void SetFormSpecificData(string formName, ContactInfo contact, BizFormItem formItem) { if (formName == TryFreeSampleFormCodeName) { formItem.SetValue("Country", CountryInfoProvider.GetCountryInfo(contact.ContactCountryID).CountryThreeLetterCode); var stateInfo = StateInfoProvider.GetStateInfo(contact.ContactStateID); var str = stateInfo != null ? stateInfo.StateDisplayName : string.Empty; formItem.SetValue("State", str); } if (formName == ContactUsFormCodeName) { formItem.SetValue("UserMessage", "Message"); } if (formName != BusinessCustomerRegistationFormCodeName) { return; } formItem.SetValue("BecomePartner", "Becoming a partner café"); }
private void SetFormValues(IForm form, BizFormItem item) { foreach (var control in form.Controls) { if (control is IFileControl) { HandleFileControl(control, item); } else { item.SetValue(control.Name, control.SubmittedValue); } } }
private void HandleFileControl(IControl control, BizFormItem item) { var fileControl = control as IFileControl; if (string.IsNullOrWhiteSpace(fileControl?.SubmittedValue) | fileControl?.SubmittedData == null) { return; } var fileNameMask = Guid.NewGuid(); var extension = fileControl.SubmittedValue.Substring(fileControl.SubmittedValue.LastIndexOf(".", StringComparison.Ordinal)); item.SetValue(fileControl.Name, $"{fileNameMask}{extension}/{fileControl.SubmittedValue}"); SaveFile(fileNameMask.ToString(), extension, fileControl.SubmittedData); }
public void UpdateFormEntry(string formName, int itemID, string fieldToUpdate, object newValue) { BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID); if (formObject == null) { throw new InvalidOperationException("The requested checkin form does not exist."); } // Gets the class name of the form DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID); string className = formClass.ClassName; BizFormItem item = BizFormItemProvider.GetItem(itemID, className); item.SetValue(item.ColumnNames.Find(t => t.ToLower() == fieldToUpdate), newValue); item.SubmitChanges(false); }
public void InsertFormEntry(string formName, FormEntry entry) { BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID); if (formObject == null) { throw new InvalidOperationException("The requested checkin form does not exist."); } // Gets the class name of the 'ContactUs' form DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID); string className = formClass.ClassName; BizFormItem item = BizFormItem.New(className); foreach (var formValue in entry.FormValues) { item.SetValue(item.ColumnNames.Find(t => t.ToLower() == formValue.Key), formValue.Value); } item.Insert(); }
private GeneralResultDTO SubmitNewKitRequestInternal(string name, string description, int[] productIDs, string[] productNames) { var newKitRequestForm = BizFormInfoProvider.GetBizFormInfo(_NewKitRequestFormCodeName, SiteContext.CurrentSiteID); if (newKitRequestForm != null) { var newKitRequestFormClass = DataClassInfoProvider.GetDataClassInfo(newKitRequestForm.FormClassID); string newKitRequestFormClassName = newKitRequestFormClass.ClassName; BizFormItem newFormItem = BizFormItem.New(newKitRequestFormClassName); newFormItem.SetValue("Name", name); newFormItem.SetValue("Description", description); newFormItem.SetValue("ProductNames", string.Join("|", productNames)); newFormItem.SetValue("ProductNodeIDs", string.Join("|", productIDs)); newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName); newFormItem.SetValue("User", MembershipContext.AuthenticatedUser.UserName); newFormItem.SetValue("FormInserted", DateTime.Now); newFormItem.SetValue("FormUpdated", DateTime.Now); newFormItem.Insert(); SendFormEmail(newFormItem); return(new GeneralResultDTO { success = true }); } else { return(new GeneralResultDTO { success = false, errorMessage = ResHelper.GetString("Kadena.NewKitRequest.ContactFormRepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode) }); } }
private GeneralResultDTO SubmitBidInternal(string name, string description, string requestType, string biddingWay, int numberOfBidings, List <HttpPostedFile> files, DateTime productionDate, DateTime?selectionDate) { var bidForm = BizFormInfoProvider.GetBizFormInfo(_BidFormCodeName, SiteContext.CurrentSiteID); if (bidForm != null) { var bidFormClass = DataClassInfoProvider.GetDataClassInfo(bidForm.FormClassID); string bidFormClassName = bidFormClass.ClassName; BizFormItem newFormItem = BizFormItem.New(bidFormClassName); newFormItem.SetValue("Name", name); newFormItem.SetValue("Description", description); newFormItem.SetValue("RequestType", requestType); newFormItem.SetValue("BiddingWayText", biddingWay); newFormItem.SetValue("BiddingWayNumber", numberOfBidings); newFormItem.SetValue("ProductionDate", productionDate); if (selectionDate.HasValue) { newFormItem.SetValue("SelectionDate", selectionDate); } newFormItem.SetValue("FormInserted", DateTime.Now); newFormItem.SetValue("FormUpdated", DateTime.Now); newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName); if (files.Count > 0) { for (int i = 0; files.Count > i; i++) { string extension = System.IO.Path.GetExtension(files[i].FileName); string fileName = new FormsHelper().GetNewGuidName(extension); string formFilesFolderPath = FormHelper.GetBizFormFilesFolderPath(SiteContext.CurrentSiteName); string fileNameString = fileName + "/" + Path.GetFileName(files[i].FileName); new FormsHelper().SaveFileToDisk(files[i], fileName, formFilesFolderPath); newFormItem.SetValue(string.Format("File{0}", i + 1), (object)fileNameString); } } newFormItem.Insert(); new FormsHelper().SendFormEmail(newFormItem, files.Count); return(new GeneralResultDTO { success = true }); } else { return(new GeneralResultDTO { success = false, errorMessage = ResHelper.GetString("Kadena.NewBidRequest.RepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode) }); } }