private void DeleteEntryFromKit() { if (IsAttachment) { _Adapter.Execute($"DELETE FROM spellvisualkitmodelattach WHERE ID = { AttachRecord[0] }"); } else { _Adapter.Execute($"UPDATE spellvisualkit SET { EffectName } = 0 WHERE ID = { ParentKitId }"); } }
public void ProcessETLMode(IRecordProcessor rp) { inputDatabase.Connect(); MapFields(rp); rp.setDatasetName(inputDatabase.NormTableName(tableName)); string[] sqls = rp.GetSelectStatements(); if (Progress != null) { Progress.ReportProgress(0); } foreach (string sql in sqls) { try { DbDataReader reader = inputDatabase.Execute(sql); int count = 1; rp.Reset(); //Extract while (reader.Read()) { //Transform rp.ProcessRecord(reader); if (Progress != null) { Progress.ReportProgress(0, "Read records: " + count.ToString()); } count++; } reader.Close(); reader = null; //Load if (outputDatabase.FileName != null) { //if output is file - Write one WriteData(); } } catch (Exception ex) { throw ex; } // Call Close when done reading. } inputDatabase.Close(); }
public Task ImportToSql(IDatabaseAdapter adapter, MainWindow.UpdateProgressFunc UpdateProgress, string IdKey, string bindingName) { return(Task.Run(() => { var binding = BindingManager.GetInstance().FindBinding(bindingName); adapter.Execute(string.Format(adapter.GetTableCreateString(binding), binding.Name)); uint currentRecord = 0; uint count = Header.RecordCount; uint updateRate = count < 100 ? 100 : count / 100; uint index = 0; StringBuilder q = null; foreach (var recordMap in Body.RecordMaps) { // This might be needed? Disabled unless bugs are reported around this //if (r.record.ID == 0) // continue; if (index == 0 || index % 250 == 0) { if (q != null) { q.Remove(q.Length - 2, 2); adapter.Execute(q.ToString()); } q = new StringBuilder(); q.Append(string.Format("INSERT INTO `{0}` VALUES ", bindingName)); } if (++index % updateRate == 0) { // Visual studio says these casts are redundant but it does not work without them double percent = (double)index / (double)count; UpdateProgress(percent); } currentRecord = recordMap.ContainsKey(IdKey) ? (uint)recordMap[IdKey] : 0; q.Append("("); foreach (var field in binding.Fields) { switch (field.Type) { case BindingType.INT: case BindingType.UINT: { q.Append(string.Format("'{0}', ", recordMap[field.Name])); break; } case BindingType.FLOAT: case BindingType.DOUBLE: { q.Append(string.Format("REPLACE('{0}', ',', '.'), ", recordMap[field.Name])); break; } case BindingType.STRING_OFFSET: { var strOffset = (uint)recordMap[field.Name]; var lookupResult = Reader.LookupStringOffset(strOffset); q.Append(string.Format("\'{0}\', ", adapter.EscapeString(lookupResult))); break; } case BindingType.UNKNOWN: break; default: throw new Exception($"ERROR: Record[{currentRecord}] Unhandled type: {field.Type} on field: {field.Name}"); } } q.Remove(q.Length - 2, 2); q.Append("), "); } if (q.Length > 0) { q.Remove(q.Length - 2, 2); adapter.Execute(q.ToString()); } // We have attempted to import the Spell.dbc so clean up unneeded data // This will be recreated if the import process is started again Reader.CleanStringsMap(); })); }
private void DeleteKitFromVisual() { _Adapter.Execute($"UPDATE spellvisual SET { KitName } = 0 WHERE ID = { ParentVisualId }"); }