[Bindable(event="message")]
private function dbSyncData():void
{
stmt.addEventListener(SQLEvent.RESULT, dbExecuteBatchSQL);
var dataArray:Array = this.params.SyncDataArray as Array;
if(dataArray == null){
dispatchEvent(new MessagesEvent("同步到 SQLite","失败:数据源记录集是空的。"));
return;
}
var dataTable:String = this.params.SyncDataTable as String;
if(dataTable == null){
dispatchEvent(new MessagesEvent("同步到 SQLite","失败:数据表名称未定义。"));
return;
}
dispatchEvent(new MessagesEvent("同步到 SQLite","准备将 "+ dataArray.length +" 条记录同步到 "+ dataTable +" 数据表"));
this._execSQLBatch = new Array();
if(dataTable == "stockdaily"){
for(var i:int=0;i<dataArray.length;i++){
var o:Object = dataArray[i];
var sql:String = "INSERT INTO stockdaily (StatDate,Symbol,FinalPrice,HighPrice,LowPrice,DealVolume,DealMoney,RunDate) "+
" VALUES ('@StatDate','@Symbol',@FinalPrice,@HighPrice,@LowPrice,@DealVolume,@DealMoney,'@RunDate')"
.replace("@StatDate", o["StatDate"])
.replace("@Symbol", o["Symbol"])
.replace("@FinalPrice", o["FinalPrice"])
.replace("@HighPrice", o["HighPrice"])
.replace("@LowPrice", o["LowPrice"])
.replace("@DealVolume", o["DealVolume"])
.replace("@DealMoney", o["DealMoney"])
.replace("@RunDate", o["RunDate"])
;
this._execSQLBatch.push(sql);
}
}else if(dataTable == "stockdailywatch"){
for(var i:int=0;i<dataArray.length;i++){
var o:Object = dataArray[i];
var sql:String = "INSERT INTO stockdailywatch (Symbol,Name) VALUES ('@Symbol','@Name')"
.replace("@StatDate", o["StatDate"])
.replace("@Name", o["Name"])
;
this._execSQLBatch.push(sql);
}
}
this._execSQLCallLatency = this.dbSyncDataResult;
this.dbExecuteBatchSQL(null);
}
private function dbSyncData():void
{
dispatchEvent(new MessagesEvent("同步到 SQLite","同步数据完毕。"));
}
private function dbSyncData():void
{
stmt.addEventListener(SQLEvent.RESULT, dbExecuteBatchSQL);
var dataArray:Array = this.params.SyncDataArray as Array;
if(dataArray == null){
dispatchEvent(new MessagesEvent("同步到 SQLite","失败:数据源记录集是空的。"));
return;
}
var dataTable:String = this.params.SyncDataTable as String;
if(dataTable == null){
dispatchEvent(new MessagesEvent("同步到 SQLite","失败:数据表名称未定义。"));
return;
}
dispatchEvent(new MessagesEvent("同步到 SQLite","准备将 "+ dataArray.length +" 条记录同步到 "+ dataTable +" 数据表"));
this._execSQLBatch = new Array();
if(dataTable == "stockdaily"){
for(var i:int=0;i<dataArray.length;i++){
var o:Object = dataArray[i];
var sql:String = "INSERT INTO stockdaily (StatDate,Symbol,FinalPrice,HighPrice,LowPrice,DealVolume,DealMoney,RunDate) "+
" VALUES ('@StatDate','@Symbol',@FinalPrice,@HighPrice,@LowPrice,@DealVolume,@DealMoney,'@RunDate')"
.replace("@StatDate", o["StatDate"])
.replace("@Symbol", o["Symbol"])
.replace("@FinalPrice", o["FinalPrice"])
.replace("@HighPrice", o["HighPrice"])
.replace("@LowPrice", o["LowPrice"])
.replace("@DealVolume", o["DealVolume"])
.replace("@DealMoney", o["DealMoney"])
.replace("@RunDate", o["RunDate"])
;
this._execSQLBatch.push(sql);
}
}else if(dataTable == "stockdailywatch"){
for(var i:int=0;i<dataArray.length;i++){
var o:Object = dataArray[i];
var sql:String = "INSERT INTO stockdailywatch (Symbol,Name) VALUES ('@Symbol','@Name')"
.replace("@StatDate", o["StatDate"])
.replace("@Name", o["Name"])
;
this._execSQLBatch.push(sql);
}
}
this._execSQLCallLatency = this.dbSyncDataResult;
this.dbExecuteBatchSQL(null);
}
private function dbSyncData():void
{
dispatchEvent(new MessagesEvent("同步到 SQLite","同步数据完毕。"));
}