fix: synchronize log
parent
54039b30b9
commit
fbddac5c9c
|
|
@ -21,5 +21,6 @@ class Log {
|
|||
{this.id = 0, DateTime? date, this.uploaded = 0})
|
||||
: date = date ?? DateTime.now();
|
||||
|
||||
String get dateFormat => DateFormat('dd.MM.yyyy hh:mm:ss').format(date);
|
||||
String get dateFormat => DateFormat('dd/MM/yyyy hh:mm:ss').format(date);
|
||||
String get dateEnFormat => DateFormat('yyyyMMdd hh:mm:ss').format(date);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import 'package:intl/intl.dart';
|
|||
import 'package:mobdr/config/constant.dart';
|
||||
import 'package:mobdr/main.dart';
|
||||
import 'package:mobdr/service/shared_prefs.dart';
|
||||
import 'package:mobdr/service/logger_util.dart';
|
||||
|
||||
class ApiProvider {
|
||||
Dio dio = Dio();
|
||||
|
|
@ -452,13 +451,36 @@ class ApiProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/// Synchronize all informations about store, competitor, calendar
|
||||
/// Synchronize log
|
||||
Future<String> SyncLog() async {
|
||||
try {
|
||||
LoggerUtil.logNStacktackDebug("Synchronisation LOG à implementer !!");
|
||||
return 'OK';
|
||||
} catch (ex) {
|
||||
return ex.toString();
|
||||
final url =
|
||||
'${ApiConstants.baseUrl}${ApiConstants.externalEndpoint}${ApiConstants.restEndpoint}/mobDR/log';
|
||||
|
||||
final headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Accept': 'application/json',
|
||||
'Cookie': 'pguid=${SharedPrefs().guid};',
|
||||
};
|
||||
|
||||
final logs = await objectbox.getLogs().first;
|
||||
|
||||
for (final log in logs) {
|
||||
final params = {
|
||||
'date': log.dateEnFormat,
|
||||
'libelle': '${log.module}.${log.libelle}',
|
||||
'type': log.type,
|
||||
'duree_ms': log.duree.toString(),
|
||||
};
|
||||
|
||||
final response =
|
||||
await http.post(Uri.parse(url), headers: headers, body: params);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// delete log
|
||||
objectbox.delLogById(log.id);
|
||||
}
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -724,6 +724,19 @@ class ObjectBox {
|
|||
.map((query) => query.find());
|
||||
}
|
||||
|
||||
/// Removes a Log object from the ObjectBox database with the specified ID.
|
||||
///
|
||||
/// Parameters:
|
||||
/// id: The ID of the Log object to remove.
|
||||
///
|
||||
/// Returns:
|
||||
/// None.
|
||||
void delLogById(int id) {
|
||||
if (!logBox.remove(id)) {
|
||||
LoggerUtil.logNStackError("delete log:${id} KO");
|
||||
}
|
||||
}
|
||||
|
||||
int getLogCount() {
|
||||
return logBox.count();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
PODS:
|
||||
- connectivity_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- ReachabilitySwift
|
||||
- device_info_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- FlutterMacOS (1.0.0)
|
||||
- FMDB (2.7.5):
|
||||
- FMDB/standard (= 2.7.5)
|
||||
|
|
@ -12,6 +17,7 @@ PODS:
|
|||
- path_provider_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- ReachabilitySwift (5.0.0)
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
|
|
@ -22,6 +28,8 @@ PODS:
|
|||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`)
|
||||
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
|
||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||
- objectbox_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/objectbox_flutter_libs/macos`)
|
||||
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
|
||||
|
|
@ -34,8 +42,13 @@ SPEC REPOS:
|
|||
trunk:
|
||||
- FMDB
|
||||
- ObjectBox
|
||||
- ReachabilitySwift
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
connectivity_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos
|
||||
device_info_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos
|
||||
FlutterMacOS:
|
||||
:path: Flutter/ephemeral
|
||||
objectbox_flutter_libs:
|
||||
|
|
@ -52,12 +65,15 @@ EXTERNAL SOURCES:
|
|||
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macos
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747
|
||||
device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f
|
||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||
ObjectBox: a7900d5335218cd437cbc080b7ccc38a5211f7b4
|
||||
objectbox_flutter_libs: f89ab4878f0f764a49077cfaa59030be69ae1d7e
|
||||
package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce
|
||||
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
|
||||
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
|
||||
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
|
||||
sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea
|
||||
wakelock_macos: bc3f2a9bd8d2e6c89fee1e1822e7ddac3bd004a9
|
||||
|
|
|
|||
Loading…
Reference in New Issue