private void detach_ccfIPv4s(ccfIPv4 entity) { this.SendPropertyChanging(); entity.ccfCategory = null; }
partial void DeleteccfIPv4(ccfIPv4 instance);
partial void InsertccfIPv4(ccfIPv4 instance);
partial void UpdateccfIPv4(ccfIPv4 instance);
} // End of updateDomains() private static void updateUrls(ISACFDataContext db) { if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Closed) { db.Connection.Open(); } List <ccfCategory> lstCategory = (from e in db.ccfCategories select e).ToList(); if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Open) { db.Connection.Close(); } FileInfo UrlsFile = null; foreach (ccfCategory Category in lstCategory) { // Try to free some memory when Category changes. GC.Collect(); UrlsFile = new FileInfo(Path.Combine(clsSettings.serviceSettings.dataDirectory.FullName, string.Format("{0}{1}{2}{1}{3}", xmlDestinationFolderName, Path.DirectorySeparatorChar, Category.name, urlsFileName))); if (!File.Exists(UrlsFile.FullName)) { continue; } bool onceAgain = true; int s = 0; const int rowsToTake = 5000; while (onceAgain) { List <string> urls = (from e in XDocument.Load(UrlsFile.FullName).Descendants("url") select(string) e.Value).Distinct().Skip(s).Take(rowsToTake).ToList(); s += rowsToTake; onceAgain = urls.Count == rowsToTake; if (db == null) { db = new ISACFDataContext(); } if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Closed) { db.Connection.Open(); } foreach (string url in urls) { if (!isIPAddress(url)) { ccfUrl newUrl = new ccfUrl(); newUrl.id_Category = Category.ID; newUrl.url = url; db.ccfUrls.InsertOnSubmit(newUrl); newUrl = null; } else { ccfIPv4 newIPv4 = new ccfIPv4(); newIPv4.id_Category = Category.ID; newIPv4.IP = url; db.ccfIPv4s.InsertOnSubmit(newIPv4); newIPv4 = null; } } db.SubmitChanges(); // Do some Cleanup. if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Open) { db.Connection.Close(); db = null; } if (urls != null) { urls = null; } // Try to free some memory. GC.Collect(); } // Do some Cleanup. if (UrlsFile != null) { UrlsFile = null; } // Try to free some memory. GC.Collect(); } if (lstCategory != null) { lstCategory = null; } if (db != null) { if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Open) { db.Connection.Close(); db = null; } } // Try to free some memory. GC.Collect(); } // End of updateUrls()