public static SchemaDto ToModel(this ISchemaEntity entity) { var dto = new SchemaDto { Properties = new SchemaPropertiesDto() }; SimpleMapper.Map(entity, dto); SimpleMapper.Map(entity.SchemaDef, dto); SimpleMapper.Map(entity.SchemaDef.Properties, dto.Properties); return(dto); }
private bool Migrate(MongoBackupStrategy backupStrategy, MongoMigrationStrategy migrationStrategy) { var currentSchema = _database .GetCollection <SchemaDto>(_storageOptions.Prefix + ".schema") .Find(_ => true) .FirstOrDefault(); if (currentSchema == null) { // We do not have a schema version yet // - assume an empty database and run full migrations currentSchema = new SchemaDto { Version = MongoSchema.None }; } if (RequiredSchemaVersion < currentSchema.Version) { var assemblyName = GetType().GetTypeInfo().Assembly.GetName(); throw new InvalidOperationException( $"{Environment.NewLine}{assemblyName.Name} version: {assemblyName.Version}, uses a schema prior to the current database." + $"{Environment.NewLine}Backwards migration is not supported. Please resolve this manually (e.g. by dropping the database)." + $"{Environment.NewLine}Please see https://github.com/sergeyzwezdin/Hangfire.Mongo#migration for further information."); } if (RequiredSchemaVersion == currentSchema.Version) { // Nothing to migrate - so let's get outta here. return(false); } if (backupStrategy == null) { throw new InvalidOperationException( $"{Environment.NewLine}You need to choose a migration strategy by setting the {nameof(MongoStorageOptions)}.{nameof(MongoStorageOptions.MigrationOptions)} property." + $"{Environment.NewLine}Please see https://github.com/sergeyzwezdin/Hangfire.Mongo#migration for further information."); } backupStrategy .Backup(_storageOptions, _database, currentSchema.Version, RequiredSchemaVersion); migrationStrategy .Execute(_storageOptions, _database, currentSchema.Version, RequiredSchemaVersion); return(true); }
public async Task <IActionResult> GetSchema(string app, string name) { var schema = await GetSchemaAsync(name); if (schema == null) { return(NotFound()); } var response = Deferred.Response(() => { return(SchemaDto.FromSchema(schema, Resources)); }); Response.Headers[HeaderNames.ETag] = schema.ToEtag(); return(Ok(response)); }
private static JToken?CreateValue(FieldPropertiesDto field) { var schema = new SchemaDto { Fields = new List <FieldDto> { new FieldDto { Name = "field", Properties = field, Partitioning = "invariant" } } }; var sut = new TestDataGenerator(schema, null !); var data = sut.GenerateTestData(); return(data["field"]["iv"]); }
public ActionResult Edit(SchemaFormViewModel model) { SchemaDto schema = serviceSchema.GetItem(model.SchemaId); ViewBag.SchemaParentId = schema.SchemaParentId; ViewBag.TemplateList = serviceTemplate.GetList(schema.SchemaParentId); try { if (ModelState.IsValid) { //schema.SectionId = model.SectionId; schema.TemplateId = model.TemplateId; schema.Iterations = model.Iterations; schema.Position = model.Position; schema.IsPage = model.IsPage; schema.Alias = model.Alias; schema.Active = model.Active; serviceSchema.Edit(schema); } else { ModelState.AddModelError("Error", "Algunos datos ingresados no son válidos"); return(View(model)); } } catch (Exception ex) { ModelState.AddModelError("Error", "Se ha producido un error: " + ex.Message); return(View(model)); } return(RedirectToAction("Index", new { SchemaId = ViewBag.SchemaId, SchemaParentId = ViewBag.SchemaParentId })); }
public TestDataGenerator(SchemaDto schema, AppLanguagesDto languages) { this.schema = schema; this.languages = languages; }
public static Schema MapToSchema(this SchemaDto schemaDto) { return(new Schema(schemaDto.id, schemaDto.name, Mapper.Map <SchemaField[]>(schemaDto.fields))); }
public void Edit(SchemaDto request) { context.SchemaRepository.Update(Mapper.Map <SchemaDto, Schema>(request)); context.Commit(); }
public void Add(SchemaDto request) { context.SchemaRepository.Add(Mapper.Map <SchemaDto, Schema>(request)); context.Commit(); }