/// <summary> /// json转sql /// </summary> /// <param name="f"></param> /// <param name="json"></param> static private void Json2Sqlite(string f, string json) { // var table = Path.GetFileName(f).Replace(Path.GetExtension(f), ""); var classname = "Game.Data." + table; var jsonObj = JsonMapper.ToObject(json); var assPath = IPath.Combine(BApplication.ProjectRoot, "Library/ScriptAssemblies/Assembly-CSharp.dll"); var ass = Assembly.LoadFile(assPath); // var t = ass.GetType(classname); // EditorUtility.DisplayProgressBar("Excel2Sqlite", string.Format("生成:{0} 记录条目:{1}", classname, jsonObj.Count), 0); if (t == null) { Debug.LogError(classname + "类不存在,请检查!"); return; } else { Debug.Log("导出:" + classname); } //数据库创建表 //sql.DB.Delete<>() sql.CreateDB(t); EditorUtility.ClearProgressBar(); // for (int i = 0; i < jsonObj.Count; i++) { var j = jsonObj[i]; var jo = JsonMapper.ToObject(t, j.ToJson()); try { sql.Insert(jo); } catch { Debug.LogError("导出数据有错,跳过! 错误位置:" + classname + ":" + i + "-" + jsonObj.Count); } } EditorUtility.DisplayProgressBar("Excel2Sqlite", string.Format("生成:{0} 记录条目:{1}", classname, jsonObj.Count), 1); }