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);
        }
示例#2
0
        public async Task <bool> Parse(string text, DocumentLoader documentLoader, DocumentItem documentItem)
        {
            if (text.Length < 40)
            {
                return(true);
            }
            var mass = text.Trim('.').Split('.');

            foreach (var sentence in mass)
            {
                if (sentence == " ")
                {
                    continue;
                }
                var models = await _loaderInfoAotRu.LoaderAotModel(sentence);

                await _iAiSentence.SaveDescription(models);

                foreach (var model in models)
                {
                    var aiSentence = await _iAiSentence.Create(model);

                    aiSentence.DocumentLoader = documentLoader;
                    aiSentence.DocumentItem   = documentItem;
                }
            }

            await _wordDbContext.SaveChangesAsync();

            return(true);
        }
示例#3
0
        public async Task <ResultCrmDb> AddUser(CrmDbModel.Model.LoadDocument.User user)
        {
            var result = new ResultCrmDb();

            try
            {
                if (string.IsNullOrWhiteSpace(user.Account))
                {
                    return(result);
                }


                _wordDbContext.Add(user);
                await _wordDbContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
                result.AddError("-", e.Message);
            }

            return(result);
        }
示例#4
0
        public async Task SaveDescription(List <AotModel> models)
        {
            foreach (var model in models)
            {
                foreach (var modelVar in model.Variants)
                {
                    foreach (var modelVarGroup in modelVar.Groups)
                    {
                        var description = await _wordDbContext.AiDescription.FirstOrDefaultAsync(f => f.Name == modelVarGroup.Descr);

                        if (description != null)
                        {
                            continue;
                        }
                        description = new AiDescription {
                            Name = modelVarGroup.Descr
                        };
                        _wordDbContext.Add(description);
                        await _wordDbContext.SaveChangesAsync();
                    }
                }
            }
        }