Ejemplo n.º 1
0
        public static void HandleClearCache(Session session, params string[] parameters)
        {
            var mode = CacheType.All;

            if (parameters.Length > 0)
            {
                if (parameters[0].Contains("weenie", StringComparison.OrdinalIgnoreCase))
                {
                    mode = CacheType.Weenie;
                }
                if (parameters[0].Contains("spell", StringComparison.OrdinalIgnoreCase))
                {
                    mode = CacheType.Spell;
                }
            }

            if (mode.HasFlag(CacheType.Weenie))
            {
                CommandHandlerHelper.WriteOutputInfo(session, "Clearing weenie cache");
                DatabaseManager.World.ClearWeenieCache();
            }

            if (mode.HasFlag(CacheType.Spell))
            {
                CommandHandlerHelper.WriteOutputInfo(session, "Clearing spell cache");
                DatabaseManager.World.ClearSpellCache();
                WorldObject.ClearSpellCache();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts a sql file to json file
        /// </summary>
        public static bool sql2json(Session session, Weenie weenie, string sql_folder, string sql_filename)
        {
            if (!LifestonedConverter.TryConvertACEWeenieToLSDJSON(weenie, out var json, out var json_weenie))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {sql_filename} to json");
                return(false);
            }

            var json_folder   = sql_folder.Replace("sql", "json");
            var json_filename = sql_filename.Replace(".sql", ".json");

            var di = new DirectoryInfo(json_folder);

            if (!di.Exists)
            {
                di.Create();
            }

            if (File.Exists(json_folder + json_filename) && LifestonedLoader.AppendMetadata(json_folder + json_filename, json_weenie))
            {
                json = JsonConvert.SerializeObject(json_weenie, LifestonedConverter.SerializerSettings);
            }

            File.WriteAllText(json_folder + json_filename, json);

            CommandHandlerHelper.WriteOutputInfo(session, $"Converted {sql_filename} to {json_filename}");

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts JSON to SQL, imports to database, and clears the weenie cache
        /// </summary>
        private static void HandleImportJson(Session session, string json_folder, string json_file, WeenieSQLWriter converter)
        {
            if (!uint.TryParse(Regex.Match(json_file, @"\d+").Value, out var wcid))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find wcid from {json_file}");
                return;
            }

            // convert json -> sql
            var sqlFile = json2sql(session, json_folder, json_file, converter);

            if (sqlFile == null)
            {
                return;
            }

            // import sql to db
            var sql_folder = json_folder.Replace("json", "sql");

            ImportSQL(sql_folder + sqlFile);
            CommandHandlerHelper.WriteOutputInfo(session, $"Imported {sqlFile}");

            // clear this weenie out of the cache
            DatabaseManager.World.ClearCachedWeenie(wcid);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts SQL to JSON, imports to database, clears the weenie cache
        /// </summary>
        private static void HandleImportSQL(Session session, string sql_folder, string sql_file)
        {
            if (!uint.TryParse(Regex.Match(sql_file, @"\d+").Value, out var wcid))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find wcid from {sql_file}");
                return;
            }

            // import sql to db
            ImportSQL(sql_folder + sql_file);
            CommandHandlerHelper.WriteOutputInfo(session, $"Imported {sql_file}");

            // clear this weenie out of the cache
            DatabaseManager.World.ClearCachedWeenie(wcid);

            // load weenie from database
            var weenie = DatabaseManager.World.GetCachedWeenie(wcid);

            if (weenie == null)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't load weenie {wcid} from db");
                return;
            }

            sql2json(session, weenie, sql_folder, sql_file);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Converts a json file to sql file
        /// </summary>
        public static string json2sql(Session session, string folder, string json_filename, WeenieSQLWriter converter)
        {
            var json_file = folder + json_filename;

            var success = LifestonedLoader.TryLoadWeenie(json_file, out var weenie);

            if (!success)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to load {json_file}");
                return(null);
            }

            // output to sql
            success = LifestonedConverter.TryConvert(weenie, out var output);

            if (!success)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {json_file}");
                return(null);
            }

            var sqlFolder = folder.Replace("json", "sql");

            var di = new DirectoryInfo(sqlFolder);

            if (!di.Exists)
            {
                di.Create();
            }

            var sqlFilename = "";

            try
            {
                if (output.LastModified == DateTime.MinValue)
                {
                    output.LastModified = DateTime.UtcNow;
                }

                sqlFilename = converter.GetDefaultFileName(output);
                var sqlFile = new StreamWriter(sqlFolder + sqlFilename);

                converter.CreateSQLDELETEStatement(output, sqlFile);
                sqlFile.WriteLine();

                converter.CreateSQLINSERTStatement(output, sqlFile);
                sqlFile.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {json_file}");
                return(null);
            }

            CommandHandlerHelper.WriteOutputInfo(session, $"Converted {json_filename} to {sqlFilename}");

            return(sqlFilename);
        }
Ejemplo n.º 6
0
        public static void HandleExportSql(Session session, params string[] parameters)
        {
            DirectoryInfo di = VerifyContentFolder(session, false);

            var sep = Path.DirectorySeparatorChar;

            if (!uint.TryParse(parameters[0], out var wcid))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"{parameters[0]} not a valid wcid");
                return;
            }

            var weenie = DatabaseManager.World.GetCachedWeenie(wcid);

            if (weenie == null)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find weenie {wcid}");
                return;
            }

            var sql_folder = $"{di.FullName}{sep}sql{sep}weenies{sep}";

            di = new DirectoryInfo(sql_folder);

            if (!di.Exists)
            {
                di.Create();
            }

            var converter = new WeenieSQLWriter();

            converter.WeenieNames     = DatabaseManager.World.GetAllWeenieNames();
            converter.SpellNames      = DatabaseManager.World.GetAllSpellNames();
            converter.TreasureDeath   = DatabaseManager.World.GetAllTreasureDeath();
            converter.TreasureWielded = DatabaseManager.World.GetAllTreasureWielded();

            var sql_filename = converter.GetDefaultFileName(weenie);

            var writer = new StreamWriter(sql_folder + sql_filename);

            try
            {
                converter.CreateSQLDELETEStatement(weenie, writer);
                writer.WriteLine();
                converter.CreateSQLINSERTStatement(weenie, writer);
                writer.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {weenie.ClassId} - {weenie.ClassName}");
                return;
            }

            CommandHandlerHelper.WriteOutputInfo(session, $"Exported {sql_folder}{sql_filename}");
        }
        public static void ImportSQLWeenieWrapped(Session session, string param, string param2)
        {
            DirectoryInfo di = VerifyContentFolder(session);

            if (!di.Exists)
            {
                return;
            }

            var sep = Path.DirectorySeparatorChar;

            var prefix = param + " ";

            var sql_folder = $"{di.FullName}{sep}sql{sep}weenies{sep}";

            if (param.Equals("folder", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(param2))
            {
                if (param2.Contains(".."))
                {
                    CommandHandlerHelper.WriteOutputInfo(session, $"Path may not contain the sequence '..'");
                    return;
                }
                sql_folder = $"{sql_folder}{param2}{sep}";
                prefix     = "";
            }
            else if (param.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                prefix = "";
            }

            di = new DirectoryInfo(sql_folder);
            if (!di.Exists)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find folder: {di.FullName}");
                return;
            }

            var files = di.Exists ? di.GetFiles($"{prefix}*.sql", SearchOption.AllDirectories) : null;

            if (files == null || files.Length == 0)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find {sql_folder}{prefix}*.sql");
                return;
            }

            foreach (var file in files)
            {
                ImportSQLWeenie(session, Path.GetDirectoryName(file.FullName) + Path.DirectorySeparatorChar, file.Name);
            }
        }
Ejemplo n.º 8
0
        public static void HandleExportJson(Session session, params string[] parameters)
        {
            DirectoryInfo di = VerifyContentFolder(session, false);

            var sep = Path.DirectorySeparatorChar;

            if (!uint.TryParse(parameters[0], out var wcid))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"{parameters[0]} not a valid wcid");
                return;
            }

            var weenie = DatabaseManager.World.GetCachedWeenie(wcid);

            if (weenie == null)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find weenie {wcid}");
                return;
            }

            if (!LifestonedConverter.TryConvertACEWeenieToLSDJSON(weenie, out var json, out var json_weenie))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {weenie.ClassId} - {weenie.ClassName} to json");
                return;
            }

            var json_folder = $"{di.FullName}{sep}json{sep}weenies{sep}";

            di = new DirectoryInfo(json_folder);

            if (!di.Exists)
            {
                di.Create();
            }

            var json_filename = $"{weenie.ClassId} - {weenie.WeeniePropertiesString.FirstOrDefault(i => i.Type == (int)PropertyString.Name)?.Value}.json";

            if (File.Exists(json_folder + json_filename) && LifestonedLoader.AppendMetadata(json_folder + json_filename, json_weenie))
            {
                json = JsonConvert.SerializeObject(json_weenie, LifestonedConverter.SerializerSettings);
            }

            File.WriteAllText(json_folder + json_filename, json);

            CommandHandlerHelper.WriteOutputInfo(session, $"Exported {json_folder}{json_filename}");
        }
Ejemplo n.º 9
0
        public static void HandleImportJson(Session session, params string[] parameters)
        {
            DirectoryInfo di = VerifyContentFolder(session);

            if (!di.Exists)
            {
                return;
            }

            var sep = Path.DirectorySeparatorChar;

            var json_folder = $"{di.FullName}{sep}json{sep}weenies{sep}";

            var wcid   = parameters[0];
            var prefix = wcid + " - ";

            if (wcid.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                prefix = "";
            }

            di = new DirectoryInfo(json_folder);

            var files = di.Exists ? di.GetFiles($"{prefix}*.json") : null;

            if (files == null || files.Length == 0)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find {json_folder}{prefix}*.json");
                return;
            }

            var converter = new WeenieSQLWriter();

            converter.WeenieNames     = DatabaseManager.World.GetAllWeenieNames();
            converter.SpellNames      = DatabaseManager.World.GetAllSpellNames();
            converter.TreasureDeath   = DatabaseManager.World.GetAllTreasureDeath();
            converter.TreasureWielded = DatabaseManager.World.GetAllTreasureWielded();

            foreach (var file in files)
            {
                HandleImportJson(session, json_folder, file.Name, converter);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Converts a sql file to json file
        /// </summary>
        public static bool sql2json(Session session, Weenie weenie, string sql_folder, string sql_filename)
        {
            if (!LifestonedConverter.TryConvertACEWeenieToLSDJSON(weenie, out var json, out var json_weenie))
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {sql_filename} to json");
                return(false);
            }

            var json_folder   = sql_folder.Replace("sql", "json");
            var json_filename = sql_filename.Replace(".sql", ".json");

            var match = Regex.Match(json_filename, @"^(\d+)");

            if (match.Success)
            {
                var wcid = match.Groups[1].Value;
                if (!json_filename.StartsWith(wcid + " -"))
                {
                    json_filename = wcid + " -" + json_filename.Substring(wcid.Length);
                }
            }

            var di = new DirectoryInfo(json_folder);

            if (!di.Exists)
            {
                di.Create();
            }

            if (File.Exists(json_folder + json_filename) && LifestonedLoader.AppendMetadata(json_folder + json_filename, json_weenie))
            {
                json = JsonConvert.SerializeObject(json_weenie, LifestonedConverter.SerializerSettings);
            }

            File.WriteAllText(json_folder + json_filename, json);

            CommandHandlerHelper.WriteOutputInfo(session, $"Converted {sql_filename} to {json_filename}");

            return(true);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns the absolute content folder path, and verifies it exists
        /// </summary>
        private static DirectoryInfo VerifyContentFolder(Session session, bool showError = true)
        {
            var content_folder = PropertyManager.GetString("content_folder").Item;

            var sep = Path.DirectorySeparatorChar;

            // handle relative path
            if (content_folder.StartsWith("."))
            {
                var cwd = Directory.GetCurrentDirectory() + sep;
                content_folder = cwd + content_folder;
            }

            var di = new DirectoryInfo(content_folder);

            if (!di.Exists && showError)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find content folder: {di.FullName}");
                CommandHandlerHelper.WriteOutputInfo(session, "To set your content folder, /modifystring content_folder <path>");
            }
            return(di);
        }
Ejemplo n.º 12
0
        public static void HandleImportSQL(Session session, params string[] parameters)
        {
            DirectoryInfo di = VerifyContentFolder(session);

            if (!di.Exists)
            {
                return;
            }

            var sep = Path.DirectorySeparatorChar;

            var sql_folder = $"{di.FullName}{sep}sql{sep}weenies{sep}";

            var wcid   = parameters[0];
            var prefix = wcid + " ";

            if (wcid.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                prefix = "";
            }

            di = new DirectoryInfo(sql_folder);

            var files = di.Exists ? di.GetFiles($"{prefix}*.sql") : null;

            if (files == null || files.Length == 0)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Couldn't find {sql_folder}{prefix}*.sql");
                return;
            }

            foreach (var file in files)
            {
                HandleImportSQL(session, sql_folder, file.Name);
            }
        }
Ejemplo n.º 13
0
        private void Run(Session session, int biotasPerTest)
        {
            CommandHandlerHelper.WriteOutputInfo(session, $"Starting Shard Database Performance Tests.\nBiotas per test: {biotasPerTest}\nThis may take several minutes to complete...\nCurrent database queue count: {DatabaseManager.Shard.QueueCount}");


            // Get the current queue wait time
            bool responseReceived = false;

            DatabaseManager.Shard.GetCurrentQueueWaitTime(result =>
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Current database queue wait time: {result.TotalMilliseconds:N0} ms");
                responseReceived = true;
            });

            while (!responseReceived)
            {
                Thread.Sleep(1);
            }


            // Generate Individual WorldObjects
            var biotas = new Collection <(Biota biota, ReaderWriterLockSlim rwLock)>();

            for (int i = 0; i < biotasPerTest; i++)
            {
                var worldObject = WorldObjectFactory.CreateNewWorldObject(testWeenies[i % testWeenies.Count]);
                biotas.Add((worldObject.Biota, worldObject.BiotaDatabaseLock));
            }


            // Add biotasPerTest biotas individually
            long trueResults             = 0;
            long falseResults            = 0;
            var  startTime               = DateTime.UtcNow;
            var  initialQueueWaitTime    = TimeSpan.Zero;
            var  totalQueryExecutionTime = TimeSpan.Zero;

            foreach (var biota in biotas)
            {
                DatabaseManager.Shard.SaveBiota(biota.biota, biota.rwLock, result =>
                {
                    if (result)
                    {
                        Interlocked.Increment(ref trueResults);
                    }
                    else
                    {
                        Interlocked.Increment(ref falseResults);
                    }
                }, (queueWaitTime, queryExecutionTime) =>
                {
                    if (initialQueueWaitTime == TimeSpan.Zero)
                    {
                        initialQueueWaitTime = queueWaitTime;
                    }

                    totalQueryExecutionTime += queryExecutionTime;
                });
            }

            while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < biotas.Count)
            {
                Thread.Sleep(1);
            }

            var endTime = DateTime.UtcNow;

            ReportResult(session, "individual add", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);


            // Update biotasPerTest biotas individually
            if (session == null || SessionIsStillInWorld(session))
            {
                ModifyBiotas(biotas);

                trueResults             = 0;
                falseResults            = 0;
                startTime               = DateTime.UtcNow;
                initialQueueWaitTime    = TimeSpan.Zero;
                totalQueryExecutionTime = TimeSpan.Zero;

                foreach (var biota in biotas)
                {
                    DatabaseManager.Shard.SaveBiota(biota.biota, biota.rwLock, result =>
                    {
                        if (result)
                        {
                            Interlocked.Increment(ref trueResults);
                        }
                        else
                        {
                            Interlocked.Increment(ref falseResults);
                        }
                    }, (queueWaitTime, queryExecutionTime) =>
                    {
                        if (initialQueueWaitTime == TimeSpan.Zero)
                        {
                            initialQueueWaitTime = queueWaitTime;
                        }

                        totalQueryExecutionTime += queryExecutionTime;
                    });
                }

                while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < biotas.Count)
                {
                    Thread.Sleep(1);
                }

                endTime = DateTime.UtcNow;
                ReportResult(session, "individual save", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
            }


            // Delete biotasPerTest biotas individually
            trueResults             = 0;
            falseResults            = 0;
            startTime               = DateTime.UtcNow;
            initialQueueWaitTime    = TimeSpan.Zero;
            totalQueryExecutionTime = TimeSpan.Zero;

            foreach (var biota in biotas)
            {
                DatabaseManager.Shard.RemoveBiota(biota.biota, biota.rwLock, result =>
                {
                    if (result)
                    {
                        Interlocked.Increment(ref trueResults);
                    }
                    else
                    {
                        Interlocked.Increment(ref falseResults);
                    }
                }, (queueWaitTime, queryExecutionTime) =>
                {
                    if (initialQueueWaitTime == TimeSpan.Zero)
                    {
                        initialQueueWaitTime = queueWaitTime;
                    }

                    totalQueryExecutionTime += queryExecutionTime;
                });
            }

            while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < biotas.Count)
            {
                Thread.Sleep(1);
            }

            endTime = DateTime.UtcNow;
            ReportResult(session, "individual remove", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);


            if (session != null && !SessionIsStillInWorld(session))
            {
                return;
            }

            // Generate Bulk WorldObjects
            biotas.Clear();

            for (int i = 0; i < biotasPerTest; i++)
            {
                var worldObject = WorldObjectFactory.CreateNewWorldObject(testWeenies[i % testWeenies.Count]);
                biotas.Add((worldObject.Biota, worldObject.BiotaDatabaseLock));
            }


            // Add biotasPerTest biotas in bulk
            trueResults             = 0;
            falseResults            = 0;
            startTime               = DateTime.UtcNow;
            initialQueueWaitTime    = TimeSpan.Zero;
            totalQueryExecutionTime = TimeSpan.Zero;

            DatabaseManager.Shard.SaveBiotasInParallel(biotas, result =>
            {
                if (result)
                {
                    Interlocked.Increment(ref trueResults);
                }
                else
                {
                    Interlocked.Increment(ref falseResults);
                }
            }, (queueWaitTime, queryExecutionTime) =>
            {
                if (initialQueueWaitTime == TimeSpan.Zero)
                {
                    initialQueueWaitTime = queueWaitTime;
                }

                totalQueryExecutionTime += queryExecutionTime;
            });

            while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < 1)
            {
                Thread.Sleep(1);
            }

            endTime = DateTime.UtcNow;
            ReportResult(session, "bulk add", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);


            // Update biotasPerTest biotas in bulk
            if (session == null || SessionIsStillInWorld(session))
            {
                ModifyBiotas(biotas);

                trueResults             = 0;
                falseResults            = 0;
                startTime               = DateTime.UtcNow;
                initialQueueWaitTime    = TimeSpan.Zero;
                totalQueryExecutionTime = TimeSpan.Zero;

                DatabaseManager.Shard.SaveBiotasInParallel(biotas, result =>
                {
                    if (result)
                    {
                        Interlocked.Increment(ref trueResults);
                    }
                    else
                    {
                        Interlocked.Increment(ref falseResults);
                    }
                }, (queueWaitTime, queryExecutionTime) =>
                {
                    if (initialQueueWaitTime == TimeSpan.Zero)
                    {
                        initialQueueWaitTime = queueWaitTime;
                    }

                    totalQueryExecutionTime += queryExecutionTime;
                });

                while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < 1)
                {
                    Thread.Sleep(1);
                }

                endTime = DateTime.UtcNow;
                ReportResult(session, "bulk save", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
            }


            // Delete biotasPerTest biotas in bulk
            trueResults             = 0;
            falseResults            = 0;
            startTime               = DateTime.UtcNow;
            initialQueueWaitTime    = TimeSpan.Zero;
            totalQueryExecutionTime = TimeSpan.Zero;

            DatabaseManager.Shard.RemoveBiotasInParallel(biotas, result =>
            {
                if (result)
                {
                    Interlocked.Increment(ref trueResults);
                }
                else
                {
                    Interlocked.Increment(ref falseResults);
                }
            }, (queueWaitTime, queryExecutionTime) =>
            {
                if (initialQueueWaitTime == TimeSpan.Zero)
                {
                    initialQueueWaitTime = queueWaitTime;
                }

                totalQueryExecutionTime += queryExecutionTime;
            });

            while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < 1)
            {
                Thread.Sleep(1);
            }

            endTime = DateTime.UtcNow;
            ReportResult(session, "bulk remove", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);


            if (session != null && !SessionIsStillInWorld(session))
            {
                return;
            }

            CommandHandlerHelper.WriteOutputInfo(session, "Database Performance Tests Completed");
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Converts a json file to sql file
        /// </summary>
        public static string json2sql(Session session, string folder, string json_filename, WeenieSQLWriter converter)
        {
            var json_file = folder + json_filename;

            // read json into lsd weenie
            var success = LifestonedLoader.TryLoadWeenie(json_file, out var weenie);

            if (!success)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to load {json_file}");
                return(null);
            }

            // convert to ace weenie
            success = LifestonedConverter.TryConvert(weenie, out var output);

            if (!success)
            {
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {json_file}");
                return(null);
            }

            // output to sql
            var sqlFolder = folder.Replace("json", "sql");

            var di = new DirectoryInfo(sqlFolder);

            if (!di.Exists)
            {
                di.Create();
            }

            var sqlFilename = "";

            try
            {
                if (output.LastModified == DateTime.MinValue)
                {
                    output.LastModified = DateTime.UtcNow;
                }

                sqlFilename = converter.GetDefaultFileName(output);
                var sqlFile = new StreamWriter(sqlFolder + sqlFilename);

                converter.CreateSQLDELETEStatement(output, sqlFile);
                sqlFile.WriteLine();

                converter.CreateSQLINSERTStatement(output, sqlFile);

                var metadata = new Adapter.GDLE.Models.Metadata(weenie);
                if (metadata.HasInfo)
                {
                    var jsonEx = JsonConvert.SerializeObject(metadata, LifestonedConverter.SerializerSettings);
                    sqlFile.WriteLine($"\n/* Lifestoned Changelog:\n{jsonEx}\n*/");
                }

                sqlFile.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                CommandHandlerHelper.WriteOutputInfo(session, $"Failed to convert {json_file}");
                return(null);
            }

            CommandHandlerHelper.WriteOutputInfo(session, $"Converted {json_filename} to {sqlFilename}");

            return(sqlFilename);
        }