Esempio n. 1
0
        private void GenerateReportedSelectedTextTables(string pageUrl, string pageUrlHash, string selectionText, string selectionTextHash, ReportItEntities rie, SelectionText st, ReportedSelectedText rst)
        {
            if (!string.IsNullOrEmpty(selectionText))
            {
                // Does the pageUrl exist?
                // Does the srcUrl exist?
                // Do they both exist in the ReportedSrcUrls table? They should be it is nice to have a sanity check
                EUReported puRecord = GetPageUrlRecord(rie, pageUrlHash);
                if (puRecord == null)
                {
                    // The page record has never been created
                    // Create Page Record
                    puRecord             = new EUReported();
                    puRecord.Count       = 1;
                    puRecord.PageUrl     = pageUrl;
                    puRecord.PageUrlHash = pageUrlHash;
                    puRecord.Processed   = false;
                    puRecord.CreatedOn   = DateTime.UtcNow;
                    puRecord.UpdatedOn   = DateTime.UtcNow;
                    rie.EUReporteds.Add(puRecord);
                }
                else
                {
                    // The page record has been created - update count
                    puRecord.Count     = puRecord.Count + 1;
                    puRecord.UpdatedOn = DateTime.UtcNow;
                }

                // Ok now check to see if the SrcUrl exists
                st = GetSelectionTextRecord(rie, selectionTextHash);
                if (st == null)
                {
                    // The SrcUrl record has never been created
                    // Create SrcUrl record
                    st                   = new SelectionText();
                    st.Count             = 1;
                    st.Processed         = false;
                    st.SelectionText1    = selectionText;
                    st.SelectionTextHash = selectionTextHash;
                    st.CreatedOn         = DateTime.UtcNow;
                    st.UpdatedOn         = DateTime.UtcNow;
                    rie.SelectionTexts.Add(st);
                }
                else
                {
                    // The srcUrl record has been created - update count
                    st.Count     = st.Count + 1;
                    st.UpdatedOn = DateTime.UtcNow;
                }


                // Ok Now the Sanity Check to make sure that the Many to Many table is correctly populated
                if (!ReportedSelectedTextExists(rie, pageUrlHash, selectionTextHash))
                {
                    rst.PageUrlHash      = pageUrlHash;
                    rst.SelectedTextHash = selectionTextHash;
                    rie.ReportedSelectedTexts.Add(rst);
                }
                rie.SaveChanges();
            }
        }
Esempio n. 2
0
        private void GenerateReportedLinksTables(string pageUrl, string pageUrlHash, string linkUrl, string linkUrlHash, ReportItEntities rie, LinkUrl lu, ReportedLinkUrl rlu)
        {
            if (!string.IsNullOrEmpty(linkUrl))
            {
                // Does the pageUrl exist?
                // Does the srcUrl exist?
                // Do they both exist in the ReportedSrcUrls table? They should be it is nice to have a sanity check
                EUReported puRecord = GetPageUrlRecord(rie, pageUrlHash);
                if (puRecord == null)
                {
                    // The page record has never been created
                    // Create Page Record
                    puRecord             = new EUReported();
                    puRecord.Count       = 1;
                    puRecord.PageUrl     = pageUrl;
                    puRecord.PageUrlHash = pageUrlHash;
                    puRecord.Processed   = false;
                    puRecord.CreatedOn   = DateTime.UtcNow;
                    puRecord.UpdatedOn   = DateTime.UtcNow;
                    rie.EUReporteds.Add(puRecord);
                }
                else
                {
                    // The page record has been created - update count
                    puRecord.Count     = puRecord.Count + 1;
                    puRecord.UpdatedOn = DateTime.UtcNow;
                }

                // Ok now check to see if the SrcUrl exists
                lu = GetLinkUrlRecord(rie, linkUrlHash);
                if (lu == null)
                {
                    // The SrcUrl record has never been created
                    // Create SrcUrl record
                    lu             = new LinkUrl();
                    lu.Count       = 1;
                    lu.Processed   = false;
                    lu.LinkUrl1    = linkUrl;
                    lu.LinkUrlHash = linkUrlHash;
                    lu.CreatedOn   = DateTime.UtcNow;
                    lu.UpdatedOn   = DateTime.UtcNow;
                    rie.LinkUrls.Add(lu);
                }
                else
                {
                    // The srcUrl record has been created - update count
                    lu.Count     = lu.Count + 1;
                    lu.UpdatedOn = DateTime.UtcNow;
                }


                // Ok Now the Sanity Check to make sure that the Many to Many table is correctly populated
                if (!ReportedLinkUrlsExists(rie, pageUrlHash, linkUrlHash))
                {
                    rlu.PageUrlHash = pageUrlHash;
                    rlu.LinkUrlHash = linkUrlHash;
                    rie.ReportedLinkUrls.Add(rlu);
                }
                rie.SaveChanges();
            }
        }