Exemplo n.º 1
0
        public override Task StartAsync()
        {
            using (var context = new InterlexCrawlerEntities())
            {
                foreach (var(id, content) in context.GetNewOrUpdatedInterlexEditorToolLazy())
                {
                    try
                    {
                        var documentGroup = new DocumentGroupModel
                        {
                            CrawlerId         = this.CrawlerId,
                            Name              = id,
                            TwoLetterLanguage = "EU",
                            Documents         =
                            {
                                new DocumentModel
                                {
                                    Raw    = encoding.GetBytes(content),
                                    Name   = "content",
                                    Format = "application/json",
                                    Url    = "local"
                                }
                            }
                        };

                        this.DocumentGroupManager.AddOrUpdateDocumentGroup(documentGroup);
                    }
                    catch (Exception e)
                    {
                        this.Logger.Error($"{id}", e);
                    }
                }
            }

            return(Task.CompletedTask);
        }