private static void CleanDatabase(string p) { List <object[]> results = SqliteUtil.SelectArray(p, "SELECT ID, english FROM Text ORDER BY ID", new object[0]); SQLiteConnection conn = new SQLiteConnection(p); conn.Open(); SQLiteTransaction transaction = conn.BeginTransaction(); foreach (var r in results) { int ID = (int)r[0]; string str = (string)r[1]; byte[] b = Encoding.Unicode.GetBytes(str); if (b.Length >= 2 && b[0] == '\xff' && b[1] == '\xfe') { string fstr = Encoding.Unicode.GetString(b, 2, b.Length - 2); SqliteUtil.Update(transaction, "UPDATE Text SET english = ? WHERE ID = ?", new object[] { fstr, ID } ); } } transaction.Commit(); conn.Close(); }
public void UpdateProductOption(ProductOption productOption) { var query = @"UPDATE productoptions SET name = @Name, description = @Description where id = @Id collate nocase"; SqliteParameter[] parameters = { new SqliteParameter("@Name", productOption.ProductId), new SqliteParameter("@Description", productOption.Description), new SqliteParameter("@Id", productOption.Id) }; SqliteUtil.Update(query, parameters); }
public void UpdateProduct(Product product) { var query = @"UPDATE Products SET name = @Name, description = @Description, price = @Price, deliveryprice = @DeliveryPrice where id = @Id collate nocase"; SqliteParameter[] parameters = { new SqliteParameter("@Id", product.Id), new SqliteParameter("@Name", product.Name), new SqliteParameter("@Description", product.Description), new SqliteParameter("@Price", product.Price), new SqliteParameter("@DeliveryPrice", product.DeliveryPrice), }; SqliteUtil.Update(query, parameters); }
private static void UpdateGracesJapanese(SQLiteTransaction ta, int id, string originalString, int debug) { // CREATE TABLE Japanese(ID INT PRIMARY KEY, string TEXT, debug INT) long exists = (long)SqliteUtil.SelectScalar(ta, "SELECT COUNT(1) FROM Japanese WHERE ID = ?", new object[1] { id }); if (exists > 0) { SqliteUtil.Update(ta, "UPDATE Japanese SET string = ?, debug = ? WHERE ID = ?", new object[3] { originalString, debug, id }); } else { SqliteUtil.Update(ta, "INSERT INTO Japanese (ID, string, debug) VALUES (?, ?, ?)", new object[3] { id, originalString, debug }); } }
public static int Replace(List <string> args) { string Database = args[0]; // remove the dumb unicode byte order mark object o1 = SqliteUtil.SelectScalar("Data Source=" + args[0], "SELECT cast(english as blob) FROM text WHERE id = 12"); object o2 = SqliteUtil.SelectScalar("Data Source=" + args[1], "SELECT cast(english as blob) FROM text WHERE id = 14"); List <object[]> objects = GenericSqliteSelect("Data Source=" + Database, //"SELECT id, string FROM japanese ORDER BY id ASC", new object[0] ); "SELECT id, english FROM text ORDER BY id ASC", new object[0]); SQLiteConnection Connection = new SQLiteConnection("Data Source=" + Database); Connection.Open(); for (int i = 0; i < objects.Count; ++i) { byte[] b = Encoding.Unicode.GetBytes((string)objects[i][1]); if (b.Length >= 2 && b[0] == '\xff' && b[1] == '\xfe') { int ID = (int)objects[i][0]; string str = (string)objects[i][1]; string fstr = Encoding.Unicode.GetString(b, 2, b.Length - 2); Console.WriteLine(fstr); SqliteUtil.Update(Connection, //"UPDATE japanese SET string = ? WHERE id = ?", "UPDATE Text SET english = ?, updated = 1 WHERE id = ?", new object[] { fstr, ID } ); } } Connection.Close(); return(0); }
public static void FormatDatabase(string Filename, string FilenameGracesJapanese, int maxCharsPerLine) { //CleanGracesJapanese("Data Source=" + FilenameGracesJapanese); //CleanDatabase( "Data Source=" + Filename ); //return; GraceNoteDatabaseEntry[] entries = GraceNoteDatabaseEntry.GetAllEntriesFromDatabase("Data Source=" + Filename, "Data Source=" + FilenameGracesJapanese); SQLiteConnection conn = new SQLiteConnection("Data Source=" + Filename); conn.Open(); SQLiteTransaction transaction = conn.BeginTransaction(); foreach (GraceNoteDatabaseEntry e in entries) { //e.TextEN = e.TextEN; if (e.Status == -1) { continue; } //e.TextEN = e.TextEN.Trim(); e.TextEN = FormatString(e.TextEN, maxCharsPerLine); SqliteUtil.Update( transaction, "UPDATE Text SET english = ? WHERE ID = ?", new object[] { e.TextEN, e.ID } ); } transaction.Commit(); conn.Close(); return; }
public static int Execute(List <string> args) { // 0xCB20 if (args.Count != 2) { Console.WriteLine("Generates a scenario db for use in Tales.Vesperia.Website from a MAPLIST.DAT."); Console.WriteLine("Usage: maplist.dat scenario.db"); return(-1); } String maplistFilename = args[0]; string connStr = "Data Source=" + args[1]; using (var conn = new System.Data.SQLite.SQLiteConnection(connStr)) { conn.Open(); using (var ta = conn.BeginTransaction()) { SqliteUtil.Update(ta, "CREATE TABLE descriptions( filename TEXT PRIMARY KEY, shortdesc TEXT, desc TEXT )"); int i = 0; foreach (MapName m in new MapList(System.IO.File.ReadAllBytes(maplistFilename)).MapNames) { Console.WriteLine(i + " = " + m.ToString()); List <string> p = new List <string>(); p.Add("VScenario" + i); p.Add(m.Name1 != "dummy" ? m.Name1 : m.Name3); p.Add(m.Name1 != "dummy" ? m.Name1 : m.Name3); SqliteUtil.Update(ta, "INSERT INTO descriptions ( filename, shortdesc, desc ) VALUES ( ?, ?, ? )", p); ++i; } ta.Commit(); } conn.Close(); } return(0); }
public static int AutoImport(List <string> args) { string dir = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfRebuild\umdimage.dat.ex\"; string voicedir = @"d:\_svn\GraceNote\GraceNote\Voices\"; string[] files = System.IO.Directory.GetFiles(dir); List <String> dbsToUp = new List <string>(); foreach (var x in nonstopDict) { string nonstopFile = GetFromSubstring(files, x.Key); string scriptFile = GetFromSubstring(files, x.Value); string scriptFileFilename = new System.IO.FileInfo(scriptFile).Name; string databaseId = scriptFileFilename.Substring(0, 4); string databaseFile = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfDB\DRBO" + databaseId; dbsToUp.Add("DRBO" + databaseId); //continue; LIN lin = new LIN(scriptFile); NonstopFile nonstop = new NonstopFile(nonstopFile); int lastScriptEntry = 0; foreach (var item in nonstop.items) { int stringId = item.data[(int)NonstopSingleStructure.StringID] + 1; int correspondingTextEntry = stringId * 2; int correspondingScriptEntry = correspondingTextEntry - 1; if (item.data[(int)NonstopSingleStructure.Type] == 0) { lastScriptEntry = correspondingTextEntry; } // --- insert comment info --- string comment = (string)SqliteUtil.SelectScalar( "Data Source=" + databaseFile, "SELECT comment FROM Text WHERE id = ?", new object[] { correspondingTextEntry }); bool weakpt = item.data[(int)NonstopSingleStructure.HasWeakPoint] > 0; comment = (comment == "" ? "" : comment + "\n\n") + "Autogenerated Info:\n" + (lastScriptEntry == 0 ? "Corresponds to file: " + scriptFileFilename : "") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "Normal Line\n" : "Background Noise\n") + (weakpt ? "Has a Weak Point\n" : "No Weakpoint\n") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF) != 255 ? "Shot with Evidence Bullet: " + item.data[(int)NonstopSingleStructure.ShootWithEvidence] + "\n" : "") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF) != 255 ? "Shot with Weak Point: " + item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] + "\n" : "") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF) == 255 && (item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF) == 255 ? "Can't be shot\n" : "") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "" : "Appears around Entry #" + lastScriptEntry + "\n") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "Sprite: " + DanganUtil.CharacterIdToName((byte)item.data[(int)NonstopSingleStructure.Character]) + " " + item.data[(int)NonstopSingleStructure.Sprite] + "\n" : "") ; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET comment = ?, updated = 1 WHERE id = ?", new object[] { comment, correspondingTextEntry }); // --- insert voice info --- string script = (string)SqliteUtil.SelectScalar( "Data Source=" + databaseFile, "SELECT english FROM Text WHERE id = ?", new object[] { correspondingScriptEntry }); string voicename; string voicefilecheck; byte charid = (byte)item.data[(int)NonstopSingleStructure.Character]; if (item.data[(int)NonstopSingleStructure.Type] == 0) { while (true) { string charac = DanganUtil.CharacterIdToName(charid); if (charac == "Naegi") { charac = "Neagi"; } voicename = "[" + charac + "] " + item.data[(int)NonstopSingleStructure.Chapter] + " " + (item.data[(int)NonstopSingleStructure.AudioSampleId] >> 8) + " " + (item.data[(int)NonstopSingleStructure.AudioSampleId] & 0xFF) + " 100"; voicefilecheck = voicedir + voicename + ".mp3"; if (System.IO.File.Exists(voicefilecheck)) { break; } charid = 0x12; } script += "<__END__>\n" + "<Voice: " + voicename + ">" ; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET english = ?, updated = 1 WHERE id = ?", new object[] { script, correspondingScriptEntry }); // update the header name thingy string header = DanganUtil.CharacterIdToName(charid); SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?", new object[] { header, correspondingTextEntry }); } else { string header = "Background Noise"; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?", new object[] { header, correspondingTextEntry }); } } } System.IO.File.WriteAllLines( @"d:\_svn\GraceNote\GraceNote\temp.txt", dbsToUp.ToArray()); return(0); }
public static int Execute(List <string> args) { List <string> Game1_Databases = new List <string>(); List <string> Game2_Databases = new List <string>(); string Game1_GracesJapanese = null; string Game2_GracesJapanese = null; string DiffLogPath = null; string MatchLogPath = null; for (int i = 0; i < args.Count; ++i) { switch (args[i]) { case "-db1": Game1_Databases.Add(args[++i]); break; case "-db2": Game2_Databases.Add(args[++i]); break; case "-gj1": Game1_GracesJapanese = args[++i]; break; case "-gj2": Game2_GracesJapanese = args[++i]; break; case "-difflog": DiffLogPath = args[++i]; break; case "-matchlog": MatchLogPath = args[++i]; break; } } if (Game1_Databases.Count == 0 || Game2_Databases.Count == 0 || Game1_GracesJapanese == null || Game2_GracesJapanese == null) { Console.WriteLine("Tool to compare entries from two games."); Console.WriteLine("This can be used for checking consistency between e.g. multiple games in the same series."); Console.WriteLine(); Console.WriteLine("Usage:"); Console.WriteLine(" Required:"); Console.WriteLine(" -db1 path Add a database of Game 1. (can be used multiple times)"); Console.WriteLine(" -db2 path Add a database of Game 2. (can be used multiple times)"); Console.WriteLine(" -gj1 path GracesJapanese of Game 1."); Console.WriteLine(" -gj2 path GracesJapanese of Game 2."); Console.WriteLine(); Console.WriteLine(" Optional:"); Console.WriteLine(" -difflog path Log all entries where the Japanese matches, but the English does not."); Console.WriteLine(" -matchlog path Log all entries where the Japanese and English both match."); return(-1); } List <GraceNoteDatabaseEntry> Game1_Entries = new List <GraceNoteDatabaseEntry>(); List <GraceNoteDatabaseEntry> Game2_Entries = new List <GraceNoteDatabaseEntry>(); Stream DiffLogStream = null; StreamWriter DiffLogWriter = null; Stream MatchLogStream = null; StreamWriter MatchLogWriter = null; if (DiffLogPath != null) { DiffLogStream = new FileStream(DiffLogPath, FileMode.Append); } else { DiffLogStream = Stream.Null; } if (MatchLogPath != null) { MatchLogStream = new FileStream(MatchLogPath, FileMode.Append); } else { MatchLogStream = Stream.Null; } DiffLogWriter = new StreamWriter(DiffLogStream); MatchLogWriter = new StreamWriter(MatchLogStream); //DirectoryInfo di1 = new DirectoryInfo( @"e:\_\ToV\" ); //DirectoryInfo di2 = new DirectoryInfo( @"e:\_\ToX\" ); //foreach ( var x in di1.GetFiles() ) { // Game1_Databases.Add( x.FullName ); //} //foreach ( var x in di2.GetFiles() ) { // Game2_Databases.Add( x.FullName ); //} foreach (var db in Game1_Databases) { Game1_Entries.AddRange( GraceNoteDatabaseEntry.GetAllEntriesFromDatabase("Data Source=" + db, "Data Source=" + Game1_GracesJapanese) ); } foreach (var db in Game2_Databases) { Game2_Entries.AddRange( GraceNoteDatabaseEntry.GetAllEntriesFromDatabase("Data Source=" + db, "Data Source=" + Game2_GracesJapanese) ); } Regex VariableRemoveRegex = new Regex("<[^<>]+>"); Regex VesperiaFuriRemoveRegex = new Regex("\r[(][0-9]+[,][\\p{IsHiragana}\\p{IsKatakana}]+[)]"); foreach (var e1 in Game1_Entries) { string j1 = VesperiaFuriRemoveRegex.Replace(VariableRemoveRegex.Replace(e1.TextJP, ""), ""); foreach (var e2 in Game2_Entries) { string j2 = VariableRemoveRegex.Replace(e2.TextJP, ""); if (j1 == j2) { if (e1.TextEN != e2.TextEN) { DiffLogWriter.WriteLine(j1); DiffLogWriter.WriteLine(e1.Database + "/" + e1.ID + ": " + e1.TextEN); DiffLogWriter.WriteLine(e2.Database + "/" + e2.ID + ": " + e2.TextEN); DiffLogWriter.WriteLine(); DiffLogWriter.WriteLine("------------------------------------------------------"); DiffLogWriter.WriteLine(); } else { MatchLogWriter.WriteLine(j1); MatchLogWriter.WriteLine(e1.Database + "/" + e1.ID + ": " + e1.TextEN); MatchLogWriter.WriteLine(e2.Database + "/" + e2.ID + ": " + e2.TextEN); MatchLogWriter.WriteLine(); MatchLogWriter.WriteLine("------------------------------------------------------"); MatchLogWriter.WriteLine(); SqliteUtil.Update(e1.Database, "UPDATE Text SET updated = 1, status = 4 WHERE ID = " + e1.ID); } } } } MatchLogWriter.Close(); MatchLogStream.Close(); DiffLogWriter.Close(); DiffLogStream.Close(); return(0); }