public static void GenSQLite(string outPath) { var tablePath = IPath.Combine(Application.dataPath, "Resource/Table/"); var xlslFiles = Directory.GetFiles(tablePath, "*.xlsx", SearchOption.AllDirectories); // if (Directory.Exists(outPath) == false) { Directory.CreateDirectory(outPath); } var _path = IPath.Combine(outPath, "Local.db"); // sql = new SQLiteService(SqliteLoder.CreateConnetion(_path)); foreach (var f in xlslFiles) { var excel = new ExcelUtility(f); var json = excel.GetJson(); Json2Sqlite(f, json); } sql.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
public static void GenxslxOrJsonToSQlite(IDictionary <string, string> path) { var outPath = IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform)); var _path = IPath.Combine(outPath, "Local.db"); sql = new SQLiteService(SqliteLoder.CreateConnetion(_path)); foreach (var f in path) { Json2Sqlite(f.Key, f.Value); } sql.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
public static void GenSQLite() { var tablePath = Path.Combine(Application.dataPath, FrameDataHelper.FrameWorkSetting.EditorTablePath); var tableDir = Path.GetDirectoryName(tablePath); var xlslFiles = Directory.GetFiles(tableDir, "*.xlsx", SearchOption.AllDirectories); sql = new SQLiteService("LocalDB"); foreach (var f in xlslFiles) { var excel = new ExcelUtility(f); var json = excel.GetJson(); Json2Sqlite(f, json); } sql.Close(); EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("提示", "导出Sqlite完成!", "确定"); AssetDatabase.Refresh(); }
public static void GenJsonToSQLite(List <string> paths) { var outPath = IPath.Combine(Application.streamingAssetsPath, Utils.GetPlatformPath(Application.platform)); var _path = IPath.Combine(outPath, "Local.db"); sql = new SQLiteService(SqliteLoder.CreateConnetion(_path)); foreach (var f in paths) { string content = File.ReadAllText(f); Json2Sqlite(f, content); } sql.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
public static void Json2SqliteQuick() { string path = AssetDatabase.GetAssetPath(Selection.activeObject); path = Path.GetFullPath(path); var outPath = IPath.Combine(Application.streamingAssetsPath, Utils.GetPlatformPath(Application.platform)); var _path = IPath.Combine(outPath, "Local.db"); sql = new SQLiteService(SqliteLoder.CreateConnetion(_path)); string content = File.ReadAllText(path); Json2Sqlite(path, content); sql.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
public static void GenJsonToSQLite(string outPath) { var tablePath = IPath.Combine(Application.dataPath, "Resource/Table"); var tableDir = Path.GetDirectoryName(tablePath); var jsonFiles = Directory.GetFiles(tableDir, "*.json", SearchOption.AllDirectories); var _path = IPath.Combine(outPath, "Local.db"); sql = new SQLiteService(SqliteLoder.CreateConnetion(_path)); foreach (var f in jsonFiles) { string content = File.ReadAllText(f); Json2Sqlite(f, content); } sql.Close(); EditorUtility.ClearProgressBar(); Debug.Log("导出Sqlite完成!"); AssetDatabase.Refresh(); }
static private void Json2Sqlite(string f, string json) { // sql = new SQLiteService("LocalDB"); // var table = Path.GetFileName(f).ToLower().Replace(".xlsx", ""); var classname = "Game.Data." + table; var jsonObj = JsonMapper.ToObject(json); var assPath = Path.Combine(Application.dataPath.Replace("Assets", ""), "Library/ScriptAssemblies/Assembly-CSharp.dll"); var ass = Assembly.LoadFile("file:///" + assPath); // var t = ass.GetType(classname); //数据库创建表 // sql.DB.Delete<>() sql.DB.DropTableByType(t); sql.DB.CreateTableByType(t); EditorUtility.ClearProgressBar(); // for (int i = 0; i < jsonObj.Count; i++) { var j = jsonObj[i]; var jo = JsonMapper.ToObject(t, j.ToJson()); EditorUtility.DisplayProgressBar("Excel2Sqlite", "正在导出:" + i + "-" + jsonObj.Count, i / jsonObj.Count); sql.DB.Insert(jo); } // TestSql(); // sql.Close(); EditorUtility.DisplayDialog("提示", "导出Sqlite完成!", "确定"); }