Exemple #1
0
        public KspMods(string a_InstallationDirectory, string a_ModPath)
        {
            InstallationDirectory = a_InstallationDirectory;
            ModDirectory          = a_ModPath;

            db = new SQLiteConnection("kmm.sqlite");

            // make sure the table exists
            if (db.GetTableInfo("KMMInfo").Count == 0)
            {
                db.CreateTable <KMMInfo>();
            }

            var tables = new Type[] { typeof(InstalledMods), typeof(ModFiles), typeof(InstalledFiles) };

            foreach (var table in tables)
            {
                var info = db.GetTableInfo(table.Name);
                if (info.Count == 0)
                {
                    db.CreateTable(table);
                }
            }

            // oh noez it does not match
            if (db.Table <KMMInfo>().Count() == 0 || db.Table <KMMInfo>().First().Version != GetAssemblyVersion())
            {
                // salvage data
                var installed_mods = db.Table <InstalledMods>().ToList();
                db.DropTable <InstalledMods>();
                db.CreateTable <InstalledMods>();
                db.InsertAll(installed_mods);

                var mod_files = db.Table <ModFiles>().ToList();
                db.DropTable <ModFiles>();
                db.CreateTable <ModFiles>();
                db.InsertAll(mod_files);

                var installed_files = db.Table <InstalledFiles>().ToList();
                db.DropTable <InstalledFiles>();
                db.CreateTable <InstalledFiles>();
                db.InsertAll(installed_files);
            }

            // make sure the table is filled
            if (db.Table <KMMInfo>().Count() == 0)
            {
                var nfo = new KMMInfo()
                {
                    Version = GetAssemblyVersion()
                };
                db.Insert(nfo);
            }
        }
Exemple #2
0
        public KspMods(string a_InstallationDirectory, string a_ModPath )
        {
            InstallationDirectory = a_InstallationDirectory;
            ModDirectory = a_ModPath;

            db = new SQLiteConnection("kmm.sqlite");

            // make sure the table exists
            if (db.GetTableInfo("KMMInfo").Count == 0)
            {
                db.CreateTable<KMMInfo>();
            }

            var tables = new Type[] { typeof(InstalledMods), typeof(ModFiles), typeof(InstalledFiles) };

            foreach (var table in tables)
            {
                var info = db.GetTableInfo(table.Name);
                if (info.Count == 0)
                    db.CreateTable(table);
            }

            // oh noez it does not match
            if (db.Table<KMMInfo>().Count() == 0 || db.Table<KMMInfo>().First().Version != GetAssemblyVersion())
            {
                // salvage data
                var installed_mods = db.Table<InstalledMods>().ToList();
                db.DropTable<InstalledMods>();
                db.CreateTable<InstalledMods>();
                db.InsertAll(installed_mods);

                var mod_files = db.Table<ModFiles>().ToList();
                db.DropTable<ModFiles>();
                db.CreateTable<ModFiles>();
                db.InsertAll(mod_files);

                var installed_files = db.Table<InstalledFiles>().ToList();
                db.DropTable<InstalledFiles>();
                db.CreateTable<InstalledFiles>();
                db.InsertAll(installed_files);
            }

            // make sure the table is filled
            if (db.Table<KMMInfo>().Count() == 0)
            {
                var nfo = new KMMInfo()
                {
                    Version = GetAssemblyVersion()
                };
                db.Insert(nfo);
            }
        }