static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            //判断设置
            var BuildSqlSetting = BDEditorApplication.BDFrameworkEditorSetting.BuildSqlSetting;

            if (!BuildSqlSetting.IsAutoImportSqlWhenExcelChange)
            {
                return;
            }
            //开始导表
            var excelList = new List <string>();

            foreach (var asset in importedAssets)
            {
                if (asset.EndsWith("xlsx", StringComparison.OrdinalIgnoreCase) && asset.Contains("Table", StringComparison.OrdinalIgnoreCase) && !asset.Contains("~"))
                {
                    excelList.Add(asset);
                }
            }

            if (excelList.Count > 0)
            {
                SqliteLoder.LoadLocalDBOnEditor(Application.streamingAssetsPath, BApplication.RuntimePlatform);
                float counter = 1f;
                foreach (var excel in excelList)
                {
                    Excel2SQLiteTools.Excel2SQLite(excel, DBType.Local);
                    EditorUtility.DisplayProgressBar("自动导表", excel, counter / excelList.Count);
                    counter++;
                }
                EditorUtility.ClearProgressBar();
                BDebug.Log("自动导表完成!");
                SqliteLoder.Close();
            }
        }
        /// <summary>
        /// 生成sqlite
        /// 默认导出到当前平台目录下
        /// </summary>
        /// <param name="ouptputPath">自定义路径</param>
        public static void ALLExcel2SQLite(string ouptputPath, RuntimePlatform platform)
        {
            //触发bd环境周期
            BDFrameEditorBehaviorHelper.OnBeginBuildSqlite();

            var xlslFiles = GetAllConfigFiles();

            SqliteLoder.LoadOnEditor(ouptputPath, platform);
            {
                foreach (var f in xlslFiles)
                {
                    try
                    {
                        Excel2SQLite(f);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("导表失败:" + f);
                    }
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            //触发bd环境周期
            BDFrameEditorBehaviorHelper.OnEndBuildSqlite(ouptputPath);
            AssetHelper.AssetHelper.GenPackageBuildInfo(ouptputPath, platform);
            Debug.Log("导出Sqlite完成!");
        }
        /// <summary>
        /// 生成sqlite
        /// </summary>
        /// <param name="outPath"></param>
        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");
            //
            var connect = SqliteLoder.CreateConnetion(_path);

            sql = new SQLiteService(connect);
            foreach (var f in xlslFiles)
            {
                var excel = new ExcelUtility(f);
                var json  = excel.GetJson();
                Json2Sqlite(f, json);
            }

            SqliteLoder.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Example #4
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            var excelList = new List <string>();

            foreach (var asset in importedAssets)
            {
                if (asset.EndsWith("xlsx") && asset.Contains("Table"))
                {
                    excelList.Add(asset);
                }
            }

            SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform);
            if (excelList.Count > 0)
            {
                float counter = 1f;
                foreach (var excel in excelList)
                {
                    Excel2SQLiteTools.Excel2SQLite(excel);
                    EditorUtility.DisplayProgressBar("自动导表", excel, counter / excelList.Count);
                    counter++;
                }
                EditorUtility.ClearProgressBar();
            }
            SqliteLoder.Close();
            Debug.Log("自动导表完成!");
        }
Example #5
0
        void OnApplicationQuit()
        {
#if UNITY_EDITOR
            SqliteLoder.Close();
            ILRuntimeHelper.Close();
#endif
        }
Example #6
0
        static public void OnForceImpotChangedExcel()
        {
            //判断是否导入设置
            if (BDEditorApplication.BDFrameworkEditorSetting.BuildSqlSetting.IsForceImportChangedExcelOnWillEnterPlaymode)
            {
                var(changedExcelList, newEcxcelInfoMap) = ExcelEditorTools.GetChangedExcels();
                if (changedExcelList.Count > 0)
                {
                    BDebug.Log("-----------------强制导入修改的excel文件.begin-----------------", "red");

                    SqliteLoder.LoadLocalDBOnEditor(Application.streamingAssetsPath, BApplication.RuntimePlatform);
                    {
                        //开始导入
                        foreach (var excel in changedExcelList)
                        {
                            var path = AssetDatabase.GUIDToAssetPath(excel);
                            Excel2SQLiteTools.Excel2SQLite(path, DBType.Local);
                        }
                    }
                    SqliteLoder.Close();
                    BDebug.Log("-----------------强制导入修改的excel文件.end-----------------", "red");
                }
                //保存配置
                ExcelEditorTools.SaveExcelCacheInfo(newEcxcelInfoMap);
            }
        }
Example #7
0
 static public void Close()
 {
     if (!Application.isPlaying)
     {
         SqliteLoder.Close();
     }
 }
Example #8
0
        public static void MenuItem_Excel2Sqlite()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            SqliteLoder.LoadLocalDBOnEditor(Application.streamingAssetsPath, BApplication.RuntimePlatform);
            {
                Excel2SQLite(path, DBType.Local);
            }
            SqliteLoder.Close();
            EditorUtility.ClearProgressBar();
            EditorUtility.DisplayDialog("提示", Path.GetFileName(path) + "\n恭喜你又成功导入一次表格吶~\n呐!呐!呐!呐! ", "OK");
            AssetDatabase.Refresh();
        }
Example #9
0
 /// <summary>
 /// 导入自定义内容到 excel
 /// 默认为Application.streamingAssetsPath
 /// </summary>
 /// <param name="path"></param>
 public static void GenxslxOrJsonToSQlite(IDictionary <string, string> path)
 {
     SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform);
     {
         foreach (var f in path)
         {
             JsonContent2Sqlite(f.Key, f.Value);
         }
     }
     SqliteLoder.Close();
     EditorUtility.ClearProgressBar();
     Debug.Log("导出Sqlite完成!");
     AssetDatabase.Refresh();
 }
Example #10
0
        /// <summary>
        /// 导入 json 到excel
        /// 默认为Application.streamingAssetsPath
        /// </summary>
        /// <param name="paths"></param>
        public static void GenJsonToSQLite(List <string> paths)
        {
            SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform);
            {
                foreach (var f in paths)
                {
                    string content = File.ReadAllText(f);

                    JsonContent2Sqlite(f, content);
                }
            }
            SqliteLoder.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Example #11
0
        public static void GenJson2SQLite()
        {
            var jsonFiles = Excel2SQLiteTools.GetAllConfigFiles("*.json");

            //连接数据库
            SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform);
            {
                foreach (var f in jsonFiles)
                {
                    string content = File.ReadAllText(f);
                    JsonContent2Sqlite(f, content);
                }
            }
            SqliteLoder.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
        }
        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");
            var c     = SqliteLoder.CreateConnetion(_path);

            sql = new SQLiteService(c);
            foreach (var f in path)
            {
                Json2Sqlite(f.Key, f.Value);
            }

            SqliteLoder.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Example #13
0
        public static void Json2SqliteQuick()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            path = Path.GetFullPath(path);

            SqliteLoder.LoadOnEditor(Application.streamingAssetsPath, Application.platform);
            {
                string content = File.ReadAllText(path);
                Debug.Log(path);
                JsonContent2Sqlite(path, content);
            }
            SqliteLoder.Close();

            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
Example #14
0
        /// <summary>
        /// 生成sqlite
        /// 默认导出到当前平台目录下
        /// </summary>
        /// <param name="root">自定义路径</param>
        public static void GenExcel2SQLite(string root, RuntimePlatform platform)
        {
            var xlslFiles = GetAllConfigFiles();

            //
            SqliteLoder.LoadOnEditor(root, platform);
            {
                foreach (var f in xlslFiles)
                {
                    var excel = new ExcelUtility(f);
                    var json  = excel.GetJson();
                    JsonContent2Sqlite(f, json);
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
        }
Example #15
0
        /// <summary>
        /// 生成sqlite
        /// 默认导出到当前平台目录下
        /// </summary>
        /// <param name="ouptputPath">自定义路径</param>
        public static void AllExcel2SQLite(string ouptputPath, RuntimePlatform platform, DBType dbType = DBType.Local)
        {
            //触发bd环境周期
            BDFrameworkPipelineHelper.OnBeginBuildSqlite();
            var xlslFiles = ExcelEditorTools.GetAllExcelFiles();

            switch (dbType)
            {
            case DBType.Local:
                SqliteLoder.LoadLocalDBOnEditor(ouptputPath, platform);
                break;

            case DBType.Server:
                SqliteLoder.LoadServerDBOnEditor(ouptputPath, platform);
                break;
            }

            //清空表
            SqliteHelper.DB.Connection.DropTable <ImportExcelLog>();
            {
                foreach (var f in xlslFiles)
                {
                    try
                    {
                        Excel2SQLite(f, dbType);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                        Debug.LogError("导表失败:" + f);
                        EditorUtility.ClearProgressBar();
                    }
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            //触发bd环境周期
            BDFrameworkPipelineHelper.OnEndBuildSqlite(ouptputPath);
            GlobalAssetsHelper.GenBasePackageAssetBuildInfo(ouptputPath, platform);
            Debug.Log("导出Sqlite完成!");
        }
        public static void GenJsonToSQLite(List <string> paths)
        {
            var outPath = IPath.Combine(Application.streamingAssetsPath,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");
            var c     = SqliteLoder.CreateConnetion(_path);

            sql = new SQLiteService(c);
            foreach (var f in paths)
            {
                string content = File.ReadAllText(f);

                Json2Sqlite(f, content);
            }

            SqliteLoder.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");
            var c         = SqliteLoder.CreateConnetion(_path);

            sql = new SQLiteService(c);
            foreach (var f in jsonFiles)
            {
                string content = File.ReadAllText(f);
                Json2Sqlite(f, content);
            }

            SqliteLoder.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,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");
            var c     = SqliteLoder.CreateConnetion(_path);

            sql = new SQLiteService(c);
            string content = File.ReadAllText(path);

            Debug.Log(path);
            Json2Sqlite(path, content);
            SqliteLoder.Close();

            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
        /// <summary>
        /// 生成sqlite
        /// 默认导出到当前平台目录下
        /// </summary>
        /// <param name="ouptputPath">自定义路径</param>
        public static void AllExcel2SQLite(string ouptputPath, RuntimePlatform platform, DBType dbType = DBType.Local)
        {
            //触发bd环境周期
            BDEditorBehaviorHelper.OnBeginBuildSqlite();
            var xlslFiles = GetAllConfigFiles();

            switch (dbType)
            {
            case DBType.Local:
                SqliteLoder.LoadLocalDBOnEditor(ouptputPath, platform);
                break;

            case DBType.Server:
                SqliteLoder.LoadServerDBOnEditor(ouptputPath, platform);
                break;
            }
            {
                foreach (var f in xlslFiles)
                {
                    try
                    {
                        Excel2SQLite(f, dbType);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("导表失败:" + f);
                        EditorUtility.ClearProgressBar();
                    }
                }
            }
            SqliteLoder.Close();
            //
            EditorUtility.ClearProgressBar();
            //触发bd环境周期
            BDEditorBehaviorHelper.OnEndBuildSqlite(ouptputPath);
            AssetHelper.AssetHelper.GenPackageBuildInfo(ouptputPath, platform);
            Debug.Log("导出Sqlite完成!");
        }
Example #20
0
 static public void Close()
 {
     SqliteLoder.Close();
 }