/// <summary> /// Synchronizes the with data dictionary. /// </summary> /// <param name="dataDict"> /// The data dictionary. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public int SyncWithDataObject(DataModelSyncDeserializer dataDict) { bool isEnterprise = false; var licenseDef = dataDict.licenseInfo; if (licenseDef != null) { // DDLogCRequest("Import LICENSEINFO"); this.Logger.LogDebug("Import LICENSEINFO", LogFlag.LogRequests); Dictionary <string, object> licenseDefDictionary = licenseDef.ToDictionary(); isEnterprise = bool.Parse(licenseDefDictionary.ValueOrDefault("IsEnterpriseVersion").ToString()); #if PORTING NSUserDefaults.StandardUserDefaults().SetBoolForKey(isEnterprise.BoolValue, "System.isEnterprise"); NSUserDefaults.StandardUserDefaults().Synchronize(); #endif } var recordDef = dataDict.records; if (recordDef != null) { // DDLogCRequest("Import RECORDS"); this.Logger.LogDebug("Import RECORDS", LogFlag.LogRequests); var recordSyncResult = UPCRMRecordSync.SyncRecordSetDefinitionsCrmDataStore(recordDef, this.DataStore, isEnterprise); if (recordSyncResult.Successful) { this.RecordCount += recordSyncResult.RecordCount; } else { return(recordSyncResult.ReturnCode); } } return(0); }
/// <summary> /// Synchronizes the with data dictionary. /// </summary> /// <param name="dataDict"> /// The data dictionary. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public int SyncWithDataDictionary(Dictionary <string, object> dataDict) { var fullSync = false; var dataModelDef = dataDict.ValueOrDefault("dataModel") as JObject; if (dataModelDef != null) { // DDLogCRequest("Import DATAMODEL"); this.Logger.LogDebug("Import DATAMODEL", LogFlag.LogRequests); var dataModelSync = new UPSyncDataModel(this.DataStore); dataModelSync.SyncWithDataModelDefinition(dataModelDef.ToObject <Dictionary <string, object> >()); fullSync = true; } var catalogDef = dataDict.ValueOrDefault("fixedCatalogs") as JArray; UPSyncCatalogs catalogSync = null; if (catalogDef != null) { // DDLogCRequest("Import FIXED CATALOGS"); this.Logger.LogDebug("Import FIXED CATALOGS", LogFlag.LogRequests); catalogSync = new UPSyncCatalogs(this.DataStore); catalogSync.SyncFixedCatalogs(catalogDef.ToObject <List <object> >()); } catalogDef = dataDict.ValueOrDefault("variableCatalogs") as JArray; if (catalogDef != null) { // DDLogCRequest("Import VARIABLE CATALOGS"); this.Logger.LogDebug("Import VARIABLE CATALOGS", LogFlag.LogRequests); if (catalogSync == null) { catalogSync = new UPSyncCatalogs(this.DataStore); } catalogSync.SyncVariableCatalogs(catalogDef.ToObject <List <object> >()); } var configurationDef = dataDict.ValueOrDefault("configuration") as JObject; if (configurationDef != null) { // DDLogCRequest("Import CONFIGURATION"); this.Logger.LogDebug("Import CONFIGURATION", LogFlag.LogRequests); var configurationSync = new UPSyncConfiguration(this.ConfigStore); configurationSync.SyncWithConfigurationDefinition(configurationDef.ToObject <Dictionary <string, object> >()); if (fullSync) { var v = this.ConfigStore.ConfigValue("System.iOSServerTimeZone"); if (!string.IsNullOrEmpty(v)) { this.DataStore.SetTimeZoneUtcDifference(v, 0); } } } bool isEnterprise = false; var licenseDef = dataDict.ValueOrDefault("licenseInfo") as JObject; if (licenseDef != null) { // DDLogCRequest("Import LICENSEINFO"); this.Logger.LogDebug("Import LICENSEINFO", LogFlag.LogRequests); Dictionary <string, object> licenseDefDictionary = licenseDef.ToObject <Dictionary <string, object> >(); isEnterprise = bool.Parse(licenseDefDictionary.ValueOrDefault("IsEnterpriseVersion").ToString()); #if PORTING NSUserDefaults.StandardUserDefaults().SetBoolForKey(isEnterprise.BoolValue, "System.isEnterprise"); NSUserDefaults.StandardUserDefaults().Synchronize(); #endif } var recordDef = dataDict.ValueOrDefault("records") as JArray; if (recordDef != null) { // DDLogCRequest("Import RECORDS"); this.Logger.LogDebug("Import RECORDS", LogFlag.LogRequests); var recordSyncResult = UPCRMRecordSync.SyncRecordSetDefinitionsCrmDataStore(recordDef.ToObject <List <object> >(), this.DataStore, isEnterprise); if (recordSyncResult.Successful) { this.RecordCount += recordSyncResult.RecordCount; } else { return(recordSyncResult.ReturnCode); } } var queryDef = dataDict.ValueOrDefault("queries"); if (queryDef != null) { var querySync = new UPSyncQuery(this.DataStore); querySync.SyncWithQueryDefinition((List <object>)queryDef); } return(0); }