私は開発しているionic3アプリケーションに問題があります。 私のアプリでJSONサーバーに接続し、たくさんの行をダウンロードします。forを使用してすべての行を取得すると、各行で関数を呼び出してデータを挿入します。 しかし、私の考えは、挿入機能よりも速く、終了前にファイナルアラートを表示することだと思います。これは私のコードです:これはイオン3多くのデータを挿入
public insertRow(indice: any, row1: any, row2: any, row3: any, row4: any,
row5: any, row6: any, row7: any, row8: any, row9: any, row10: any,
row30: any)
{
let sql = "INSERT INTO TableRows (id,Nombre,Rio,Pais,Comunidad,
Zona,Localidad,Interes,Caracter,Cascada_max,Cuerda_max,Desnivel,
Longitud, Tiempo_aprox,Tiempo_descenso,Tiempo_retorno,Observaciones,
Descripcion_barranco,Periodo_optimo,Caudal,Caudal_filtro,Aproximacion,
Retorno,Loc_entrada_barranco,Loc_salida_barranco,Loc_entrada_parking,
Loc_salida_parking,Autor,Actualizacion,Idioma,Visible)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
console.log(sql);
return this.isReady()
.then(()=>{
return this.database.executeSql(sql,
[indice,BARRANCO, RIO, PAIS,COMUNIDAD,
ZONA,LOCALIDAD,INTERES,CARACTER, CASCADA_MAX,
CUERDA_MAX,DESNIVEL,LONGITUD,TIEMPO_APROX,
TIEMPO_DESCENSO,TIEMPO_RETORNO, OBSERVACIONES,
DESCRIPCION_BARRANCO,PERIODO_OPTIMO,CAUDAL,
CAUDAL_FILTRO,APROXIMACION, RETORNO,
LOC_ENTRADA_BARRANCO,LOC_SALIDA_BARRANCO,
LOC_ENTRADA_PARKING, LOC_SALIDA_PARKING,
AUTOR,actualización,idioma, visible]);
}).then((data)=>{
console.log("El insert devuelve esto " + JSON.stringify(data));
})
}
誰かが私が時間通りに行うことができます方法を知っているのインサートのサービスです
private downloadRows()
{
this.platform.ready().then(()=>{
this.translateService.get('ACTUALIZANDOBARRANCOS').subscribe(
value => {
let loadingContent = value;
let loader = this.loadingController.create({
content: loadingContent,
spinner: "bubbles"
});
this.servicioDownloads.downloadAllRows().then(rows=> {
this.datosrows= rows;
loader.present();
for (var i = 0; i < this.datosrows.length; i++)
{
var datos = this.datosrows[i];
// we are going to insert rows
this.servicioDataBase.insertRow
(datos.indice,
datos.row1,
datos.row2,
datos.row3,
datos.row4,
datos.row5,
datos.row6,
datos.row7,
datos.row8,
datos.row9,
datos.row10,
//...
datos.row30
).catch(()=>{
console.log("da error");
});
}
loader.dismiss();
this.translateService.get('FINALIZADO').subscribe(
Titulo =>{
let titulo = Titulo;
this.translateService.get('BARRANCOSACTUALIZADOS').subscribe(
Descripcion =>{
let descripcion = Descripcion;
let alerta = this.alertCtrl.create({
title: titulo,
subTitle: descripcion,
buttons: ['OK']
})
alerta.present();
}
);
}
);
}).catch(error=>{
loader.dismiss();
this.translateService.get('ERROR').subscribe(
Titulo =>{
let titulo = Titulo;
this.translateService.get('ERRORDESCARGABARRANCOS').subscribe(
Descripcion =>{
let descripcion = Descripcion;
let alerta = this.alertCtrl.create({
title: titulo,
subTitle: descripcion,
buttons: ['OK']
})
alerta.present();
}
);
}
);
})
});
})
}
//、私は終了のためのときに挿入意味ですか?
ありがとう!
cordova-sqlite-porterを試すことができます。 https://stackoverflow.com/a/35385963/5059916 –
ありがとう@TomislavStankovic、私はそれを見に行くと私はあなたに教えてくれる –
@TomislavStankovicそれは完璧に動作します、ありがとう、私はsqliteポーターを使用し、正常に動作します! 1つだけがもっと考えると思う。すべてのデータをインポートしたときに、すべての行を表示すると画面に出ましたが、近いアプリケーションの後にこの行が表示されなくなり、再び開いてしまいました。私はvirtualscrollを使用します。 –