예제 #1
0
		static void Main(string[] args)
		{
			Regex regex = new Regex(@"href=\""(?<url>.*?)\""", RegexOptions.IgnoreCase | RegexOptions.Multiline);

			foreach (String uri in Utilities.LinkUris)
			{
				try
				{
					using (ComponentLink componentLink = new ComponentLink())
					{
						String url = componentLink.GetLinkAsString("tcm:0-0-0", uri, "tcm:0-0-0", String.Empty, String.Empty, false, false);

						if (!String.IsNullOrEmpty(url))
						{
							Match match = regex.Match(url);

							if (match.Success)
								Utilities.OutputLink(uri, match.Groups["url"].Value);
							else
								Console.WriteLine("Error resolving component link for {0}: Invalid url {1}.", uri, url);
						}
						else
						{
							Console.WriteLine("Error resolving component link for {0}: Link is null or not resolved.", uri);
						}
					}
				}
				catch (Exception ex)
				{
					Console.WriteLine("Error resolving component link for {0}:\n{1}", uri, Utilities.FormatException(ex));
				}
			}

			foreach (String uri in Utilities.BrokerUris)
			{
				try
				{
					using (ComponentPresentationFactory factory = new ComponentPresentationFactory())
					{
						ComponentPresentation presentation = factory.GetComponentPresentationWithHighestPriority(uri);

						if (presentation != null)
							Utilities.OutputDCP(uri, presentation.Content);
						else
							Console.WriteLine("Error retrieving dynamic component presentation for {0}: Presentation is null.", uri);
					}
				}
				catch (Exception ex)
				{
					Console.WriteLine("Error retrieving dynamic component presentation for {0}:\n{1}", uri, Utilities.FormatException(ex));
				}
			}

			Console.WriteLine("Press any key to exit");
			Console.ReadKey();
		}
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="URI"></param>
        /// <returns></returns>
        public static XmlDocument GetComponent(string URI)
        {
            ComponentPresentationFactory cpf;
            XmlDocument result = null;
            int         contentRepositoryId = GetContentRepositoryId(URI);

            cpf = new ComponentPresentationFactory(contentRepositoryId);
            ComponentPresentation cp = cpf.GetComponentPresentationWithHighestPriority(URI);

            if (cp != null && (!string.IsNullOrEmpty(cp.Content)))
            {
                result = new XmlDocument();
                result.LoadXml(cp.Content);
            }
            else
            {
                result = null;
            }

            return(result);
        }
예제 #3
0
        static void Main(String[] args)
        {
            try
            {
                IJvmLoader loader = JvmLoader.GetJvmLoader();
                Console.WriteLine("CodeMesh using Java: {0}", loader.JvmPath);
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Java virtual machine could not be loaded\n{0}", Utilities.FormatException(ex));
                Console.ReadKey();
                return;
            }

            foreach (String uri in Utilities.LinkUris)
            {
                try
                {
                    using (ComponentLink componentLink = new ComponentLink(Utilities.PublicationUri))
                    {
                        Link link = componentLink.GetLink(uri);

                        if (link != null && link.IsResolved)
                        {
                            Utilities.OutputLink(uri, link.Url);
                        }
                        else
                        {
                            Console.WriteLine("Error resolving component link for {0}: Link is null or not resolved.", uri);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error resolving component link for {0}:\n{1}", uri, Utilities.FormatException(ex));
                }
            }

            foreach (String uri in Utilities.BrokerUris)
            {
                try
                {
                    using (ComponentPresentationFactory factory = new ComponentPresentationFactory(Utilities.PublicationUri))
                    {
                        ComponentPresentation presentation = factory.GetComponentPresentationWithHighestPriority(uri);

                        if (presentation != null)
                        {
                            Utilities.OutputDCP(uri, presentation.Content);
                        }
                        else
                        {
                            Console.Write("Error retrieving dynamic component presentation for {0}: Presentation is null.", uri);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error retrieving dynamic component presentation for {0}:\n{1}", uri, Utilities.FormatException(ex));
                }
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
예제 #4
0
        static void Main(string[] args)
        {
            Regex regex = new Regex(@"href=\""(?<url>.*?)\""", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            foreach (String uri in Utilities.LinkUris)
            {
                try
                {
                    using (ComponentLink componentLink = new ComponentLink())
                    {
                        String url = componentLink.GetLinkAsString("tcm:0-0-0", uri, "tcm:0-0-0", String.Empty, String.Empty, false, false);

                        if (!String.IsNullOrEmpty(url))
                        {
                            Match match = regex.Match(url);

                            if (match.Success)
                            {
                                Utilities.OutputLink(uri, match.Groups["url"].Value);
                            }
                            else
                            {
                                Console.WriteLine("Error resolving component link for {0}: Invalid url {1}.", uri, url);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Error resolving component link for {0}: Link is null or not resolved.", uri);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error resolving component link for {0}:\n{1}", uri, Utilities.FormatException(ex));
                }
            }

            foreach (String uri in Utilities.BrokerUris)
            {
                try
                {
                    using (ComponentPresentationFactory factory = new ComponentPresentationFactory())
                    {
                        ComponentPresentation presentation = factory.GetComponentPresentationWithHighestPriority(uri);

                        if (presentation != null)
                        {
                            Utilities.OutputDCP(uri, presentation.Content);
                        }
                        else
                        {
                            Console.WriteLine("Error retrieving dynamic component presentation for {0}: Presentation is null.", uri);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error retrieving dynamic component presentation for {0}:\n{1}", uri, Utilities.FormatException(ex));
                }
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
예제 #5
0
        static void Main(String[] args)
        {
            try
            {
                IJvmLoader loader = JvmLoader.GetJvmLoader();
                Console.WriteLine("CodeMesh using Java: {0}", loader.JvmPath);
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Java virtual machine could not be loaded\n{0}", Utilities.FormatException(ex));
                Console.ReadKey();
                return;
            }

            foreach (String uri in Utilities.LinkUris)
            {
                try
                {
                    using (ComponentLink componentLink = new ComponentLink(Utilities.PublicationUri))
                    {
                        Link link = componentLink.GetLink(uri);

                        if (link != null && link.IsResolved)
                            Utilities.OutputLink(uri, link.Url);
                        else
                            Console.WriteLine("Error resolving component link for {0}: Link is null or not resolved.", uri);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error resolving component link for {0}:\n{1}", uri, Utilities.FormatException(ex));
                }
            }

            foreach (String uri in Utilities.BrokerUris)
            {
                try
                {
                    using (ComponentPresentationFactory factory = new ComponentPresentationFactory(Utilities.PublicationUri))
                    {
                        ComponentPresentation presentation = factory.GetComponentPresentationWithHighestPriority(uri);

                        if (presentation != null)
                        {
                            Utilities.OutputDCP(uri, presentation.Content);
                        }
                        else
                        {
                            Console.Write("Error retrieving dynamic component presentation for {0}: Presentation is null.", uri);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error retrieving dynamic component presentation for {0}:\n{1}", uri, Utilities.FormatException(ex));
                }
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }