Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
changeContent.instanceChanges = this._iModelDb!.withPreparedStatement("SELECT ECInstanceId FROM ecchange.change.InstanceChange WHERE Summary.Id=? ORDER BY ECInstanceId", (stmt: ECSqlStatement): any[] => {
stmt.bindId(1, changeSummary.id);
const instanceChanges = new Array();
while (stmt.step() === DbResult.BE_SQLITE_ROW) {
const row = stmt.getRow();
const instanceChange: any = ChangeSummaryManager.queryInstanceChange(this._iModelDb!, Id64.fromJSON(row.id));
switch (instanceChange.opCode) {
case ChangeOpCode.Insert: {
// Get the instance after the insert
const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterInsert));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Update: {
// Get the instance before the update
let rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeUpdate));
assert(rows.length === 1);
instanceChange.before = rows[0];
// Get the instance after the update
rows = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterUpdate));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Delete: {
break;
}
case ChangeOpCode.Update: {
// Get the instance before the update
let rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeUpdate));
assert(rows.length === 1);
instanceChange.before = rows[0];
// Get the instance after the update
rows = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterUpdate));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Delete: {
// Get the instance before the delete
const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeDelete));
assert(rows.length === 1);
instanceChange.before = rows[0];
break;
}
default:
throw new Error("Unexpected ChangedOpCode " + instanceChange.opCode);
}
instanceChanges.push(instanceChange);
}
return instanceChanges;
});
const instanceChanges = new Array();
while (stmt.step() === DbResult.BE_SQLITE_ROW) {
const row = stmt.getRow();
const instanceChange: any = ChangeSummaryManager.queryInstanceChange(this._iModelDb!, Id64.fromJSON(row.id));
switch (instanceChange.opCode) {
case ChangeOpCode.Insert: {
// Get the instance after the insert
const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterInsert));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Update: {
// Get the instance before the update
let rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeUpdate));
assert(rows.length === 1);
instanceChange.before = rows[0];
// Get the instance after the update
rows = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterUpdate));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Delete: {
// Get the instance before the delete
const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeDelete));
assert(rows.length === 1);
instanceChange.before = rows[0];
break;
}
default:
const instanceChange: any = ChangeSummaryManager.queryInstanceChange(this._iModelDb!, Id64.fromJSON(row.id));
switch (instanceChange.opCode) {
case ChangeOpCode.Insert: {
// Get the instance after the insert
const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterInsert));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Update: {
// Get the instance before the update
let rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeUpdate));
assert(rows.length === 1);
instanceChange.before = rows[0];
// Get the instance after the update
rows = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterUpdate));
assert(rows.length === 1);
instanceChange.after = rows[0];
break;
}
case ChangeOpCode.Delete: {
// Get the instance before the delete
const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeDelete));
assert(rows.length === 1);
instanceChange.before = rows[0];
break;
}
default:
throw new Error("Unexpected ChangedOpCode " + instanceChange.opCode);
}
instanceChanges.push(instanceChange);
}