コード例 #1
0
        private BackupObject GetBackupObject(Action <ExportImportProgressInfo> progressCallback)
        {
            var result       = new BackupObject();
            var progressInfo = new ExportImportProgressInfo {
                Description = "Search promotions..."
            };

            progressCallback(progressInfo);
            var allPromotions = _marketingSearchService.SearchResources(new MarketingSearchCriteria
            {
                Count         = int.MaxValue,
                ResponseGroup = SearchResponseGroup.WithPromotions
            }).Promotions;

            progressInfo.Description = String.Format("{0} promotions loading...", allPromotions.Count());
            progressCallback(progressInfo);
            result.Promotions = allPromotions.Select(x => _promotionService.GetPromotionById(x.Id)).ToList();

            progressInfo.Description = "Search dynamic content objects...";
            progressCallback(progressInfo);

            var searchResult           = SearchInFolder(null);
            var allFolderSearchResults = searchResult != null?searchResult.Traverse(ChildrenForFolder).ToArray() : null;


            if (allFolderSearchResults != null)
            {
                progressInfo.Description = String.Format("Loading folders...");
                progressCallback(progressInfo);
                result.ContentFolders = allFolderSearchResults.SelectMany(x => x.ContentFolders).ToList();

                progressInfo.Description = String.Format("Loading places...");
                progressCallback(progressInfo);
                result.ContentPlaces = allFolderSearchResults.SelectMany(x => x.ContentPlaces)
                                       .Select(x => _dynamicContentService.GetPlaceById(x.Id))
                                       .ToList();

                progressInfo.Description = String.Format("Loading contents...");
                progressCallback(progressInfo);
                result.ContentItems = allFolderSearchResults.SelectMany(x => x.ContentItems)
                                      .Select(x => _dynamicContentService.GetContentItemById(x.Id))
                                      .ToList();

                progressInfo.Description = String.Format("Loading publications...");
                progressCallback(progressInfo);
                result.ContentPublications = allFolderSearchResults.SelectMany(x => x.ContentPublications)
                                             .Select(x => _dynamicContentService.GetPublicationById(x.Id))
                                             .ToList();
            }
            return(result);
        }
コード例 #2
0
        private void ContentComplete(IEnumerable <string> folderIds, BackupObject backupObject)
        {
            const SearchResponseGroup responseGroup = SearchResponseGroup.WithFolders | SearchResponseGroup.WithContentItems
                                                      | SearchResponseGroup.WithContentPlaces;

            foreach (var folderId in folderIds)
            {
                var responce =
                    _marketingSearchService.SearchResources(new MarketingSearchCriteria {
                    FolderId = folderId, Count = int.MaxValue, ResponseGroup = responseGroup
                });
                backupObject.ContentFolders.AddRange(responce.ContentFolders);
                backupObject.ContentItems.AddRange(responce.ContentItems);
                backupObject.ContentPlaces.AddRange(responce.ContentPlaces);
                ContentComplete(responce.ContentFolders.Select(x => x.Id).ToArray(), backupObject);
            }
        }
コード例 #3
0
        private BackupObject GetBackupObject()
        {
            var responce = _marketingSearchService.SearchResources(new MarketingSearchCriteria {
                Count = int.MaxValue, ResponseGroup = SearchResponseGroup.Full
            });

            var backupObject = new BackupObject
            {
                Promotions          = responce.Promotions.Select(x => _promotionService.GetPromotionById(x.Id)).ToArray(),
                Coupons             = responce.Coupons,
                ContentPlaces       = responce.ContentPlaces,
                ContentItems        = responce.ContentItems,
                ContentPublications = responce.ContentPublications.Select(x => _dynamicContentService.GetPublicationById(x.Id)).ToArray(),
                ContentFolders      = responce.ContentFolders
            };

            ContentComplete(responce.ContentFolders.Select(x => x.Id).ToArray(), backupObject);
            return(backupObject);
        }
コード例 #4
0
        private BackupObject GetBackupObject(Action <ExportImportProgressInfo> progressCallback)
        {
            var result       = new BackupObject();
            var progressInfo = new ExportImportProgressInfo {
                Description = "Search promotions..."
            };

            progressCallback(progressInfo);
            var allPromotions = _promotionSearchService.SearchPromotions(new Domain.Marketing.Model.Promotions.Search.PromotionSearchCriteria
            {
                Take = int.MaxValue
            }).Results;

            progressInfo.Description = String.Format("{0} promotions loading...", allPromotions.Count());
            progressCallback(progressInfo);
            result.Promotions = _promotionService.GetPromotionsByIds(allPromotions.Select(x => x.Id).ToArray());

            progressInfo.Description = "Search dynamic content objects...";
            progressCallback(progressInfo);

            progressInfo.Description = String.Format("Loading folders...");
            progressCallback(progressInfo);
            result.ContentFolders = LoadFoldersRecursive(null);

            progressInfo.Description = String.Format("Loading places...");
            progressCallback(progressInfo);
            result.ContentPlaces = _dynamicContentSearchService.SearchContentPlaces(new DynamicContentPlaceSearchCriteria {
                Take = int.MaxValue
            }).Results.ToList();

            progressInfo.Description = String.Format("Loading contents...");
            progressCallback(progressInfo);
            result.ContentItems = _dynamicContentSearchService.SearchContentItems(new DynamicContentItemSearchCriteria {
                Take = int.MaxValue
            }).Results.ToList();

            progressInfo.Description = String.Format("Loading publications...");
            progressCallback(progressInfo);
            result.ContentPublications = _dynamicContentSearchService.SearchContentPublications(new DynamicContentPublicationSearchCriteria {
                Take = int.MaxValue
            }).Results.ToList();

            progressInfo.Description = String.Format("Loading coupons...");
            progressCallback(progressInfo);
            var couponsTotal = _couponService.SearchCoupons(new CouponSearchCriteria {
                Take = 0
            }).TotalCount;
            var pageSize = 500;

            Paginate(couponsTotal, pageSize, (x) =>
            {
                progressInfo.Description = String.Format($"Loading coupons: {Math.Min(x * pageSize, couponsTotal)} of {couponsTotal} loaded");
                progressCallback(progressInfo);
                result.Coupons.AddRange(_couponService.SearchCoupons(new CouponSearchCriteria {
                    Skip = (x - 1) * pageSize, Take = pageSize
                }).Results);
            });

            progressInfo.Description = String.Format("Loading usages...");
            progressCallback(progressInfo);
            var usagesTotal = _usageService.SearchUsages(new PromotionUsageSearchCriteria {
                Take = 0
            }).TotalCount;

            Paginate(usagesTotal, pageSize, (x) =>
            {
                progressInfo.Description = String.Format($"Loading usages: {Math.Min(x * pageSize, usagesTotal)} of {usagesTotal} loaded");
                progressCallback(progressInfo);
                result.Usages.AddRange(_usageService.SearchUsages(new PromotionUsageSearchCriteria {
                    Skip = (x - 1) * pageSize, Take = pageSize
                }).Results);
            });

            return(result);
        }
コード例 #5
0
		private BackupObject GetBackupObject(Action<ExportImportProgressInfo> progressCallback)
        {
	        var result = new BackupObject();
            var progressInfo = new ExportImportProgressInfo { Description = "Search promotions..." };
            progressCallback(progressInfo);
			var allPromotions = _marketingSearchService.SearchResources(new MarketingSearchCriteria
            {
                Count = int.MaxValue,
                ResponseGroup = SearchResponseGroup.WithPromotions
            }).Promotions;

			progressInfo.Description = String.Format("{0} promotions loading...", allPromotions.Count());
            progressCallback(progressInfo);
			result.Promotions = allPromotions.Select(x=> _promotionService.GetPromotionById(x.Id)).ToList();

			progressInfo.Description = "Search dynamic content objects...";
			 progressCallback(progressInfo);

            var searchResult = SearchInFolder(null);
            var allFolderSearchResults = searchResult != null ? searchResult.Traverse(ChildrenForFolder).ToArray() : null;


            if (allFolderSearchResults != null)
            {
				progressInfo.Description = String.Format("Loading folders...");
				progressCallback(progressInfo);
				result.ContentFolders = allFolderSearchResults.SelectMany(x => x.ContentFolders).ToList();

				progressInfo.Description = String.Format("Loading places...");
				progressCallback(progressInfo);
                result.ContentPlaces = allFolderSearchResults.SelectMany(x => x.ContentPlaces)
															 .Select(x => _dynamicContentService.GetPlaceById(x.Id))
															 .ToList();

				progressInfo.Description = String.Format("Loading contents...");
				progressCallback(progressInfo);
                result.ContentItems = allFolderSearchResults.SelectMany(x => x.ContentItems)
														    .Select(x => _dynamicContentService.GetContentItemById(x.Id))
															.ToList();
	
				progressInfo.Description = String.Format("Loading publications...");
				progressCallback(progressInfo);
				result.ContentPublications = allFolderSearchResults.SelectMany(x => x.ContentPublications)
																   .Select(x => _dynamicContentService.GetPublicationById(x.Id))
																   .ToList();
            }
            return result;
        }