public void backgroundExecuteSqlBatch(ExecuteSqlBatchOptions options, ICallback success, ICallback error) { // Currently, all ReactMethods are run on the same ActionQueue. This prevents // queries from being able to run in parallel but it makes the code simpler. // // `executeSqlBatch` takes care of putting the work on the awaiting queue // so we don't have to. executeSqlBatch(options, success, error); }
public void executeSqlBatch(ExecuteSqlBatchOptions options, ICallback success, ICallback error) { QueueWithCancellation(() => { var dbFileName = options.DBArgs.DBName; if (dbFileName == null) { error.Invoke("You must specify database path"); return(Task.CompletedTask); } OpenDB dbInfo; if (!_openDBs.TryGetValue(dbFileName, out dbInfo)) { error.Invoke("No such database, you must open it first"); return(Task.CompletedTask); } var results = new List <Dictionary <string, object> >(); foreach (var query in options.Executes) { try { var rawResult = ExecuteQuery(dbInfo, query); results.Add(new Dictionary <string, object> { { "qid", query.QID }, { "type", "success" }, { "result", rawResult } }); } catch (RNSQLiteException ex) { results.Add(new Dictionary <string, object> { { "qid", query.QID }, { "type", "error" }, { "error", ex.JsonMessage }, { "result", ex.JsonMessage } }); } } success.Invoke(results); return(Task.CompletedTask); }); }