예제 #1
0
        internal SyncStatusDbContext CreateSyncStatusContext()
        {
            // var connectionString = Database.Connection.ConnectionString;
            var syncStatusContext = new SyncStatusDbContext(_nameOrConnectionString);

            return(syncStatusContext);
        }
예제 #2
0
        private SyncStatusServerObject AddOrCreateNewSyncObject(SyncStatusDbContext syncStatusContext, string type, string mobilePrimaryKey)
        {
            var syncObj = syncStatusContext.SyncStatusServerObjects.Find(type, mobilePrimaryKey);

            if (syncObj == null)
            {
                syncObj = new SyncStatusServerObject(type, mobilePrimaryKey);
                syncStatusContext.SyncStatusServerObjects.Add(syncObj);
            }
            return(syncObj);
        }
예제 #3
0
        private void AttachObject(IRealmiusObjectServer obj, SyncStatusDbContext syncStatusContext, UpdatedDataBatch updatedResult)
        {
            var typeName = GetEfTypeName(obj);
            var syncObj  = AddOrCreateNewSyncObject(syncStatusContext, typeName, obj.MobilePrimaryKey);

            var current = JObject.FromObject(obj);
            var diff    = JsonHelper.GetJsonDiff(JObject.Parse(syncObj.FullObjectAsJson ?? "{}"), current);

            var dateTimeNow = GetDate();

            foreach (JProperty jProperty in diff.Properties())
            {
                syncObj.ColumnChangeDates[jProperty.Name] = dateTimeNow;
            }

            ProcessAndAddChanges(syncObj, obj, updatedResult, diff.ToString());
        }