-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSyncLog.cs
More file actions
59 lines (53 loc) · 2.27 KB
/
SyncLog.cs
File metadata and controls
59 lines (53 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace NETCoreSync
{
public class SyncLog
{
public List<SyncLogData> SentChanges { get; } = new List<SyncLogData>();
public AppliedInfo AppliedChanges { get; } = new AppliedInfo();
public class AppliedInfo
{
public List<SyncLogData> Inserts { get; } = new List<SyncLogData>();
public List<SyncLogData> Updates { get; } = new List<SyncLogData>();
public List<SyncLogData> Deletes { get; } = new List<SyncLogData>();
public List<SyncLogConflict> Conflicts { get; } = new List<SyncLogConflict>();
}
public class SyncLogData
{
public string TypeName { get; set; }
public string Id { get; set; }
public long LastUpdated { get; set; }
public long? Deleted { get; set; }
public string JsonData { get; set; }
public string FriendlyId { get; set; }
internal static SyncLogData FromJObject(JObject jObject, Type syncType, SyncConfiguration.SchemaInfo schemaInfo)
{
SyncLogData syncLogData = new SyncLogData();
syncLogData.TypeName = syncType.Name;
syncLogData.Id = Convert.ToString(jObject[schemaInfo.PropertyInfoId.Name].Value<object>());
syncLogData.LastUpdated = jObject[schemaInfo.PropertyInfoLastUpdated.Name].Value<long>();
syncLogData.Deleted = jObject[schemaInfo.PropertyInfoDeleted.Name].Value<long?>();
syncLogData.JsonData = jObject.ToString();
if (schemaInfo.PropertyInfoFriendlyId != null)
{
syncLogData.FriendlyId = jObject[schemaInfo.PropertyInfoFriendlyId.Name].Value<string>();
}
return syncLogData;
}
}
public class SyncLogConflict
{
public SyncEngine.ConflictType ConflictType { get; set; }
public SyncLogData Data { get; set; }
public SyncLogConflict(SyncEngine.ConflictType conflictType, SyncLogData data)
{
ConflictType = conflictType;
Data = data;
}
}
}
}