예제 #1
0
        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());
                }
            }
        }
예제 #2
0
        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());
                }
            }
        }
예제 #3
0
 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());
     }
   }
 }