private List <NewsItem> GetNewsListDataSource() { if (this.CurrentNewsItem == null) { return(new List <NewsItem>(0)); } List <NewsItem> dataSource = new List <NewsItem>(this.NumberOfNewsToShow); List <NewsItem> allNewsWithSameCategories = new List <NewsItem>(); TrackedList <Guid> categoryIds = (TrackedList <Guid>) this.CurrentNewsItem.GetValue("Category"); foreach (Guid id in categoryIds) { var items = App.WorkWith() .NewsItems() .Where(nI => nI.GetValue <TrackedList <Guid> >("Category").Contains(id)).Get().ToList(); allNewsWithSameCategories.AddRange(items); } return(allNewsWithSameCategories .Distinct() .Where(n => n.Status == ContentLifecycleStatus.Live && n.Id != this.CurrentNewsItem.Id) .OrderByDescending(n => n.PublicationDate) .Take(this.NumberOfNewsToShow) .ToList()); }
private TrackedList <Guid> GetCurrentPageCategoryID() { var currentNode = SiteMapBase.GetActualCurrentNode(); var result = new TrackedList <Guid>(); if (currentNode != null) { result.AddRange(currentNode.GetCustomFieldValue("Category") as TrackedList <Guid>); } return(result); }
/// <summary> /// Initializes a new <see cref="IItemQueue{TItem}"/>. /// </summary> /// <param name="itemQueue">An <see cref="IItemQueue{TItem}"/>.</param> /// <param name="queueItemHandler">An <see cref="IQueueItemHandler{TItem}"/>.</param> /// <param name="queueProcessorSettings">An <see cref="ItemQueueProcessorSettings"/>.</param> /// <param name="logger">An <see cref="ILogger"/>.</param> /// <exception cref="ArgumentNullException"> /// - <paramref name="itemQueue"/> /// - <paramref name="queueItemHandler"/> /// - <paramref name="queueProcessorSettings"/> /// - <paramref name="logger"/> /// </exception> public QueueProcessor(IItemQueue <TItem> itemQueue, IQueueItemHandler <TItem> queueItemHandler, IQueueProcessorSettings queueProcessorSettings, ILogger logger) { _ItemQueue = itemQueue ?? throw new ArgumentNullException(nameof(itemQueue)); _QueueItemHandler = queueItemHandler ?? throw new ArgumentNullException(nameof(queueItemHandler)); _QueueProcessorSettings = queueProcessorSettings ?? throw new ArgumentNullException(nameof(queueProcessorSettings)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); var runningTaks = _RunningTasks = new TrackedList <Task>(); _ProcessQueueLock = new SemaphoreSlim(1, 1); _TaskLock = new SemaphoreSlim(1, 1); runningTaks.CountSetting.Changed += (newCount, oldCold) => ProcessQueue(); itemQueue.QueueSize.Changed += (newQueueSize, oldQueueSize) => ProcessQueue(); itemQueue.HeldQueueSize.Changed += (newQueueSize, oldQueueSize) => ProcessQueue(); }
private IEnumerable <Classification> MapClassificationData(TrackedList <Guid> classifications) { var classificationData = new List <Classification>(); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); if (classifications != null) { foreach (var cat in classifications) { classificationData.Add(new Classification { Id = taxonomyManager.GetTaxon(cat).Id, Title = taxonomyManager.GetTaxon(cat).Title, Url = taxonomyManager.GetTaxon(cat).UrlName }); } } return(classificationData); }
/// <summary> /// Initializes a new <see cref="ItemQueueProcessor{TItem}"/>. /// </summary> /// <param name="itemQueue">The <see cref="IItemQueue{TItem}"/> to listen for.</param> /// <param name="itemQueueProcessorSettings">The <see cref="IItemQueueProcessorSettings"/>.</param> /// <param name="logger">An <see cref="ILogger"/>.</param> /// <param name="processItemFunc">An action to process the messages.</param> /// <exception cref="ArgumentNullException"> /// - <paramref name="itemQueue"/> /// - <paramref name="itemQueueProcessorSettings"/> /// - <paramref name="logger"/> /// - <paramref name="processItemFunc"/> /// </exception> public ItemQueueProcessor(IItemQueue <TItem> itemQueue, IItemQueueProcessorSettings itemQueueProcessorSettings, ILogger logger, Func <TItem, CancellationToken, Task <bool> > processItemFunc) { var runningTaks = new TrackedList <Task>(); _ItemQueue = itemQueue ?? throw new ArgumentNullException(nameof(itemQueue)); _ItemQueueProcessorSettings = itemQueueProcessorSettings ?? throw new ArgumentNullException(nameof(itemQueueProcessorSettings)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _ProcessItemFunc = processItemFunc ?? throw new ArgumentNullException(nameof(processItemFunc)); _StartLock = new SemaphoreSlim(0, 1); _ProcessQueueLock = new SemaphoreSlim(1, 1); _RunningThreads = runningTaks; _RunningTask = new Setting <Task>(defaultValue: null); runningTaks.CountSetting.Changed += async(newCount, oldCold) => await ProcessQueueAsync(CancellationToken.None).ConfigureAwait(false); itemQueue.QueueSize.Changed += async(newQueueSize, oldQueueSize) => await ProcessQueueAsync(CancellationToken.None).ConfigureAwait(false); itemQueue.HeldQueueSize.Changed += async(newQueueSize, oldQueueSize) => await ProcessQueueAsync(CancellationToken.None).ConfigureAwait(false); }
private List <RealEstateItem> GetRealEstateItems() { if (this.CurrentItem == null) { return(new List <RealEstateItem>(0)); } List <RealEstateItem> dataSource = new List <RealEstateItem>(this.NumberOfItemsToShow); TrackedList <Guid> categoryIds = (TrackedList <Guid>) this.CurrentItem.GetValue("Category"); foreach (Guid id in categoryIds) { var items = this.RealEstateManager.GetItems() .Where(nI => nI.GetValue <TrackedList <Guid> >("Category").Contains(id)); var filter = items .Distinct() .Where(i => i.Status == ContentLifecycleStatus.Live && i.Id != this.CurrentItem.Id); FlatTaxon itemType = this.CurrentItem.GetTaxon <FlatTaxon>(TaxonType.Types); if (itemType != null) { filter = filter.Where(i => i.GetValue <TrackedList <Guid> >("Types").Contains(itemType.Id)); } FlatTaxon location = this.CurrentItem.GetTaxon <FlatTaxon>(TaxonType.Locations); if (location != null) { filter = filter.Where(i => i.GetValue <TrackedList <Guid> >("Locations").Contains(location.Id)); } return(filter.OrderByDescending(n => n.PublicationDate) .Take(this.NumberOfItemsToShow) .ToList()); } return(new List <RealEstateItem>()); }
public static List <DynamicContent> GetRelatedDynamicContentItemsByHierarchicalTaxonomy(TrackedList <Guid> detailsPageItemTaxonIds, Guid detailPageItemId, string fieldName, string dynamicContentType) { DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); Type contentType = TypeResolutionService.ResolveType(dynamicContentType); var allItems = dynamicModuleManager.GetDataItems(contentType).Where(h => h.Status == ContentLifecycleStatus.Live && h.Visible && h.ApprovalWorkflowState == "Published").ToList(); List <DynamicContent> relatedItems = new List <DynamicContent>(); foreach (var item in allItems) { var articleTaxonIds = item.GetValue <TrackedList <Guid> >(fieldName); if (articleTaxonIds.Any(x => detailsPageItemTaxonIds.Contains(x))) { // Skip the current loaded item in the details page if (item.Id != detailPageItemId) { relatedItems.Add(item); } } } return(relatedItems); }
public DummyDynamicFieldsContainer(params Guid[] taxaItemIds) { Tags = new TrackedList <Guid>(taxaItemIds); }
public Message() { Claims = new TrackedList <MessageClaim>(); }
private void AddMetaDataTagsFromArticle(DynamicContent dynamicContent) { Page.RemoveExistingPublishedTags(); // add published date tags Page.AddCustomMetaTags("Published", dynamicContent.PublicationDate.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture)); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); if (dynamicContent.DoesFieldExist("Category")) { TrackedList <Guid> categoryIds = dynamicContent.GetValue("Category") as TrackedList <Guid>; if (categoryIds != null && categoryIds.Any()) { var categoryList = string.Join(",", categoryIds.Select(cid => taxonomyManager.GetTaxon(cid).Title)); Page.AddCustomMetaTags("webcategory", categoryList); } } if (dynamicContent.DoesFieldExist("resourcetypes")) { TrackedList <Guid> resourcetypesIds = dynamicContent.GetValue("resourcetypes") as TrackedList <Guid>; if (resourcetypesIds != null && resourcetypesIds.Any()) { var resourcetypesList = string.Join(",", resourcetypesIds.Select(cid => taxonomyManager.GetTaxon(cid).Title)); Page.AddCustomMetaTags("resourcetypes", resourcetypesList); } } Page.RemoveExistingModuleTags(); string modulePage = dynamicContent.GetType().Name; try { if (!AppSettingsUtility.GetValue <string>("MetaDataTags.Article.Name").IsNullOrWhitespace()) { modulePage = AppSettingsUtility.GetValue <string>("MetaDataTags.Article.Name"); } } catch (Exception) { } Page.AddCustomMetaTags("Module", modulePage); Type type; if (dynamicContent.SystemParentItem != null) { type = dynamicContent.SystemParentItem.GetType(); } else { type = dynamicContent.GetType(); } string articleType = type.FullName.Split('.')[4]; //Could change this to work with On-Scene Articles... if (articleType.ToLower().Contains("healthprogress")) { Page.AddCustomMetaTags("Publication", "Health Progress"); //Health Progress } if (dynamicContent.DoesFieldExist("author")) { var authorname = dynamicContent.Author; if (authorname != null) { Page.AddCustomMetaTags("ContentAuthor", authorname); } } var authorsFieldName = "organizationalauthors"; if (dynamicContent.DoesFieldExist(authorsFieldName)) { TrackedList <Guid> authorIds = dynamicContent.GetValue(authorsFieldName) as TrackedList <Guid>; if (authorIds != null) { var authorList = string.Join(",", authorIds.Select(cid => taxonomyManager.GetTaxon(cid).Title)); Page.AddCustomMetaTags("contentauthor", authorList); } } }
public ActionResult Details(Telerik.Sitefinity.DynamicModules.Model.DynamicContent item) { dynamic dynamicJobResultsList = null; string location = string.Empty; Dictionary <string, List <string> > locationDict = new Dictionary <string, List <string> >(); if (!string.IsNullOrWhiteSpace(Request.QueryString["location"])) { location = Request.QueryString["location"]; string[] locArr = location.Split(','); for (int i = 0; i < locArr.Length; i++) { var locationDetails = GetLocationGuid(locArr[i].Trim(new char[] { ' ' })); if (locationDetails.Key != null) { if (locationDict.ContainsKey(locationDetails.Key)) { locationDict[locationDetails.Key].Add(locationDetails.Value); } else { locationDict[locationDetails.Key] = new List <string>(); locationDict[locationDetails.Key].Add(locationDetails.Value); } } } } JXTNext_SearchJobsRequest request = new JXTNext_SearchJobsRequest(); JobSearchResultsFilterModel filterModelNew = new JobSearchResultsFilterModel(); if (item.DoesFieldExist("ConsultantName")) { string consultantFullName = item.GetString("ConsultantName"); if (!string.IsNullOrEmpty(consultantFullName)) { ViewBag.ConsultantName = consultantFullName; List <string> consultantNameList = consultantFullName.Split(new char[] { ' ' }).ToList(); filterModelNew.ConsultantSearch = new Consultant(); filterModelNew.ConsultantSearch.Email = null; filterModelNew.ConsultantSearch.FirstName = consultantNameList.First(); if (consultantNameList.Count > 1) { filterModelNew.ConsultantSearch.LastName = consultantNameList.Last(); } if (!this.PageSize.HasValue || this.PageSize.Value <= 0) { this.PageSize = PageSizeDefaultValue; } request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModelNew, this.PageSize, PageSizeDefaultValue); string sortingBy = this.Sorting; if (filterModelNew != null && !filterModelNew.SortBy.IsNullOrEmpty()) { sortingBy = filterModelNew.SortBy; } request.SortBy = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy); ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy); Log.Write($"Job Search by Consultant name request json : " + JsonConvert.SerializeObject(request), ConfigurationPolicy.ErrorLog); ISearchJobsResponse response = _BLConnector.SearchJobs(request); JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse; dynamicJobResultsList = jobResultsList as dynamic; } } else if (item.DoesFieldExist("Email")) { var email = item.GetString("Email"); if (!string.IsNullOrEmpty(email)) { filterModelNew = new JobSearchResultsFilterModel() { ConsultantSearch = new Consultant() { Email = email } }; if (!this.PageSize.HasValue || this.PageSize.Value <= 0) { this.PageSize = PageSizeDefaultValue; } request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModelNew, this.PageSize, PageSizeDefaultValue); string sortingBy = this.Sorting; if (filterModelNew != null && !filterModelNew.SortBy.IsNullOrEmpty()) { sortingBy = filterModelNew.SortBy; } request.SortBy = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy); ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy); Log.Write($"Job Search by Consultant Email request json : " + JsonConvert.SerializeObject(request), ConfigurationPolicy.ErrorLog); ISearchJobsResponse response = _BLConnector.SearchJobs(request); JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse; dynamicJobResultsList = jobResultsList as dynamic; } } filterModelNew.ConsultantSearch = null; filterModelNew.Filters = new List <JobSearchFilterReceiver>(); if (dynamicJobResultsList.Total == 0) { if (item.DoesFieldExist("Category")) { JobSearchFilterReceiver classificationSearch = new JobSearchFilterReceiver(); classificationSearch.rootId = "Classifications"; classificationSearch.searchTarget = "Categories"; classificationSearch.values = new List <JobSearchFilterReceiverItem>(); TrackedList <Guid> classIds = (TrackedList <Guid>)item.GetValue("Category"); if (classIds != null && classIds.Count > 0) { foreach (var id in classIds) { JobSearchFilterReceiverItem filterItem = new JobSearchFilterReceiverItem(); filterItem.ItemID = id.ToString().ToUpper(); filterItem.SubTargets = null; classificationSearch.values.Add(filterItem); } } filterModelNew.Filters.Add(classificationSearch); } if (locationDict.Count > 0) { JobSearchFilterReceiver locationSearch = new JobSearchFilterReceiver(); locationSearch.rootId = "CountryLocationArea"; locationSearch.searchTarget = "Categories"; locationSearch.values = new List <JobSearchFilterReceiverItem>(); foreach (var cnsltLocation in locationDict) { JobSearchFilterReceiverItem filterItem = new JobSearchFilterReceiverItem(); filterItem.ItemID = cnsltLocation.Key.ToString().ToUpper(); filterItem.SubTargets = new List <JobSearchFilterReceiverItem>(); var subLocations = cnsltLocation.Value; foreach (string subLocation in subLocations) { JobSearchFilterReceiverItem jobSearchFilterReceiverItem = new JobSearchFilterReceiverItem(); jobSearchFilterReceiverItem.ItemID = subLocation; jobSearchFilterReceiverItem.SubTargets = null; filterItem.SubTargets.Add(jobSearchFilterReceiverItem); } locationSearch.values.Add(filterItem); } filterModelNew.Filters.Add(locationSearch); } request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModelNew, this.PageSize, PageSizeDefaultValue); string sortBy = this.Sorting; if (filterModelNew != null && !filterModelNew.SortBy.IsNullOrEmpty()) { sortBy = filterModelNew.SortBy; } request.SortBy = JobSearchResultsFilterModel.GetSortEnumFromString(sortBy); ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy); Log.Write($"Job Search by Consultant related classification and location request json : " + JsonConvert.SerializeObject(request), ConfigurationPolicy.ErrorLog); ISearchJobsResponse searchResponse = _BLConnector.SearchJobs(request); JXTNext_SearchJobsResponse relatedJobResultsList = searchResponse as JXTNext_SearchJobsResponse; dynamicJobResultsList = relatedJobResultsList as dynamic; } ViewBag.PageSize = (int)this.PageSize; ViewBag.CssClass = this.CssClass; ViewBag.JobResultsPageUrl = SfPageHelper.GetPageUrlById(ResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(ResultsPageId)); ViewBag.CurrentPageUrl = SfPageHelper.GetPageUrlById(SiteMapBase.GetActualCurrentNode().Id); ViewBag.JobDetailsPageUrl = SfPageHelper.GetPageUrlById(DetailsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(DetailsPageId)); return(this.View(this.templateNamePrefix + this.TemplateName, dynamicJobResultsList)); }