Beispiel #1
0
        static public void Insert()
        {
            //TODO
            //暂时热更内不支持创建插入操作
            //该条测试可能会对后面有影响
            var h1 = new APITestHero()
            {
                Id = 1
            };
            var h2 = new APITestHero()
            {
                Id = 2
            };
            var h3 = new APITestHero()
            {
                Id = 3
            };

            if (!ILRuntimeHelper.IsRunning)
            {
                SqliteLoder.LoadLocalDBOnEditor(Application.streamingAssetsPath, Application.platform);
                SqliteHelper.DB.CreateTable <APITestHero>();
                SqliteHelper.DB.InsertTable(new List <APITestHero>()
                {
                    h1, h2, h3
                });
            }

            Assert.IsPass(true);
        }
        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();
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #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") && !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();
            }
        }
Beispiel #5
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();
        }
Beispiel #6
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完成!");
        }
        /// <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完成!");
        }