public static IHtmlString ShortDescription(this BizTalkBaseObject artefact)
        {
            if (string.IsNullOrEmpty(artefact.Description))
            {
                return(new HtmlString(string.Empty));
            }

            var decs = artefact.Description.Length > 100 ? string.Concat(artefact.Description.Substring(0, 100), " ...") : artefact.Description;

            return(new HtmlString(string.Concat("<br />", decs)));
        }
        public static string PageTitle(this HtmlHelper html, BizTalkBaseObject artefact)
        {
            const string title = Constants.ApplicationName;

            if (artefact is BizTalkApplication)
            {
                return(string.Concat(title, " - Application: ", artefact.Name));
            }

            if (artefact is Pipeline)
            {
                return(string.Concat(title, " - Pipeline: ", artefact.Name));
            }

            if (artefact is SendPort)
            {
                return(string.Concat(title, " - Send port: ", artefact.Name));
            }

            if (artefact is ReceivePort)
            {
                return(string.Concat(title, " - Receive port: ", artefact.Name));
            }

            if (artefact is Schema)
            {
                return(string.Concat(title, " - Schema: ", artefact.Name));
            }

            if (artefact is BizTalkAssembly)
            {
                return(string.Concat(title, " - Assembly: ", artefact.Name));
            }

            if (artefact is Transform)
            {
                return(string.Concat(title, " - Map: ", artefact.Name));
            }

            if (artefact is Host)
            {
                return(string.Concat(title, " - Host: ", artefact.Name));
            }

            if (artefact is Orchestration)
            {
                return(string.Concat(title, " - Orchestration: ", artefact.Name));
            }

            return(title);
        }
        private static string GetArtifactPrefix(BizTalkBaseObject artefact)
        {
            if (artefact is BizTalkApplication)
            {
                return("Application: ");
            }

            if (artefact is Pipeline)
            {
                return("Pipeline: ");
            }

            if (artefact is SendPort)
            {
                return("Send port: ");
            }

            if (artefact is ReceivePort)
            {
                return("Receive port: ");
            }

            if (artefact is Schema)
            {
                return("Schema: ");
            }

            if (artefact is BizTalkAssembly)
            {
                return("Assembly: ");
            }

            if (artefact is Transform)
            {
                return("Map: ");
            }

            if (artefact is Host)
            {
                return("Host: ");
            }

            if (artefact is Orchestration)
            {
                return("Orchestration: ");
            }

            return(string.Empty);
        }
        /// <summary>
        /// Used to link to the correct path taking the current manifest in
        /// </summary>
        public static string Path(this BizTalkBaseObject artefact, Manifest manifest)
        {
            if (artefact == null)
            {
                throw new ArgumentNullException("artefact");
            }

            var versionPrefix = string.Empty;
            var reuqestPath   = HttpContext.Current.Request.ApplicationPath;

            if (manifest != null && !manifest.IsDefaultLatest)
            {
                versionPrefix = manifest.Version + "/";
            }

            if (reuqestPath != "/")
            {
                reuqestPath = reuqestPath + "/";
            }

            if (artefact is BizTalkApplication)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Id));
            }

            if (artefact is BizTalkAssembly)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/Assembly/", artefact.Id, "/", artefact.Name));
            }

            if (artefact is Orchestration)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/Orchestration/", artefact.Id));
            }

            if (artefact is Pipeline)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/Pipeline/", artefact.Id));
            }

            if (artefact is ReceivePort)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/ReceivePort/", artefact.Id));
            }

            //Here we need to actually go to the receive port that contains the location as location doesn't have their own page
            if (artefact is ReceiveLocation)
            {
                var rp = ((ReceiveLocation)artefact).ReceivePort;
                return(string.Concat(reuqestPath, versionPrefix, "Application/", rp.Application.Id, "/ReceivePort/", rp.Id));
            }

            if (artefact is Schema)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/Schema/", artefact.Id, "/", artefact.Name));
            }

            if (artefact is SendPort)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/SendPort/", artefact.Id));
            }

            if (artefact is SendPortGroup)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/SendPortGroup/", artefact.Id));
            }

            if (artefact is Transform)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Application/", artefact.Application.Id, "/Map/", artefact.Id));
            }

            if (artefact is Host)
            {
                return(string.Concat(reuqestPath, versionPrefix, "Host/", artefact.Id));
            }


            throw new ApplicationException("Unknown BizTalk type");
        }
 internal ArtifactEntry(BizTalkBaseObject obj)
 {
     artifactKey = new ArtifactKey(obj.QualifiedName, obj.Name);
     artifact    = obj;
 }
 internal bool Contains(BizTalkBaseObject obj)
 {
     return(this.artifactKey.QualifiedName == obj.QualifiedName &&
            this.artifactKey.ArtifactName == obj.Name);
 }