internal static async Task <string> RenderReplacementPackageModulesDesignedAsync(string areaName) { List <SelectionItem <string> > list = ( from module in await DesignedModules.LoadDesignedModulesAsync() where module.AreaName == areaName orderby module.Name select new SelectionItem <string> { Text = module.Name, Value = module.ModuleGuid.ToString(), Tooltip = module.Description, }).ToList <SelectionItem <string> >(); list.Insert(0, new SelectionItem <string> { Text = __ResStr("none", "(none)"), Value = null }); return(DropDownListEditComponentBase <string> .RenderDataSource(list, areaName)); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(Guid?model) { model = model ?? Guid.Empty; string areaName = await ModuleSelectionModuleNewEditComponent.GetAreaNameFromGuidAsync(false, model); List <SelectionItem <string> > list = ( from module in await DesignedModules.LoadDesignedModulesAsync() where module.AreaName == areaName orderby module.Name select new SelectionItem <string> { Text = module.Name, Value = module.ModuleGuid.ToString(), Tooltip = module.Description, }).ToList <SelectionItem <string> >(); list.Insert(0, new SelectionItem <string> { Text = this.__ResStr("none", "(none)"), Value = null }); return(await DropDownListComponent.RenderDropDownListAsync(this, model.ToString(), list, null)); }
private GridDefinition GetGridModel() { return(new GridDefinition { ModuleGuid = Module.ModuleGuid, SettingsModuleGuid = Module.PermanentGuid, InitialPageSize = 20, RecordType = typeof(BrowseItem), AjaxUrl = GetActionUrl(nameof(ModulesBrowse_GridData)), DirectDataAsync = async(int skip, int take, List <DataProviderSortInfo> sort, List <DataProviderFilterInfo> filters) => { // module settings services ModuleDefinition modSettings = await ModuleDefinition.LoadAsync(Manager.CurrentSite.ModuleEditingServices, AllowNone : true); //if (modSettings == null) // throw new InternalError("No module edit settings services available - no module has been defined"); Module.ModuleBrowseInfo info = new Module.ModuleBrowseInfo() { Skip = skip, Take = take, Sort = sort, Filters = filters, }; await YetaWF.Core.IO.Module.GetModulesAsync(info); SerializableList <DesignedModule> designedList = await DesignedModules.LoadDesignedModulesAsync(); List <BrowseItem> list = new List <BrowseItem>(); foreach (ModuleDefinition s in info.Modules) { int useCount = (await s.__GetPagesAsync()).Count; list.Add(new BrowseItem(Module, modSettings, designedList, s, useCount)); } return new DataSourceResult { Data = list.ToList <object>(), Total = info.Total }; }, }); }
internal static async Task <string> GetAreaNameFromGuidAsync(bool newMods, Guid?moduleGuid) { if (moduleGuid != null && moduleGuid != Guid.Empty) { if (newMods) { InstalledModules.ModuleTypeEntry modEntry = InstalledModules.TryFindModuleEntry((Guid)moduleGuid); if (modEntry != null) { return(modEntry.Package.AreaName); } else { moduleGuid = null; } } else { return((from m in await DesignedModules.LoadDesignedModulesAsync() where m.ModuleGuid == (Guid)moduleGuid select m.AreaName).FirstOrDefault()); } } return(null); }
/// <summary> /// Creates a site map for the current site. /// </summary> public async Task CreateAsync(bool slow = false) { string file = GetTempFile(); await FileSystem.FileSystemProvider.DeleteFileAsync(file); // header await FileSystem.FileSystemProvider.AppendAllTextAsync(file, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n" + "<urlset xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns =\"http://www.sitemaps.org/schemas/sitemap/0.9\" >\r\n" ); // Dynamic Urls in types DynamicUrlsImpl dynamicUrls = new DynamicUrlsImpl(); List <Type> types = dynamicUrls.GetDynamicUrlTypes(); foreach (Type type in types) { ISiteMapDynamicUrls iSiteMap = Activator.CreateInstance(type) as ISiteMapDynamicUrls; if (iSiteMap != null) { await iSiteMap.FindDynamicUrlsAsync(AddSiteMapPageAsync, ValidForSiteMap); } } // search all designed modules that have dynamic urls foreach (DesignedModule desMod in await DesignedModules.LoadDesignedModulesAsync()) { ModuleDefinition mod = await ModuleDefinition.LoadAsync(desMod.ModuleGuid, AllowNone : true); if (mod != null) { ISiteMapDynamicUrls iSiteMap = mod as ISiteMapDynamicUrls; if (iSiteMap != null) { await iSiteMap.FindDynamicUrlsAsync(AddSiteMapPageAsync, ValidForSiteMap); } } } // Designed pages List <Guid> pages = await PageDefinition.GetDesignedGuidsAsync(); foreach (Guid pageGuid in pages) { PageDefinition page = await PageDefinition.LoadAsync(pageGuid); if (page == null) { continue; } if (!PagesFound.Contains(page.PageGuid)) // don't include same again (this could be a page that generates dynamic Urls) { await AddUrlAsync(file, page, page.EvaluatedCanonicalUrl, page.Updated, page.SiteMapPriority, page.ChangeFrequency); } } // end await FileSystem.FileSystemProvider.AppendAllTextAsync(file, "</urlset>\r\n" ); string finalFile = GetFile(); await FileSystem.FileSystemProvider.DeleteFileAsync(finalFile); await FileSystem.FileSystemProvider.MoveFileAsync(file, finalFile); if (Manager.CurrentSite.DefaultSiteMap) { await FileSystem.FileSystemProvider.CopyFileAsync(finalFile, Path.Combine(YetaWFManager.RootFolder, "sitemap.xml")); } }
public async Task SearchSiteAsync(bool slow) { SearchConfigData searchConfig = await SearchConfigDataProvider.GetConfigAsync(); DateTime searchStarted = DateTime.UtcNow; // once we have all new keywords, delete all keywords that were added before this date/time using (SearchDataProvider searchDP = new SearchDataProvider()) { // Search all generated pages (unique modules or classes, like data providers) DynamicUrlsImpl dynamicUrls = new DynamicUrlsImpl(); List <Type> types = dynamicUrls.GetDynamicUrlTypes(); // search types that generate dynamic urls foreach (Type type in types) { #if DEBUG // if (type.Name != "FileDocumentDisplayModule") continue;//used for debugging #endif ISearchDynamicUrls iSearch = Activator.CreateInstance(type) as ISearchDynamicUrls; if (iSearch != null) { try { SearchWords searchWords = new SearchWords(searchConfig, searchDP, searchStarted); await iSearch.KeywordsForDynamicUrlsAsync(searchWords); if (slow) { Thread.Sleep(500);// delay a bit (slow can only be used by scheduler items) } } catch (Exception exc) { Logging.AddErrorLog("KeywordsForDynamicUrls failed for {0}", type.FullName, exc); } } } // search all designed modules that have dynamic urls foreach (DesignedModule desMod in await DesignedModules.LoadDesignedModulesAsync()) { try { ModuleDefinition mod = await ModuleDefinition.LoadAsync(desMod.ModuleGuid, AllowNone : true); if (mod != null && types.Contains(mod.GetType()) && mod.WantSearch) { ISearchDynamicUrls iSearch = mod as ISearchDynamicUrls; if (iSearch != null) { SearchWords searchWords = new SearchWords(searchConfig, searchDP, searchStarted); await iSearch.KeywordsForDynamicUrlsAsync(searchWords); if (slow) { Thread.Sleep(500);// delay a bit (slow can only be used by scheduler items) } } } } catch (Exception exc) { Logging.AddErrorLog("KeywordsForDynamicUrls failed for module {0}", desMod.ModuleGuid, exc); } } // Search all designed pages and extract keywords List <Guid> pages = await PageDefinition.GetDesignedGuidsAsync(); foreach (Guid pageGuid in pages) { PageDefinition page = await PageDefinition.LoadAsync(pageGuid); if (page != null) { SearchWords searchWords = new SearchWords(searchConfig, searchDP, searchStarted); await SearchPageAsync(searchWords, page); if (slow) { Thread.Sleep(500);// delay a bit (slow can only be used by scheduler items) } } } // Remove old keywords await searchDP.RemoveOldItemsAsync(searchStarted); } }