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); }
/// <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> /// 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()); } } }
/// <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))); }