本文整理汇总了C#中DBConnector.TableUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# DBConnector.TableUpdate方法的具体用法?C# DBConnector.TableUpdate怎么用?C# DBConnector.TableUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnector
的用法示例。
在下文中一共展示了DBConnector.TableUpdate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportEconomyLevelLocalizations
/// <summary>
/// loads the localized economy level names and check
/// </summary>
internal void ImportEconomyLevelLocalizations(String Filename)
{
DBConnector lDBCon = null;
dsEliteDB Data;
DataSet DataNames;
Dictionary<String, Int32> foundLanguagesFromFile = new Dictionary<String, Int32>();
Int32 Counter = 0;
Data = new dsEliteDB();
DataNames = new DataSet();
try
{
lDBCon = new DBConnector(Program.DBCon.ConfigData, true);
DataNames.ReadXml(Filename);
lDBCon.TableRead("select * from tbLanguage", Data.tblanguage);
lDBCon.TableRead("select * from tbLevelLocalization", Data.tblevellocalization);
lDBCon.TableRead("select * from tbEconomyLevel", Data.tbeconomylevel);
if(DataNames.Tables["Levels"] != null)
{
sendProgressEvent(new ProgressEventArgs() {Info="import economy level localization", CurrentValue=Counter, TotalValue=DataNames.Tables["Levels"].Rows.Count });
// first check if there's a new language
foreach (DataColumn LanguageFromFile in DataNames.Tables["Levels"].Columns)
{
if(!LanguageFromFile.ColumnName.Equals("ID", StringComparison.InvariantCultureIgnoreCase))
{
DataRow[] LanguageName = Data.tblanguage.Select("language = " + DBConnector.SQLAString(LanguageFromFile.ColumnName));
if(LanguageName.Count() == 0)
{
// add a non existing language
DataRow newRow = Data.tblanguage.NewRow();
int? Wert = DBConvert.To<int?>(Data.tblanguage.Compute("max(id)", ""));
if(Wert == null)
Wert = 0;
newRow["id"] = Wert;
newRow["language"] = LanguageFromFile.ColumnName;
Data.tblanguage.Rows.Add(newRow);
foundLanguagesFromFile.Add(LanguageFromFile.ColumnName, (Int32)Wert);
}
else
foundLanguagesFromFile.Add((String)LanguageName[0]["language"], (Int32)LanguageName[0]["id"]);
}
}
// submit changes (tbLanguage)
lDBCon.TableUpdate(Data.tblanguage);
// compare and add the localized names
foreach (DataRow LocalizationFromFile in DataNames.Tables["Levels"].AsEnumerable())
{
String BaseName = (String)LocalizationFromFile[Program.BASE_LANGUAGE];
DataRow[] Level = Data.tbeconomylevel.Select("level = " + DBConnector.SQLAString(DBConnector.DTEscape(BaseName)));
foreach (KeyValuePair<String, Int32> LanguageFormFile in foundLanguagesFromFile)
{
DataRow[] currentLocalizations = Data.tblevellocalization.Select(" economylevel_id = " + Level[0]["id"] +
" and language_id = " + LanguageFormFile.Value);
if(currentLocalizations.Count() == 0)
{
// add a new localization
dsEliteDB.tblevellocalizationRow newRow = (dsEliteDB.tblevellocalizationRow)Data.tblevellocalization.NewRow();
newRow.economylevel_id = (Int32)Level[0]["id"];
newRow.language_id = LanguageFormFile.Value;
newRow.locname = LocalizationFromFile[LanguageFormFile.Key].ToString();
Data.tblevellocalization.Rows.Add(newRow);
}
}
Counter++;
sendProgressEvent(new ProgressEventArgs() {Info="import economy level localization", CurrentValue=Counter, TotalValue=DataNames.Tables["Levels"].Rows.Count });
}
}
// submit changes
lDBCon.TableUpdate(Data.tblevellocalization);
lDBCon.Dispose();
}
catch (Exception ex)
{
if(lDBCon != null)
lDBCon.Dispose();
throw new Exception("Error while loading commodity names", ex);
}
//.........这里部分代码省略.........
示例2: ImportCommodityPriceWarnLevels
/// <summary>
/// loads the existing price-warnlevel data
/// </summary>
internal void ImportCommodityPriceWarnLevels(String Filename)
{
DBConnector lDBCon = null;
dsEliteDB Data;
List<EDCommoditiesWarningLevels> WarnLevels;
Int32 Counter = 0;
WarnLevels = JsonConvert.DeserializeObject<List<EDCommoditiesWarningLevels>>(File.ReadAllText(Filename));
Data = new dsEliteDB();
try
{
lDBCon = new DBConnector(Program.DBCon.ConfigData, true);
lDBCon.TableRead("select * from tbCommodity", Data.tbcommodity);
sendProgressEvent(new ProgressEventArgs() {Info="import warnlevels", CurrentValue=Counter, TotalValue=WarnLevels.Count });
// first check if there's a new language
foreach (EDCommoditiesWarningLevels Warnlevel in WarnLevels)
{
DataRow[] Commodity = Data.tbcommodity.Select("commodity = " + DBConnector.SQLAString(DBConnector.DTEscape(Warnlevel.Name)));
if(Commodity.Count() > 0)
{
Commodity[0]["pwl_demand_buy_low"] = Warnlevel.PriceWarningLevel_Demand_Buy_Low;
Commodity[0]["pwl_demand_buy_high"] = Warnlevel.PriceWarningLevel_Demand_Buy_High;
Commodity[0]["pwl_supply_buy_low"] = Warnlevel.PriceWarningLevel_Supply_Buy_Low;
Commodity[0]["pwl_supply_buy_high"] = Warnlevel.PriceWarningLevel_Supply_Buy_High;
Commodity[0]["pwl_demand_sell_low"] = Warnlevel.PriceWarningLevel_Demand_Sell_Low;
Commodity[0]["pwl_demand_sell_high"] = Warnlevel.PriceWarningLevel_Demand_Sell_High;
Commodity[0]["pwl_supply_sell_low"] = Warnlevel.PriceWarningLevel_Supply_Sell_Low;
Commodity[0]["pwl_supply_sell_high"] = Warnlevel.PriceWarningLevel_Supply_Sell_High;
}
Counter++;
sendProgressEvent(new ProgressEventArgs() { Info="import warnlevels", CurrentValue=Counter, TotalValue=WarnLevels.Count });
}
// submit changes (tbLanguage)
lDBCon.TableUpdate(Data.tbcommodity);
lDBCon.Dispose();
}
catch (Exception ex)
{
if(lDBCon != null)
lDBCon.Dispose();
throw new Exception("Error while loading commodity names", ex);
}
}
示例3: ImportCommodityLocalizations
/// <summary>
/// loads the localized commodity names and check if
/// the self added names now included in the official dictionary
/// </summary>
internal void ImportCommodityLocalizations(DataSet DataNames, enLocalisationImportType importType = enLocalisationImportType.onlyNew)
{
DBConnector lDBCon = null;
dsEliteDB Data;
Dictionary<String, Int32> foundLanguagesFromFile = new Dictionary<String, Int32>();
String sqlString;
Int32 currentSelfCreatedIndex;
Int32 Counter = 0;
Boolean idColumnFound = false;
String BaseName;
DataRow[] Commodity;
Data = new dsEliteDB();
try
{
lDBCon = new DBConnector(Program.DBCon.ConfigData, true);
// gettin' some freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=2");
sqlString = "select min(id) As min_id from tbCommodity";
lDBCon.Execute(sqlString, "minID", DataNames);
if(Convert.IsDBNull(DataNames.Tables["minID"].Rows[0]["min_id"]))
currentSelfCreatedIndex = -1;
else
{
currentSelfCreatedIndex = ((Int32)DataNames.Tables["minID"].Rows[0]["min_id"]) - 1;
if(currentSelfCreatedIndex >= 0)
currentSelfCreatedIndex = -1;
}
lDBCon.TableRead("select * from tbLanguage", Data.tblanguage);
lDBCon.TableRead("select * from tbCommodityLocalization", Data.tbcommoditylocalization);
lDBCon.TableRead("select * from tbCommodity", Data.tbcommodity);
if(DataNames.Tables["Names"] != null)
{
sendProgressEvent(new ProgressEventArgs() {Info="import commodity localization", CurrentValue=Counter, TotalValue=DataNames.Tables["Names"].Rows.Count });
// first check if there's a new language
foreach (DataColumn LanguageFromFile in DataNames.Tables["Names"].Columns)
{
if(!LanguageFromFile.ColumnName.Equals("id", StringComparison.InvariantCultureIgnoreCase))
{
DataRow[] LanguageName = Data.tblanguage.Select("language = " + DBConnector.SQLAString(LanguageFromFile.ColumnName));
if(LanguageName.Count() == 0)
{
// add a non existing language
DataRow newRow = Data.tblanguage.NewRow();
int? Wert = DBConvert.To<int?>(Data.tblanguage.Compute("max(id)", ""));
if(Wert == null)
Wert = 0;
Wert += 1;
newRow["id"] = Wert;
newRow["language"] = LanguageFromFile.ColumnName;
Data.tblanguage.Rows.Add(newRow);
foundLanguagesFromFile.Add(LanguageFromFile.ColumnName, (Int32)Wert);
}
else
foundLanguagesFromFile.Add((String)LanguageName[0]["language"], (Int32)LanguageName[0]["id"]);
}
else
idColumnFound = true;
}
// submit changes (tbLanguage)
lDBCon.TableUpdate(Data.tblanguage);
// compare and add the localized names
foreach (DataRow LocalizationFromFile in DataNames.Tables["Names"].AsEnumerable())
{
int? commodityID = null;
if (idColumnFound)
commodityID = DBConvert.To<int?>(LocalizationFromFile["id"]);
if (commodityID == 1)
Debug.Print("Stop");
BaseName = (String)LocalizationFromFile[Program.BASE_LANGUAGE];
if ((commodityID == null) || (commodityID < 0))
{
// no id or selfcreated
Commodity = Data.tbcommodity.Select("commodity = " + DBConnector.SQLAString(DBConnector.DTEscape(BaseName)));
}
else
{
//.........这里部分代码省略.........
示例4: ImportStations_Own
//.........这里部分代码省略.........
{
// data from file is newer
CopyEDStationToDataRow(Station, (DataRow)FoundRows[0], true, null, true);
CopyEDStationEconomiesToDataRows(Station, Data.tbstationeconomy);
// commodities are not considered because there was no possibility for input in the old RN
ImportCounter += 1;
}
}
else
{
// new data is user changed data, old data is original data
// copy the original data ("tbStations") to the saving data table ("tbStations_org")
// and get the correct system ID
Data.tbstations_org.LoadDataRow(FoundRows[0].ItemArray, false);
CopyEDStationToDataRow(Station, (DataRow)FoundRows[0], true, null, true);
CopyEDStationEconomiesToDataRows(Station, Data.tbstationeconomy);
// commodities are not considered because there was no possibility for input in the old RN
ImportCounter += 1;
}
}
}
else
{
// add a new station
Station.Id = currentSelfCreatedIndex;
dsEliteDB.tbstationsRow newRow = (dsEliteDB.tbstationsRow)Data.tbstations.NewRow();
CopyEDStationToDataRow(Station, (DataRow)newRow, true, null, true);
newRow.visited = setVisitedFlag;
newRow.updated_at = DateTime.UtcNow;
Data.tbstations.Rows.Add(newRow);
currentSelfCreatedIndex -= 1;
ImportCounter += 1;
CopyEDStationEconomiesToDataRows(Station, Data.tbstationeconomy);
// commodities are not considered because there was no possibility for input in the old RN
ImportCounter += 1;
}
if ((ImportCounter > 0) && ((ImportCounter % 100) == 0))
{
// save changes
Debug.Print("added Stations : " + ImportCounter.ToString());
lDBCon.TableUpdate(Data.tbstations);
lDBCon.TableUpdate(Data.tbstations_org);
lDBCon.TableUpdate(Data.tbstationeconomy);
}
}
else
Debug.Print("why");
Counter++;
sendProgressEvent(new ProgressEventArgs() { Info="import self-added stations", CurrentValue=Counter, TotalValue=Stations.Count });
}
// save changes
lDBCon.TableUpdate(Data.tbstations);
lDBCon.TableUpdate(Data.tbstations_org);
lDBCon.TableUpdate(Data.tbstationeconomy);
lDBCon.TransCommit();
// reset freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
lDBCon.Dispose();
}
catch (Exception ex)
{
if(lDBCon != null)
{
if (lDBCon.TransActive())
lDBCon.TransRollback();
try
{
lDBCon.Dispose();
// reset freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
lDBCon.Dispose();
}
catch (Exception) { }
}
throw new Exception("Error while importing Station data", ex);
}
}
示例5: ImportStations
//.........这里部分代码省略.........
}
else
{
// Location is existing - keep the newer version
Timestamp_old = (DateTime)(FoundRows[0]["updated_at"]);
Timestamp_new = DateTimeOffset.FromUnixTimeSeconds(Station.UpdatedAt).DateTime;
if (Timestamp_new > Timestamp_old)
{
// data from file is newer
CopyEDStationToDataRow(Station, (DataRow)FoundRows[0], false, null, true);
CopyEDStationEconomiesToDataRows(Station, Data.tbstationeconomy);
CopyEDStationCommodityToDataRow(Station, Data, ref currentComodityClassificationID);
ImportCounter += 1;
}
}
}
else
{
// self-created stations don't have the correct id so they must be identified by name
FoundRows = (dsEliteDB.tbstationsRow[])Data.tbstations.Select("stationname = " + DBConnector.SQLAString(DBConnector.DTEscape(Station.Name.ToString())) + " and " +
" system_id = " + Station.SystemId + " and " +
" id < 0");
if (FoundRows.Count() > 0)
{
// self created station is existing -> correct id and get new data from EDDB
CopyEDStationToDataRow(Station, (DataRow)FoundRows[0], false, null, true);
// update immediately because otherwise the references are wrong after changing a id
lDBCon.TableUpdate(Data.tbstations);
lDBCon.TableUpdate(Data.tbstations_org);
lDBCon.TableUpdate(Data.tbstationeconomy);
lDBCon.TableUpdate(Data.tbcommodityclassification);
lDBCon.TableUpdate(Data.tbcommodity_has_attribute);
lDBCon.TableUpdate(Data.tbattribute);
lDBCon.TableRefresh(Data.tbstationeconomy);
lDBCon.TableRefresh(Data.tbcommodityclassification);
lDBCon.TableRefresh(Data.tbcommodity_has_attribute);
lDBCon.TableRefresh(Data.tbattribute);
}
else
{
// add a new Location
dsEliteDB.tbstationsRow newStationRow = (dsEliteDB.tbstationsRow)Data.tbstations.NewRow();
CopyEDStationToDataRow(Station, (DataRow)newStationRow, false, null, true);
Data.tbstations.Rows.Add(newStationRow);
added++;
}
CopyEDStationEconomiesToDataRows(Station, Data.tbstationeconomy);
CopyEDStationCommodityToDataRow(Station, Data, ref currentComodityClassificationID);
ImportCounter += 1;
}
if ((ImportCounter > 0) && ((ImportCounter % 100) == 0))
{
// save changes
Debug.Print("added Stations : " + ImportCounter.ToString());
示例6: ImportSystems_Own
//.........这里部分代码省略.........
{
// old data is changed by user and the new data is also a user changed data
// keep the newer version in the main table
Timestamp_old = (DateTime)(FoundRows[0]["updated_at"]);
Timestamp_new = DateTimeOffset.FromUnixTimeSeconds(System.UpdatedAt).DateTime;
if (Timestamp_new > Timestamp_old)
{
// data from file is newer -> take it but hold the old id
CopyEDSystemToDataRow(System, (DataRow)FoundRows[0], true, null, true);
ImportCounter += 1;
}
}
else
{
// new data is user changed data, old data is original data
// copy the original data ("tbSystems") to the saving data table ("tbSystems_org")
// and get the correct system ID
Data.tbsystems_org.LoadDataRow(FoundRows[0].ItemArray, false);
CopyEDSystemToDataRow(System, (DataRow)FoundRows[0], true, null, true);
ImportCounter += 1;
}
}
else
{
System.Id = (Int32)FoundRows[0]["id"];
}
}
else
{
// add a new system
// memorize the changed system ids for importing user changed stations in the (recommend) second step
if (!OnlyAddUnknown)
changedSystemIDs.Add(System.Id, currentSelfCreatedIndex);
System.Id = currentSelfCreatedIndex;
dsEliteDB.tbsystemsRow newRow = (dsEliteDB.tbsystemsRow)Data.tbsystems.NewRow();
CopyEDSystemToDataRow(System, (DataRow)newRow, true, null, true);
newRow.visited = setVisitedFlag;
newRow.updated_at = DateTime.UtcNow;
Data.tbsystems.Rows.Add(newRow);
currentSelfCreatedIndex -= 1;
ImportCounter += 1;
}
if ((ImportCounter > 0) && ((ImportCounter % 100) == 0))
{
// save changes
Debug.Print("added Systems : " + ImportCounter.ToString());
lDBCon.TableUpdate(Data.tbsystems);
lDBCon.TableUpdate(Data.tbsystems_org);
}
}
Counter++;
sendProgressEvent(new ProgressEventArgs() { Info="import self-added systems", CurrentValue=Counter, TotalValue=Systems.Count });
}
// save changes
lDBCon.TableUpdate(Data.tbsystems);
lDBCon.TableUpdate(Data.tbsystems_org);
lDBCon.TransCommit();
// reset freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
lDBCon.Dispose();
// return all changed ids
return changedSystemIDs;
}
catch (Exception ex)
{
if(lDBCon != null)
{
if (lDBCon.TransActive())
lDBCon.TransRollback();
try
{
// reset freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
lDBCon.Dispose();
}
catch (Exception)
{ }
}
throw new Exception("Error while importing system data", ex);
}
}
示例7: ImportSystems
//.........这里部分代码省略.........
if (Timestamp_new > Timestamp_old)
{
// data from file is newer
CopyEDSystemToDataRow(importSystem, (DataRow)localDataSet.tbsystems_org.Rows[0], false, null, true);
ImportCounter += 1;
dataChanged = true;
}
}
}
else
{
// system is existing - keep the newer version
Timestamp_old = (DateTime)(localDataSet.tbsystems.Rows[0]["updated_at"]);
Timestamp_new = DateTimeOffset.FromUnixTimeSeconds(importSystem.UpdatedAt).DateTime;
if (Timestamp_new > Timestamp_old)
{
// data from file is newer
CopyEDSystemToDataRow(importSystem, localDataSet.tbsystems.Rows[0], false, null, true);
ImportCounter += 1;
dataChanged = true;
updated += 1;
}
}
}
else
{
if(dataAdapter_sys != null)
{
dataAdapter_sys.Dispose();
dataAdapter_sys = null;
}
// check if there's a user generated system
// self-created systems don't have the correct id so it must be identified by name
lDBCon.TableRead(String.Format("select * from tbSystems where systemname = {0} and id < 0 lock in share mode;", DBConnector.SQLAEscape(importSystem.Name.ToString()) ), localDataSet.tbsystems, ref dataAdapter_sys);
if (localDataSet.tbsystems.Rows.Count > 0)
{
// self created systems is existing -> correct id and get new data from EDDB
// (changed system_id in tbStations are automatically internal updated by the database itself)
CopyEDSystemToDataRow(importSystem, (DataRow)localDataSet.tbsystems.Rows[0], false, null, true);
dataChanged = true;
}
else
{
// add a new system
dsEliteDB.tbsystemsRow newRow = (dsEliteDB.tbsystemsRow)localDataSet.tbsystems.NewRow();
CopyEDSystemToDataRow(importSystem, (DataRow)newRow, false, null, true);
localDataSet.tbsystems.Rows.Add(newRow);
dataChanged = true;
}
added += 1;
ImportCounter += 1;
}
if(dataChanged)
{
if(localDataSet.tbsystems.Rows.Count > 0)
lDBCon.TableUpdate(localDataSet.tbsystems, dataAdapter_sys);
if(localDataSet.tbsystems_org.Rows.Count > 0)
lDBCon.TableUpdate(localDataSet.tbsystems_org, dataAdapter_sysorg);
dataChanged = false;
}
counter++;
if(sendProgressEvent(new ProgressEventArgs() { Info = String.Format("import systems : analysed={0}, updated={1}, added={2}", counter, ImportCounter-added, added), CurrentValue=counter, TotalValue=systemsTotal}))
break;
}
}
// reset freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
lDBCon.Dispose();
}
catch (Exception ex)
{
if(lDBCon != null)
{
if (lDBCon.TransActive())
lDBCon.TransRollback();
try
{
// reset freaky performance
lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
lDBCon.Dispose();
}
catch (Exception) { }
}
throw new Exception("Error while importing system data", ex);
}
}