Exemplo n.º 1
0
        public async Task DoImportAsync(Stream inputStream, ExportImportOptions options, Action <ExportImportProgressInfo> progressCallback, ICancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var progressInfo = new ExportImportProgressInfo();

            using (var streamReader = new StreamReader(inputStream))
                using (var reader = new JsonTextReader(streamReader))
                {
                    while (reader.Read())
                    {
                        if (reader.TokenType == JsonToken.PropertyName)
                        {
                            if (reader.Value.ToString() == "MenuLinkLists")
                            {
                                await reader.DeserializeJsonArrayWithPagingAsync <MenuLinkList>(_jsonSerializer, _batchSize,
                                                                                                async items =>
                                {
                                    foreach (var item in items)
                                    {
                                        await _menuService.AddOrUpdateAsync(item);
                                    }
                                }, processedCount =>
                                {
                                    progressInfo.Description = $"{ processedCount } menu links have been imported";
                                    progressCallback(progressInfo);
                                }, cancellationToken);
                            }
                            else if (reader.Value.ToString() == "CmsContent")
                            {
                                if (options != null && options.HandleBinaryData)
                                {
                                    progressInfo.Description = "importing binary data:  themes and pages importing...";
                                    progressCallback(progressInfo);

                                    await reader.DeserializeJsonArrayWithPagingAsync <ContentFolder>(_jsonSerializer, _batchSize,
                                                                                                     items =>
                                    {
                                        foreach (var item in items)
                                        {
                                            SaveContentFolderRecursive(item, progressCallback);
                                        }
                                        return(Task.CompletedTask);
                                    }, processedCount =>
                                    {
                                        progressInfo.Description = $"{ processedCount } menu links have been imported";
                                        progressCallback(progressInfo);
                                    }, cancellationToken);
                                }
                            }
                        }
                    }
                }
        }
        public async Task <ActionResult> UpdateMenuLinkList([FromBody] MenuLinkList list)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            await _menuService.AddOrUpdateAsync(list);

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <ActionResult> UpdateAsync([FromBody] MenuLinkList list)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            //ToDo
            //CheckCurrentUserHasPermissionForObjects(ContentPredefinedPermissions.Update, new ContentScopeObject { StoreId = list.StoreId });

            await _menuService.AddOrUpdateAsync(list);

            return(NoContent());
        }