public int DeleteDocumentGroup(string identifier)
 {
     using (var context = new CrawlerFrameworkEntities())
     {
         return context.p_DeleteDocumentGroup(identifier);
     }
 }
 public void AddNewLog(CrawlerLog crawlerLog)
 {
     using (var context = new CrawlerFrameworkEntities())
     {
         context.CrawlerLogs.Add(crawlerLog);
         context.SaveChanges();
     }
 }
 public void AddDocumentGroup(DocumentGroup newDocumentGroup)
 {
     using (var context = new CrawlerFrameworkEntities())
     {
         context.DocumentGroups.Add(newDocumentGroup);
         context.SaveChanges();
     }
 }
        public string GetIdentifier(string identifier)
        {
            using (var context = new CrawlerFrameworkEntities())
            {
                var documentGroupIdentifier = (from d in context.DocumentGroups
                                               where d.Identifier == identifier
                                               select d.Identifier).FirstOrDefault();

                return documentGroupIdentifier;
            }
        }
        public int GetOrCreateCrawlerId(string crawlerName)
        {
            using (var context = new CrawlerFrameworkEntities())
            {
                lock (lockObject)
                {
                    var crawler = (from c in context.Crawlers
                                   where c.CrawlerName == crawlerName
                                   select c.CrawlerId).FirstOrDefault();

                    if (crawler == 0)
                    {
                        Crawler newCrawler = new Crawler();
                        newCrawler.CrawlerName = crawlerName;
                        context.Crawlers.Add(newCrawler);
                        context.SaveChanges();

                        return this.GetOrCreateCrawlerId(crawlerName);
                    }

                    return crawler;
                }
            }
        }
 public void AddNewLogRange(IEnumerable<CrawlerLog> crawlerLogs)
 {
     using (var context = new CrawlerFrameworkEntities())
     {
         context.CrawlerLogs.AddRange(crawlerLogs);
         context.SaveChanges();
     }
 }