예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var setting = new CefSettings();

            setting.Locale = "vi";

            setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";

            setting.BrowserSubprocessPath = System.IO.Path.GetFullPath(@"x86\CefSharp.BrowserSubprocess.exe");
            //setting.CefCommandLineArgs.Add("disable-gpu", "1");
            //setting.RemoteDebuggingPort = 8088;
            Cef.Initialize(setting, performDependencyCheck: true, browserProcessHandler: null);

            browser = new ChromiumWebBrowser("")// ChromiumWebBrowser(www)
            {
                Dock = DockStyle.Fill
            };

            browser.MenuHandler     = new CustomMenuHandler();
            browser.LifeSpanHandler = new LifeSpanHandler();

            BrowserSettings browserSettings = new BrowserSettings();

            browserSettings.FileAccessFromFileUrls      = CefState.Enabled;
            browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;

            browser.BrowserSettings = browserSettings;

            browser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
            browser.JavascriptObjectRepository.ObjectBoundInJavascript      += (sender1, e1) =>
            {
                var name = e1.ObjectName;

                Debug.WriteLine($"Object {e1.ObjectName} was bound successfully.");
                MessageBox.Show(e1.ObjectName);
            };
            browser.JavascriptObjectRepository.Register("dotNetObject", new GenericCefSharp.MainHost(this.browser), isAsync: true, options: BindingOptions.DefaultBinder);
            SqliteUtil.getSettings();
            browser.IsBrowserInitializedChanged += (sender1, args1) =>
            {
                if (browser.IsBrowserInitialized)
                {
                    goHome();
                    //browser.LoadHtml(File.ReadAllText(HtmlPageUtils.getIndex()));
                }
            };

            // Add it to the form and fill it to the form window.
            this.Controls.Add(browser);
            browser.BringToFront();

            browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;
            browser.LoadingStateChanged         += Browser_LoadingStateChanged;
            ChromeDevToolsSystemMenu.CreateSysMenu(this);

            ChromeDevToolsSystemMenu.RegisterGlobalHotKey(this, Keys.Home, ChromeDevToolsSystemMenu.MOD_ALT);
#if DEBUG
            ChromeDevToolsSystemMenu.RegisterGlobalHotKey(this, Keys.F12, ChromeDevToolsSystemMenu.MOD_CONTROL);
#endif
        }
예제 #2
0
        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();
        }
예제 #3
0
        public void RemoveProductOption(Guid id)
        {
            var query = "DELETE FROM ProductOptions WHERE id = @Id collate nocase";

            SqliteParameter[] parameters = { new SqliteParameter("@Id", id) };

            SqliteUtil.Delete(query, parameters);
        }
예제 #4
0
        public List <Product> GetAllProducts()
        {
            var query = "SELECT * FROM Products";

            var products = SqliteUtil.Query <Product>(toProduct, query);

            return(products);
        }
예제 #5
0
        public void RemoveProduct(Guid productId)
        {
            var query = $"DELETE FROM Products WHERE id = @productId collate nocase";

            SqliteParameter[] parameters = { new SqliteParameter("@productId", productId) };

            SqliteUtil.Delete(query, parameters);
        }
예제 #6
0
 static void Main()
 {
     Cef.EnableHighDPISupport();
     SqliteUtil.initSetting();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     frm = new frmMain();
     Application.Run(frm);
 }
예제 #7
0
        public List <ProductOption> GetAllProductOptions(Guid productId)
        {
            var query = "SELECT * FROM ProductOptions WHERE productId = @productId collate nocase";

            SqliteParameter[] parameters = { new SqliteParameter("@productId", productId) };

            var options = SqliteUtil.Query <ProductOption>(toProductOption, query, parameters);

            return(options);
        }
예제 #8
0
        public RequestLog[] Get()
        {
            var sqliteUtil = new SqliteUtil(this.GetDbPath(), RequestLogUtil.GetSql4CreateTables());
            var result     = sqliteUtil.Select <RequestLogInDb>("RequestLog",
                                                                " CreatedOn >= '" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"
                                                                ).OrderByDescending(o => o.CreatedOn).ToList();
            var entities = new RequestLogUtil().ConvertTo(result);

            return(entities.ToArray());
        }
예제 #9
0
        public List <Product> GetProductsByName(string name)
        {
            var query = "SELECT * FROM Products WHERE LOWER(name) LIKE @Name";

            SqliteParameter[] parameters = { new SqliteParameter("@Name", $"%{name.ToLower()}%") };

            var products = SqliteUtil.Query <Product>(toProduct, query, parameters);

            return(products);
        }
예제 #10
0
 public string ClearCache([FromQuery] string url)
 {
     using (var conn = SqliteUtil.GetConn())
     {
         conn.Open();
         var cmd = new SqliteCommand("DELETE FROM Articles WHERE @feedurl='' OR FeedUrl=@feedurl", conn);
         cmd.Parameters.AddWithValue("@feedurl", url ?? "");
         cmd.ExecuteNonQuery();
         return("Cache cleared");
     }
 }
예제 #11
0
        public RequestLog Get(string id)
        {
            var sqliteUtil = new SqliteUtil(this.GetDbPath(), RequestLogUtil.GetSql4CreateTables());
            //demo用,注意SQLInjection。
            var result = sqliteUtil.Select <RequestLog>("RequestLog",
                                                        " Id = '" + id + "'"
                                                        ).FirstOrDefault();

            return(result != null ? result : new RequestLog()
            {
                Id = "", WebIp = "", ApiIp = "", CreatedOn = DateTime.Now
            });
예제 #12
0
        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);
        }
예제 #13
0
    private static int GetFileVersion(string filePath)
    {
        if (IsVersion1(filePath))
        {
            return(1);
        }

        // Versions 2+ are SQLite databases. Open it and read the version number inside.
        var sqlite = IntPtr.Zero; //sqlite3*
        var stmt   = IntPtr.Zero; // sqlite3_stmt*

        try {
            using NativeString filePathNative = new(filePath);
            using NativeBuffer sqliteBuffer   = new(IntPtr.Size);
            var result = NativeMethods.sqlite3_open(filePathNative.Ptr, sqliteBuffer.Ptr);
            if (result != NativeMethods.SQLITE_OK)
            {
                throw new Exception("This is not an SQL Notebook file.");
            }
            sqlite = Marshal.ReadIntPtr(sqliteBuffer.Ptr);

            var versionSql = "SELECT version FROM _sqlnotebook_version";
            using NativeString versionSqlNative  = new(versionSql);
            using NativeBuffer versionStmtNative = new(IntPtr.Size);
            result = NativeMethods.sqlite3_prepare_v2(sqlite, versionSqlNative.Ptr, versionSqlNative.ByteCount,
                                                      versionStmtNative.Ptr, IntPtr.Zero);
            stmt = Marshal.ReadIntPtr(versionStmtNative.Ptr); // sqlite3_stmt*
            if (result != NativeMethods.SQLITE_OK || stmt == IntPtr.Zero)
            {
                // it's ok, a plain SQLite database is a valid version 2 SQL Notebook file
                return(2);
            }

            if (NativeMethods.sqlite3_step(stmt) == NativeMethods.SQLITE_ROW)
            {
                return(NativeMethods.sqlite3_column_int(stmt, 0));
            }
            return(2); // missing version row; it's still a valid version 2 file
        } finally {
            if (stmt != IntPtr.Zero)
            {
                SqliteUtil.ThrowIfError(sqlite, NativeMethods.sqlite3_finalize(stmt));
            }
            if (sqlite != IntPtr.Zero)
            {
                SqliteUtil.ThrowIfError(IntPtr.Zero, NativeMethods.sqlite3_close(sqlite));
            }
        }
    }
예제 #14
0
        public void AddProductOption(ProductOption productOption)
        {
            var query = @"INSERT INTO productoptions (id, productid, name, description) 
                values (@Id, @ProductId, @Name, @Description)";

            SqliteParameter[] parameters =
            {
                new SqliteParameter("@Id",          productOption.Id),
                new SqliteParameter("@ProductId",   productOption.ProductId),
                new SqliteParameter("@Name",        productOption.Name),
                new SqliteParameter("@Description", productOption.Description),
            };

            SqliteUtil.Insert(query, parameters);
        }
예제 #15
0
        public Product GetProductById(Guid id)
        {
            var query = "SELECT * FROM Products WHERE id = @id collate nocase";

            SqliteParameter[] parameters = { new SqliteParameter("@id", id) };

            var products = SqliteUtil.Query <Product>(toProduct, query, parameters);

            if (products.Count == 1)
            {
                return(products[0]);
            }

            return(null);
        }
예제 #16
0
        public void AddProduct(Product product)
        {
            var query = @"INSERT INTO Products (id, name, description, price, deliveryprice)
                values (@Id, @Name, @Description, @Price, @DeliveryPrice)";

            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.Insert(query, parameters);
        }
예제 #17
0
        public bool ProductExists(Guid id)
        {
            var query = "SELECT id FROM Products WHERE id = @Id collate nocase";

            SqliteParameter[] parameters = { new SqliteParameter("@Id", id) };

            var products = SqliteUtil.Query <Product>(
                (SqliteDataReader reader) => {
                return(new Product()
                {
                    Id = Guid.Parse(reader.GetValueOrDefault <string>("Id"))
                });
            }, query, parameters);

            return(products.Count > 0);
        }
예제 #18
0
        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);
        }
예제 #19
0
 public bool Get()
 {
     try
     {
         var sqliteUtil = new SqliteUtil(this.GetDbPath(), RequestLogUtil.GetSql4CreateTables());
         var result     = sqliteUtil.GetCount("RequestLog");
         if (result >= 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #20
0
        public ProductOption GetProductOptionById(Guid productId, Guid optionId)
        {
            var query = "SELECT * FROM productoptions WHERE productId = @productId collate nocase AND id = @optionId collate nocase";

            SqliteParameter[] parameters =
            {
                new SqliteParameter("@productId", productId),
                new SqliteParameter("@optionId",  optionId),
            };

            var options = SqliteUtil.Query <ProductOption>(toProductOption, query, parameters);

            if (options.Count == 1)
            {
                return(options[0]);
            }

            return(null);
        }
예제 #21
0
        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
                });
            }
        }
예제 #22
0
        public IEnumerable <CachedArticle> GetCache([FromQuery] string url)
        {
            var retval = new List <CachedArticle>();

            using (var conn = SqliteUtil.GetConn())
            {
                conn.Open();
                var cmd = new SqliteCommand("SELECT * FROM Articles WHERE FeedUrl=@feedurl", conn);
                cmd.Parameters.AddWithValue("@feedurl", url);
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    retval.Add(new CachedArticle
                    {
                        ArticleUrl     = reader["ArticleUrl"].ToString(),
                        LastFetchedUTC = DateTime.Parse(reader["LastFetchedUTC"].ToString())
                    });
                }
                return(retval);
            }
        }
예제 #23
0
        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);
        }
예제 #24
0
        public static int Execute(List <string> args)
        {
            if (args.Count < 2)
            {
                Console.WriteLine("Usage: infile.sqlite outfile.ebm");
                return(-1);
            }

            string infile  = args[0];
            string outfile = args[1];
            var    ebm     = new ebm();

            var rows = SqliteUtil.SelectArray("Data Source=" + infile, "SELECT Ident, Unknown2, Unknown3, CharacterId, Unknown5, Unknown6, Unknown7, Unknown8, Entry FROM ebm ORDER BY ID");

            foreach (var row in rows)
            {
                ebmEntry e = new ebmEntry()
                {
                    Ident       = (uint)(long)row[0],
                    Unknown2    = (uint)(long)row[1],
                    Unknown3    = (uint)(long)row[2],
                    CharacterId = (int)row[3],
                    Unknown5    = (uint)(long)row[4],
                    Unknown6    = (uint)(long)row[5],
                    Unknown7    = (uint)(long)row[6],
                    Unknown8    = (uint)(long)row[7],
                    Text        = (string)row[8],
                };
                ebm.EntryList.Add(e);
            }

            using (Stream s = new FileStream(outfile, FileMode.Create)) {
                ebm.WriteFile(s, TextUtils.GameTextEncoding.UTF8);
                s.Close();
            }

            return(0);
        }
예제 #25
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;
        }
예제 #26
0
        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);
        }
예제 #27
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);
        }
예제 #28
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);
        }
예제 #29
0
 private void frmSetting_Load(object sender, EventArgs e)
 {
     SqliteUtil.initSetting();
     SqliteUtil.getSettings(grdData);
 }
예제 #30
0
 private void cmdSave_Click(object sender, EventArgs e)
 {
     SqliteUtil.saveSettings(grdData);
     MessageBox.Show("OK");
 }