/// <summary>
        /// Import products using given parameters
        /// </summary>
        Task <ProductImporterResult> IProductImporter.Import(ProductImportContext context, object parameters)
        {
            var result = Import(context, (TParameters)parameters);

            Parameters = GenerateParameters();
            return(result);
        }
Exemplo n.º 2
0
        public async Task <ProductImportResult> Import(string importerName, object parameters)
        {
            var importer = _importers.First(i => i.Name == importerName);
            var context  = new ProductImportContext();
            var result   = await importer.Import(context, parameters);

            HandleResult(result);

            return(result);
        }
Exemplo n.º 3
0
        public ImportState ImportParallel(string importerName, object parameters)
        {
            var context = new ProductImportContext();
            var session = new ImportState(this)
            {
                Session = context.Session
            };

            _runningImports.Add(context.Session, session);

            var importer = _importers.First(i => i.Name == importerName);
            var task     = importer.Import(context, parameters);

            task.ContinueWith(session.TaskCompleted);

            // Wait for the task unless it is long running
            if (!importer.LongRunning)
            {
                task.Wait(new TimeSpan(0, 0, 0, Config.MaxImporterWait));
            }

            // Return session object, it can be running, completed or faulted in the meantime
            return(session);
        }
 /// <summary>
 /// Import products using typed parameters
 /// </summary>
 protected abstract Task <ProductImporterResult> Import(ProductImportContext context, TParameters parameters);