コード例 #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
ファイル: ImdbImport.cs プロジェクト: timotrob/VelocityDB
        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
ファイル: ImdbImport.cs プロジェクト: VelocityDB/VelocityDB
 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());
     }
   }
 }