public SynchronizationResultDto SyncData(SynchronizationRequestDto synchronizationRequest) { //TODO> the method should return only the fields //specified in the metadata, and not all entities //attributes. var user = SecurityFacade.CurrentUser(); if (null == user) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } var syncResult = new SynchronizationResultDto(); foreach (var application in synchronizationRequest.Applications) { var applicationMetadata = MetadataProvider .Application(application.appName) .ApplyPolicies(ApplicationMetadataSchemaKey.GetSyncInstance(), user, ClientPlatform.Mobile); var syncAppData = _dataSetProvider.LookupAsBaseDataSet(application.appName) .Sync(applicationMetadata, application); if (!application.FetchMetadata) { //used to reduce the amount of data sent syncAppData.Metadata = null; } syncResult.SynchronizationData.Add(syncAppData); } return(syncResult); }
private static void BuildSlicedMetadataCache() { SlicedEntityMetadataCache.Clear(); foreach (var app in _applicationMetadata) { var entityName = app.Entity; var entityMetadata = Entity(entityName); if (app.IsMobileSupported()) { app.Schemas().Add(ApplicationMetadataSchemaKey.GetSyncInstance(), ApplicationSchemaFactory.GetSyncInstance(app.ApplicationName, app.IdFieldName)); } foreach (var webSchema in app.Schemas()) { var schema = webSchema.Value; schema.DepandantFields(DependencyBuilder.BuildDependantFields(schema.Fields, schema.DependableFields)); schema._fieldWhichHaveDeps = schema.DependantFields.Keys; var instance = SlicedEntityMetadataBuilder.GetInstance(entityMetadata, schema, app.FetchLimit); SlicedEntityMetadataCache[new SlicedEntityMetadataKey(webSchema.Key, entityName)] = instance; } } }