private void manageDBUpdate() { DirectoryInfo dbSchema = new DirectoryInfo(AppPath.ConfigRoot()); FileInfo[] dbs = dbSchema.GetFiles("DBSchema.sql"); if (dbs.Count() == 1) { GS.Backup("", "", true); string[] f = File.ReadAllLines(dbs[0].FullName); List <string> newSchema = new List <string>(); foreach (string l in f) { GS.db.Query(l.Replace("`[DBNAME]`", ConfigFile.GetConfig().DatabaseConfig().DatabaseName), true); if (GS.db.QueryError != 0) { newSchema.Add(l); } } string fname = Path.GetFileNameWithoutExtension(dbs[0].FullName); fname += "-compiled-" + GS.dateManager.GetCurrentPersianDate("-"); fname = Path.GetDirectoryName(dbs[0].FullName) + "\\" + fname + Path.GetExtension(dbs[0].FullName); dbs[0].MoveTo(fname); //if (newSchema.Count > 0) //{ // string pp = Path.GetDirectoryName(dbs[0].FullName) + "\\DBSchema.sql"; // StreamWriter sw = new StreamWriter(pp, true); // foreach (string s in newSchema) // { // sw.WriteLine(s); // sw.Flush(); // } // sw.Close(); //} } //Process[] cp = Process.GetProcessesByName("mysql.exe"); //Process[] cp = Process.GetProcessesByName("mysqld"); //foreach(Process p in cp) //{ // if (p.ProcessName.Contains("my")) // { // MessageBox.Show(p.ProcessName); // } //} //DirectoryInfo dbSchema = new DirectoryInfo(AppPath.ConfigRoot()); //FileInfo[] dbs= dbSchema.GetFiles("DBSchema.sql"); //if (dbs.Count() == 1) //{ // GS.Backup("","",true); // string[] f =File.ReadAllLines(dbs[0].FullName); // List<string> newSchema =new List<string>(); // foreach(string l in f) // { // GS.db.Query(l.Replace("`[DBNAME]`",ConfigFile.GetConfig().DatabaseConfig().DatabaseName),true); // if (GS.db.QueryError != 0) // { // newSchema.Add(l); // } // } // string fname=Path.GetFileNameWithoutExtension(dbs[0].FullName); // fname += "-compiled-"+GS.dateManager.GetCurrentPersianDate("-"); // fname = Path.GetDirectoryName(dbs[0].FullName)+"\\"+fname+Path.GetExtension(dbs[0].FullName); // dbs[0].MoveTo(fname); // if (newSchema.Count > 0) // { // string pp = Path.GetDirectoryName(dbs[0].FullName) + "\\DBSchema.sql"; // StreamWriter sw = new StreamWriter(pp, true); // foreach (string s in newSchema) // { // sw.WriteLine(s); // sw.Flush(); // } // sw.Close(); // } //} //DataTable dtsm = GS.db.Query("SELECT * FROM `setting` WHERE `SettingName` LIKE 'itemsell;%'"); //if (dtsm.Rows.Count == 0) //{ // GS.db.Query("INSERT INTO `setting` (`id`, `SettingName`, `SettingValue`) VALUES (NULL, 'itemsell;گزارش فروش کالا', 'گزارش فروش کالا');", true); //} //dtsm = GS.db.Query("SELECT * FROM `setting` WHERE `SettingName` LIKE 'MonthlyEarnedReport;%'"); //if (dtsm.Rows.Count == 0) //{ // GS.db.Query("INSERT INTO `setting` (`id`, `SettingName`, `SettingValue`) VALUES (NULL,'MonthlyEarnedReport;گزارش دریافتی ماهانه','گزارش دریافتی ماهانه %mName');", true); //} //dtsm = GS.db.Query("SELECT * FROM `setting` WHERE `SettingName` LIKE 'YearlyEarnedReport;%'"); //if (dtsm.Rows.Count == 0) //{ // GS.db.Query("INSERT INTO `setting` (`id`, `SettingName`, `SettingValue`) VALUES (NULL,'YearlyEarnedReport;گزارش دریافتی سالانه','گزارش دریافتی سالانه %y');", true); //} //dtsm = GS.db.Query("SELECT * FROM `setting` WHERE `SettingName` LIKE 'yearlyReport;%'"); //if (dtsm.Rows.Count == 0) //{ // GS.db.Query("INSERT INTO `setting` (`id`, `SettingName`, `SettingValue`) VALUES (NULL,'yearlyReport;فروش سالانه','گزارش سالانه %y');", true); //} //dtsm = GS.db.Query("SELECT * FROM `setting` WHERE `SettingName` LIKE 'monthlyReport;%'"); //if (dtsm.Rows.Count == 0) //{ // GS.db.Query("INSERT INTO `setting` (`id`, `SettingName`, `SettingValue`) VALUES (NULL,'monthlyReport;فروش ماهانه','گزارش ماهانه %mName');", true); //} //dtsm = GS.db.Query("SELECT * FROM `setting` WHERE `SettingName` LIKE 'monthlyReport;%'"); //if (dtsm.Rows.Count == 0) //{ // GS.db.Query("ALTER TABLE `setting` CHANGE `SettingValue` `SettingValue` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;", true); //} }