public void ReportCounts(ISaveDataProgress progress) { progress.IncrementCount(SaveProgressMeasure.UpdatedRows, Updates.Count); foreach (var upd in Updates) { progress.IncrementCount(SaveProgressMeasure.UpdatedFields, upd.Values.Length); } }
public void SaveChanges(BedTable table, ISaveDataProgress progress) { try { m_adapterByTable[table].SaveChanges(table, progress); } catch (Exception err) { throw new DataError("DAE-00360", err); } }
public void SaveChanges(BedTable table, ISaveDataProgress progress) { using (DbTransaction tran = m_conn.SystemConnection.BeginTransaction()) { try { m_conn.RunScript(dmp => SaveChanges(table, dmp, progress), tran, null); tran.Commit(); } catch { tran.Rollback(); throw; } } }
public void SaveChanges(BedTable table, ISqlDumper dmp, ISaveDataProgress progress) { if (IsReadOnly) { throw new InternalError("DAE-00020 BedAdapter is read only, can not save changes"); } DataScript script = table.GetBaseModifyScript(); MultiTableUpdateScript lscript = table.GetLinkedDataScript(m_structure.FullName); if (progress != null) { script.ReportCounts(progress); lscript.ReportCounts(progress); } dmp.UpdateData(m_structure, script, progress); dmp.UpdateData(lscript, progress); }
public void UpdateData(MultiTableUpdateScript script, ISaveDataProgress progress) { if (script == null) { return; } int updrows = 0, updflds = 0; if (progress != null) { updrows = progress.GetCurrent(SaveProgressMeasure.UpdatedRows); updflds = progress.GetCurrent(SaveProgressMeasure.UpdatedFields); } foreach (var upd in script.Updates) { Put("^update %f ^set ", upd.Table); for (int i = 0; i < upd.Columns.Length; i++) { if (i > 0) { Put(", "); } Put("%i=%v", upd.Columns[i], upd.Values[i]); } Where(upd.Table, upd.CondCols, upd.CondValues); EndCommand(); updrows++; updflds += upd.Values.Length; if (progress != null) { progress.SetCurrent(SaveProgressMeasure.UpdatedRows, updrows); progress.SetCurrent(SaveProgressMeasure.UpdatedFields, updflds); } if (progress != null && progress.IsCanceled) { throw new OperationCanceledError(); } } }
public void SaveChanges(BedTable table, ISaveDataProgress progress) { throw new NotImplementedError("DAE-00273"); }
public void UpdateData(ITableStructure table, DataScript script, ISaveDataProgress progress) { if (script == null) { return; } int delcnt = 0, inscnt = 0, updrows = 0, updflds = 0; if (progress != null) { updrows = progress.GetCurrent(SaveProgressMeasure.UpdatedRows); updflds = progress.GetCurrent(SaveProgressMeasure.UpdatedFields); } foreach (var del in script.Deletes) { Put("^delete ^from %f", table.FullName); Where(table.FullName, del.CondCols, del.CondValues); EndCommand(); delcnt++; if (progress != null) { progress.SetCurrent(SaveProgressMeasure.DeletedRows, delcnt); } if (progress != null && progress.IsCanceled) { throw new OperationCanceledError(); } } foreach (var upd in script.Updates) { Put("^update %f ^set ", table.FullName); for (int i = 0; i < upd.Columns.Length; i++) { if (i > 0) { Put(", "); } Put("%i=%v", upd.Columns[i], new ValueTypeHolder(upd.Values[i], table.Columns[upd.Columns[i]].DataType)); } Where(table.FullName, upd.CondCols, upd.CondValues); EndCommand(); updrows++; updflds += upd.Values.Length; if (progress != null) { progress.SetCurrent(SaveProgressMeasure.UpdatedRows, updrows); progress.SetCurrent(SaveProgressMeasure.UpdatedFields, updflds); } if (progress != null && progress.IsCanceled) { throw new OperationCanceledError(); } } IColumnStructure autoinc = table.FindAutoIncrementColumn(); bool isIdentityInsert = false; foreach (var ins in script.Inserts) { if (autoinc != null) { if (ins.Columns.Contains(autoinc.ColumnName)) { if (!isIdentityInsert) { AllowIdentityInsert(table.FullName, true); } isIdentityInsert = true; } else { if (isIdentityInsert) { AllowIdentityInsert(table.FullName, false); } isIdentityInsert = false; } } var vals = new ValueTypeHolder[ins.Columns.Length]; for (int i = 0; i < ins.Columns.Length; i++) { vals[i] = new ValueTypeHolder(ins.Values[i], table.Columns[ins.Columns[i]].DataType); } PutCmd("^insert ^into %f (%,i) ^values (%,v)", table.FullName, ins.Columns, vals); inscnt++; if (progress != null) { progress.SetCurrent(SaveProgressMeasure.InsertedRows, inscnt); } if (progress != null && progress.IsCanceled) { throw new OperationCanceledError(); } } if (isIdentityInsert) { AllowIdentityInsert(table.FullName, false); } }
public void SaveChanges(BedTable table, ISaveDataProgress progress) { m_table.SaveFixedData(table.ToInMemoryTable()); }
public void UpdateData(MultiTableUpdateScript script, ISaveDataProgress progress) { throw new NotImplementedError("DAE-00104"); }
public void UpdateData(ITableStructure table, DataScript script, ISaveDataProgress progress) { var tbl = Tables[table.FullName] as TableStructure; tbl.UpdateData(script); }