/// <summary> /// Sets the extra rest params. /// </summary> private void SetExtraRestParams() { string parms = "?getCategorizedItems=false"; parms += string.Format("&entityTypeId={0}", EntityTypeId); if (!string.IsNullOrEmpty(EntityTypeQualifierColumn)) { parms += string.Format("&entityQualifier={0}", EntityTypeQualifierColumn); if (!string.IsNullOrEmpty(EntityTypeQualifierValue)) { parms += string.Format("&entityQualifierValue={0}", EntityTypeQualifierValue); } } if (!string.IsNullOrEmpty(ExcludedCategoryIds)) { parms += string.Format("&excludedCategoryIds={0}", ExcludedCategoryIds); } if (RootCategoryId.HasValue) { var rootCategory = CategoryCache.Get(RootCategoryId.Value); if (rootCategory.EntityTypeId == this.EntityTypeId) { parms += string.Format("&rootCategoryId={0}", rootCategory.Id); } } ItemRestUrlExtraParams = parms; }
/// <summary> /// Rs the filter_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void rFilter_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Category": var category = CategoryCache.Get(int.Parse(e.Value)); e.Value = category != null ? category.Name : string.Empty; break; case "EntityType": var entityType = EntityTypeCache.Get(int.Parse(e.Value)); e.Value = entityType != null ? entityType.FriendlyName : string.Empty; break; case "Owner": int?personId = e.Value.AsIntegerOrNull(); if (personId.HasValue) { var person = new PersonService(new RockContext()).Get(personId.Value); if (person != null) { e.Value = person.FullNameReversed; } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; } }
/// <summary> /// Handles the SaveClick event of the mdCategoryDetailConfig control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdCategoryDetailConfig_SaveClick(object sender, EventArgs e) { var selectedCategory = CategoryCache.Get(cpRootCategoryDetail.SelectedValue.AsInteger()); this.SetAttributeValue(AttributeKey.RootCategory, selectedCategory != null ? selectedCategory.Guid.ToString() : string.Empty); var excludedCategoryIds = cpExcludeCategoriesDetail.SelectedValuesAsInt(); var excludedCategoryGuids = new List <Guid>(); foreach (int excludedCategoryId in excludedCategoryIds) { var excludedCategory = CategoryCache.Get(excludedCategoryId); if (excludedCategory != null) { excludedCategoryGuids.Add(excludedCategory.Guid); } } this.SetAttributeValue(AttributeKey.ExcludeCategories, excludedCategoryGuids.AsDelimited(",")); this.SaveAttributeValues(); mdCategoryDetailConfig.Visible = false; mdCategoryDetailConfig.Hide(); Block_BlockUpdated(sender, e); }
/// <summary> /// Handles the RowDataBound event of the rGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridViewRowEventArgs" /> instance containing the event data.</param> protected void rGrid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Literal lEntityType = e.Row.FindControl("lEntityType") as Literal; if (lEntityType != null) { lEntityType.Text = "None (Global Attributes)"; int categoryId = (int)rGrid.DataKeys[e.Row.RowIndex].Value; var category = CategoryCache.Get(categoryId); int entityTypeId = int.MinValue; if (category != null && !string.IsNullOrWhiteSpace(category.EntityTypeQualifierValue) && int.TryParse(category.EntityTypeQualifierValue, out entityTypeId) && entityTypeId > 0) { var entityType = EntityTypeCache.Get(entityTypeId); if (entityType != null) { lEntityType.Text = entityType.FriendlyName; } } } } }
public static void AddMoveHistory(RockContext rockContext, Location location, Attendance attendeeAttendance, bool isSubroom) { var moveSummary = string.Format("{0}</span> at <span class=\"field-name\">{1}", location.Name, Rock.RockDateTime.Now); if (isSubroom) { moveSummary += string.Format("</span> (a subroom of <span class=\"field-name\">{0})", location.ParentLocation.Name); } var changes = new History.HistoryChangeList(); changes.AddCustom("Entry", History.HistoryChangeType.Record.ToString(), moveSummary.Truncate(250)); changes.First().Caption = "Moved To Location"; changes.First().RelatedEntityTypeId = locationEntityTypeId; changes.First().RelatedEntityId = location.Id; changes.First().RelatedData = GetHostInfo(); HistoryService.SaveChanges( rockContext, typeof(Rock.Model.Person), CategoryCache.Get(4).Guid, attendeeAttendance.PersonAlias.PersonId, changes, true ); }
/// <summary> /// Adds the schedule columns. /// </summary> private void AddScheduleColumns() { ScheduleService scheduleService = new ScheduleService(new RockContext()); // limit Schedules to ones that have a CheckInStartOffsetMinutes var scheduleQry = scheduleService.Queryable().Where(a => a.CheckInStartOffsetMinutes != null && a.IsActive); // limit Schedules to the Category from the Filter int scheduleCategoryId = CategoryCache.Get(Rock.SystemGuid.Category.SCHEDULE_SERVICE_TIMES.AsGuid()).Id; scheduleQry = scheduleQry.Where(a => a.CategoryId == scheduleCategoryId); // clear out any existing schedule columns just in case schedules been added/removed var scheduleList = scheduleQry.ToList().OrderBy(a => a.ToString()).ToList(); var checkBoxEditableFields = gGroupLocationSchedule.Columns.OfType <CheckBoxEditableField>().ToList(); foreach (var field in checkBoxEditableFields) { gGroupLocationSchedule.Columns.Remove(field); } foreach (var item in scheduleList) { string dataFieldName = string.Format("scheduleField_{0}", item.Id); CheckBoxEditableField field = new CheckBoxEditableField { HeaderText = item.Name.Replace(" ", "<br/>"), DataField = dataFieldName }; gGroupLocationSchedule.Columns.Add(field); } }
/// <summary> /// Sets the value. /// </summary> /// <param name="schedule">The schedule.</param> public void SetValue(Schedule schedule) { if (schedule != null) { // If setting the value to an inactive schedule, enable the "Show Inactive Schedules" checkbox. if (AllowInactiveSelection && !schedule.IsActive) { _cbShowInactiveSchedules.Checked = true; SetExtraRestParams(true); } ItemId = schedule.Id.ToString(); string parentCategoryIds = string.Empty; var parentCategory = schedule.CategoryId.HasValue ? CategoryCache.Get(schedule.CategoryId.Value) : null; while (parentCategory != null) { parentCategoryIds = parentCategory.Id + "," + parentCategoryIds; parentCategory = parentCategory.ParentCategory; } InitialItemParentIds = parentCategoryIds.TrimEnd(new[] { ',' }); ItemName = schedule.Name; } else { ItemId = Constants.None.IdValue; ItemName = Constants.None.TextHtml; } }
/// <summary> /// Sets the value. /// </summary> /// <param name="mergeTemplate">The merge template.</param> public void SetValue(MergeTemplate mergeTemplate) { if (mergeTemplate != null) { ItemId = mergeTemplate.Id.ToString(); var parentCategoryIds = new List <string>(); var parentCategory = CategoryCache.Get(mergeTemplate.CategoryId); while (parentCategory != null) { if (!parentCategoryIds.Contains(parentCategory.Id.ToString())) { parentCategoryIds.Insert(0, parentCategory.Id.ToString()); } else { // infinite recursion break; } parentCategory = parentCategory.ParentCategory; } InitialItemParentIds = parentCategoryIds.AsDelimited(","); ItemName = mergeTemplate.Name; } else { ItemId = Constants.None.IdValue; ItemName = Constants.None.TextHtml; } }
public IQueryable <Tag> AvailableNames(int entityTypeId, int ownerId, Guid entityGuid, string name = null, string entityQualifier = null, string entityQualifierValue = null, Guid?categoryGuid = null, bool?includeInactive = null) { var tags = (( TagService )Service) .Get(entityTypeId, entityQualifier, entityQualifierValue, ownerId, categoryGuid, includeInactive) .Where(t => t.Name.StartsWith(name) && !t.TaggedItems.Any(i => i.EntityGuid == entityGuid) && t.IsActive); if (categoryGuid.HasValue) { var category = CategoryCache.Get(categoryGuid.Value); if (category != null) { tags = tags .Where(a => a.CategoryId.HasValue && a.CategoryId.Value == category.Id); } } var person = GetPerson(); var tagItems = new List <Tag>(); foreach (var tag in tags.OrderBy(t => t.Name)) { if (tag.IsAuthorized(Rock.Security.Authorization.TAG, person)) { tagItems.Add(tag); } } return(tagItems.AsQueryable <Tag>()); }
/// <summary> /// ts the filter display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void rFilter_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { if (e.Key == "Category") { int?categoryId = e.Value.AsIntegerOrNull(); if (categoryId.HasValue) { var category = CategoryCache.Get(categoryId.Value); if (category != null) { e.Value = category.Name; } } else { e.Value = string.Empty; } } else if (e.Key == "Active") { e.Value = ddlActiveFilter.SelectedValue; } else { e.Value = string.Empty; } }
/// <summary> /// Gets the services. /// </summary> /// <returns></returns> private List <Schedule> GetServices() { var services = new List <Schedule>(); var scheduleCategory = CategoryCache.Get(GetAttributeValue("ScheduleCategory").AsGuid()); if (scheduleCategory != null) { using (var rockContext = new RockContext()) { foreach (var schedule in new ScheduleService(rockContext) .Queryable().AsNoTracking() .Where(s => s.IsActive && s.CategoryId.HasValue && s.CategoryId.Value == scheduleCategory.Id) .OrderBy(s => s.Name)) { services.Add(schedule); } } } return(services); }
void SetPrCategoryByLookupText(object sender, bool isHours) { var selectedItem = dgProjInvProjectLineGrid.SelectedItem as ProjectInvoiceProjectLineLocal; if (selectedItem == null) { return; } var le = sender as CorasauGridLookupEditor; if (string.IsNullOrEmpty(le.EnteredText)) { return; } var prCat = CategoryCache?.Get(le.EnteredText); if (prCat != null) { dgProjInvProjectLineGrid.SetLoadedRow(selectedItem); selectedItem.PrCategory = prCat.KeyStr; le.EditValue = prCat.KeyStr; } le.EnteredText = null; }
/// <summary> /// Binds the attribute to attribute value container /// </summary> private void BindAttribute(Rock.Model.Person person) { var adultCategoryGuid = GetAttributeValue(AttributeKey.AdultAttributeCategory).AsGuidOrNull(); var childCategoryGuid = GetAttributeValue(AttributeKey.ChildAttributeCategory).AsGuidOrNull(); var isAdult = person.AgeClassification == AgeClassification.Adult || person.AgeClassification == AgeClassification.Unknown; var isChild = person.AgeClassification == AgeClassification.Child || person.AgeClassification == AgeClassification.Unknown; pnlAdultFields.Visible = false; pnlChildFields.Visible = false; if (isAdult && adultCategoryGuid.HasValue) { avcAdultAttributes.IncludedCategoryNames = new string[] { CategoryCache.Get(adultCategoryGuid.Value).Name }; avcAdultAttributes.AddDisplayControls(person); pnlAdultFields.Visible = avcAdultAttributes.GetDisplayedAttributes().Any(); } if (isChild && childCategoryGuid.HasValue) { avcChildAttributes.IncludedCategoryNames = new string[] { CategoryCache.Get(childCategoryGuid.Value).Name }; avcChildAttributes.AddDisplayControls(person); pnlChildFields.Visible = avcChildAttributes.GetDisplayedAttributes().Any(); } }
/// <summary> /// Gets the prayer requests for the new session. /// </summary> /// <returns>An enumerable of <see cref="PrayerRequest"/> objects.</returns> protected virtual IEnumerable <PrayerRequest> GetPrayerRequests(RockContext rockContext) { var prayerRequestService = new PrayerRequestService(rockContext); var category = CategoryCache.Get(PrayerCategory); if (category == null) { return(null); } var query = prayerRequestService.GetByCategoryIds(new List <int> { category.Id }); if (PublicOnly) { query = query.Where(a => a.IsPublic.HasValue && a.IsPublic.Value); } if (MyCampus) { var campusId = RequestContext.CurrentPerson?.PrimaryCampusId; if (campusId.HasValue) { query = query.Where(a => a.CampusId.HasValue && a.CampusId == campusId); } } query = query.OrderByDescending(a => a.IsUrgent) .ThenBy(a => a.PrayerCount); return(query); }
/// <summary> /// Handles the ItemCommand event of the rptChannels control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="RepeaterCommandEventArgs"/> instance containing the event data.</param> protected void rptChannels_ItemCommand(object source, RepeaterCommandEventArgs e) { string selectedChannelValue = e.CommandArgument.ToString(); SetUserPreference(SELECTED_CHANNEL_SETTING, selectedChannelValue); SelectedChannelId = selectedChannelValue.AsIntegerOrNull(); var selectedChannelGuid = ContentChannelCache.Get(SelectedChannelId.Value).Guid; var queryString = new Dictionary <string, string> { { "ContentChannelGuid", selectedChannelGuid.ToString() } }; // Get CategoryGuid from Route var categoryGuid = PageParameter("CategoryGuid").AsGuidOrNull(); if (!categoryGuid.HasValue) { var categoryId = ddlCategory.SelectedValueAsId(); categoryGuid = CategoryCache.Get(categoryId.GetValueOrDefault())?.Guid; } // if user has selected a category or one was provided as a query param add it to the new route params if (categoryGuid.HasValue) { queryString.Add("CategoryGuid", categoryGuid.ToString()); } // Navigate to page with route parameters set so new Url is generated in browser NavigateToCurrentPage(queryString); }
/// <summary> /// Handles the filter display for each saved user value /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <exception cref="System.NotImplementedException"></exception> protected void rFilter_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Category": { var categoryId = e.Value.AsIntegerOrNull(); if (categoryId.HasValue && categoryId > 0) { var category = CategoryCache.Get(categoryId.Value); if (category != null) { e.Value = category.Name; } } else { e.Value = string.Empty; } break; } case "Communication Type": { if (!string.IsNullOrWhiteSpace(e.Value)) { e.Value = ((CommunicationType)Enum.Parse(typeof(CommunicationType), e.Value)).ConvertToString(); } break; } case "Active": { break; } case "Supports": { break; } case "Created By": { var personId = e.Value.AsIntegerOrNull(); if (personId.HasValue && personId != 0) { var personService = new PersonService(new RockContext()); var person = personService.Get(personId.Value); if (person != null) { e.Value = person.FullName; } } break; } } }
public override List <BreadCrumb> GetBreadCrumbs(PageReference pageReference) { var entityTypeName = string.Empty; Guid entityTypeGuid = Guid.Empty; Guid.TryParse(GetAttributeValue("EntityType"), out entityTypeGuid); var entityType = EntityTypeCache.Get(entityTypeGuid); if (entityType != null) { entityTypeName = entityType.FriendlyName; } int parentCategoryId = int.MinValue; CategoryCache category = null; if (int.TryParse(PageParameter("CategoryId"), out parentCategoryId)) { category = CategoryCache.Get(parentCategoryId); if (entityType == null && category != null) { entityType = EntityTypeCache.Get(category.EntityTypeId.Value); if (entityType != null) { entityTypeName = entityType.FriendlyName; } } } if (entityType == null && category == null) { return(base.GetBreadCrumbs(pageReference)); } var breadCrumbs = new List <BreadCrumb>(); // add categories to the breadcrumbs while (category != null) { var parms = new Dictionary <string, string>(); parms.Add("CategoryId", category.Id.ToString()); breadCrumbs.Add(new BreadCrumb(category.Name, new PageReference(pageReference.PageId, 0, parms))); category = category.ParentCategory; } string rootPageTitle = string.IsNullOrWhiteSpace(GetAttributeValue("EntityQualifierColumn")) ? entityTypeName + " Categories" : this.RockPage.PageTitle; breadCrumbs.Add(new BreadCrumb(rootPageTitle, new PageReference(pageReference.PageId))); breadCrumbs.Reverse(); return(breadCrumbs); }
void SetInvoiceable(ProjectJournalLineLocal rec) { var Cat = (PrCategory)CategoryCache.Get(rec._PrCategory); if (Cat != null) { rec.Invoiceable = Cat._Invoiceable; } }
/// <summary> /// Handles the DisplayFilterValue event of the gfSettings control. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> void gfSettings_DisplayFilterValue(object sender, Rock.Web.UI.Controls.GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Category": { int?categoryId = e.Value.AsIntegerOrNull(); if (categoryId.HasValue) { var category = CategoryCache.Get(categoryId.Value); if (category != null) { e.Value = category.Name; } } else { e.Value = string.Empty; } break; } case "Summary Contains": { break; } case "Who": { int personId = int.MinValue; if (int.TryParse(e.Value, out personId)) { var person = new PersonService(new RockContext()).GetNoTracking(personId); if (person != null) { e.Value = person.FullName; } } break; } case "Date Range": { e.Value = DateRangePicker.FormatDelimitedValues(e.Value); break; } default: { e.Value = string.Empty; break; } } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); RockPage.AddScriptLink("~/Scripts/jquery.visible.min.js"); string eventTarget = this.Page.Request.Params["__EVENTTARGET"] ?? string.Empty; if (!Page.IsPostBack) { BindFilter(); tglStatus.Checked = GetUserPreference(STATUS_FILTER_SETTING).AsBoolean(); SelectedChannelId = PageParameter("ContentChannelId").AsIntegerOrNull(); if (!SelectedChannelId.HasValue) { var selectedChannelGuid = PageParameter("ContentChannelGuid").AsGuidOrNull(); if (selectedChannelGuid.HasValue) { SelectedChannelId = ContentChannelCache.Get(selectedChannelGuid.Value)?.Id; } } if (!SelectedChannelId.HasValue) { SelectedChannelId = GetUserPreference(SELECTED_CHANNEL_SETTING).AsIntegerOrNull(); } if (ddlCategory.Visible) { var categoryGuid = PageParameter("CategoryGuid").AsGuidOrNull(); if (categoryGuid.HasValue) { var categoryId = CategoryCache.Get(categoryGuid.Value)?.Id; SetUserPreference(CATEGORY_FILTER_SETTING, categoryId.ToString()); ddlCategory.SetValue(categoryId); } else { ddlCategory.SetValue(GetUserPreference(CATEGORY_FILTER_SETTING).AsIntegerOrNull()); } } GetData(); } else if (eventTarget.StartsWith(gContentChannelItems.UniqueID)) { // if we got a PostBack from the Grid (or child controls) make sure the Grid is bound GetData(); } }
/// <summary> /// Gets the occurrences with option to override the ICal.Event.DTStart /// </summary> /// <param name="beginDateTime">The begin date time.</param> /// <param name="endDateTime">The end date time.</param> /// <param name="scheduleStartDateTimeOverride">The schedule start date time override.</param> /// <returns></returns> public IList <Occurrence> GetOccurrences(DateTime beginDateTime, DateTime?endDateTime, DateTime?scheduleStartDateTimeOverride) { var occurrences = new List <Occurrence>(); DDay.iCal.Event calEvent = GetCalendarEvent(); if (calEvent == null) { return(occurrences); } if (scheduleStartDateTimeOverride.HasValue) { calEvent.DTStart = new DDay.iCal.iCalDateTime(scheduleStartDateTimeOverride.Value); } if (calEvent.DTStart != null) { var exclusionDates = new List <DateRange>(); if (this.CategoryId.HasValue && this.CategoryId.Value > 0) { var category = CategoryCache.Get(this.CategoryId.Value); if (category != null) { exclusionDates = category.ScheduleExclusions .Where(e => e.Start.HasValue && e.End.HasValue) .ToList(); } } foreach (var occurrence in endDateTime.HasValue ? ScheduleICalHelper.GetOccurrences(calEvent, beginDateTime, endDateTime.Value) : ScheduleICalHelper.GetOccurrences(calEvent, beginDateTime)) { bool exclude = false; if (exclusionDates.Any() && occurrence.Period.StartTime != null) { var occurrenceStart = occurrence.Period.StartTime.Value; if (exclusionDates.Any(d => d.Start.Value <= occurrenceStart && d.End.Value >= occurrenceStart)) { exclude = true; } } if (!exclude) { occurrences.Add(occurrence); } } } return(occurrences); }
/// <summary> /// Gets the services. /// </summary> /// <returns></returns> private List <Schedule> GetServices(CampusCache campus = null) { var services = new List <Schedule>(); if (!string.IsNullOrWhiteSpace(GetAttributeValue("ScheduleCategories"))) { List <Guid> categoryGuids = GetAttributeValue("ScheduleCategories").Split(',').Select(g => g.AsGuid()).ToList(); string campusAttributeGuid = GetAttributeValue("CampusAttribute"); DateTime?weekend = bddlWeekend.SelectedValue.AsDateTime(); using (var rockContext = new RockContext()) { var attributeValueQry = new AttributeValueService(rockContext).Queryable(); foreach (Guid categoryGuid in categoryGuids) { var scheduleCategory = CategoryCache.Get(categoryGuid); if (scheduleCategory != null && campus != null) { var schedules = new ScheduleService(rockContext) .Queryable().AsNoTracking() .Where(s => s.CategoryId == scheduleCategory.Id) .Join( attributeValueQry.Where(av => av.Attribute.Guid.ToString() == campusAttributeGuid && av.Value.Contains(campus.Guid.ToString())), p => p.Id, av => av.EntityId, (p, av) => new { Schedule = p, Value = av.Value }); // Check to see if the event was applicable the week for which we are entering data foreach (var schedule in schedules) { var occurrences = InetCalendarHelper.GetOccurrences(schedule.Schedule.iCalendarContent, weekend.Value.Date.AddDays(-6), weekend.Value.Date.AddDays(1)); if (occurrences.Count > 0) { services.Add(schedule.Schedule); } } } else if (scheduleCategory != null) { foreach (var schedule in new ScheduleService(rockContext) .Queryable().AsNoTracking() .Where(s => s.CategoryId.HasValue && s.CategoryId.Value == scheduleCategory.Id) .OrderBy(s => s.Name)) { services.Add(schedule); } } } } } return(services.OrderBy(s => s.GetNextStartDateTime(RockDateTime.Now).HasValue ? s.GetNextStartDateTime(RockDateTime.Now).Value.Ticks : s.EffectiveEndDate.HasValue?s.EffectiveEndDate.Value.Ticks: 0).ToList()); }
/// <summary> /// Gets the category. /// </summary> /// <returns></returns> private CategoryCache GetCategory() { var guid = GetGuidFromSelectedAttribute(AttributeKey.Category); if (!guid.HasValue) { return(null); } return(CategoryCache.Get(guid.Value)); }
/// <summary> /// Gets the Guid for the Category that has the specified Id /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public override Guid?GetGuid(int id) { var cacheItem = CategoryCache.Get(id); if (cacheItem != null) { return(cacheItem.Guid); } return(null); }
/// <summary> /// Shows the edit. /// </summary> /// <param name="attributeId">The attribute id.</param> protected void ShowEdit(int categoryId) { Category category = null; if (categoryId > 0) { category = new CategoryService(new RockContext()).Get(categoryId); } if (category == null) { // if there is a parent category set the entity type and qualifiers and hide the settings if (_parentCategoryId.HasValue) { var parentCategory = CategoryCache.Get(_parentCategoryId.Value); entityTypePicker.SelectedEntityTypeId = parentCategory.EntityTypeId; tbEntityQualifierField.Text = parentCategory.EntityTypeQualifierColumn; tbEntityQualifierValue.Text = parentCategory.EntityTypeQualifierValue; pnlEntityInfo.Visible = false; } category = new Category { Id = 0, EntityTypeId = _entityTypeId, EntityTypeQualifierColumn = _entityCol, EntityTypeQualifierValue = _entityVal, ParentCategoryId = _parentCategoryId, }; } else { entityTypePicker.SelectedEntityTypeId = category.EntityTypeId; tbEntityQualifierField.Text = category.EntityTypeQualifierColumn; tbEntityQualifierValue.Text = category.EntityTypeQualifierValue; } entityTypePicker.RequiredFieldValidator.ErrorMessage = "Entity type is required."; entityTypePicker.ValidationGroup = BlockValidationGroup; tbName.Text = category.Name; tbDescription.Text = category.Description; catpParentCategory.SetValue(category.ParentCategoryId); tbIconCssClass.Text = category.IconCssClass; cpHighlight.Value = category.HighlightColor; category.LoadAttributes(); phAttributes.Controls.Clear(); Rock.Attribute.Helper.AddEditControls(category, phAttributes, true, BlockValidationGroup); hfIdValue.Value = categoryId.ToString(); mdDetails.Show(); }
/// <summary> /// Gets the categories to be included in the picker. /// </summary> /// <returns>A collection of <see cref="CategoryCache"/> objects.</returns> protected virtual IEnumerable <CategoryCache> GetCategories() { var categories = new List <CategoryCache>(); var parentCategory = CategoryCache.Get(ParentCategory); if (parentCategory != null) { categories.AddRange(parentCategory.Categories.OrderBy(a => a.Name)); } return(categories); }
/// <summary> /// Shows the edit details. /// </summary> /// <param name="category">The category.</param> private void ShowEditDetails(Category category) { if (category.Id > 0) { lTitle.Text = ActionTitle.Edit(Category.FriendlyTypeName).FormatAsHtmlTitle(); lIcon.Text = "<i class='fa fa-square-o'></i>"; } else { lTitle.Text = ActionTitle.Add(Category.FriendlyTypeName).FormatAsHtmlTitle(); if (!string.IsNullOrEmpty(category.IconCssClass)) { lIcon.Text = String.Format("<i class='{0}'></i>", category.IconCssClass); } else { lIcon.Text = "<i class='fa fa-square-o'></i>"; } } SetEditMode(true); tbName.Text = category.Name; tbDescription.Text = category.Description; var excludeCategoriesGuids = this.GetAttributeValue(AttributeKey.ExcludeCategories).SplitDelimitedValues().AsGuidList(); List <int> excludedCategoriesIds = new List <int>(); if (excludeCategoriesGuids != null && excludeCategoriesGuids.Any()) { foreach (var excludeCategoryGuid in excludeCategoriesGuids) { var excludedCategory = CategoryCache.Get(excludeCategoryGuid); if (excludedCategory != null) { excludedCategoriesIds.Add(excludedCategory.Id); } } } cpParentCategory.EntityTypeId = category.EntityTypeId; cpParentCategory.EntityTypeQualifierColumn = category.EntityTypeQualifierColumn; cpParentCategory.EntityTypeQualifierValue = category.EntityTypeQualifierValue; cpParentCategory.ExcludedCategoryIds = excludedCategoriesIds.AsDelimited(","); var rootCategory = CategoryCache.Get(this.GetAttributeValue(AttributeKey.RootCategory).AsGuid()); cpParentCategory.RootCategoryId = rootCategory != null ? rootCategory.Id : ( int? )null; cpParentCategory.SetValue(category.ParentCategoryId); tbIconCssClass.Text = category.IconCssClass; cpHightlightColor.Text = category.HighlightColor; }
/// <summary> /// Gets the changes. /// </summary> /// <param name="modelType">Type of the model.</param> /// <param name="categoryGuid">The category unique identifier.</param> /// <param name="entityId">The entity identifier.</param> /// <param name="changes">The changes.</param> /// <param name="caption">The caption.</param> /// <param name="relatedModelType">Type of the related model.</param> /// <param name="relatedEntityId">The related entity identifier.</param> /// <param name="modifiedByPersonAliasId">The modified by person alias identifier.</param> /// <param name="sourceOfChange">The source of change.</param> /// <returns></returns> internal static List <History> GetChanges(Type modelType, Guid categoryGuid, int entityId, History.HistoryChangeList changes, string caption, Type relatedModelType, int?relatedEntityId, int?modifiedByPersonAliasId, string sourceOfChange = null) { SetHistoryEntriesSourceOfChange(changes, sourceOfChange, sourceOfChange != null); var entityType = EntityTypeCache.Get(modelType); var category = CategoryCache.Get(categoryGuid); var creationDate = RockDateTime.Now; int?relatedEntityTypeId = null; if (relatedModelType != null) { var relatedEntityType = EntityTypeCache.Get(relatedModelType); if (relatedModelType != null) { relatedEntityTypeId = relatedEntityType.Id; } } List <History> historyRecordsToInsert = new List <History>(); if (entityType != null && category != null) { foreach (var historyChange in changes.Where(m => m != null)) { var history = new History(); history.EntityTypeId = entityType.Id; history.CategoryId = category.Id; history.EntityId = entityId; history.Caption = caption.Truncate(200); history.RelatedEntityTypeId = relatedEntityTypeId; history.RelatedEntityId = relatedEntityId; historyChange.CopyToHistory(history); if (modifiedByPersonAliasId.HasValue) { history.CreatedByPersonAliasId = modifiedByPersonAliasId; } // If not specified, manually set the creation date on these history items so that they will be grouped together. if (historyChange.ChangedDateTime == null) { history.CreatedDateTime = creationDate; } historyRecordsToInsert.Add(history); } } return(historyRecordsToInsert); }
async void getCostAndSales(ProjectInvoiceProjectLineLocal rec) { var project = rec._Project; if (project == null) { return; } var proj = (Uniconta.DataModel.Project)ProjectCache.Get(project); var Categories = proj.Categories ?? await proj.LoadCategories(api); rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d; var Category = rec._PrCategory; var prcategory = (Uniconta.DataModel.PrCategory)CategoryCache.Get(Category); if (prcategory != null && prcategory._Forward) { rec.ProjectForward = invoiceProposal._Project; } var projCat = (from ct in Categories where ct._PrCategory == Category select ct).FirstOrDefault(); if (projCat != null) { rec.costPct = projCat._CostPctCharge; rec.salesPct = projCat._SalesPctCharge; rec.costAmount = projCat._CostAmountCharge; rec.salesAmount = projCat._SalesAmountCharge; } else { var prstd = (PrStandard)PrStandardCache.Get(proj._PrStandard); if (prstd == null) { return; } var PrCategories = prstd.Categories ?? await prstd.LoadCategories(api); var prCat = (from ct in PrCategories where ct._PrCategory == Category select ct).FirstOrDefault(); if (prCat != null) { rec.costPct = prCat._CostPctCharge; rec.salesPct = prCat._SalesPctCharge; rec.costAmount = prCat._CostAmountCharge; rec.salesAmount = prCat._SalesAmountCharge; } } RecalculateAmount(); }
/// <summary> /// Gfs the filter_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> void gfFilter_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case UserPreferenceKey.Categories: { var categories = new List <string>(); foreach (var idVal in e.Value.SplitDelimitedValues()) { int id = int.MinValue; if (int.TryParse(idVal, out id)) { if (id != 0) { var category = CategoryCache.Get(id); if (category != null) { categories.Add(CategoryCache.Get(id).Name); } } } } e.Value = categories.AsDelimited(", "); break; } case UserPreferenceKey.Type: { int?typeId = e.Value.AsIntegerOrNull(); if (typeId.HasValue) { var contentType = new ContentChannelTypeService(new RockContext()).Get(typeId.Value); if (contentType != null) { e.Value = contentType.Name; } } break; } default: { e.Value = string.Empty; break; } } }