protected void gridData_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerInvariant()) { case "delete": CheckPermissions("DeleteData"); // Get record ID int formRecordID = ValidationHelper.GetInteger(actionArgument, 0); // Get BizFormInfo object if (bfi != null) { // Get class object if (dci != null) { // Get record object var item = BizFormItemProvider.GetItem(formRecordID, dci.ClassName); // Delete all files of the record BizFormInfoProvider.DeleteBizFormRecordFiles(dci.ClassFormDefinition, item, SiteContext.CurrentSiteName); // Delete the form record item.Delete(); } } break; } }
/// <summary> /// Loads model for the dashboard live tile. /// </summary> /// <param name="liveTileContext">Context of the live tile. Contains information about the user and the site the model is requested for</param> /// <exception cref="ArgumentNullException"><paramref name="liveTileContext"/> is null</exception> /// <returns>Live tile model</returns> public LiveTileModel GetModel(LiveTileContext liveTileContext) { if (liveTileContext == null) { throw new ArgumentNullException("liveTileContext"); } return(CacheHelper.Cache(() => { var formsClassNames = BizFormInfoProvider.GetBizForms() .OnSite(liveTileContext.SiteInfo.SiteID) .Source(s => s.Join <DataClassInfo>("FormClassID", "ClassID")) .Column("ClassName") .GetListResult <string>(); // Leave tile empty if there are no forms on current site if (!formsClassNames.Any()) { return null; } int newSubmissionsCount = formsClassNames.Sum(className => BizFormItemProvider.GetItems(className) .WhereGreaterThan("FormInserted", DateTime.Now.AddDays(-7).Date) .Count); return new LiveTileModel { Value = newSubmissionsCount, Description = ResHelper.GetString("bizform.livetiledescription"), }; } , new CacheSettings(5, "FormsLiveTileModelProvider", liveTileContext.SiteInfo.SiteID))); }
/// <summary> /// Gets all BizForms object types /// </summary> public static IEnumerable <string> GetFormObjectTypes() { return(DataClassInfoProvider.GetClasses() .WhereTrue("ClassIsForm") .Columns("ClassName") .Select(r => BizFormItemProvider.GetObjectType(r["ClassName"].ToString()))); }
public List <FormEntry> GetFormEntries(string formName) { List <FormEntry> entries = new List <FormEntry>(); 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; // Loads the form's data ObjectQuery <BizFormItem> data = BizFormItemProvider.GetItems(className); // Checks whether the form contains any records if (!DataHelper.DataSourceIsEmpty(data)) { // Loops through the form's data records foreach (BizFormItem item in data) { FormEntry entry = new FormEntry(); entry.ID = item.ItemID; foreach (var columnName in item.ColumnNames) { entry.FormValues.Add(columnName.ToLower(), item.GetStringValue(columnName, "")); } entries.Add(entry); } } return(entries); }
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); } }
/// <summary> /// Converts an Object's IDs, Guids, or CodeNames to the Objects CodeNames /// </summary> /// <param name="classObjSummary">The Class Object Summary</param> /// <param name="ObjectIdentifications">List of Object IDs, Guids, or CodeNames</param> /// <returns>A list of the Object's Code Names</returns> private static IEnumerable <string> ObjectIdentitiesToCodeNames(ClassObjSummary classObjSummary, IEnumerable <object> ObjectIdentifications) { switch (classObjSummary.ClassName.ToLower()) { case "cms.tree": case "cms.document": return(new DocumentQuery().Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); default: if (classObjSummary.ClassIsDocumentType) { return(new DocumentQuery(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } else if (classObjSummary.ClassIsCustomTable) { return(CustomTableItemProvider.GetItems(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } else if (classObjSummary.ClassIsForm) { return(BizFormItemProvider.GetItems(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } else { return(new ObjectQuery(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } } }
protected void FieldEditor_OnAfterDefinitionUpdate(object sender, EventArgs e) { // Update form to log synchronization if (FormInfo != null) { BizFormInfoProvider.SetBizFormInfo(FormInfo); // State of unigrids may contain where/order by clauses no longer valid after definition update UniGrid.ResetStates(BizFormItemProvider.GetObjectType(FieldEditor.ClassName)); } }
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); }
protected void Page_Load(object sender, EventArgs e) { // Check 'ReadData' permission CheckPermissions("ReadData"); // Register scripts ScriptHelper.RegisterDialogScript(Page); if (ShowSelectFieldsButton) { var url = ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_Data_SelectFields.aspx") + QueryHelper.BuildQueryWithHash("formid", formId.ToString()); ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" + url + "' ,'BizFormFields', 500, 500); }")); } ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "Edit", ScriptHelper.GetScript( "function EditRecord(formId, recordId) { " + " document.location.replace('" + ResolveUrl($"~/CMSModules/BizForms/Tools/{GetPageFile()}") + "?formID=' + formId + '&formRecordID=' + recordId); } ")); // Display a warning message when a form with Web Forms development model is used on an MVC website if (SiteContext.CurrentSite.SiteIsContentOnly && bfi.FormDevelopmentModel == (int)FormDevelopmentModelEnum.WebForms) { ShowWarning(GetString("bizform_edit.webformformonmvc.warning")); } // Initialize unigrid gridData.OnExternalDataBound += gridData_OnExternalDataBound; gridData.OnLoadColumns += gridData_OnLoadColumns; gridData.OnAction += gridData_OnAction; if (bfi != null) { dci = DataClassInfoProvider.GetDataClassInfo(bfi.FormClassID); if (dci != null) { string className = dci.ClassName; // Set alternative form and data container gridData.ObjectType = BizFormItemProvider.GetObjectType(className); gridData.FilterFormName = className + ".filter"; gridData.FilterFormData = bfi; // Get primary column name gridData.OrderBy = primaryColumn = GetPrimaryColumn(FormInfo, bfi.FormName); } } }
/// <summary> /// Loads model for the dashboard live tile. /// </summary> /// <param name="liveTileContext">Context of the live tile. Contains information about the user and the site the model is requested for</param> /// <exception cref="ArgumentNullException"><paramref name="liveTileContext"/> is null</exception> /// <returns>Live tile model</returns> public LiveTileModel GetModel(LiveTileContext liveTileContext) { if (liveTileContext == null) { throw new ArgumentNullException("liveTileContext"); } return(CacheHelper.Cache(() => { // If site has more than 1 form on lower license, BizFormItemProvider.GetItems method returns null which results in exception // Standard license check if (!BizFormItemProvider.LicenseVersionCheck(RequestContext.CurrentDomain, ObjectActionEnum.Edit)) { return null; } var formsClassNames = BizFormInfoProvider.GetBizForms() .OnSite(liveTileContext.SiteInfo.SiteID) .Source(s => s.Join <DataClassInfo>("FormClassID", "ClassID")) .Column("ClassName") .GetListResult <string>(); // Leave tile empty if there are no forms on current site if (!formsClassNames.Any()) { return null; } int newSubmissionsCount = formsClassNames.Sum(className => BizFormItemProvider.GetItems(className) .WhereGreaterThan("FormInserted", DateTime.Now.AddDays(-7).Date) .Count); return new LiveTileModel { Value = newSubmissionsCount, Description = ResHelper.GetString("bizform.livetiledescription"), }; } , new CacheSettings(5, "FormsLiveTileModelProvider", liveTileContext.SiteInfo.SiteID))); }
protected void Page_Load(object sender, EventArgs e) { // Check 'ReadData' permission CheckPermissions("ReadData"); // Register scripts ScriptHelper.RegisterDialogScript(Page); if (mShowSelectFieldsButton) { var url = ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_Data_SelectFields.aspx") + QueryHelper.BuildQueryWithHash("formid", formId.ToString()); ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" + url + "' ,'BizFormFields', 500, 500); }")); } ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "Edit", ScriptHelper.GetScript( "function EditRecord(formId, recordId) { " + " document.location.replace('" + ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_EditRecord.aspx") + "?formID=' + formId + '&formRecordID=' + recordId); } ")); // Initialize unigrid gridData.OnExternalDataBound += gridData_OnExternalDataBound; gridData.OnLoadColumns += gridData_OnLoadColumns; gridData.OnAction += gridData_OnAction; if (bfi != null) { dci = DataClassInfoProvider.GetDataClassInfo(bfi.FormClassID); if (dci != null) { className = dci.ClassName; // Set alternative form and data container gridData.ObjectType = BizFormItemProvider.GetObjectType(className); gridData.FilterFormName = className + "." + "filter"; gridData.FilterFormData = bfi; // Get primary column name gridData.OrderBy = primaryColumn = GetPrimaryColumn(FormInfo, bfi.FormName); } } }
protected void Page_Load(object sender, EventArgs e) { // Check 'ReadData' permission CheckPermissions("ReadData"); // Get form ID from url formId = QueryHelper.GetInteger("formid", 0); // Register scripts ScriptHelper.RegisterDialogScript(this); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" + ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_Data_SelectFields.aspx") + "?formid=" + formId + "' ,'BizFormFields', 500, 500); }")); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Edit", ScriptHelper.GetScript( "function EditRecord(formId, recordId) { " + " document.location.replace('BizForm_Edit_EditRecord.aspx?formID=' + formId + '&formRecordID=' + recordId); } " )); // Prepare header actions string[,] actions = new string[2, 6]; // New record link actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("bizform_edit_data.newrecord"); actions[0, 2] = null; actions[0, 3] = ResolveUrl("BizForm_Edit_EditRecord.aspx?formid=" + formId.ToString()); actions[0, 4] = null; actions[0, 5] = GetImageUrl("CMSModules/CMS_Form/newrecord.png"); // Select fields link actions[1, 0] = HeaderActions.TYPE_HYPERLINK; actions[1, 1] = GetString("bizform_edit_data.selectdisplayedfields"); actions[1, 2] = null; actions[1, 3] = "javascript:SelectFields();"; actions[1, 4] = null; actions[1, 5] = GetImageUrl("CMSModules/CMS_Form/selectfields16.png"); CurrentMaster.HeaderActions.Actions = actions; // Initialize unigrid gridData.OnExternalDataBound += gridData_OnExternalDataBound; gridData.OnLoadColumns += gridData_OnLoadColumns; gridData.OnAction += gridData_OnAction; // Get BizFormInfo object bfi = BizFormInfoProvider.GetBizFormInfo(formId); EditedObject = bfi; if (bfi != null) { dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID); if (dci != null) { className = dci.ClassName; // Set alternative form and data container gridData.ObjectType = BizFormItemProvider.GetObjectType(className); gridData.FilterFormName = className + "." + "filter"; gridData.FilterFormData = bfi; // Get primary column name gridData.OrderBy = primaryColumn = GetPrimaryColumn(FormInfo, bfi.FormName); } } }