Exemplo n.º 1
0
            public static GetChangesResult FromPayload(JObject payload)
            {
                string synchronizationId = payload[nameof(SynchronizationId)].Value <string>();
                Dictionary <string, object> customInfo = payload[nameof(CustomInfo)].ToObject <Dictionary <string, object> >();
                PayloadAction    payloadAction         = (PayloadAction)Enum.Parse(typeof(PayloadAction), payload[nameof(PayloadAction)].Value <string>());
                GetChangesResult result = new GetChangesResult(payloadAction, synchronizationId, customInfo);

                result.Changes      = payload[nameof(Changes)].ToObject <JArray>();
                result.MaxTimeStamp = payload[nameof(MaxTimeStamp)].Value <long>();
                result.LogChanges   = payload[nameof(LogChanges)].ToObject <List <SyncLog.SyncLogData> >();
                return(result);
            }
Exemplo n.º 2
0
        internal void GetChanges(GetChangesParameter parameter, ref GetChangesResult result)
        {
            if (parameter == null)
            {
                throw new NullReferenceException(nameof(parameter));
            }
            result = new GetChangesResult(parameter.PayloadAction, parameter.SynchronizationId, parameter.CustomInfo);
            result.MaxTimeStamp = GetMinValueTicks();
            if (parameter.LastSync == 0)
            {
                parameter.LastSync = GetMinValueTicks();
            }

            parameter.Log.Add($"Preparing Data Since LastSync: {parameter.LastSync}");
            parameter.Log.Add($"SyncTypes Count: {SyncConfiguration.SyncTypes.Count}");
            for (int i = 0; i < SyncConfiguration.SyncTypes.Count; i++)
            {
                Type syncType = SyncConfiguration.SyncTypes[i];
                parameter.Log.Add($"Processing Type: {syncType.Name} ({i + 1} of {SyncConfiguration.SyncTypes.Count})");
                parameter.Log.Add($"Getting Type Changes...");
                List <object> appliedIds = null;
                if (parameter.AppliedIds != null && parameter.AppliedIds.ContainsKey(syncType))
                {
                    appliedIds = parameter.AppliedIds[syncType];
                }
                (JObject typeChanges, int typeChangesCount, long typeMaxTimeStamp, List <SyncLog.SyncLogData> typeLogChanges) = GetTypeChanges(parameter.LastSync, syncType, parameter.SynchronizationId, parameter.CustomInfo, appliedIds);
                parameter.Log.Add($"Type Changes Count: {typeChangesCount}");
                if (typeChangesCount != 0 && typeChanges != null)
                {
                    result.Changes.Add(typeChanges);
                }
                if (typeMaxTimeStamp > result.MaxTimeStamp)
                {
                    result.MaxTimeStamp = typeMaxTimeStamp;
                }
                result.LogChanges.AddRange(typeLogChanges);
                parameter.Log.Add($"Type: {syncType.Name} Processed");
            }
        }