/// <summary> /// 获取数据库结构 /// </summary> /// <param name="isGetData">是否要获得表数据</param> /// <param name="tablesName">如果要获得数据,需有将获得表的名称集合</param> /// <returns></returns> public DataSet GetDataSet(bool isGetData = false, List <string> tablesName = null) { DataSet ds = new DataSet("MyDataSet"); //仅数据库结构(不包括数据) if (!isGetData) { tablesName = DBTables.Select(t => t.Name).ToList(); } DBDataSet = _schemaReader.GetDataSet(tablesName, isGetData); return(DBDataSet); }
// generate a WorldDef-object from the retrieved sql-results protected void WorldDefFromSQLResults(GUC.Utilities.Threading.AbstractRunnable sender, DBAgent.FinishedQueueEventHandlerArgs e) { // convert the sql-query-results from string to their respective datatypes sqlResultInUse = true; sqlResults = e.GetSQLResults(); DBTables.ConvertSQLResults(sqlResults, colGetTypeInfo, false); // construct the WorldDef-object according to the converted sql-data worldDef = new WorldDef(this); ApplyWorldEffects(ref worldDef, ref sqlResults, ref colGetTypeInfo); // initalize VobInst-objects from database via loaders of the VobSystem //VobSystem.VobInstLoader vobInstLoader = new VobSystem.VobInstLoader(ref worldDef); //vobInstLoader.Start(); //vobInstLoader.FinishedLoading += delegate (object sender, FinishedLoadingArgs e) //{ // // release control over sqlResults on finishing line // sqlResultInUse = false; //}; }
protected void VobDefFromSQLResults(AbstractRunnable s, DBAgent.FinishedQueueEventHandlerArgs e) { try { var cgi = GetColGetTypeInfo(); // convert the received database-results List <List <List <object> > > sqlResults = e.GetSQLResults(); DBTables.ConvertSQLResults(sqlResults, cgi); int i_VobDef = DBTableLoadOrder.IndexOf("VobDef"); List <DBTables.ColumnGetTypeInfo> cgt_VobDef = cgi[i_VobDef]; List <List <object> > tableVobDef = sqlResults[DBTableLoadOrder.IndexOf("VobDef")]; int i_VobDefEffect = DBTableLoadOrder.IndexOf("VobDefEffect"); List <DBTables.ColumnGetTypeInfo> cgt_VobDefEffect = cgi[i_VobDefEffect]; List <List <object> > tableVobDefEffect = sqlResults[DBTableLoadOrder.IndexOf("VobDefEffect")]; Dictionary <int, Effect> effectByID = null; //EffectLoader effectLoader = new EffectLoader(dbFilePath, "Vob"); EffectLoader effectLoader = new EffectLoader(GetDBFilePath(), "DefEffect", "DefChange"); effectLoader.Load(true, (object sender, EffectLoader.FinishedLoadingEffectsArgs eff) => { effectByID = eff.EffectsByID; }); if ((effectByID == null) || (effectByID.Count < 1)) { MakeLogError("Aborting generation of VobDef because no Effects were loaded!"); return; } List <IDAndEffectIDs> idAndEffectIDList = null; if (!TryGenerateIDAndEffectIDList(tableVobDefEffect, out idAndEffectIDList)) { MakeLogWarning("The provided parameter tableVobDefEffect was either null " + "or didn't contain any elements!"); } List <int> failedIndices; if (!TryGenerateVobDefs(idAndEffectIDList, effectByID, out vobDefByID, out failedIndices)) { MakeLogError("Generation of VobDef failed!"); StringBuilder sb = new StringBuilder(); sb.Append("Failed to generate VobDef with [temporary index | VobDefID]: "); for (int i = 0; i < failedIndices.Count; i++) { sb.Append("["); sb.Append(i); sb.Append("|"); if ((failedIndices[i] < 0) || (failedIndices[i] > (idAndEffectIDList.Count - 1))) { sb.Append("?"); } else { sb.Append(failedIndices[i]); } sb.Append("],"); } MakeLogError(sb.ToString()); return; } } catch (Exception ex) { MakeLogError("Failed to finish generating VodDef-objects from sqlResults: " + ex); } }