static void Main(string[] args) { SessionBase.BaseDatabasePath = @"d:/Databases"; bool dirExist = Directory.Exists(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir)); if (!dirExist) { ImdbImport.ImprortImdb(s_systemDir); } KevinBaconNumbers kevinBaconNumbers = new KevinBaconNumbers(); using (SessionNoServer session = new SessionNoServer(s_systemDir)) { try { session.BeginRead(); kevinBaconNumbers.calculateNumbers(session); kevinBaconNumbers.printResults(); session.Commit(); } catch (Exception e) { session.Abort(); Console.WriteLine(e.ToString()); } } }
public static void ImprortImdb(string systemDir) { ImdbImport imdbImport = new ImdbImport(); using (SessionNoServer session = new SessionNoServer(systemDir)) { try { session.BeginUpdate(); File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"), true); ImdbRoot imdbRoot = new ImdbRoot(session); session.Persist(imdbRoot); imdbImport.ParseActors(session, imdbRoot); imdbImport.ParseActresses(session, imdbRoot); foreach (ActingPerson acting in imdbRoot.ActorSet) { if (!imdbRoot.ActingByNameSet.Add(acting)) { Console.WriteLine("Dublicate ActingPerson found (in ActorSet): " + acting.Name); } } foreach (ActingPerson acting in imdbRoot.ActressSet) { if (!imdbRoot.ActingByNameSet.Add(acting)) { Console.WriteLine("Dublicate ActingPerson found (in ActressSet): " + acting.Name); } } session.Commit(); } catch (Exception e) { session.Abort(); Console.WriteLine(e.ToString()); } } }
public static void ImprortImdb(string systemDir) { ImdbImport imdbImport = new ImdbImport(); using (SessionNoServer session = new SessionNoServer(systemDir)) { try { session.BeginUpdate(); File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"), true); ImdbRoot imdbRoot = new ImdbRoot(session); session.Persist(imdbRoot); imdbImport.ParseActors(session, imdbRoot); imdbImport.ParseActresses(session, imdbRoot); foreach (ActingPerson acting in imdbRoot.ActorSet) if (!imdbRoot.ActingByNameSet.Add(acting)) Console.WriteLine("Dublicate ActingPerson found (in ActorSet): " + acting.Name); foreach (ActingPerson acting in imdbRoot.ActressSet) if (!imdbRoot.ActingByNameSet.Add(acting)) Console.WriteLine("Dublicate ActingPerson found (in ActressSet): " + acting.Name); session.Commit(); } catch (Exception e) { session.Abort(); Console.WriteLine(e.ToString()); } } }