public void AddToProcessQueue(string link, int parentId, int websiteId, int sessionId) { using ItsyBitsyDbContext context = new ItsyBitsyDbContext(); var newItem = new ProcessQueue() { Link = link, ParentId = parentId, SessionId = sessionId, WebsiteId = websiteId }; context.ProcessQueue.Add(newItem); context.SaveChanges(); }
public int SaveLink(DownloadResult response, int websiteId, int sessionId) { try { using ItsyBitsyDbContext context = new ItsyBitsyDbContext(); var newPage = new Page() { SessionId = sessionId, StatusCode = response.Status, WebsiteId = websiteId, Uri = response.Uri, ContentType = (byte)response.ContentType, DownloadTime = response.DownloadTime, ContentLength = response.ContentLengthBytes }; context.Page.Add(newPage); if (response.ParentId.HasValue) { var newPageRelation = new PageRelation() { ParentPageId = response.ParentId.Value, ChildPage = newPage, }; context.PageRelation.Add(newPageRelation); } context.SaveChanges(); return(newPage.Id); } catch (Exception e) { throw e; } }
public void RemoveQueuedItems(IEnumerable <ProcessQueue> successfullyQueued) { using ItsyBitsyDbContext context = new ItsyBitsyDbContext(); context.ProcessQueue.RemoveRange(successfullyQueued); context.SaveChanges(); }