Ejemplo n.º 1
0
        public static int Import( List<string> args )
        {
            if ( args.Count < 3 ) {
                Console.WriteLine( "Usage: sscr Database GracesJapanese" );
                return -1;
            }

            string InFile = args[0];
            string OutDatabase = args[1];
            string GracesJapanese = args[2];
            SSCR SscrFile = new SSCR( System.IO.File.ReadAllBytes( InFile ) );
            System.IO.File.WriteAllBytes( OutDatabase, Properties.Resources.gndb_template );

            List<GraceNoteDatabaseEntry> Entries = new List<GraceNoteDatabaseEntry>( SscrFile.Names.Count + SscrFile.SystemTerms.Count + SscrFile.Somethings.Count );
            foreach ( var x in SscrFile.Names ) {
                Entries.Add( new GraceNoteDatabaseEntry( x.Name, x.Name, "", 0, 1, x.Id, (int)x.Unknown ) );
            }
            foreach ( var x in SscrFile.SystemTerms ) {
                Entries.Add( new GraceNoteDatabaseEntry( x.Term, x.Term, "", 0, 2, "", (int)x.Unknown ) );
            }
            foreach ( var x in SscrFile.Somethings ) {
                Entries.Add( new GraceNoteDatabaseEntry( x.Text, x.Text, "", 0, 3, x.Id, (int)x.Unknown4 ) );
            }

            GraceNoteDatabaseEntry.InsertSQL( Entries.ToArray(), "Data Source=" + OutDatabase, "Data Source=" + GracesJapanese );

            return 0;
        }
Ejemplo n.º 2
0
        public static int Export( List<string> args )
        {
            if ( args.Count < 2 ) {
                Console.WriteLine( "Usage: original.sscr db new.sscr" );
                return -1;
            }

            string SourceFile = args[0];
            string InDatabase = args[1];
            string OutFile = args[2];
            SSCR SscrFile = new SSCR( System.IO.File.ReadAllBytes( SourceFile ) );

            ReadDatabase( SscrFile, "Data Source=" + InDatabase );

            SscrFile.CreateFile( OutFile );

            return 0;
        }
Ejemplo n.º 3
0
        public static void ReadDatabase( SSCR SscrFile, string ConnectionString )
        {
            SQLiteConnection Connection = new SQLiteConnection( ConnectionString );
            Connection.Open();

            using ( SQLiteTransaction Transaction = Connection.BeginTransaction() )
            using ( SQLiteCommand Command = new SQLiteCommand( Connection ) ) {
                Command.CommandText = "SELECT english, PointerRef FROM Text ORDER BY ID";
                SQLiteDataReader r = Command.ExecuteReader();
                int NameCounter = 0;
                int SysTextCounter = 0;
                int SomethingCounter = 0;
                while ( r.Read() ) {
                    String SQLText;
                    try { SQLText = r.GetString( 0 ).Replace( "''", "'" ); }
                    catch ( System.InvalidCastException ) { SQLText = ""; }
                    int PointerRef = r.GetInt32( 1 );

                    switch ( PointerRef ) {
                        case 1:
                            SscrFile.Names[NameCounter].Name = SQLText;
                            NameCounter++;
                            break;
                        case 2:
                            SscrFile.SystemTerms[SysTextCounter].Term = SQLText;
                            SysTextCounter++;
                            break;
                        case 3:
                            SscrFile.Somethings[SomethingCounter].Text = SQLText;
                            SomethingCounter++;
                            break;
                    }
                }

                Transaction.Rollback();
            }
            return;
        }