public static bool json2sql_quest(FileInfo fi, DirectoryInfo outputFolder = null) { // read json quest if (!GDLELoader.TryLoadQuest(fi.FullName, out var result)) { Console.WriteLine($"Failed to parse {fi.FullName}"); return(false); } // convert to sql quest if (!GDLEConverter.TryConvert(result, out var quest)) { Console.WriteLine($"Failed to convert {fi.FullName}"); return(false); } // output to sql try { if (QuestSQLWriter == null) { QuestSQLWriter = new QuestSQLWriter(); } if (quest.LastModified == DateTime.MinValue) { quest.LastModified = DateTime.UtcNow; } var sqlFilename = fi.Name.Replace(".json", ".sql"); var sqlFolder = outputFolder ?? fi.Directory; var sqlFile = new StreamWriter(sqlFolder.FullName + Path.DirectorySeparatorChar + sqlFilename); QuestSQLWriter.CreateSQLDELETEStatement(quest, sqlFile); sqlFile.WriteLine(); QuestSQLWriter.CreateSQLINSERTStatement(quest, sqlFile); sqlFile.Close(); Console.WriteLine($"Converted {fi.FullName} to {fi.DirectoryName}{Path.DirectorySeparatorChar}{sqlFilename}"); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine($"Failed to convert {fi.FullName}"); return(false); } return(true); }
private async void cmd8QuestsParse_Click(object sender, EventArgs e) { cmd8QuestsParse.Enabled = false; progressBarQuests.Style = ProgressBarStyle.Marquee; progressBarQuests.Value = 0; await Task.Run(() => { var aceQuests = questDefDB.ConvertToACE(); QuestSQLWriter.WriteFiles(aceQuests, Settings.Default["OutputFolder"] + "\\8 QuestDefDB\\SQL\\"); }); progressBarQuests.Style = ProgressBarStyle.Continuous; progressBarQuests.Value = 100; cmd8QuestsParse.Enabled = true; }