|
4 | 4 | using FwDataMiniLcmBridge; |
5 | 5 | using FwLiteProjectSync; |
6 | 6 | using LcmCrdt; |
7 | | -using LexCore.Exceptions; |
| 7 | +using LcmDebugger; |
8 | 8 | using Microsoft.Extensions.DependencyInjection; |
9 | 9 | using Microsoft.Extensions.Hosting; |
| 10 | +using Microsoft.Extensions.Logging; |
10 | 11 | using Microsoft.Extensions.Options; |
| 12 | +using MiniLcm.Exceptions; |
11 | 13 | using Refit; |
12 | 14 | using SIL.Harmony; |
13 | 15 | using SIL.Harmony.Core; |
14 | | -using Microsoft.Extensions.Logging; |
15 | 16 |
|
16 | 17 | var builder = Host.CreateApplicationBuilder(); |
17 | 18 | //slows down import to log all sql. |
|
22 | 23 |
|
23 | 24 | using var app = builder.Build(); |
24 | 25 |
|
25 | | -var fieldWorksProjectList = app.Services.GetRequiredService<FieldWorksProjectList>(); |
26 | | -var fwDataProject = fieldWorksProjectList.GetProject("petit-test-train-flex") ?? throw new InvalidOperationException("Could not find project"); |
27 | | - |
28 | | -var importService = app.Services.GetRequiredService<MiniLcmImport>(); |
29 | | -await importService.Import(fwDataProject); |
30 | 26 | await using var scope = app.Services.CreateAsyncScope(); |
31 | 27 |
|
32 | 28 | var crdtProjectsService = app.Services.GetRequiredService<CrdtProjectsService>(); |
33 | | -var crdtProject = crdtProjectsService.GetProject(fwDataProject.Name); |
34 | | -if (crdtProject is null) throw new NotFoundException("project", "crdt"); |
35 | | -var crdtApi = await crdtProjectsService.OpenProject(crdtProject, scope.ServiceProvider); |
36 | | -var dataModel = scope.ServiceProvider.GetRequiredService<DataModel>(); |
37 | | -JsonSerializerOptions options = new(JsonSerializerDefaults.Web) |
| 29 | +var crdtApi = await crdtProjectsService.OpenProject( |
| 30 | + new CrdtProject("test", "sbe-flex - Copy.sqlite"), |
| 31 | + scope.ServiceProvider); |
| 32 | +var dbContext = scope.ServiceProvider.GetRequiredService<LcmCrdtDbContext>(); |
| 33 | +var jsonOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web) |
38 | 34 | { |
39 | 35 | TypeInfoResolver = scope.ServiceProvider.GetRequiredService<IOptions<CrdtConfig>>().Value |
40 | 36 | .MakeLcmCrdtExternalJsonTypeResolver() |
41 | 37 | }; |
42 | | -var (commits, _) = await dataModel.GetChanges(new SyncState([])); |
43 | | -await using var f = File.Create("commits.json"); |
44 | | -await JsonSerializer.SerializeAsync(f, commits, options); |
45 | | - |
46 | | -var fwDataFactory = app.Services.GetRequiredService<FwDataFactory>(); |
47 | | -// var miniLcmApi = fwDataFactory.GetFwDataMiniLcmApi(fwDataProject, false); |
48 | | -// var entries = await miniLcmApi.GetEntries().ToArrayAsync(); |
49 | | -// var entries = miniLcmApi.GetEntries(new(Filter: new() { GridifyFilter = "LexemeForm[sbe]=ta" })).ToArrayAsync(); |
50 | | -// var entry = Utils.GetLexEntry(app.Services, fwDataProject, new Guid("{018d71a9-12c2-4129-be8a-35fe246afda2}")); |
51 | | - |
52 | | -fwDataFactory.Dispose(); |
| 38 | +await using var transaction = await dbContext.Database.BeginTransactionAsync(); |
| 39 | +var dataModel = scope.ServiceProvider.GetRequiredService<DataModel>(); |
| 40 | +await dataModel.SyncWith(FakeSyncSource.FromJsonFile("changes.json", jsonOptions)); |
| 41 | +await transaction.RollbackAsync(); |
0 commit comments