예제 #1
0
        public async Task UpdateAsync(Type updatedData, IStatus status)
        {
            var data = await stashController.GetDataAsync(status);

            var index = convertProductToIndexDelegate.Convert(updatedData);

            if (!data.ContainsKey(index))
            {
                data.Add(index, updatedData);

                if (recordsController != null)
                {
                    await recordsController.SetRecordAsync(
                        index,
                        RecordsTypes.Created,
                        status);
                }
            }
            else
            {
                data[index] = updatedData;

                if (recordsController != null)
                {
                    await recordsController.SetRecordAsync(
                        index,
                        RecordsTypes.Updated,
                        status);
                }
            }
        }
예제 #2
0
        public override async Task ProcessActivityAsync(IStatus status)
        {
            var updateAllProductsTask = await statusController.CreateAsync(status, $"Update {activityContext.Item2}");

            var activityContextString = activityContextController.ToString(activityContext);

            await activityRecordsController.SetRecordAsync(activityContextString, RecordsTypes.Started, updateAllProductsTask);

            var productsPageResults = await getPageResultsAsyncDelegate.GetPageResultsAsync(updateAllProductsTask);

            var extractTask = await statusController.CreateAsync(updateAllProductsTask, $"Extract {activityContext.Item2}");

            var newProducts = itemizePageResultsDelegate.Itemize(productsPageResults);
            await statusController.CompleteAsync(extractTask);

            if (newProducts.Any())
            {
                var updateTask = await statusController.CreateAsync(updateAllProductsTask, $"Save {activityContext.Item2}");

                var current             = 0;
                var updateProgressEvery = 10;

                foreach (var product in newProducts)
                {
                    if (++current % updateProgressEvery == 0)
                    {
                        await statusController.UpdateProgressAsync(updateTask, current, newProducts.Count(), product.Title);
                    }

                    await dataController.UpdateAsync(product, updateTask);
                }

                await statusController.CompleteAsync(updateTask);
            }

            await activityRecordsController.SetRecordAsync(activityContextString, RecordsTypes.Completed, updateAllProductsTask);

            await dataController.CommitAsync(updateAllProductsTask);

            await statusController.CompleteAsync(updateAllProductsTask);
        }
예제 #3
0
 public async Task SetRecordAsync(string activity, RecordsTypes recordType, IStatus status)
 {
     var index = convertStringToIndexDelegate.Convert(activity);
     await indexRecordsController.SetRecordAsync(index, recordType, status);
 }