runSyncService method

dynamic runSyncService({
  1. Function? reflectionAgent,
  2. IConfigRF? config,
  3. Map<String, dynamic>? inputData,
})

Implementation

runSyncService({
  Function? reflectionAgent,
  IConfigRF? config,
  Map<String, dynamic>? inputData,
}) async {
  reflectionAgent!.call();
  Configuration _configuration = new Configuration();
  config!.configure(_configuration);
  Libs.config = _configuration;
  Models modelList = new Models();
  _configuration.model.appModels!.register(modelList);

  if (inputData != null) {
    for (var model in inputData.entries) {
      var modelRF = Models.models[model.key];
      var jsonData =
          await Dynamic(modelRF!.model).syncableDataJsonMap(_configuration);
      for (var jsonRow in jsonData) {
        await _sync(null, modelRF.model!, jsonRow,
            showLoader: false, config: _configuration);
      }
    }
  } else {
    /// Sync ALL Data here
    for (var entry in modelList.get().entries) {
      var modelRF = entry.value as ModelRF;
      if (modelRF.syncable) {
        var jsonData =
            await Dynamic(modelRF.model).syncableDataJsonMap(_configuration);
        for (var jsonRow in jsonData) {
          await _sync(null, modelRF.model!, jsonRow,
              showLoader: false, config: _configuration);
        }
      }
    }
  }
}