Esempio n. 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets a resource matching the specified name from the Owning object from a collection
		/// of resources specified by the field id.
		/// </summary>
		/// <param name="cache">database</param>
		/// <param name="hvoOwner">id of the owning object</param>
		/// <param name="flid">field id in the owning object</param>
		/// <param name="name">name of the specified resource</param>
		/// <param name="newVersion">new version number for the resource</param>
		/// ------------------------------------------------------------------------------------
		public static void SetResource(FdoCache cache, int hvoOwner, int flid, string name,
			Guid newVersion)
		{
			CmResource resource = GetResource(cache, hvoOwner, flid, name);
			if (resource == null)
			{
				// Resource does not exist yet. Add it to the collection.
				FdoOwningCollection<ICmResource> resources =
					new FdoOwningCollection<ICmResource>(cache, hvoOwner, flid);
				CmResource newResource = new CmResource();
				resources.Add(newResource);
				newResource.Name = name;
				newResource.Version = newVersion;
				return;
			}

			resource.Version = newVersion;
		}
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets a resource matching the specified name from the Owning object from a collection
        /// of resources specified by the field id.
        /// </summary>
        /// <param name="cache">database</param>
        /// <param name="hvoOwner">id of the owning object</param>
        /// <param name="flid">field id in the owning object</param>
        /// <param name="name">name of the specified resource</param>
        /// <param name="newVersion">new version number for the resource</param>
        /// ------------------------------------------------------------------------------------
        public static void SetResource(FdoCache cache, int hvoOwner, int flid, string name,
                                       Guid newVersion)
        {
            CmResource resource = GetResource(cache, hvoOwner, flid, name);

            if (resource == null)
            {
                // Resource does not exist yet. Add it to the collection.
                FdoOwningCollection <ICmResource> resources =
                    new FdoOwningCollection <ICmResource>(cache, hvoOwner, flid);
                CmResource newResource = new CmResource();
                resources.Add(newResource);
                newResource.Name    = name;
                newResource.Version = newVersion;
                return;
            }

            resource.Version = newVersion;
        }
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Fixes any orphaned footnotes or pictures caused by TE-8674/TE-8719.
		/// </summary>
		/// <returns>List of descriptions of any problems fix or any remaining problems that the
		/// user might still need to fix</returns>
		/// ------------------------------------------------------------------------------------
		private List<string> FixOrcsWithoutProps()
		{
			// If we've already checked this project out and fixed any orphans, we're done.
			foreach (ICmResource res in m_scr.ResourcesOC)
			{
				if (res.Name == ksFixedOrphanedFootnotes && res.Version == kguidFixedOrphanedFootnotes)
					return null;
			}

			List<string> issuesToReport = null;

			// Do the cleanup.
			foreach (IScrBook book in m_scr.ScriptureBooksOS)
			{
				List<FootnoteOrcLocation> footnotes = new List<FootnoteOrcLocation>(book.FootnotesOS.Count);
				foreach (IStFootnote footnote in book.FootnotesOS)
					footnotes.Add(new FootnoteOrcLocation(footnote));

				List<OrcLocation> parasWithOrcs = new List<OrcLocation>(book.FootnotesOS.Count);

				BCVRef startRef = new BCVRef(book.CanonicalNum, 0, 0);
				BCVRef endRef = new BCVRef(startRef);

				bool foundProblem = FindOrcsWithoutPropsInText(book.TitleOA, null, ref startRef, ref endRef, footnotes, parasWithOrcs);

				int sectionNumber = 1;
				foreach (IScrSection section in book.SectionsOS)
				{
					startRef = new BCVRef(section.VerseRefStart);
					endRef = new BCVRef(section.VerseRefEnd);
					string sLocationFmt = (section.IsIntro) ? "Section {1}, {0}" : "Section {0}";
					string sLocation = String.Format(sLocationFmt, "Heading", sectionNumber);

					foundProblem |= FindOrcsWithoutPropsInText(section.HeadingOA, sLocation, ref startRef, ref endRef, footnotes, parasWithOrcs);
					sLocation = (section.IsIntro) ? String.Format(sLocationFmt, "Contents", sectionNumber) : null;

					foundProblem |= FindOrcsWithoutPropsInText(section.ContentOA, sLocation, ref startRef, ref endRef, footnotes, parasWithOrcs);
					sectionNumber++;
				}

				if (!foundProblem)
				{
					// Might still have orphaned footnotes, so look through list to check
					foreach (FootnoteOrcLocation fn in footnotes)
					{
						if (fn.location == null)
						{
							foundProblem = true;
							break;
						}
					}
				}

				if (foundProblem)
				{
					if (issuesToReport == null)
						issuesToReport = new List<string>();
					FixOrcsWithoutProps(book, parasWithOrcs, footnotes, issuesToReport);
				}
			}

			// Make an entry in the "Resources" so that we know this project has been fixed up.
			ICmResource resourceFixed = new CmResource();
			m_scr.ResourcesOC.Add(resourceFixed);
			resourceFixed.Name = ksFixedOrphanedFootnotes;
			resourceFixed.Version = kguidFixedOrphanedFootnotes;
			return issuesToReport;
		}