public void UpdateMetadata(MetadataModel metadata) { if (!metadata.Title.TrimHasValue()) { metadata.Title = Gallery.Title; } if (!metadata.Description.TrimHasValue()) { if (Gallery.Abstract.TrimHasValue()) { metadata.Description = Gallery.Abstract; } else { metadata.Description = Gallery.Title; } } if (!metadata.OGImage.TrimHasValue()) { if (Gallery.ThumbnailUrl.TrimHasValue()) { metadata.OGImage = Gallery.ThumbnailUrl; } else if (Gallery.Items.Count > 0) { metadata.OGImage = Gallery.Items[0].ImageUrl; } } }
public void AttachOperationsMergeTest() { MetadataModel model = GetModel(); var context = new ModelContext(model); var customerOld = new Contact { State = TrackingState.Unchanged, Id = Guid.NewGuid(), FirstName = "First1", LastName = "Last1" }; var customerNew = new Contact { State = TrackingState.Unchanged, Id = customerOld.Id, FirstName = "First1", LastName = "Last2" }; var customerOther = new Contact { State = TrackingState.Unchanged, Id = Guid.NewGuid(), FirstName = "FirstOther", LastName = "LastOther" }; context.AttachSingle(customerOld); var operations = context.Merge(new[] { customerNew, customerOther }); Assert.Equal(2, operations.Items.Count()); Assert.Equal(customerOld, operations.Items.First()); Assert.Single(operations.Added); Assert.Equal(customerOther, operations.Added.First()); Assert.Single(operations.Merged); Assert.Equal(customerOld, operations.Merged.First().Key); Assert.Single(operations.Merged.First().Value); Assert.Equal(nameof(Contact.LastName), operations.Merged.First().Value.First().Name); }
public ActionResult DeleteAttribute(ContainerViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; metadata.DialogStack.Push(postedModel); IModelContainer eavContainer = FindContainer(metadata.CurrentContext.Containers, postedModel.ID); IModelAttribute eavAttribute = eavContainer.Attributes.Single(it => it.AttributeID == ID); if (eavAttribute.ObjectState != ObjectState.New) { eavAttribute.MarkDeleted(); } else { eavContainer.Attributes.Remove(eavAttribute); } TempData["Metadata"] = metadata; if (eavContainer is IModelRootContainer) { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateRootContainer"), null)); } else { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateChildContainer"), null)); } }
public ActionResult DeleteChildContainer(ContainerViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; metadata.DialogStack.Push(postedModel); IModelChildContainer eavContainer = FindContainer(metadata.CurrentContext.Containers, ID) as IModelChildContainer; if (eavContainer.ObjectState != ObjectState.New) { eavContainer.MarkDeleted(); } else { eavContainer.ParentContainer.ChildContainers.Remove(eavContainer); } TempData["Metadata"] = metadata; if (eavContainer.ParentContainer is IModelRootContainer) { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateRootContainer"), null)); } else { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateChildContainer"), null)); } }
public ActionResult UpdateAttribute(AttributeViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; IModelContainer eavContainer = FindContainer(metadata.CurrentContext.Containers, postedModel.ContainerID); IModelAttribute eavAttribute = eavContainer.Attributes.Single(it => it.AttributeID == postedModel.ID); if (UpdateRequested) { eavAttribute.Name = postedModel.Name; eavAttribute.DataName = postedModel.DataName; eavAttribute.DisplayText = postedModel.DisplayText; eavAttribute.DataType = postedModel.DataType; eavAttribute.IsKey = postedModel.IsKey; } else if (eavAttribute.ObjectState == ObjectState.New && (String.IsNullOrWhiteSpace(eavAttribute.Name) || (String.IsNullOrWhiteSpace(eavAttribute.DataName)))) { eavContainer.Attributes.Remove(eavAttribute); } TempData["Metadata"] = metadata; if (eavContainer is IModelRootContainer) { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateRootContainer"), null)); } else { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateChildContainer"), null)); } }
public ActionResult UpdateRootContainer(ContainerViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; IModelRootContainer eavContainer = FindContainer(metadata.CurrentContext.Containers, postedModel.ID) as IModelRootContainer; if (UpdateRequested) { eavContainer.Name = postedModel.Name; eavContainer.DataName = postedModel.DataName; eavContainer.DisplayText = postedModel.DisplayText; eavContainer.IsRepeating = postedModel.IsRepeating; foreach (AttributeViewModel attributeModel in postedModel.Attributes) { eavContainer.Attributes.Single(it => it.AttributeID == attributeModel.ID).Sequence = attributeModel.Sequence; } foreach (ContainerViewModel containerModel in postedModel.ChildContainers) { eavContainer.ChildContainers.Single(it => it.ContainerID == containerModel.ID).Sequence = containerModel.Sequence; } } else if (eavContainer.ObjectState == ObjectState.New && (String.IsNullOrWhiteSpace(eavContainer.Name) || (String.IsNullOrWhiteSpace(eavContainer.DataName))) && !eavContainer.ChildContainers.Any()) { eavContainer.Context.Containers.Remove(eavContainer); } TempData["Metadata"] = metadata; return(BuildResult("Context Editor", Url.Content("~/Metadata/ContextEditorDialog"), Url.Content("~/Metadata/UpdateContext"), null)); }
/// <summary> /// CTOR of Compass. /// </summary> public Compass() { InitializeComponent(); MetadataModel.CreateModel(); this.vm = new MetadataViewModel(MetadataModel.Instance); this.DataContext = this.vm; }
public JsonResult Metadata(string entity) { var model = new List <MetadataModel>(); var assembly = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(x => x.GetTypes()) .FirstOrDefault(x => x.Name.ToLowerInvariant() == entity.ToLowerInvariant()); if (assembly != null) { foreach (var prop in assembly.GetProperties()) { var attrs = (MetadataAttribute[])prop.GetCustomAttributes (typeof(MetadataAttribute), false); foreach (var attr in attrs) { var attrModel = new MetadataModel() { Title = attr.Title, PropertyName = prop.Name, ControlType = attr.ControlType.ToString(), State = attr.State.ToString() }; model.Add(attrModel); } } } return(Json(model, JsonRequestBehavior.AllowGet)); }
/// <summary>Get SMAPI's internal mod database.</summary> /// <param name="metadataPath">The file path for the SMAPI metadata file.</param> public ModDatabase GetModDatabase(string metadataPath) { MetadataModel metadata = JsonConvert.DeserializeObject <MetadataModel>(File.ReadAllText(metadataPath)); ModDataRecord[] records = metadata.ModData.Select(pair => new ModDataRecord(pair.Key, pair.Value)).ToArray(); return(new ModDatabase(records, this.GetUpdateUrl)); }
private static bool AreSameMetadata(MetadataModel source, MetadataModel target) { if (source == null && target == null) { return(true); } if (source == null || target == null || source.Count != target.Count) { return(false); } if (source.Any(entity => target.Count(c => c.Key == entity.Key) != 1)) { return(false); } return(source.All(sourceData => { var sourceDataItems = sourceData.Value; var targetDataItems = target[sourceData.Key]; return sourceDataItems.Count == targetDataItems.Count && sourceDataItems.All(sourceDataItem => targetDataItems.Count(targetDataItem => AreSameDataItems(sourceDataItem, targetDataItem)) == 1); })); }
public async Task <ActionResult> DeleteOnUpdate(string ProcessID, string FieldID) { _Connection.DatabaseConnection(); _Metadata.SetDatabase(_Connection.GetDatabase()); _Field.SetDatabase(_Connection.GetDatabase()); _Properties.SetDatabase(_Connection.GetDatabase()); MetadataModel metadata = _Metadata.GetMetadata(ProcessID); //Obtem-se os metadados do processo cujo o id foi recebido como argumento de entrada; FieldModel fieldToDelete = _Field.GetField(FieldID); //Obtem-se o modelo do campo a remover da base de dados; _Properties.DeleteProperties(fieldToDelete.Properties); //Apaga as propriedades agregadas ao campo; _Field.DeleteField(FieldID); //Apaga o campo agregado ao processo; List <string> UpdatedFields = new List <string>(); foreach (string field in metadata.Field) { if (!field.Equals(FieldID.ToUpper())) { UpdatedFields.Add(field); } } metadata.Field = UpdatedFields; _Metadata.ReplaceMetadata(ProcessID, metadata); //Efetua o replace do modelo de dados MetadataModel existente pelo novo modelo atualizado; return(await Task.Run(() => RedirectToAction("Read", "Field", new { ProcessId = ProcessID }))); //Antes no action estava display; }
// GET: Federation public ActionResult Index() { return(Content( MetadataModel.CreateFederationMetadata() .ToXmlString(CertificateHelper.SigningCertificate), "application/samlmetadata+xml")); }
public void JsonSerializationDeserializationTest() { var builder = new MetadataModelBuilder(); builder.Entity <Invoice>(); builder.Entity <Article>().HasOne(p => p.ArticleSettings).WithPrincipal(); builder.ApplyConventions(); MetadataModel model = null; using (var ms = new MemoryStream()) { var json = new JsonSerializerSettings(); json.Converters.Add(new LucileJsonInheritanceConverter()); var serializer = JsonSerializer.Create(json); using (var streamWriter = new StreamWriter(ms, Encoding.UTF8, 512, true)) { serializer.Serialize(streamWriter, builder); } ms.Seek(0, SeekOrigin.Begin); using (var streamReader = new StreamReader(ms)) using (var jsonReader = new JsonTextReader(streamReader)) { var newBuilder = serializer.Deserialize <MetadataModelBuilder>(jsonReader); model = newBuilder.ToModel(); } } TestModelValidations.ValidateInvoiceArticleDefaultModel(model); }
/// <summary> /// Add new entry in metadata /// </summary> /// <param name="metadataModel">metadata item</param> public void Add(MetadataModel metadataModel) { var metadata = _session.Query <Metadata>().FirstOrDefault() ?? GetDefaultMetadata(); metadataModel.ApplyToMetadata(metadata); _session.Store(metadata); }
public async Task <Message <MetadataModel> > UpdateMetadata(int id, MetadataModel model) { var requestUrl = CreateRequestUri(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Metadatas/" + id.ToString())); return(await PutAsync <MetadataModel>(requestUrl, model)); }
public MetadataModelBuilder FromModel(MetadataModel model) { foreach (var item in model.Entities) { var entity = this.Entity(item.ClrType); if (item.BaseEntity != null) { entity.BaseEntity = this.Entity(item.BaseEntity.ClrType); } foreach (var prop in item.GetProperties().Where(p => p.Entity == item)) { var scalar = entity.Property(prop.Name, prop.PropertyType); scalar.CopyFrom(prop); if (prop.IsPrimaryKey) { entity.PrimaryKey.Add(prop.Name); } } foreach (var nav in item.GetNavigations().Where(p => p.Entity == item)) { var navigation = entity.Navigation(nav.Name); navigation.CopyFrom(nav); } } return(this); }
public async Task <ActionResult> Delete(string id) { if (id != null) { _Connection.DatabaseConnection(); _Metadata.SetDatabase(_Connection.GetDatabase()); //Estabeleçe a conexão; _GetBranchById.SetDatabase(_Connection.GetDatabase()); _GetStateById.SetDatabase(_Connection.GetDatabase()); //_Metadata.ReadFromDatabase(); MetadataModel model = _Metadata.GetMetadata(id); _GetBranchById.ReadFromDatabase(model.Branch); _GetStateById.ReadFromDatabase(model.State); ViewMetadataModel ModelToDelete = new ViewMetadataModel() { Id = model.Id, Name = model.Name, Version = model.Version.ToString(), Date = model.Date.ToString(), Branch = _GetBranchById.GetBranches(), State = _GetStateById.GetStateDescription() }; return(await Task.Run(() => View("Delete", ModelToDelete))); } return(await Task.Run(() => View("Delete"))); }
public static bool GetRotInfo(FileInfo fi, out ushort rotateme) { bool gotRotInfo = false; rotateme = 1; FIBITMAP?dibNull = GetJPGImageHandle(fi); if (dibNull != null) { FIBITMAP dib = (FIBITMAP)dibNull; var iMetadata = new ImageMetadata(dib); MetadataModel exifMain = iMetadata[FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN]; if (exifMain != null) { MetadataTag orientationTag = exifMain.GetTag("Orientation"); if (orientationTag != null) { var rotInfo = (ushort[])orientationTag.Value; rotateme = rotInfo[0]; gotRotInfo = true; } } CleanUpResources(dib); } return(gotRotInfo); }
public ActionResult BrowserFriendly() { return(Content( MetadataModel.CreateFederationMetadata() .ToXmlString(CertificateHelper.SigningCertificate), "text/xml")); }
public async Task <IActionResult> getMetaData(string ConversationType) { string BaseUrl = _configuration.GetSection("ApiURL:baseURL").Value; string metaDataUrl = _configuration.GetSection("ApiURL:metaDataURL").Value + ConversationType; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(BaseUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(metaDataUrl); MetadataModel metadata = new MetadataModel(); if (response.IsSuccessStatusCode) { string jsonString = await response.Content.ReadAsStringAsync(); metadata = JsonConvert.DeserializeObject <MetadataModel>(jsonString); } return(Json(metadata, new JsonSerializerSettings { Formatting = Formatting.Indented, })); }
public ActionResult UpdateContext(ContextViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; IModelContext eavContext = metadata.CurrentContext; if (UpdateRequested) { eavContext.Name = postedModel.Name; eavContext.DataName = postedModel.DataName; eavContext.DisplayText = postedModel.DisplayText; foreach (ContainerViewModel containerModel in postedModel.Containers) { eavContext.Containers.Single(it => it.ContainerID == containerModel.ID).Sequence = containerModel.Sequence; } } else if (eavContext.ObjectState == ObjectState.New && (String.IsNullOrWhiteSpace(eavContext.Name) || (String.IsNullOrWhiteSpace(eavContext.DataName))) && !eavContext.Containers.Any()) { metadata.Contexts.Remove(eavContext); } TempData["Metadata"] = metadata; return(BuildResult(null, null, null, metadata.Contexts.Select(it => new { Value = it.ContextID, Text = it.Name }))); }
/// <summary> /// Muestra los metadatos de un contenedor /// </summary> private static void ShowMetadata(MetadataModel metadata) { Console.WriteLine($"Nombre: {metadata.Name}"); Console.WriteLine($"Uri: {metadata.Uri}"); Console.WriteLine($"Etag: {metadata.ETag}"); Console.WriteLine($"LastModified: {metadata.LastModified}"); ShowMetadataProperties(metadata.Properties); }
public void Add(MetadataModel metadata) { _dbContext.RemoveRange(_dbContext.Query <MetadataCategory>().ToArray()); if (metadata.Any()) { _dbContext.AddRange(_mapper.Map <IEnumerable <MetadataCategory> >(metadata).ToArray()); } }
public ActionResult PostRedirectGetTarget(string view) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; TempData["Metadata"] = metadata; return(View(view, metadata)); }
public override void VisitModel(MetadataModel model) { //BFS Visiting foreach (var convention in _modelConventions) { convention.Apply(model); } }
public ActionResult TestWebApi(MetadataModel modeloListaController, string botonSubmit) { if (modeloListaController != null && modeloListaController.Clases != null && modeloListaController.Clases.Count > 0) { ViewBag.url = MetadataService.buildWebApiUrl(modeloListaController.Clases.Where(x => x.NombreClase == botonSubmit.Split('_')[1]).FirstOrDefault()); } return(View()); }
public static MetadataModel CompleteModel(this MetadataModel model) { foreach (var entity in model.Entities) { AddIdAttribute(entity); AddNameAttribute(entity); } return(model); }
public async Task <HttpResponseMessage> getMetaData(string ConversationType) { HttpRequestMessage request = Request; MetadataModel metaData = new MetadataModel(); metaData = await metaDataRepository.getMetaData(ConversationType); return(GlobalFunctions.CreateResponse <MetadataModel>(request, HttpStatusCode.OK, metaData)); }
public LazyLoadingManager(MetadataModel model) { if (model == null) { throw new ArgumentNullException("model"); } this.Model = model; }
public GenericManager() { ParserService = new JsonParserService(); Model = new MetadataModel(); CreateWorkflows = new List <WorkflowDefinition>(); UpdateWorkflows = new List <WorkflowDefinition>(); DeleteWorkflows = new List <WorkflowDefinition>(); AssociateWorkflow = new List <WorkflowDefinition>(); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => s.IsInvalid ? null : s.Items, (current, parent) => { current.Parent = parent; return true; }); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => { if (s.IsInvalid || (s.Type != MemberType.Namespace && s.Type != MemberType.Toc)) return null; else return s.Items; }, (member, parent) => { if (member.Type != MemberType.Toc) { yaml.Members.Add(member); } return true; }); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => s.IsInvalid ? null : s.Items, (current, parent) => { if (current.Type != MemberType.Toc) { if (current.Type.IsPageLevel()) { current.Href = current.Name + Constants.YamlExtension; } else { current.Href = parent.Href; } } return true; }); }
public void Run(MetadataModel yaml, ResolverContext context) { yaml.TocYamlViewModel = yaml.TocYamlViewModel.ShrinkToSimpleTocWithNamespaceNotEmpty(); }