public async Task <DocumentLoader> SaveDocumentLoader(FileRtf fileRtf)
        {
            var documentLoader = new DocumentLoader();

            documentLoader.Name     = fileRtf.Caption;
            documentLoader.Category = fileRtf.Category;
            documentLoader.FileSize = fileRtf.FileSize;
            documentLoader.VidDoc   = fileRtf.VidDoc;
            documentLoader.ProfName = fileRtf.ProfName;
            await _wordDbContext.AddAsync(documentLoader);

            var query = fileRtf.Items.Where(f => f.ParentId == null);

            foreach (var item in query)
            {
                var documentItem = new DocumentItem();
                documentItem.DocumentLoader = documentLoader;
                documentItem.Number         = item.Number;
                documentItem.IsRootItem     = item.IsRoot;
                documentItem.TextContent    = item.TextContent;
                await _wordDbContext.AddAsync(documentItem);
                await CreateModel(fileRtf.Items, item, documentItem, documentItem, documentLoader);
            }

            await _wordDbContext.SaveChangesAsync();

            var queryA = await _wordDbContext.DocumentItem.Where(f => f.DocumentLoaderId == documentLoader.Id).ToListAsync();

            foreach (var item in queryA.Where(f => f.ParentId == null))
            {
                await UpdateParagraph(queryA, item, item);
            }

            return(documentLoader);
        }
Exemple #2
0
        /// <summary>
        /// Создание объекта документа
        /// </summary>
        /// <returns></returns>
        private FileRtf CreateRtf()
        {
            var result = new FileRtf();

            InitDictionaries(_lines);
            result.Caption  = GetCellValue(1);
            result.VidDoc   = GetCellValue(3);
            result.Category = GetCellValue(8);
            result.Items    = CreateItem(_cotent);
            return(result);
        }