public ActionResult <GenericResponse <TypeResponse> > TypeGet(string type) { if (string.IsNullOrEmpty(type)) { ASF.ArchiLogger.LogNullError(nameof(type)); return(BadRequest(new GenericResponse <TypeResponse>(false, string.Format(Strings.ErrorIsEmpty, nameof(type))))); } Type targetType = WebUtilities.ParseType(type); if (targetType == null) { return(BadRequest(new GenericResponse <object>(false, string.Format(Strings.ErrorIsInvalid, type)))); } string baseType = targetType.BaseType?.GetUnifiedName(); HashSet <string> customAttributes = targetType.CustomAttributes.Select(attribute => attribute.AttributeType.GetUnifiedName()).ToHashSet(); string underlyingType = null; Dictionary <string, string> body = new Dictionary <string, string>(); if (targetType.IsClass) { foreach (FieldInfo field in targetType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(field => !field.IsPrivate)) { JsonPropertyAttribute jsonProperty = field.GetCustomAttribute <JsonPropertyAttribute>(); if (jsonProperty != null) { body[jsonProperty.PropertyName ?? field.Name] = field.FieldType.GetUnifiedName(); } } foreach (PropertyInfo property in targetType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(property => property.CanRead && !property.GetMethod.IsPrivate)) { JsonPropertyAttribute jsonProperty = property.GetCustomAttribute <JsonPropertyAttribute>(); if (jsonProperty != null) { body[jsonProperty.PropertyName ?? property.Name] = property.PropertyType.GetUnifiedName(); } } } else if (targetType.IsEnum) { Type enumType = Enum.GetUnderlyingType(targetType); underlyingType = enumType.GetUnifiedName(); foreach (object value in Enum.GetValues(targetType)) { body[value.ToString()] = Convert.ChangeType(value, enumType).ToString(); } } TypeResponse.TypeProperties properties = new TypeResponse.TypeProperties(baseType, customAttributes.Count > 0 ? customAttributes : null, underlyingType); TypeResponse response = new TypeResponse(body, properties); return(Ok(new GenericResponse <TypeResponse>(response))); }
//MENSAJE PERSONALIZADO 1 public ResponseEntity(string _message, TypeResponse _type, object _data) { this.Message = _message; this.Success = false; this.TypeResponse = _type.ToString(); this.Data = _data; this.Title = getTitle(_type); }
public TypeResponse LoadTypesFromDb() { TypeResponse types = new TypeResponse(); SqlCommand selectTypes = new SqlCommand(SelectTypes, MapObjects.MapDbConnection.Connection); MapObjects.MapDbConnection.Open(); SqlDataReader typesReader = selectTypes.ExecuteReader(); int count = 0; do { count++; while (typesReader.Read()) { switch (count) { case 1: NodeType nodeType = new NodeType(); nodeType.LoadSessionObject(typesReader); types.NodeTypes[nodeType.Name] = nodeType; break; case 2: RelationshipType relationshipType = new RelationshipType(); relationshipType.LoadSessionObject(typesReader); types.RelationshipTypes[relationshipType.Name] = relationshipType; break; case 3: DescriptorType descriptorType = new DescriptorType(); descriptorType.LoadSessionObject(typesReader); types.DescriptorTypes[descriptorType.Name] = descriptorType; break; case 4: MetadataType metadataType = new MetadataType(); metadataType.LoadSessionObject(typesReader); types.MetadataTypes[metadataType.Name] = metadataType; break; default: break; } } }while (typesReader.NextResult()); MapObjects.MapDbConnection.Close(); return(types); }
public TypeResponse GetAllMapTypes(GlymaSessionConfiguration configuration) { TypeResponse result = null; // run the call against the application proxy NodeServiceApplicationProxy.Invoke(_serviceContext, proxy => result = proxy.GetAllMapTypes(configuration)); return(result); }
public TypeResponse LoadTypesFromDb() { TypeResponse types = new TypeResponse(); SqlCommand selectTypes = new SqlCommand(SelectTypes, MapObjects.MapDbConnection.Connection); MapObjects.MapDbConnection.Open(); SqlDataReader typesReader = selectTypes.ExecuteReader(); int count = 0; do { count++; while (typesReader.Read()) { switch (count) { case 1: NodeType nodeType = new NodeType(); nodeType.LoadSessionObject(typesReader); types.NodeTypes[nodeType.Name] = nodeType; break; case 2: RelationshipType relationshipType = new RelationshipType(); relationshipType.LoadSessionObject(typesReader); types.RelationshipTypes[relationshipType.Name] = relationshipType; break; case 3: DescriptorType descriptorType = new DescriptorType(); descriptorType.LoadSessionObject(typesReader); types.DescriptorTypes[descriptorType.Name] = descriptorType; break; case 4: MetadataType metadataType = new MetadataType(); metadataType.LoadSessionObject(typesReader); types.MetadataTypes[metadataType.Name] = metadataType; break; default: break; } } } while (typesReader.NextResult()); MapObjects.MapDbConnection.Close(); return types; }
public TypeResponse GetAllMapTypes(GlymaSessionConfiguration configuration) { TypeResponse result = null; // execute the call against the service app ExecuteOnChannel("GetAllMapTypes", delegate(IGlymaNodeServiceApp channel) { result = channel.GetAllMapTypes(configuration); }); return(result); }
public string getTitle(TypeResponse _type) { string tituloAlertPNotify = string.Empty; if (_type.ToString() == "error") { tituloAlertPNotify = Constantes.TitleResponse.error; } if (_type.ToString() == "alert") { tituloAlertPNotify = Constantes.TitleResponse.alert; } if (_type.ToString() == "info") { tituloAlertPNotify = Constantes.TitleResponse.info; } if (_type.ToString() == "success") { tituloAlertPNotify = Constantes.TitleResponse.success; } return(tituloAlertPNotify); }