Пример #1
0
        public override async Task ProcessActivityAsync(IStatus status)
        {
            var updateWishlistTask = await statusController.CreateAsync(status, "Update Wishlisted");

            var requestContentTask = await statusController.CreateAsync(updateWishlistTask, "Request content");

            var wishlistedProductPageResult = await getProductsPageResultDelegate.GetDeserializedAsync(
                requestContentTask,
                Uris.Paths.Account.Wishlist);

            await statusController.CompleteAsync(requestContentTask);

            var saveDataTask = await statusController.CreateAsync(updateWishlistTask, "Save");

            foreach (var product in wishlistedProductPageResult.Products)
            {
                if (product == null)
                {
                    continue;
                }
                await wishlistedDataController.CreateAsync(product.Id, saveDataTask);
            }

            await statusController.CompleteAsync(saveDataTask);

            await wishlistedDataController.CommitAsync(updateWishlistTask);

            await statusController.CompleteAsync(updateWishlistTask);
        }
Пример #2
0
        public override async Task ProcessActivityAsync(IStatus status)
        {
            // This activity will centralize processing and marking updated account products.
            // Currently the process is the following:
            // 1) Itemize account products that were created after last updateData-accountProducts
            // Please note, that every updateData-accountProducts that results in new products will
            // overwrite this timestamp, so it's expected that updateData-updated is run between the
            // sessions that produce new account products.
            // 2) Itemize all account products and confirm is isNew or Updates passes the condition
            // ...
            // In the future additional heuristics can be employed - such as using products, not just
            // account products and other. Currently they are considered as YAGNI

            var updateDataUpdatedStatus = await statusController.CreateAsync(status, "Process updated account products");

            var addNewlyCreatedStatus = await statusController.CreateAsync(updateDataUpdatedStatus, "Add account products created since last data update");

            var accountProductsNewOrUpdated = new List <long>();

            //var lastUpdatedAccountProductsData = await activityContextCreatedIndexController.GetCreatedAsync(
            //    activityContextController.ToString((A.UpdateData, Context.AccountProducts)), addNewlyCreatedStatus);

            //var newlyCreatedAccountProducts = await accountProductDataController.ItemizeAsync(lastUpdatedAccountProductsData, addNewlyCreatedStatus);

            //accountProductsNewOrUpdated.AddRange(newlyCreatedAccountProducts);

            await statusController.CompleteAsync(addNewlyCreatedStatus);

            var addUpdatedAccountProductsStatus = await statusController.CreateAsync(updateDataUpdatedStatus, "Add updated account products");

            var current = 0;

            foreach (var id in await accountProductDataController.ItemizeAllAsync(addUpdatedAccountProductsStatus))
            {
                await statusController.UpdateProgressAsync(
                    addUpdatedAccountProductsStatus,
                    ++current,
                    await accountProductDataController.CountAsync(addUpdatedAccountProductsStatus),
                    id.ToString());

                var accountProduct = await accountProductDataController.GetByIdAsync(id, status);

                if (confirmAccountProductUpdatedDelegate.Confirm(accountProduct))
                {
                    accountProductsNewOrUpdated.Add(id);
                }
            }

            foreach (var accountProduct in accountProductsNewOrUpdated)
            {
                await updatedIndexController.CreateAsync(accountProduct, addUpdatedAccountProductsStatus);
            }

            await statusController.CompleteAsync(addUpdatedAccountProductsStatus);

            await updatedIndexController.CommitAsync(updateDataUpdatedStatus);

            await statusController.CompleteAsync(updateDataUpdatedStatus);
        }