private void CopyValues() { logger.Info("Copying values."); try { using (var sourceTableHandler = new TableHandler(sourceDatabase)) using (var targetDbHandler = new DatabaseHandler(selectedDatabase.DatabasePath)) { var records = sourceTableHandler.GetRows(tableName); var values = new List <string>(); foreach (DataRow row in records) { values.Clear(); foreach (var value in row.ItemArray) { values.Add(value.ToString()); } var command = QueryBuilder.InsertInto(TargetTableName).Values(values).Build(); targetDbHandler.ExecuteNonQuery(command); } } StatusInfo = LocalisationHelper.GetString("TableMigrator_CopySuccess"); logger.Info("Successfully copied values"); } catch (Exception ex) { logger.Error("Failed to copy table values.", ex); StatusInfo = LocalisationHelper.GetString("TableMigrator_CopySemiSuccess"); } }
public static TableHandler OpenInAB(string fileName, string abName) { TableHandler handle = new TableHandler(fileName); handle.Open(fileName, abName); return(handle); }
private void DeleteColumn() { if (selectedColumn != null) { var userAgrees = dialogService.AskForUserAgreement("MessageBox_ColumnDeleteWarning", "MessageBoxTitle_DeleteColumn", selectedColumn.Name); if (!userAgrees) { return; } try { using (var tableHandler = new TableHandler(Properties.Settings.Default.CurrentDatabase)) { tableHandler.DeleteColumn(TableName, selectedColumn.Name); Columns.Remove(selectedColumn); ColumnCount--; } } catch (Exception ex) { logger.Error("Failed to delete column '" + selectedColumn.Name + "' on table '" + tableName + "'.", ex); dialogService.ShowMessage("MessageBox_ColumnDeletionFailed"); }; } }
//读取音效数据 public void OnInit() { TableHandler table = TableHandler.OpenFromResmap("Audio"); for (int row = 0; row < table.GetRecordsNum(); row++) { AudioInfo info = new AudioInfo(); info.id = Convert.ToInt32(table.GetValue(row, 0)); info.name = table.GetValue(row, 1); string type = table.GetValue(row, 2).Trim(); if (type.Equals("1")) { info.soundType = SoundType.BGM; } else if (type.Equals("3")) { info.soundType = SoundType.VOICE; } else { info.soundType = SoundType.AUDIO; } info.volume = Convert.ToSingle(table.GetValue(row, 3)); info.loop = table.GetValue(row, 4).Trim().Equals("1"); _resmapSound.Add(info.id, info); } }
public void saveRecord() { DataValidation.Result dataValidationResult = new DataValidation.Result(); // 1. Validate the data foreach (TableHandler tableHandler in listTableHandler) { if (!tableHandler.getTableIO().isRecordOptional()) { dataValidationResult = tableHandler.getTableIO().recordValid(); if (dataValidationResult != null && !dataValidationResult.isValid()) { dataValidationResult.showMessage(); break; } } } if (dataValidationResult == null || dataValidationResult.isValid()) { // 2. Retrieve the id from the primary table String primaryId = null; if (listTableHandler.Count != 0) { TableHandler primaryTableHandler = listTableHandler[0]; if (true /*|| primaryTableHandler.getTableIO().getState().Equals(TableIO.State.Add)*/) { Control idControl = primaryTableHandler.getTableIO().findControl(Net7.Table_item_base._id); if (idControl != null) { primaryId = idControl.Text; } } } else { // Data is invalid, issue a halt to this process } // 3. Save each table // TODO: This generates multiple calls to TableIO.enableFiels() foreach (TableHandler tableHandler in listTableHandler) { if (!tableHandler.getTableIO().isRecordOptional()) { if (!tableHandler.getTableIO().recordSave(primaryId)) { return; } } } // 4. Set the proper state foreach (TableHandler tableHandler in listTableHandler) { tableHandler.getTableIO().setState(TableIO.State.View); } } }
private void Export() { StatusInfo = string.Empty; using (var tableHandler = new TableHandler(Properties.Settings.Default.CurrentDatabase)) { var stringBuilder = new StringBuilder(); if (IsFirstRowColumnTitles) { var columns = tableHandler.GetColumns(tableName); string combinedColumnHeaders = GetCombinedColumnHeadersFor(columns); stringBuilder.Append(combinedColumnHeaders + Environment.NewLine); } var rows = tableHandler.GetRows(tableName); foreach (DataRow row in rows) { string combinedValues = GetCombinedRowValuesFor(row); stringBuilder.Append(combinedValues + Environment.NewLine); } ExportCSV(stringBuilder.ToString()); } }
private void UpdateTableTree() { Tables.Clear(); IEnumerable <Table> tables; using (var dbHandler = new DatabaseHandler(selectedDatabase.DatabasePath)) { tables = dbHandler.GetTables(); } foreach (var table in tables) { var tableTreeItem = new TableTreeItem { DisplayName = table.Name }; using (var tableHandler = new TableHandler(selectedDatabase.DatabasePath)) { var columns = tableHandler.GetColumns(table.Name); foreach (var column in columns) { tableTreeItem.Columns.Add(new ColumnTreeItem { DisplayName = column.Name }); } } Tables.Add(tableTreeItem); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { TableHandler.HandleClick(sender, e, dataGridView1, (val) => { this.button1.Text = "Actualizar"; this.textBox1.Text = val.Cells["Nombre"].Value.ToString(); }); }
static Dictionary <string, ResmapInfo> InitResmap(string resmapName) { Dictionary <string, ResmapInfo> dic = new Dictionary <string, ResmapInfo>(); if (!File.Exists(DataDir + resmapName)) { return(dic); } TableHandler handler = TableHandler.OpenFromData(resmapName); for (int row = 0; row < handler.GetRecordsNum(); row++) { string key = handler.GetValue(row, 0); if (dic.ContainsKey(key)) { Debug.LogErrorFormat("{0}中有重名的键,键名{1}", resmapName, key); continue; } ResmapInfo info = new ResmapInfo() { key = key, editorPath = handler.GetValue(row, 1), abName = handler.GetValue(row, 2), }; dic.Add(key, info); } return(dic); }
static int GetColumn(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { TableHandler obj = (TableHandler)ToLua.CheckObject <TableHandler>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); string o = obj.GetColumn(arg0); LuaDLL.lua_pushstring(L, o); return(1); } else if (count == 3) { TableHandler obj = (TableHandler)ToLua.CheckObject <TableHandler>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); string arg1 = ToLua.CheckString(L, 3); string o = obj.GetColumn(arg0, arg1); LuaDLL.lua_pushstring(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: TableHandler.GetColumn")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Init() { _bundleDic = new Dictionary <string, AssetBundleInfo>(); _moduleDic = new Dictionary <string, List <AssetBundleInfo> >(); _multiLngNameDic = new Dictionary <string, string[]>(); //加载ab依赖关系文件 if (GameMain.Inst.ResourceMode != 0) { _rootManifest = LoadAsset <AssetBundleManifest>("assetbundle", "AssetBundleManifest", "manifest"); } _resmap_sprite = InitResmap("resmap_sprite"); _resmap_prefab = InitResmap("resmap_prefab"); _resmap_obj = InitResmap("resmap_obj"); //多语言资源名表 TableHandler mutilLngTable = TableHandler.OpenFromData("multiLngConfig"); for (int row = 0; row < mutilLngTable.GetRecordsNum(); row++) { string[] s = new string[mutilLngTable.GetFieldsNum() - 1]; for (int i = 1; i < mutilLngTable.GetFieldsNum(); i++) { s[i - 1] = mutilLngTable.GetValue(row, i); } _multiLngNameDic.Add(mutilLngTable.GetValue(row, 0), s); } LoadAB("res_shader", "shader"); //预加载shader,永久不卸载 }
//读取音效数据 public IEnumerator OnInit() { TableHandler table = new TableHandler(); table.OpenFromData("audio.txt"); for (int row = 0; row < table.GetRecordsNum(); row++) { AudioInfo info = new AudioInfo(); info.id = Convert.ToInt32(table.GetValue(row, 0)); info.name = table.GetValue(row, 1); info.editorPath = table.GetValue(row, 2); info.ab = table.GetValue(row, 3); string type = table.GetValue(row, 4).Trim(); if (type.Equals("1")) { info.soundType = SoundType.BGM; } else if (type.Equals("3")) { info.soundType = SoundType.VOICE; } else { info.soundType = SoundType.AUDIO; } info.volume = Convert.ToSingle(table.GetValue(row, 5)); info.loop = table.GetValue(row, 6).Trim().Equals("1"); _resmapSound.Add(info.id, info); } yield return(null); }
private void ExportToSql() { using (var tableHandler = new TableHandler(Properties.Settings.Default.CurrentDatabase)) { var tableCreateStatement = tableHandler.GetTable(tableName).CreateStatement; if (!tableCreateStatement.EndsWith(";")) { tableCreateStatement += ";"; } var stringBuilder = new StringBuilder(tableCreateStatement); stringBuilder.Append(Environment.NewLine); var valueList = new List <string>(); var queryBuilder = QueryBuilder.InsertInto(tableName); var rows = tableHandler.GetRows(tableName); foreach (DataRow row in rows) { valueList.Clear(); foreach (var value in row.ItemArray) { valueList.Add(value.ToString()); } queryBuilder.Values(valueList); stringBuilder.Append(Environment.NewLine + queryBuilder.Build()); } ExportSQL(stringBuilder.ToString()); } }
static Dictionary <string, List <string> > InitLocalResConfig() { Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >(); if (!File.Exists(DataDir + MultiLngFile)) { return(dic); } TableHandler handler = TableHandler.OpenFromData(MultiLngFile); for (int row = 0; row < handler.GetRecordsNum(); row++) { string key = handler.GetValue(row, 0); if (dic.ContainsKey(key)) { Debug.LogErrorFormat("{0}中有重名的键,键名{1}", MultiLngFile, key); continue; } List <string> resNameList = new List <string>(); for (int i = 1; i < handler.GetFieldsNum(); i++) { resNameList.Add(handler.GetValue(row, i)); } dic.Add(key, resNameList); } return(dic); }
public static TableHandler OpenFromData(string fileName) { TableHandler handle = new TableHandler(fileName); handle.Open(fileName, "Data"); return(handle); }
static int OpenFromMemory(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes <byte[]>(L, 2)) { TableHandler obj = (TableHandler)ToLua.CheckObject <TableHandler>(L, 1); byte[] arg0 = ToLua.CheckByteBuffer(L, 2); bool o = obj.OpenFromMemory(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2)) { TableHandler obj = (TableHandler)ToLua.CheckObject <TableHandler>(L, 1); string arg0 = ToLua.ToString(L, 2); bool o = obj.OpenFromMemory(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: TableHandler.OpenFromMemory")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void ParseFight_Buff() { _fight_BuffDic = new Dictionary <int, Fight_BuffParser>(); TableHandler handler = TableHandler.OpenFromResmap("Fight_Buff"); for (int i = 0; i < handler.GetRecordsNum() - 1; i++) { int key = int.Parse(handler.GetValue(i, 0)); Fight_BuffParser info = new Fight_BuffParser() { sn = int.Parse(handler.GetValue(i, 0)), actionType = int.Parse(handler.GetValue(i, 1)), buffType = int.Parse(handler.GetValue(i, 2)), valueList = ToIntArray(handler.GetValue(i, 3)), turn = int.Parse(handler.GetValue(i, 4)), dispelType = int.Parse(handler.GetValue(i, 5)), fxSn_act = int.Parse(handler.GetValue(i, 6)), fxSn_con = int.Parse(handler.GetValue(i, 7)), fxSn_des = int.Parse(handler.GetValue(i, 8)), sort = ToIntArray(handler.GetValue(i, 9)), viewType = int.Parse(handler.GetValue(i, 10)), icon = handler.GetValue(i, 11), desc = handler.GetValue(i, 12), }; } }
private void Initialize() { using (var dbHandler = new DatabaseHandler(FilePath)) using (var tableHandler = new TableHandler(FilePath)) { var tables = dbHandler.GetTables(); Name = dbHandler.GetDatabaseName(); DisplayName = Path.GetFileNameWithoutExtension(FilePath); TableCount = tables.Count(); foreach (var table in tables) { var tableRowCount = tableHandler.GetRowCount(table.Name); RowCount += tableRowCount; var columns = tableHandler.GetColumns(table.Name); TableOverviewData.Add(new TableOverviewDataItem { ColumnCount = columns.Count, Name = table.Name, RowCount = tableRowCount }); } TableOverviewData.Sort((x, y) => string.Compare(x.Name, y.Name)); var fileInfo = new FileInfo(FilePath); FileSize = GetSize(fileInfo.Length); } }
public async Task TearDown() { //clear all table data TableHandler handler = new TableHandler(); await handler.ClearSelectedTables(new List <string> { "CachedWords" }); }
private void RenameTable() { using (var tableHandler = new TableHandler(originalElement.DatabasePath)) { tableHandler.RenameTable(originalElement.DisplayName, NewName); MainTreeHandler.UpdateTableName(originalElement.DisplayName, NewName, originalElement.DatabasePath); } }
private int CalcUpgradePrice(int u) { TableHandler.Row row = TableHandler.Get(DesignConstStorage.tNameCarPrice, TableHandler.SteamMode.Resource).Rows[Index]; int carPrice = row.Get <int>("price") * 2; int price = (int)(carPrice * 0.1f) * (u + 1); return(price); }
static void Main(string[] args) { TableHandler tableHandler = new TableHandler(); DataTable newTable = tableHandler.CreateTable("AAA"); newTable.Rows.Add(); newTable.Rows.Add(); newTable.Rows[0]["Jahr"] = 2020; newTable.Rows[1]["Jahr"] = 2009; Console.WriteLine("Tabelle vorher:"); PrintTable(newTable); tableHandler.AddRow(ref newTable); tableHandler.AddRow(ref newTable); tableHandler.AddRow(ref newTable); Console.WriteLine("Tabelle sortiert:"); newTable.DefaultView.Sort = "Jahr Asc"; newTable = newTable.DefaultView.ToTable(); PrintTable(newTable); Console.WriteLine("\nTabelle speichern.\n"); tableHandler.SaveTable(newTable); Console.WriteLine("\nTabelle ausgeben.\n"); var tableList = tableHandler.GetTableNames(); PrintTableList(tableList); Console.WriteLine("AAA"); PrintTable(tableHandler.LoadDataTable("AAA")); Console.WriteLine("\nZeile löschen.\n"); tableHandler.DeleteRow(newTable, 2020); Console.WriteLine("\nTabelle speichern.\n"); tableHandler.SaveTable(newTable); Console.WriteLine("\nTabelle ausgeben.\n"); PrintTable(tableHandler.LoadDataTable("AAA")); Console.WriteLine("\nTabelle wieder löschen.\n"); tableHandler.DeleteTable(newTable); tableList = tableHandler.GetTableNames(); PrintTableList(tableList); }
public void Awake() { if (instance) { Destroy(instance); } instance = this; Table table = TableHandler.Load("Data"); city = GetComponent <City>(); }
public IEnumerator OnInit() { // 读取所有assetbundle名和依赖 if (AppConst.resourceMode != 0) { yield return(OnLoadAsset <AssetBundleManifest>( "assetbundle", "AssetBundleManifest", delegate(string name, AssetBundleManifest manifest) { _assetBundleManifest = manifest; })); } // sprite资源映射表 _resmap_sprite = new Dictionary <string, string[]>(); TableHandler spriteTable = new TableHandler(); spriteTable.OpenFromData("resmap_sprite.txt"); for (int row = 0; row < spriteTable.GetRecordsNum(); row++) { string[] s = new string[2]; s[0] = spriteTable.GetValue(row, 1); s[1] = spriteTable.GetValue(row, 2); _resmap_sprite.Add(spriteTable.GetValue(row, 0), s); } yield return(0); // prefab资源映射表 _resmap_prefab = new Dictionary <string, string[]>(); TableHandler prefabTable = new TableHandler(); prefabTable.OpenFromData("resmap_prefab.txt"); for (int row = 0; row < prefabTable.GetRecordsNum(); row++) { string[] s = new string[2]; s[0] = prefabTable.GetValue(row, 1); s[1] = prefabTable.GetValue(row, 2); _resmap_prefab.Add(prefabTable.GetValue(row, 0), s); } yield return(0); // object资源映射表 _resmap_object = new Dictionary <string, string[]>(); TableHandler objectTable = new TableHandler(); objectTable.OpenFromData("resmap_object.txt"); for (int row = 0; row < objectTable.GetRecordsNum(); row++) { string[] s = new string[2]; s[0] = objectTable.GetValue(row, 1); s[1] = objectTable.GetValue(row, 2); _resmap_object.Add(objectTable.GetValue(row, 0), s); } yield return(0); }
private void UpdateAvailableColumns() { using (var tableHandler = new TableHandler(selectedDatabase.DatabasePath)) { Columns.Clear(); var columns = tableHandler.GetColumns(selectedTable); foreach (var column in columns) { Columns.Add(new ColumnItem(column.Name)); } } }
public void ReadTableValues() { //Arrange TablePageObject tableObject = new TablePageObject(driver, "https://getbootstrap.com/docs/4.1/content/tables/"); tableObject.NavigateTo(); // Act TableHandler tableHandler = new TableHandler(tableObject.table); var value = tableHandler.ReadCell("First", 2); //Assert Assert.That(Is.Equals("Jacob", value)); }
private void ReindexTable() { var userAgrees = dialogService.AskForUserAgreement("MessageBox_ReindexTable", "MessageBoxTitle_ReindexTable", tableName); if (!userAgrees) { return; } using (var tableHandler = new TableHandler(Properties.Settings.Default.CurrentDatabase)) { tableHandler.ReindexTable(TableName); } }
/// <summary> /// <para>Select the record corresponding to the specified id.</para> /// </summary> /// <param name="selectId">The id to select</param> public Boolean selectRecord(String selectId) { TableHandler primaryTableHandler = listTableHandler[0]; ItemRecordManager itemRecordManager = (ItemRecordManager)primaryTableHandler.getTableIO().getRecordManager(); frmItems gui = (frmItems)itemRecordManager.getGui(); frmItems.EditorType previousEditorType = gui.getCurrentEditorType(); String selectCommand = primaryTableHandler.getTableIO().getRecordManager().selectDataRowFromId(selectId); String currentId = getPrimaryId(); Boolean foundRecord = primaryTableHandler.getTableIO().recordSearch(selectCommand); if (!foundRecord) { // Remain with this current editor selectCommand = primaryTableHandler.getTableIO().getRecordManager().selectDataRowFromId(currentId); primaryTableHandler.getTableIO().recordSearch(selectCommand); return(false); } primaryTableHandler.getTableIO().viewRecord(); // A new type of editor may have been activated frmItems.EditorType currentEditorType = gui.getCurrentEditorType(); if (!currentEditorType.Equals(previousEditorType)) { // Let that new editor handle the record // Note that this call is recursive since it calls this same // function. An infinite loop is avoided as long as the previous // and current editor types are different return(gui.getCurrentEditor().selectRecord(selectId)); } Boolean skippedFirstTable = false; foreach (TableHandler tableHandler in listTableHandler) { if (!skippedFirstTable) { skippedFirstTable = true; } else { selectCommand = tableHandler.getTableIO().getRecordManager().selectDataRowFromId(selectId); tableHandler.getTableIO().recordSearch(selectCommand); tableHandler.getTableIO().viewRecord(); } } return(foundRecord); }
static int GetFieldsNum(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); TableHandler obj = (TableHandler)ToLua.CheckObject <TableHandler>(L, 1); int o = obj.GetFieldsNum(); LuaDLL.lua_pushinteger(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int OpenFromResmap(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); string arg0 = ToLua.CheckString(L, 1); TableHandler o = TableHandler.OpenFromResmap(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }