public string GenerateDescriptionSingle(SolutionComponent solutionComponent, bool withManaged, bool withSolutionInfo, bool withUrls)
        {
            EntityKeyMetadata metaData = _source.GetEntityKeyMetadata(solutionComponent.ObjectId.Value);

            if (metaData != null)
            {
                string behavior = SolutionComponent.GetRootComponentBehaviorName(solutionComponent.RootComponentBehavior?.Value);

                FormatTextTableHandler handler = new FormatTextTableHandler();
                handler.SetHeader("EntityKeyName", "IsCustomizable", "Behavior");

                if (withManaged)
                {
                    handler.AppendHeader("IsManaged");
                }

                handler.AppendHeader("KeyAttributes");

                if (withUrls)
                {
                    handler.AppendHeader("Url");
                }

                List <string> values = new List <string>();

                values.AddRange(new[]
                {
                    string.Format("{0}.{1}", metaData.EntityLogicalName, metaData.LogicalName)
                    , metaData.IsCustomizable?.Value.ToString()
                    , behavior
                });

                if (withManaged)
                {
                    values.Add(metaData.IsManaged.ToString());
                }

                values.Add(string.Join(",", metaData.KeyAttributes.OrderBy(s => s)));

                if (withUrls)
                {
                    var entityMetadata = _source.GetEntityMetadata(metaData.EntityLogicalName);

                    if (entityMetadata != null)
                    {
                        values.Add(_source.Service.ConnectionData?.GetEntityKeyMetadataUrl(entityMetadata.MetadataId.Value, metaData.MetadataId.Value));
                    }
                }

                handler.AddLine(values);

                var str = handler.GetFormatedLinesWithHeadersInLine(false).FirstOrDefault();

                return(string.Format("{0} {1}", this.ComponentTypeEnum.ToString(), str));
            }

            return(solutionComponent.ToString());
        }
        public void GenerateDescription(StringBuilder builder, IEnumerable <SolutionComponent> components, bool withManaged, bool withSolutionInfo, bool withUrls)
        {
            FormatTextTableHandler handler = new FormatTextTableHandler();

            handler.SetHeader("EntityName", "DisplayName", "IsCustomizable", "Behavior");

            if (withManaged)
            {
                handler.AppendHeader("IsManaged");
            }

            if (withUrls)
            {
                handler.AppendHeader("Url");
            }

            foreach (var comp in components)
            {
                string behavior = SolutionComponent.GetRootComponentBehaviorName(comp.RootComponentBehavior?.Value);

                EntityMetadata metaData = _source.GetEntityMetadata(comp.ObjectId.Value);

                if (metaData != null)
                {
                    List <string> values = new List <string>();

                    values.AddRange(new[]
                    {
                        metaData.LogicalName
                        , metaData.DisplayName?.UserLocalizedLabel?.Label
                        , metaData.IsCustomizable?.Value.ToString()
                        , behavior
                    });

                    if (withManaged)
                    {
                        values.Add(metaData.IsManaged.ToString());
                    }

                    if (withUrls)
                    {
                        values.Add(_source.Service.ConnectionData?.GetEntityMetadataUrl(metaData.MetadataId.Value));
                    }

                    handler.AddLine(values);
                }
                else
                {
                    handler.AddLine(comp.ObjectId.ToString(), behavior);
                }
            }

            List <string> lines = handler.GetFormatedLines(true);

            lines.ForEach(item => builder.AppendFormat(formatSpacer, item).AppendLine());
        }
        public string GenerateDescriptionSingle(SolutionComponent solutionComponent, bool withManaged, bool withSolutionInfo, bool withUrls)
        {
            if (this._source.AllOptionSetMetadata.Any())
            {
                if (this._source.AllOptionSetMetadata.ContainsKey(solutionComponent.ObjectId.Value))
                {
                    var optionSet = this._source.AllOptionSetMetadata[solutionComponent.ObjectId.Value];

                    string behavior = SolutionComponent.GetRootComponentBehaviorName(solutionComponent.RootComponentBehavior?.Value);

                    FormatTextTableHandler handler = new FormatTextTableHandler();
                    handler.SetHeader("OptionSetName", "IsCustomizable", "Behavior");

                    if (withManaged)
                    {
                        handler.AppendHeader("IsManaged");
                    }

                    if (withUrls)
                    {
                        handler.AppendHeader("Url");
                    }

                    List <string> values = new List <string>();

                    values.AddRange(new[]
                    {
                        optionSet.Name
                        , optionSet.IsCustomizable?.Value.ToString()
                        , behavior
                    });

                    if (withManaged)
                    {
                        values.Add(optionSet.IsManaged.ToString());
                    }

                    if (withUrls)
                    {
                        values.Add(_source.Service.ConnectionData?.GetGlobalOptionSetUrl(optionSet.MetadataId.Value));
                    }

                    handler.AddLine(values);

                    var str = handler.GetFormatedLinesWithHeadersInLine(false).FirstOrDefault();

                    return(string.Format("{0} {1}", this.ComponentTypeEnum.ToString(), str));
                }
            }

            return(solutionComponent.ToString());
        }
Пример #4
0
        protected void AppendIntoTableHeaderSingle(FormatTextTableHandler handler, bool withUrls, bool withManaged, bool withSolutionInfo)
        {
            if (withManaged)
            {
                handler.AppendHeader("IsManaged");
            }

            if (withSolutionInfo)
            {
                handler.AppendHeader("SolutionName");
            }

            if (withUrls)
            {
                handler.AppendHeader("Url");
            }
        }
        private string GenerateDescriptionSingleInternal(EntityMetadata metaData, int?behaviorCode, bool withUrls, bool withManaged, bool withSolutionInfo)
        {
            string behavior = SolutionComponent.GetRootComponentBehaviorName(behaviorCode);

            FormatTextTableHandler handler = new FormatTextTableHandler();

            handler.SetHeader("EntityName", "DisplayName", "IsCustomizable", "Behavior");

            if (withManaged)
            {
                handler.AppendHeader("IsManaged");
            }

            if (withUrls)
            {
                handler.AppendHeader("Url");
            }

            List <string> values = new List <string>();

            values.AddRange(new[]
            {
                metaData.LogicalName
                , metaData.DisplayName?.UserLocalizedLabel?.Label
                , metaData.IsCustomizable?.Value.ToString()
                , behavior
            });

            if (withManaged)
            {
                values.Add(metaData.IsManaged.ToString());
            }

            if (withUrls)
            {
                values.Add(_source.Service.ConnectionData?.GetEntityMetadataUrl(metaData.MetadataId.Value));
            }

            handler.AddLine(values);

            var str = handler.GetFormatedLinesWithHeadersInLine(false).FirstOrDefault();

            return(string.Format("{0} {1}", this.ComponentTypeEnum.ToString(), str));
        }
        protected override FormatTextTableHandler GetDescriptionHeader(bool withManaged, bool withSolutionInfo, bool withUrls, Action <FormatTextTableHandler, bool, bool, bool> action)
        {
            FormatTextTableHandler handler = new FormatTextTableHandler();

            handler.SetHeader("PluginType", "Primary Entity", "Secondary Entity", "Message", "Stage", "Rank", "Status", "ImageType", "Name", "EntityAlias", "IsCustomizable", "Behavior");

            action(handler, false, withManaged, withSolutionInfo);

            handler.AppendHeader("Attributes");

            return(handler);
        }
        public void GenerateDescription(StringBuilder builder, IEnumerable <SolutionComponent> components, bool withManaged, bool withSolutionInfo, bool withUrls)
        {
            FormatTextTableHandler handlerUnknowed = new FormatTextTableHandler();

            FormatTextTableHandler handler = new FormatTextTableHandler();

            handler.SetHeader("OptionSetName", "IsCustomizable", "Behavior");

            if (withManaged)
            {
                handler.AppendHeader("IsManaged");
            }

            if (withUrls)
            {
                handler.AppendHeader("Url");
            }

            foreach (var comp in components)
            {
                string behavior = SolutionComponent.GetRootComponentBehaviorName(comp.RootComponentBehavior?.Value);

                if (this._source.AllOptionSetMetadata.ContainsKey(comp.ObjectId.Value))
                {
                    var optionSet = this._source.AllOptionSetMetadata[comp.ObjectId.Value];

                    List <string> values = new List <string>();

                    values.AddRange(new[]
                    {
                        optionSet.Name
                        , optionSet.IsCustomizable?.Value.ToString()
                        , behavior
                    });

                    if (withManaged)
                    {
                        values.Add(optionSet.IsManaged.ToString());
                    }

                    if (withUrls)
                    {
                        values.Add(_source.Service.ConnectionData?.GetGlobalOptionSetUrl(optionSet.MetadataId.Value));
                    }

                    handler.AddLine(values);
                }
                else
                {
                    handlerUnknowed.AddLine(comp.ObjectId.ToString(), behavior);
                }
            }

            if (handlerUnknowed.Count > 0)
            {
                List <string> lines = handlerUnknowed.GetFormatedLines(true);
                builder.AppendFormat(formatSpacer, unknowedMessage).AppendLine();
                lines.ForEach(item => builder.AppendFormat(formatSpacer, item).AppendLine());
            }

            {
                List <string> lines = handler.GetFormatedLines(true);

                lines.ForEach(item => builder.AppendFormat(formatSpacer, item).AppendLine());
            }
        }
        public string GenerateDescriptionSingle(SolutionComponent solutionComponent, bool withManaged, bool withSolutionInfo, bool withUrls)
        {
            RelationshipMetadataBase metaData = _source.GetRelationshipMetadata(solutionComponent.ObjectId.Value);

            if (metaData != null)
            {
                string behavior = SolutionComponent.GetRootComponentBehaviorName(solutionComponent.RootComponentBehavior?.Value);

                if (metaData is OneToManyRelationshipMetadata)
                {
                    FormatTextTableHandler handlerManyToOne = new FormatTextTableHandler();
                    handlerManyToOne.SetHeader("ReferencingAttribute", "Type", "ReferencedEntity", "SchemaName", "Behavior", "IsCustomizable");

                    if (withManaged)
                    {
                        handlerManyToOne.AppendHeader("IsManaged");
                    }

                    if (withUrls)
                    {
                        handlerManyToOne.AppendHeader("Url");
                    }

                    var relationship = metaData as OneToManyRelationshipMetadata;

                    List <string> values = new List <string>();

                    values.AddRange(new[]
                    {
                        string.Format("{0}.{1}", relationship.ReferencingEntity, relationship.ReferencingAttribute)
                        , "Many to One"
                        , relationship.ReferencedEntity
                        , relationship.SchemaName
                        , behavior
                        , relationship.IsCustomizable?.Value.ToString()
                    });

                    if (withManaged)
                    {
                        values.Add(metaData.IsManaged.ToString());
                    }

                    if (withUrls)
                    {
                        var entityMetadata = _source.GetEntityMetadata(relationship.ReferencedEntity);
                        if (entityMetadata != null)
                        {
                            values.Add(_source.Service.ConnectionData?.GetRelationshipMetadataRelativeUrl(entityMetadata.MetadataId.Value, relationship.MetadataId.Value));
                        }
                    }

                    handlerManyToOne.AddLine(values);

                    var str = handlerManyToOne.GetFormatedLinesWithHeadersInLine(false).FirstOrDefault();

                    return(string.Format("{0} {1}", this.ComponentTypeEnum.ToString(), str));
                }
                else if (metaData is ManyToManyRelationshipMetadata)
                {
                    FormatTextTableHandler handlerManyToMany = new FormatTextTableHandler();
                    handlerManyToMany.SetHeader("Entity - Entity", "Type", "SchemaName", "Behavior", "IsCustomizable");

                    if (withManaged)
                    {
                        handlerManyToMany.AppendHeader("IsManaged");
                    }

                    if (withUrls)
                    {
                        handlerManyToMany.AppendHeader("Url");
                    }

                    var relationship = metaData as ManyToManyRelationshipMetadata;

                    List <string> values = new List <string>();

                    values.AddRange(new[]
                    {
                        string.Format("{0} - {1}", relationship.Entity1LogicalName, relationship.Entity2LogicalName)
                        , "Many to Many"
                        , relationship.SchemaName
                        , behavior
                        , relationship.IsCustomizable?.Value.ToString()
                    });

                    if (withManaged)
                    {
                        values.Add(metaData.IsManaged.ToString());
                    }

                    if (withUrls)
                    {
                        var entityMetadata = _source.GetEntityMetadata(relationship.Entity1LogicalName);
                        if (entityMetadata != null)
                        {
                            values.Add(_source.Service.ConnectionData?.GetRelationshipMetadataRelativeUrl(entityMetadata.MetadataId.Value, relationship.MetadataId.Value));
                        }
                    }

                    handlerManyToMany.AddLine(values);

                    var str = handlerManyToMany.GetFormatedLinesWithHeadersInLine(false).FirstOrDefault();

                    return(string.Format("{0} {1}", this.ComponentTypeEnum.ToString(), str));
                }
            }

            return(solutionComponent.ToString());
        }
        public void GenerateDescription(StringBuilder builder, IEnumerable <SolutionComponent> components, bool withManaged, bool withSolutionInfo, bool withUrls)
        {
            FormatTextTableHandler handler = new FormatTextTableHandler();

            FormatTextTableHandler handlerManyToOne = new FormatTextTableHandler();

            handlerManyToOne.SetHeader("ReferencingAttribute", "Type", "ReferencedEntity", "SchemaName", "IsCustomizable", "Behavior");

            FormatTextTableHandler handlerManyToMany = new FormatTextTableHandler();

            handlerManyToMany.SetHeader("Entity - Entity", "Type", "SchemaName", "IsCustomizable", "Behavior");

            if (withManaged)
            {
                handlerManyToOne.AppendHeader("IsManaged");
                handlerManyToMany.AppendHeader("IsManaged");
            }

            if (withUrls)
            {
                handlerManyToOne.AppendHeader("Url");
                handlerManyToMany.AppendHeader("Url");
            }

            foreach (var comp in components)
            {
                RelationshipMetadataBase metaData = _source.GetRelationshipMetadata(comp.ObjectId.GetValueOrDefault());

                string behavior = SolutionComponent.GetRootComponentBehaviorName(comp.RootComponentBehavior?.Value);

                if (metaData != null)
                {
                    if (metaData is OneToManyRelationshipMetadata)
                    {
                        var relationship = metaData as OneToManyRelationshipMetadata;

                        List <string> values = new List <string>();

                        values.AddRange(new[]
                        {
                            string.Format("{0}.{1}", relationship.ReferencingEntity, relationship.ReferencingAttribute)
                            , "Many to One"
                            , relationship.ReferencedEntity
                            , relationship.SchemaName
                            , (relationship.IsCustomizable?.Value).GetValueOrDefault().ToString()
                            , behavior
                        });

                        if (withManaged)
                        {
                            values.Add(metaData.IsManaged.ToString());
                        }

                        if (withUrls)
                        {
                            var entityMetadata = _source.GetEntityMetadata(relationship.ReferencedEntity);
                            if (entityMetadata != null)
                            {
                                values.Add(_source.Service.ConnectionData?.GetRelationshipMetadataUrl(entityMetadata.MetadataId.Value, relationship.MetadataId.Value));
                            }
                        }

                        handlerManyToOne.AddLine(values);
                    }
                    else if (metaData is ManyToManyRelationshipMetadata)
                    {
                        var relationship = metaData as ManyToManyRelationshipMetadata;

                        List <string> values = new List <string>();

                        values.AddRange(new[]
                        {
                            string.Format("{0} - {1}", relationship.Entity1LogicalName, relationship.Entity2LogicalName)
                            , "Many to Many"
                            , relationship.SchemaName
                            , behavior
                            , (relationship.IsCustomizable?.Value).GetValueOrDefault().ToString()
                        });

                        if (withManaged)
                        {
                            values.Add(metaData.IsManaged.ToString());
                        }

                        if (withUrls)
                        {
                            var entityMetadata = _source.GetEntityMetadata(relationship.Entity1LogicalName);
                            if (entityMetadata != null)
                            {
                                values.Add(_source.Service.ConnectionData?.GetRelationshipMetadataUrl(entityMetadata.MetadataId.Value, relationship.MetadataId.Value));
                            }
                        }

                        handlerManyToMany.AddLine(values);
                    }
                }
                else
                {
                    handler.AddLine(comp.ObjectId.ToString(), behavior);
                }
            }

            List <string> linesUnknowed = handler.GetFormatedLines(true);

            List <string> linesOne = handlerManyToOne.GetFormatedLines(true);

            List <string> linesMany = handlerManyToMany.GetFormatedLines(true);

            if (linesUnknowed.Any())
            {
                builder.AppendFormat(formatSpacer, unknowedMessage).AppendLine();
                linesUnknowed.ForEach(item => builder.AppendFormat(formatSpacer, item).AppendLine());
            }

            linesOne.ForEach(item => builder.AppendFormat(formatSpacer, item).AppendLine());
            linesMany.ForEach(item => builder.AppendFormat(formatSpacer, item).AppendLine());
        }