Confluence page summary DTO.
Esempio n. 1
0
		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		public Page(PageSummary summary)
		{
			Id = summary.Id;
			ParentId = summary.ParentId;
			Name = summary.Name;
			Space = summary.Space;
			Version = summary.Version;
		}
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 public Page(PageSummary summary)
 {
     Id       = summary.Id;
     ParentId = summary.ParentId;
     Name     = summary.Name;
     Space    = summary.Space;
     Version  = summary.Version;
 }
		public Page GetCachedPage(PageSummary summary)
		{
			var cached = GetCachedContent(summary.Id, summary.Version);
			if (cached != null)
			{
				return new Page(summary)
				{
					Content = cached
				};
			}

			var page = GetPage(summary.Id);
			SetCachedContent(page.Id, page.Version, page.Content);

			return page;
		}
        public Page GetCachedPage(PageSummary summary)
        {
            var cached = GetCachedContent(summary.Id, summary.Version);

            if (cached != null)
            {
                return(new Page(summary)
                {
                    Content = cached
                });
            }

            var page = GetPage(summary.Id);

            SetCachedContent(page.Id, page.Version, page.Content);

            return(page);
        }
Esempio n. 5
0
		private bool UpdateSummaryPage(IEnumerable<IProjectPage> pages, PageSummary summary)
		{
			var updated = new PageDocument();

			var tbody = new XElement(
				"tbody",
				new XElement(
					"tr",
					new XElement("th", "Area"),
					new XElement("th", "Project"),
					new XElement("th", "Type"),
					new XElement("th", ".NET"),
					new XElement("th", "Owner"),
					new XElement("th", "Status")));

			foreach (var page in pages.OrderBy(p => p.OrderKey))
			{
				tbody.Add(page.RenderSummaryRow(false));
			}

			updated.Root.Add(
				new XElement(
					"table",
					tbody));

			var content = updated.Render();
			var existing = m_confluence.GetCachedPage(summary);

			var before = NormalizeForComparison(existing.Content);
			var after = NormalizeForComparison(content);

			if (after == before)
				return false;

			existing.Content = content;
			m_confluence.UpdatePage(existing);
			return true;
		}
Esempio n. 6
0
		private IProjectPage RebuildProject(string areaName, PageSummary project)
		{
			Console.WriteLine("Processing page '{0} / {1}'...", areaName, project.Name);

			IProjectPage page;
			try
			{
				ProjectType projectType;
				var projectName = ResolveProjectName(project.Name, out projectType);

				var existing = m_confluence.GetCachedPage(project);
				var document = new PageDocument(existing.Content);

				switch (projectType)
				{
					case ProjectType.Library:
						page = new LibraryProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.Website:
						page = new WebsiteProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.Webservice:
						page = new WebserviceProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.Service:
						page = new ServiceProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.Console:
						page = new ConsoleProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.Windows:
						page = new WindowsProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.CloudRole:
						page = new CloudRoleProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.CloudService:
						page = new CloudServiceProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.FabricService:
						page = new FabricServiceProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					case ProjectType.FabricApplication:
						page = new FabricApplicationProjectPage(areaName, projectName, project.Name, document, m_owners);
						break;

					default:
						throw new InvalidOperationException(
							$"Unknown how to process project of type '{projectType.ToString().ToLowerInvariant()}'.");
				}

				page.CheckPage(m_tfs);

				var updated = UpdateProjectPage(page, existing);
				if (updated)
				{
					Console.WriteLine("[{0}] {1} #{2}... UPDATED", areaName, projectName, projectType.ToString().ToLowerInvariant());
				}
				else
				{
					Console.WriteLine("[{0}] {1} #{2}... not changed", areaName, projectName, projectType.ToString().ToLowerInvariant());
				}
			}
			catch (Exception e)
			{
				throw new InvalidOperationException(
					$"An error occurred while processing page '{project.Name}' version {project.Version}.",
					e);
			}

			return page;
		}
Esempio n. 7
0
		private List<IProjectPage> RebuildArea(PageSummary area)
		{
			var areaName = ResolveAreaName(area.Name);

			var knownAreas = new HashSet<string>
			{
				"Archive",
				"ContentCast",
				"DataSource",
				"GuidedSelling",
				"Internal",
				"PartnerAccess",
				"Platform",
				"Production",
				"Sandbox",
				"Vortex"
			};

			if (!knownAreas.Contains(areaName))
				throw new InvalidOperationException($"Unknown area name '{area.Name}'.");

			var result = new ConcurrentBag<IProjectPage>();

			var projects = m_children[area.Id];
			Parallel.ForEach(
				projects,
				new ParallelOptions { MaxDegreeOfParallelism = 5 },
				project =>
				{
					var page = RebuildProject(areaName, project);
					result.Add(page);
				});

			var updated = UpdateAreaPage(result, area);
			if (updated)
			{
				Console.WriteLine("Rebuild [{0}] area summary ... UPDATED", areaName);
			}
			else
			{
				Console.WriteLine("Rebuild [{0}] area summary ... not changed", areaName);
			}

			return result.ToList();
		}