public AdminController(IContentManager contentManager, IOrchardServices services, IShapeFactory shapeFactory, IContentDefinitionManager contentDefinitionManager, IRemoteContentFetchService remoteContentFetchService, ISynchronisationMapFactory synchronisationMapFactory, IRepository<ContentSyncSettings> contentSyncSettingsRepository, ISignals signals, ILoggerFactory loggerFactory, ICacheManager cacheManager, IImportExportService importExportService, IRecipeParser recipeParser, IRemoteImportService remoteImportService, IEnumerable<IHardComparer> hardComparers, IEnumerable<ISoftComparer> softComparers) { _contentManager = contentManager; _services = services; _shapeFactory = shapeFactory; _contentDefinitionManager = contentDefinitionManager; _remoteContentFetchService = remoteContentFetchService; _synchronisationMapFactory = synchronisationMapFactory; _contentSyncSettingsRepository = contentSyncSettingsRepository; _signals = signals; _loggerFactory = loggerFactory; _cacheManager = cacheManager; _importExportService = importExportService; _recipeParser = recipeParser; _remoteImportService = remoteImportService; _hardComparers = hardComparers; _softComparers = softComparers; Logger = loggerFactory.CreateLogger(typeof (AdminController)); }
public ExecuteRecipeAction( IOrchardServices orchardServices, ISetupService setupService, ShellSettings shellSettings, IEnumerable<IRecipeExecutionStep> recipeExecutionSteps, IRecipeParser recipeParser, IRecipeExecutor recipeExecutor, IDatabaseManager databaseManager, ISweepGenerator sweepGenerator, IRecipeStepQueue recipeStepQueue, IRepository<RecipeStepResultRecord> recipeStepResultRepository) { _orchardServices = orchardServices; _setupService = setupService; _shellSettings = shellSettings; _recipeExecutionSteps = recipeExecutionSteps; _recipeParser = recipeParser; _recipeExecutor = recipeExecutor; _databaseManager = databaseManager; _sweepGenerator = sweepGenerator; _recipeStepQueue = recipeStepQueue; _recipeStepResultRepository = recipeStepResultRepository; RecipeExecutionTimeout = 600; }
public RecipeExecutor( IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager) { _recipeManager = recipeManager; _shellDescriptorManager = shellDescriptorManager; }
public RecipePartHandler(IRecipeParser recipeParser) { _recipeParser = recipeParser; OnLoading<RecipePart>((context, part) => LazyLoadHandlers(part)); OnVersioning<RecipePart>((context, part, newVersionPart) => LazyLoadHandlers(newVersionPart)); }
public RecipeExecutor( IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager) { _recipeManager = recipeManager; _shellDescriptorManager = shellDescriptorManager; }
public override void Init() { base.Init(); _recipeManager = _container.Resolve <IRecipeManager>(); _recipeParser = _container.Resolve <IRecipeParser>(); _recipeHarvester = _container.Resolve <IRecipeHarvester>(); }
public RecipeHarvester( IExtensionManager extensionManager, IWebSiteFolder webSiteFolder, IRecipeParser recipeParser) { _extensionManager = extensionManager; _webSiteFolder = webSiteFolder; _recipeParser = recipeParser; Logger = NullLogger.Instance; T = NullLocalizer.Instance; }
public RemoteContentFetchService( IRecipeParser recipeParser, IOrchardServices orchardServices, Lazy<IEnumerable<IContentHandler>> handlers, ILoggerFactory loggerFactory) { _recipeParser = recipeParser; _orchardServices = orchardServices; _handlers = handlers; Logger = loggerFactory.CreateLogger(typeof (RemoteContentFetchService)); }
public RecipeHarvester( IExtensionManager extensionManager, IWebSiteFolder webSiteFolder, IRecipeParser recipeParser) { _extensionManager = extensionManager; _webSiteFolder = webSiteFolder; _recipeParser = recipeParser; Logger = NullLogger.Instance; T = NullLocalizer.Instance; }
public AdminController( IOrchardServices services, IImportExportService importExportService, IRecipeResultAccessor recipeResultAccessor, IEnumerable <IExportAction> exportActions, IEnumerable <IImportAction> importActions, IRecipeParser recipeParser) { _importExportService = importExportService; _recipeResultAccessor = recipeResultAccessor; _exportActions = exportActions; _importActions = importActions; _recipeParser = recipeParser; Services = services; T = NullLocalizer.Instance; }
public ImportExportService( IOrchardServices orchardServices, IContentDefinitionManager contentDefinitionManager, IContentDefinitionWriter contentDefinitionWriter, IAppDataFolder appDataFolder, IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager) { _orchardServices = orchardServices; _contentDefinitionManager = contentDefinitionManager; _contentDefinitionWriter = contentDefinitionWriter; _appDataFolder = appDataFolder; _recipeParser = recipeParser; _recipeManager = recipeManager; _shellDescriptorManager = shellDescriptorManager; Logger = NullLogger.Instance; T = NullLocalizer.Instance; }
public ImportExportService( IOrchardServices orchardServices, IContentDefinitionManager contentDefinitionManager, IContentDefinitionWriter contentDefinitionWriter, IAppDataFolder appDataFolder, IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager) { _orchardServices = orchardServices; _contentDefinitionManager = contentDefinitionManager; _contentDefinitionWriter = contentDefinitionWriter; _appDataFolder = appDataFolder; _recipeParser = recipeParser; _recipeManager = recipeManager; _shellDescriptorManager = shellDescriptorManager; Logger = NullLogger.Instance; T = NullLocalizer.Instance; }
public LenientImportExportService(IOrchardServices orchardServices, IContentDefinitionManager contentDefinitionManager, IContentDefinitionWriter contentDefinitionWriter, IAppDataFolder appDataFolder, IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager, IClock clock, IEnumerable <IExportEventHandler> exportEventHandlers, IEnumerable <IExportAction> exportActions, IEnumerable <IImportAction> importActions) : base(orchardServices, appDataFolder, clock, exportActions, importActions) { _orchardServices = orchardServices; _contentDefinitionManager = contentDefinitionManager; _contentDefinitionWriter = contentDefinitionWriter; _appDataFolder = appDataFolder; _clock = clock; _exportEventHandlers = exportEventHandlers; }
public RecipeExecutor( IEventBus eventBus, ISession session, IRecipeParser recipeParser, IOrchardFileSystem fileSystem, IApplicationLifetime applicationLifetime, ShellSettings shellSettings, IOrchardHost orchardHost, ILogger<RecipeExecutor> logger, IStringLocalizer<RecipeExecutor> localizer) { _orchardHost = orchardHost; _shellSettings = shellSettings; _applicationLifetime = applicationLifetime; _eventBus = eventBus; _session = session; _recipeParser = recipeParser; _fileSystem = fileSystem; _logger = logger; T = localizer; }
public RecipeExecutor( IEventBus eventBus, ISession session, IRecipeParser recipeParser, IOrchardFileSystem fileSystem, IApplicationLifetime applicationLifetime, ShellSettings shellSettings, IOrchardHost orchardHost, ILogger <RecipeExecutor> logger, IStringLocalizer <RecipeExecutor> localizer) { _orchardHost = orchardHost; _shellSettings = shellSettings; _applicationLifetime = applicationLifetime; _eventBus = eventBus; _session = session; _recipeParser = recipeParser; _fileSystem = fileSystem; _logger = logger; T = localizer; }
public ImportExportService( IOrchardServices orchardServices, IContentDefinitionManager contentDefinitionManager, IContentDefinitionWriter contentDefinitionWriter, IAppDataFolder appDataFolder, IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager, IClock clock, IEnumerable<IExportEventHandler> exportEventHandlers) { _orchardServices = orchardServices; _contentDefinitionManager = contentDefinitionManager; _contentDefinitionWriter = contentDefinitionWriter; _appDataFolder = appDataFolder; _recipeParser = recipeParser; _recipeManager = recipeManager; _shellDescriptorManager = shellDescriptorManager; _clock = clock; _exportEventHandlers = exportEventHandlers; Logger = NullLogger.Instance; T = NullLocalizer.Instance; }
public ImportExportService( IOrchardServices orchardServices, IContentDefinitionManager contentDefinitionManager, IContentDefinitionWriter contentDefinitionWriter, IAppDataFolder appDataFolder, IRecipeParser recipeParser, IRecipeManager recipeManager, IShellDescriptorManager shellDescriptorManager, IClock clock, IEnumerable <IExportEventHandler> exportEventHandlers) { _orchardServices = orchardServices; _contentDefinitionManager = contentDefinitionManager; _contentDefinitionWriter = contentDefinitionWriter; _appDataFolder = appDataFolder; _recipeParser = recipeParser; _recipeManager = recipeManager; _shellDescriptorManager = shellDescriptorManager; _clock = clock; _exportEventHandlers = exportEventHandlers; Logger = NullLogger.Instance; T = NullLocalizer.Instance; }
public ExecuteRecipeAction( IOrchardServices orchardServices, ISetupService setupService, ShellSettings shellSettings, IEnumerable <IRecipeExecutionStep> recipeExecutionSteps, IRecipeParser recipeParser, IRecipeExecutor recipeExecutor, IDatabaseManager databaseManager, ISweepGenerator sweepGenerator, IRecipeStepQueue recipeStepQueue, IRepository <RecipeStepResultRecord> recipeStepResultRepository) { _orchardServices = orchardServices; _setupService = setupService; _shellSettings = shellSettings; _recipeExecutionSteps = recipeExecutionSteps; _recipeParser = recipeParser; _recipeExecutor = recipeExecutor; _databaseManager = databaseManager; _sweepGenerator = sweepGenerator; _recipeStepQueue = recipeStepQueue; _recipeStepResultRepository = recipeStepResultRepository; }
public RecipesController( ICookingProcedureProvider cookingProcedureProvider, IIngredientProvider ingredientProvider, IIngredientMapper ingredientMapper, IRecipeProvider recipeProvider, IRecipeMapper recipeMapper, IPdfGenerator pdfGenerator, IScraper scraper, IRecipeParser RecipeParser, ISiteSettingsProvider siteSettingsProvider, IFileHandler fileHandler ) { this.cookingProcedureProvider = cookingProcedureProvider; this.ingredientProvider = ingredientProvider; this.ingredientMapper = ingredientMapper; this.recipeProvider = recipeProvider; this.recipeMapper = recipeMapper; this.pdfGenerator = pdfGenerator; this.scraper = scraper; this.RecipeParser = RecipeParser; this.siteSettingsProvider = siteSettingsProvider; this.fileHandler = fileHandler; }
public static Recipe ParseRecipe(this IRecipeParser recipeParser, string recipeText) { var recipeDocument = XDocument.Parse(recipeText, LoadOptions.PreserveWhitespace); return(recipeParser.ParseRecipe(recipeDocument)); }
public void Init() { _tempFolderName = Path.GetTempFileName(); File.Delete(_tempFolderName); var assembly = GetType().Assembly; foreach (var name in assembly.GetManifestResourceNames()) { if (name.StartsWith(DataPrefix)) { string text; using (var stream = assembly.GetManifestResourceStream(name)) { using (var reader = new StreamReader(stream)) text = reader.ReadToEnd(); } // Pro filtering var relativePath = name .Substring(DataPrefix.Length) .Replace(".txt", ":txt") .Replace(".recipe.xml", ":recipe:xml") .Replace('.', Path.DirectorySeparatorChar) .Replace(":txt", ".txt") .Replace(":recipe:xml", ".recipe.xml"); var targetPath = Path.Combine(_tempFolderName, relativePath); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); using (var stream = new FileStream(targetPath, FileMode.Create)) { using (var writer = new StreamWriter(stream)) { writer.Write(text); } } } } var builder = new ContainerBuilder(); var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock<ICriticalErrorProvider>().Object); _folders = new ModuleFolders(new[] { _tempFolderName }, harvester); builder.RegisterType<RecipeManager>().As<IRecipeManager>(); builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>(); builder.RegisterType<RecipeStepExecutor>().As<IRecipeStepExecutor>(); builder.RegisterType<StubStepQueue>().As<IRecipeStepQueue>().InstancePerLifetimeScope(); builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>(); builder.RegisterType<StubRecipeScheduler>().As<IRecipeScheduler>(); builder.RegisterType<ExtensionManager>().As<IExtensionManager>(); builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>(); builder.RegisterType<StubClock>().As<IClock>(); builder.RegisterType<StubCacheManager>().As<ICacheManager>(); builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>(); builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>(); builder.RegisterInstance(_folders).As<IExtensionFolders>(); builder.RegisterInstance(new Mock<IRecipeExecuteEventHandler>().Object); builder.RegisterType<Environment.Extensions.ExtensionManagerTests.StubLoaders>().As<IExtensionLoader>(); builder.RegisterType<RecipeParser>().As<IRecipeParser>(); builder.RegisterType<StubWebSiteFolder>().As<IWebSiteFolder>(); builder.RegisterType<CustomRecipeHandler>().As<IRecipeHandler>(); _container = builder.Build(); _recipeManager = _container.Resolve<IRecipeManager>(); _recipeParser = _container.Resolve<IRecipeParser>(); _recipeHarvester = _container.Resolve<IRecipeHarvester>(); }
public RecipeManager( IContentManager contentManager, IRecipeParser recipeParser) { _contentManager = contentManager; }
public void Init() { _tempFolderName = Path.GetTempFileName(); File.Delete(_tempFolderName); var assembly = GetType().Assembly; foreach (var name in assembly.GetManifestResourceNames()) { if (name.StartsWith(DataPrefix)) { string text; using (var stream = assembly.GetManifestResourceStream(name)) { using (var reader = new StreamReader(stream)) text = reader.ReadToEnd(); } // Pro filtering var relativePath = name .Substring(DataPrefix.Length) .Replace(".txt", ":txt") .Replace(".recipe.xml", ":recipe:xml") .Replace('.', Path.DirectorySeparatorChar) .Replace(":txt", ".txt") .Replace(":recipe:xml", ".recipe.xml"); var targetPath = Path.Combine(_tempFolderName, relativePath); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); using (var stream = new FileStream(targetPath, FileMode.Create)) { using (var writer = new StreamWriter(stream)) { writer.Write(text); } } } } var builder = new ContainerBuilder(); var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock <ICriticalErrorProvider>().Object); _folders = new ModuleFolders(new[] { _tempFolderName }, harvester); builder.RegisterType <RecipeManager>().As <IRecipeManager>(); builder.RegisterType <RecipeHarvester>().As <IRecipeHarvester>(); builder.RegisterType <RecipeStepExecutor>().As <IRecipeStepExecutor>(); builder.RegisterType <StubStepQueue>().As <IRecipeStepQueue>().InstancePerLifetimeScope(); builder.RegisterType <StubRecipeJournal>().As <IRecipeJournal>(); builder.RegisterType <StubRecipeScheduler>().As <IRecipeScheduler>(); builder.RegisterType <ExtensionManager>().As <IExtensionManager>(); builder.RegisterType <StubAppDataFolder>().As <IAppDataFolder>(); builder.RegisterType <StubClock>().As <IClock>(); builder.RegisterType <StubCacheManager>().As <ICacheManager>(); builder.RegisterType <StubParallelCacheContext>().As <IParallelCacheContext>(); builder.RegisterType <StubAsyncTokenProvider>().As <IAsyncTokenProvider>(); builder.RegisterInstance(_folders).As <IExtensionFolders>(); builder.RegisterType <Environment.Extensions.ExtensionManagerTests.StubLoaders>().As <IExtensionLoader>(); builder.RegisterType <RecipeParser>().As <IRecipeParser>(); builder.RegisterType <StubWebSiteFolder>().As <IWebSiteFolder>(); builder.RegisterType <CustomRecipeHandler>().As <IRecipeHandler>(); _container = builder.Build(); _recipeManager = _container.Resolve <IRecipeManager>(); _recipeParser = _container.Resolve <IRecipeParser>(); _recipeHarvester = _container.Resolve <IRecipeHarvester>(); }
public override void Init() { base.Init(); _recipeManager = _container.Resolve<IRecipeManager>(); _recipeParser = _container.Resolve<IRecipeParser>(); _recipeHarvester = _container.Resolve<IRecipeHarvester>(); }
public static void ParseRecipesImpl( string ingredientsLogFileName, string downloaderPath, IIngredientClassifier classifier, IIngredientTypes types, List <ClassifiedRecipe> recipes) { Dictionary <string, int> whyNotParsed = new Dictionary <string, int>(); var sources = new List <KeyValuePair <IRecipeDownloader, IRecipeParser> >(); // adding skinnytaste sources.Add( new KeyValuePair <IRecipeDownloader, IRecipeParser>( new SkinnyTasteRecipeDownloader("/", downloaderPath), new SkinnyTasteRecipeParser() )); // adding paleoleap sources.Add( new KeyValuePair <IRecipeDownloader, IRecipeParser>( new PaleoLeapRecipeDownloader("/", downloaderPath), new PaleoLeapRecipeParser() )); int recipesTotal = 0, recipesParsed = 0; HashSet <string> ingredientTypesUsed = new HashSet <string>(); HashSet <string> ingredientGroupsUsed = new HashSet <string>(); using (StreamWriter interpretedIngredients = new StreamWriter(ingredientsLogFileName)) { interpretedIngredients.WriteLine("url\tdeclaration\tdetail\tquantity\tname\tclass\ttype"); foreach (var source in sources) { IRecipeDownloader d = source.Key; IRecipeParser p = source.Value; foreach (RawWebPage rawWebPage in d.DownloadedAlready) { ++recipesTotal; rawWebPage.Name = RecipeDownloader.RemoveSpecialCharacters(rawWebPage.Name); RecipeParsingResult parsed = p.TryParseRawWebPage(rawWebPage); if (!parsed.Succeeded) { Console.Error.WriteLine("WARNING: failed to parse {0}:{1}:{2} ({3})", rawWebPage.Source, rawWebPage.Url, rawWebPage.FileName, parsed.ErrorMessage); if (!whyNotParsed.ContainsKey(parsed.ErrorMessage)) { whyNotParsed[parsed.ErrorMessage] = 0; } ++whyNotParsed[parsed.ErrorMessage]; continue; } ++recipesParsed; Recipe recipe = parsed.Result; ClassifiedRecipe makingSenseOfIt = classifier.ClassifyIngredients(recipe); if (makingSenseOfIt.Succeeded) { recipes.Add(makingSenseOfIt); } foreach (var ingredient in recipe.Ingredients) { // understand what kind of ingredient this is string ingredientClass = null; IngredientType ingredientType = null; if (null != ingredient.Name && !makingSenseOfIt.Classification.Classified.TryGetValue(ingredient.Name, out ingredientClass)) { ingredientClass = null; } if (null != ingredientClass && !types.ClassToType.TryGetValue(ingredientClass, out ingredientType)) { ingredientType = null; } if (null == ingredientClass) { ingredientClass = "[unknown]"; } if (null == ingredientType) { ingredientType = new IngredientType(); } interpretedIngredients.WriteLine("{0}\t{1}\t{2}\t=\"{3}\"\t{4}\t{5}\t{6}", d.UrlRoot + recipe.OriginalWebPage.Url, ingredient.Declaration, ingredient.Detail, ingredient.Quantity, ingredient.Name.Name, ingredientClass, ingredientType); ingredientTypesUsed.Add(ingredientType.Type); ingredientGroupsUsed.Add(ingredientType.Group); } } } } Console.WriteLine("Recipes: {0} total, {1} parsed, {2} distinct ingredient types, {3} distinct ingredient groups used", recipesTotal, recipesParsed, ingredientTypesUsed.Count, ingredientGroupsUsed.Count); List <KeyValuePair <string, int> > whyNot = new List <KeyValuePair <string, int> >(whyNotParsed); whyNot.Sort((KeyValuePair <string, int> x, KeyValuePair <string, int> y) => { return(-x.Value.CompareTo(y.Value)); }); foreach (var whyNotElement in whyNot) { Console.WriteLine("Failed to parse {0} recipe pages because {1}.", whyNotElement.Value, whyNotElement.Key); } }