Ejemplo n.º 1
0
        private void PopulateLabels(EntityMeta currentEntity, XElement form)
        {
            var matches = from cell in (IEnumerable <Object>)form.XPathEvaluate("//row/cell")
                          where (cell as XElement).Elements("control").Any() &&
                          (cell as XElement).Descendants("label").Any()
                          select new
            {
                LogicalName = (cell as XElement).Element("control").Attribute("id").Value,
                Label       = (cell as XElement).Element("labels").Element("label").Attribute("description").Value
            };

            foreach (var match in matches)
            {
                // Put the label into the Attribute that matches based on LogicalName
                // and is in the Active solution, or in System solution
                if (currentEntity.Attributes
                    .Any(x => x.LogicalName == match.LogicalName && x.SolutionUniqueName.ToLower() == "active"))
                {
                    currentEntity.Attributes
                    .First(x => x.LogicalName == match.LogicalName && x.SolutionUniqueName.ToLower() == "active")
                    .Label = match.Label;
                }
                else if (currentEntity.Attributes.Any(x => x.LogicalName == match.LogicalName))
                {
                    currentEntity.Attributes
                    .First(x => x.LogicalName == match.LogicalName)
                    .Label = match.Label;
                }
            }
        }
Ejemplo n.º 2
0
        public void GetAllMetadataFromDb()
        {
            _Entities          = new List <EntityMeta>();
            _EntitiesRetrieved = true;

            var connectionManager = ConfigurationManager.ConnectionStrings["Everest_MSCRM"];

            using (SqlConnection connection = new SqlConnection(connectionManager.ConnectionString))
            {
                using (SqlCommand command = new SqlCommand(
                           @"  
                            SELECT e.LogicalName, e.Name, a.LogicalName, l.Label, e.EntityId, s.UniqueName	
                            FROM MetadataSchema.Attribute a
                                INNER JOIN MetadataSchema.LocalizedLabel l ON a.AttributeId = l.ObjectId
                                INNER JOIN MetadataSchema.Entity e ON a.EntityId = e.EntityId
	                            INNER JOIN Solution s ON a.SolutionId = s.SolutionId AND e.SolutionId = s.SolutionId AND l.SolutionId = s.SolutionId
                            WHERE l.ObjectColumnName = 'DisplayName'
                                AND e.IsCustomizable = 1
                                AND e.IsImportable = 1
                        ", connection))
                {
                    connection.Open();
                    var reader = command.ExecuteReader();

                    try
                    {
                        while (reader.Read())
                        {
                            var currentEntityLogicalName = (string)reader[0];

                            // Setup the AttributeMeta object
                            var attMeta = new AttributeMeta()
                            {
                                LogicalName        = (string)reader[2],
                                DisplayName        = (string)reader[3],
                                EntityName         = (string)reader[0],
                                SolutionUniqueName = (string)reader[5]
                            };

                            // Check if the current entity already exists
                            if (_Entities.Any(x => x.LogicalName == currentEntityLogicalName))
                            {
                                _Entities.First(x => x.LogicalName == currentEntityLogicalName)
                                .Attributes
                                .Add(attMeta);
                            }
                            else
                            {
                                // Set the entity name
                                var toUse = new EntityMeta()
                                {
                                    LogicalName   = (string)reader[0],
                                    LocalizedName = (string)reader[1],
                                    EntityId      = (Guid)reader[4]
                                };
                                // Add the attribute
                                toUse.Attributes = new List <AttributeMeta>()
                                {
                                    attMeta
                                };

                                _Entities.Add(toUse);
                            }
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public EntityMeta(EntityMeta newE)
 {
     this.LocalizedName = newE.LocalizedName;
     this.LogicalName   = newE.LogicalName;
     this.Attributes    = new List <AttributeMeta>(newE.Attributes);
 }