Esempio n. 1
0
        public void Update(BaseCollectionItem baseCollectionItem)
        {
            var itemsToUpdate = InMemoryBaseCollectionItems.Where(x => x.Id == baseCollectionItem.Id).ToList();

            foreach (var item in itemsToUpdate)
            {
                item.ItemProcessed = baseCollectionItem.ItemProcessed;
            }
        }
Esempio n. 2
0
        public void Update(BaseCollectionItem baseCollectionItem)
        {
            var query = baseCollectionItem.Id.ToString();
            var items = SearchItems(query, "Id");

            foreach (var item in items)
            {
                ClearLuceneIndexRecord(item.Id);
                Insert(baseCollectionItem);
            }
        }
Esempio n. 3
0
        private static BaseCollectionItem ExtractContentFromWeb(BaseCollectionItem item, Logger log)
        {
            //TODO: extract content from web using repository
            var webpage = new WebPageDataService(item.Data.ItemUrl, log);

            item.Data.ItemTitle         = webpage.ExtractedTitle;
            item.Data.ItemContent_Raw   = webpage.ExtractedContent;
            item.Data.ItemContent_Image = webpage.ExtractedImage;
            Console.WriteLine(item.Data.ItemUrl + ":" + item.Data.ItemTitle);
            return(item);
        }
Esempio n. 4
0
        public void Update(BaseCollectionItem baseCollectionItem)
        {
            this.MySqlClient.Open();
            var query   = @"update basecollectionitem 
                           set ItemProcessed=@ItemProcessed where Id=@Id;";
            var command = new MySqlCommand(query, this.MySqlClient);

            command.Parameters.AddWithValue("@ItemProcessed", baseCollectionItem.ItemProcessed);
            command.Parameters.AddWithValue("@Id", baseCollectionItem.Id);
            command.CommandType = CommandType.Text;
            var affectedRows = command.ExecuteNonQuery();

            this.MySqlClient.Close();
        }
Esempio n. 5
0
        public void Insert(BaseCollectionItem baseCollectionItem)
        {
            baseCollectionItem.Id          = Guid.NewGuid();
            baseCollectionItem.CreatedDate = DateTime.Now;
            var analyzer = new StandardAnalyzer(Version.LUCENE_30);

            using (var writer = new IndexWriter(LuceneService.Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
            {
                // add data to lucene search index (replaces older entry if any)

                AddToLuceneIndex(baseCollectionItem, writer);
                // close handles
                analyzer.Close();
                writer.Dispose();
            }
        }
Esempio n. 6
0
        public void Update(BaseCollectionItem baseCollectionItem)
        {
            baseCollectionItem.Id          = Guid.NewGuid();
            baseCollectionItem.CreatedDate = DateTime.Now;
            ////var data = baseCollectionItem.Data.SerializeToByteArray();
            SqlClient.Open();
            var query   = @"update dbo.basecollectionitem 
                           set ItemProcessed=@ItemProcessed where Id=@Id;";
            var command = new SqlCommand(query, SqlClient);

            command.Parameters.Add("@ItemProcessed", SqlDbType.Bit).Value   = baseCollectionItem.ItemProcessed;
            command.Parameters.Add("@Id", SqlDbType.UniqueIdentifier).Value = baseCollectionItem.Id;
            command.CommandType = CommandType.Text;
            var affectedRows = command.ExecuteNonQuery();

            SqlClient.Close();
        }
Esempio n. 7
0
        public void Insert(BaseCollectionItem baseCollectionItem)
        {
            baseCollectionItem.Id          = Guid.NewGuid();
            baseCollectionItem.CreatedDate = DateTime.Now;
            ////var data = baseCollectionItem.Data.SerializeToByteArray();
            this.MySqlClient.Open();
            var query   = @"Insert into basecollectionitem (Id, Data, ItemProcessed, CreatedDate)
                        values(@ItemId, @ItemData, @ItemProcessed, @CreatedDate)";
            var command = new MySqlCommand(query, this.MySqlClient);

            command.Parameters.AddWithValue("@ItemId", baseCollectionItem.Id);
            command.Parameters.AddWithValue("@ItemData", baseCollectionItem.Data.SerializeToByteArray());
            command.Parameters.AddWithValue("@ItemProcessed", baseCollectionItem.ItemProcessed);
            command.Parameters.AddWithValue("@CreatedDate", baseCollectionItem.CreatedDate);
            command.CommandType = CommandType.Text;
            command.ExecuteNonQuery();

            this.MySqlClient.Close();
        }
Esempio n. 8
0
        public void Insert(BaseCollectionItem baseCollectionItem)
        {
            baseCollectionItem.Id          = Guid.NewGuid();
            baseCollectionItem.CreatedDate = DateTime.Now;
            ////var data = baseCollectionItem.Data.SerializeToByteArray();
            SqlClient.Open();
            var query   = @"Insert into dbo.basecollectionitem (Id, Data, ItemProcessed, CreatedDate)
                        values(@ItemId, @ItemData, @ItemProcessed, @CreatedDate)";
            var command = new SqlCommand(query, SqlClient);

            command.Parameters.Add("@ItemId", SqlDbType.UniqueIdentifier).Value = baseCollectionItem.Id;
            command.Parameters.Add("@ItemData", SqlDbType.VarBinary).Value      =
                baseCollectionItem.Data.SerializeToByteArray();
            command.Parameters.Add("@ItemProcessed", SqlDbType.Bit).Value    = baseCollectionItem.ItemProcessed;
            command.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = baseCollectionItem.CreatedDate;
            command.CommandType = CommandType.Text;
            command.ExecuteNonQuery();

            SqlClient.Close();
        }
Esempio n. 9
0
        private static void AddToLuceneIndex(BaseCollectionItem baseCollectionItem, IndexWriter writer)
        {
            // remove older index entry
            var searchQuery = new TermQuery(new Term("Id", baseCollectionItem.Id.ToString()));

            writer.DeleteDocuments(searchQuery);

            // add new index entry
            var doc = new Document();

            // add lucene fields mapped to db fields
            doc.Add(new Field("Id", baseCollectionItem.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("TableId", baseCollectionItem.TableId.ToString(), Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Data", baseCollectionItem.Data.XmlSerializeToString(), Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("ItemProcessed", baseCollectionItem.ItemProcessed.ToString(), Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("CreatedDate", baseCollectionItem.CreatedDate.ToString(CultureInfo.InvariantCulture), Field.Store.YES, Field.Index.ANALYZED));

            // add entry to index
            writer.AddDocument(doc);
        }
Esempio n. 10
0
 public void Insert(BaseCollectionItem baseCollectionItem)
 {
     baseCollectionItem.Id          = Guid.NewGuid();
     baseCollectionItem.CreatedDate = DateTime.Now;
     InMemoryBaseCollectionItems.Add(baseCollectionItem);
 }