Skip to content

Commit

Permalink
check items
Browse files Browse the repository at this point in the history
  • Loading branch information
ghsales committed Sep 28, 2024
1 parent 6913cec commit c6acbcb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
9 changes: 9 additions & 0 deletions src/SSync.Server.LitebDB/Abstractions/ISSyncEntityRoot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SSync.Server.LitebDB.Abstractions
{
public interface ISSyncEntityRoot
{
public Guid Id { get; set; }
public DateTime UpdatedAt { get; set; }
public DateTime? DeletedAt { get; set; }
}
}
34 changes: 18 additions & 16 deletions src/SSync.Server.LitebDB/Sync/SchemaCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using SSync.Shared.ClientServer.LitebDB.Extensions;
using System.Data;
using System.Reflection;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
Expand Down Expand Up @@ -63,29 +62,32 @@ public async Task<List<object>> PullChangesAsync(SSyncParameter parameter, SSync
Log($"Start pull changes");
var steps = _builder.GetSteps();

foreach (var (SyncType, Parameter) in steps.Where(s => parameter.Colletions.Contains(s.Parameter)))
if (steps is not null)
{
parameter.CurrentColletion = Parameter;
foreach (var (SyncType, Parameter) in steps.Where(s => parameter.Colletions.Contains(s.Parameter)))
{
parameter.CurrentColletion = Parameter;

Log($"Start pull changes of collection {Parameter}");
Log($"Start pull changes of collection {Parameter}");

MethodInfo? method = typeof(SchemaCollection)!
.GetMethod(nameof(CheckChanges), BindingFlags.Instance | BindingFlags.NonPublic)!
.MakeGenericMethod(SyncType, parameter.GetType()) ?? throw new PullChangesException("Not found pull request handler");
MethodInfo? method = typeof(SchemaCollection)!
.GetMethod(nameof(CheckChanges), BindingFlags.Instance | BindingFlags.NonPublic)!
.MakeGenericMethod(SyncType, parameter.GetType()) ?? throw new PullChangesException("Not found pull request handler");

var task = (Task)method.Invoke(this, [parameter])!;
var task = (Task)method.Invoke(this, [parameter])!;

if (task is not null)
{
await task.ConfigureAwait(false);
if (task is not null)
{
await task.ConfigureAwait(false);

var resultProperty = task.GetType().GetProperty("Result");
var resultProperty = task.GetType().GetProperty("Result");

var collectionResult = resultProperty?.GetValue(task);
var collectionResult = resultProperty?.GetValue(task);

if (collectionResult is not null)
{
result.Add(collectionResult);
if (collectionResult is not null)
{
result.Add(collectionResult);
}
}
}
}
Expand Down

0 comments on commit c6acbcb

Please sign in to comment.