writeInsert method
Implementation
Future<RemoteDto> writeInsert() async {
if (!initialized) throw ArgumentError(AbstractDao.C_MUST_INIT);
bool success = false;
try {
await tableTransactions.insert();
tableTransactions.setCrc(null);
success = true;
} on SqlException catch (e) {
if (e.sqlExceptionEnum == SqlExceptionEnum.DUPLICATE_ENTRY) {
waterLine.setWaterError(WaterError.DUPLICATE_ENTRY);
print("$C_CLASSNAME:writeInsert(DUPLICATE_ENTRY):$e");
} else if (e.sqlExceptionEnum == SqlExceptionEnum.FAILED_SELECT) {
waterLine.setWaterError(WaterError.INVALID_ENTRY);
print("$C_CLASSNAME:writeInsert(INVALID_ENTRY):$e");
} else if (e.sqlExceptionEnum == SqlExceptionEnum.PARTITION_NOT_FOUND) {
waterLine.setWaterError(WaterError.PARTITION_NOT_FOUND);
print("$C_CLASSNAME:writeInsert(PARTITION_NOT_FOUND):$e");
} else {
waterLine.setWaterError(WaterError.FAILED_UPDATE);
print("$C_CLASSNAME:writeInsert(FAILED_UPDATE):$e");
}
}
if (success) {
setStates();
wroteDto = true;
}
RemoteDto remoteDto = await commitChanges(null);
return remoteDto;
}