当前位置: 首页>>代码示例>>C#>>正文


C# IDomainObjectDTORepository.Update方法代码示例

本文整理汇总了C#中IDomainObjectDTORepository.Update方法的典型用法代码示例。如果您正苦于以下问题:C# IDomainObjectDTORepository.Update方法的具体用法?C# IDomainObjectDTORepository.Update怎么用?C# IDomainObjectDTORepository.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDomainObjectDTORepository的用法示例。


在下文中一共展示了IDomainObjectDTORepository.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Perform one increment migration step.
		///
		/// In this case, the migration is not related to a model change,
		/// but is a simple data change that removes the class elements in the xml.
		/// The end resujlt xml will have the top-level 'rt' element and zero, or more,
		/// property level elements.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000014);

			// No. We need to convert all instances, even if they are no longer part of the model.
			// DM19, for example, removes LgWritingSystem instances and the class form the model,
			// but it tries to access the data as if it had been properly processed by DM15,
			// *but* this code would leave out LgWritingSystem instnaces form being processed here.
			//foreach (var dto in domainObjectDtoRepository.AllInstancesWithSubclasses("CmObject"))
			foreach (var dto in domainObjectDtoRepository.AllInstances())
			{
				var rtElement = XElement.Parse(dto.Xml);
				// Removes all current child nodes (class level),
				// and replaces them with the old property nodes (if any).
#if !__MonoCS__
				rtElement.ReplaceNodes(rtElement.Elements().Elements());
				dto.Xml = rtElement.ToString();
#else // FWNX-165: work around mono bug https://bugzilla.novell.com/show_bug.cgi?id=592435
				var copy = new XElement(rtElement);
				copy.ReplaceNodes(rtElement.Elements().Elements());
				dto.Xml = copy.ToString();
#endif
				domainObjectDtoRepository.Update(dto);
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:37,代码来源:DataMigration7000015.cs

示例2: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Changes all StFootnotes to ScrFootnotes
		/// </summary>
		/// <param name="domainObjectDtoRepository">
		/// Repository of all CmObject DTOs available for one migration step.
		/// </param>
		/// <remarks>
		/// The method must add/remove/update the DTOs to the repository,
		/// as it adds/removes objects as part of it work.
		///
		/// Implementors of this interface should ensure the Repository's
		/// starting model version number is correct for the step.
		/// Implementors must also increment the Repository's model version number
		/// at the end of its migration work.
		///
		/// The method also should normally modify the xml string(s)
		/// of relevant DTOs, since that string will be used by the main
		/// data migration calling client (ie. BEP).
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000002);

			var footnotesToChangeClasses = new List<DomainObjectDTO>();
			foreach (var footnote in domainObjectDtoRepository.AllInstancesSansSubclasses("StFootnote"))
			{
				XElement footnoteEl = XElement.Parse(footnote.Xml);
				footnoteEl.Attribute("class").Value = "ScrFootnote";

				// Add the empty ScrFootnote element to the ScrFootnote
				footnoteEl.Add(new XElement("ScrFootnote"));

				// Update the object XML
				footnote.Xml = footnoteEl.ToString();
				footnote.Classname = "ScrFootnote";
				footnotesToChangeClasses.Add(footnote);
			}

			// Udate the repository
			var startingStructure = new ClassStructureInfo("StText", "StFootnote");
			var endingStructure = new ClassStructureInfo("StFootnote", "ScrFootnote");
			foreach (var changedPara in footnotesToChangeClasses)
				domainObjectDtoRepository.Update(changedPara,
					startingStructure,
					endingStructure);

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:50,代码来源:DataMigration7000003.cs

示例3: PerformMigration

		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000050);

			var newGuidValue = Guid.NewGuid().ToString().ToLowerInvariant();
			const string className = "LangProject";
			var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses(className).First();
			var ownedDtos = domainObjectDtoRepository.GetDirectlyOwnedDTOs(lpDto.Guid).ToList();
			var data = lpDto.Xml;
			domainObjectDtoRepository.Remove(lpDto); // It is pretty hard to change an immutable Guid identifier in BEP-land, so nuke it, and make a new one.

			var lpElement = XElement.Parse(data);
			lpElement.Attribute("guid").Value = newGuidValue;
			var newLpDto = new DomainObjectDTO(newGuidValue, className, lpElement.ToString());
			domainObjectDtoRepository.Add(newLpDto);

			// Change ownerguid attr for each owned item to new guid.
			foreach (var ownedDto in ownedDtos)
			{
				var ownedElement = XElement.Parse(ownedDto.Xml);
				ownedElement.Attribute("ownerguid").Value = newGuidValue;
				ownedDto.Xml = ownedElement.ToString();
				domainObjectDtoRepository.Update(ownedDto);
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:DataMigration7000051.cs

示例4: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Changes all StTxtParas that are owned by Scripture to be ScrTxtParas
		/// </summary>
		/// <param name="domainObjectDtoRepository">
		/// Repository of all CmObject DTOs available for one migration step.
		/// </param>
		/// <remarks>
		/// The method must add/remove/update the DTOs to the repository,
		/// as it adds/removes objects as part of it work.
		///
		/// Implementors of this interface should ensure the Repository's
		/// starting model version number is correct for the step.
		/// Implementors must also increment the Repository's model version number
		/// at the end of its migration work.
		///
		/// The method also should normally modify the xml string(s)
		/// of relevant DTOs, since that string will be used by the main
		/// data migration calling client (ie. BEP).
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000001);

			var parasToChangeClasses = new List<DomainObjectDTO>();
			foreach (var stTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("StTxtPara"))
			{
				var paraOwner = domainObjectDtoRepository.GetOwningDTO(stTxtPara);
				if (paraOwner.Classname != "StText" && paraOwner.Classname != "StFootnote")
				{
					continue; // Paragraph is not owned by an StText or StFootnote (shouldn't ever happen)
				}

				var textOwner = domainObjectDtoRepository.GetOwningDTO(paraOwner);
				if (textOwner.Classname != "ScrBook" && textOwner.Classname != "ScrSection")
				{
					continue; // StText is not part of Scripture, don't change.
				}
				// Its one of the paragraphs that we care about. We just need to change the
				// class in the xml to be a ScrTxtPara and change the objectsByClass map.
				DataMigrationServices.ChangeToSubClass(stTxtPara, "StTxtPara", "ScrTxtPara");
				parasToChangeClasses.Add(stTxtPara);
			}

			// Udate the repository
			var startingStructure = new ClassStructureInfo("StPara", "StTxtPara");
			var endingStructure = new ClassStructureInfo("StTxtPara", "ScrTxtPara");
			foreach (var changedPara in parasToChangeClasses)
				domainObjectDtoRepository.Update(changedPara,
					startingStructure,
					endingStructure);

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:55,代码来源:DataMigration7000002.cs

示例5: DeleteWeatherListAndField

		/// <summary>
		/// The Weather list is never used, so delete it (and remove any empty Weather elements
		/// from the RnGenericRec elements).
		/// </summary>
		private void DeleteWeatherListAndField(IDomainObjectDTORepository repoDTO)
		{
			// Remove the Weather list.
			DomainObjectDTO dtoLP = GetDtoLangProj(repoDTO);
			string sWeatherListGuid = RemoveWeatherConditionsElement(dtoLP).ToLowerInvariant();
			repoDTO.Update(dtoLP);
			DomainObjectDTO dtoDeadList = null;
			foreach (var dto in repoDTO.AllInstancesWithSubclasses("CmPossibilityList"))
			{
				if (dto.Guid.ToLowerInvariant() == sWeatherListGuid)
				{
					dtoDeadList = dto;
					break;
				}
			}
			List<DomainObjectDTO> rgdtoDead = new List<DomainObjectDTO>();
			GatherDeadObjects(repoDTO, dtoDeadList, rgdtoDead);
			foreach (var dto in rgdtoDead)
				repoDTO.Remove(dto);

			// Remove any empty Weather elements in the RnGenericRec objects.
			foreach (var dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec"))
			{
				string sXml = dto.Xml;
				int idx = sXml.IndexOf("<Weather");
				if (idx > 0)
				{
					dto.Xml = RemoveEmptyWeather(sXml, idx);
					repoDTO.Update(dto);
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:36,代码来源:DataMigration7000017.cs

示例6: UpdateDTO

		/// <summary>
		/// Rest the xml in the DTO and register the DTO as udated with the repository.
		/// Use this overload only if the class name is NOT changing.
		/// </summary>
		/// <remarks>
		/// There is no validation of the xml, other than making sure it is not null,
		/// or an emty string.
		/// </remarks>
		internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos,
			DomainObjectDTO dirtball, string newXmlValue)
		{
			if (dtoRepos == null) throw new ArgumentNullException("dtoRepos");
			if (dirtball == null) throw new ArgumentNullException("dirtball");
			if (String.IsNullOrEmpty(newXmlValue)) throw new ArgumentNullException("newXmlValue");

			dirtball.Xml = newXmlValue;
			dtoRepos.Update(dirtball);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:18,代码来源:DataMigrationServices.cs

示例7: PerformMigration

		public void PerformMigration(IDomainObjectDTORepository repoDto)
		{
			DataMigrationServices.CheckVersionNumber(repoDto, 7000041);

			var dtoLexDb = repoDto.AllInstancesSansSubclasses("LexDb").First();
			var xeLexDb = XElement.Parse(dtoLexDb.Xml);
			var guidComplexTypes = GetGuidValue(xeLexDb, "ComplexEntryTypes/objsur");
			var guidVariantTypes = GetGuidValue(xeLexDb, "VariantEntryTypes/objsur");
			BuildStandardMaps(guidComplexTypes, guidVariantTypes);
			var extraTypes = new List<LexTypeInfo>();
			var unprotectedTypes = new List<LexTypeInfo>();
			foreach (var dto in repoDto.AllInstancesSansSubclasses("LexEntryType"))
			{
				var xeType = XElement.Parse(dto.Xml);
				// ReSharper disable PossibleNullReferenceException
				var guid = xeType.Attribute("guid").Value;
				// ReSharper restore PossibleNullReferenceException
				string name;
				if (m_mapGuidName.TryGetValue(guid, out name))
				{
					m_mapGuidName.Remove(guid);
					m_mapNameGuid.Remove(name);
					var xeProt = xeType.XPathSelectElement("IsProtected");
					if (xeProt == null)
					{
						unprotectedTypes.Add(new LexTypeInfo(dto, xeType));
					}
					else
					{
						var xaVal = xeProt.Attribute("val");
						if (xaVal == null || xaVal.Value.ToLowerInvariant() != "true")
							unprotectedTypes.Add(new LexTypeInfo(dto, xeType));
					}
				}
				else
				{
					extraTypes.Add(new LexTypeInfo(dto, xeType));
				}
			}
			foreach (var info in unprotectedTypes)
			{
				var xeProt = info.XmlElement.XPathSelectElement("IsProtected");
				if (xeProt != null)
					xeProt.Remove();
				info.XmlElement.Add(new XElement("IsProtected", new XAttribute("val", "true")));
				info.DTO.Xml = info.XmlElement.ToString();
				repoDto.Update(info.DTO);
			}
			if (m_mapGuidName.Count > 0)
				FixOrAddMissingTypes(repoDto, extraTypes);
			FixOwnershipOfSubtypes(repoDto);
			DataMigrationServices.IncrementVersionNumber(repoDto);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:53,代码来源:DataMigration7000042.cs

示例8: PerformMigration

		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000065);

			// Cache all basic data properties for each class in the mdc.
			var mdc = domainObjectDtoRepository.MDC;
			var cachedBasicProperties = CacheBasicProperties(mdc);
			foreach (var kvp in cachedBasicProperties)
			{
				var className = kvp.Key;
				if (mdc.GetAbstract(mdc.GetClassId(className)))
					continue; // Won't find any of those as dtos.

				var basicProps = kvp.Value;
				foreach (var dto in domainObjectDtoRepository.AllInstancesSansSubclasses(className))
				{
					var rootElementChanged = false;
					var rootElement = XElement.Parse(dto.Xml);
					foreach (var basicPropertyInfo in basicProps)
					{
						if (basicPropertyInfo.m_isCustom)
						{
							var customPropElement = rootElement.Elements("Custom").FirstOrDefault(element => element.Attribute("name").Value == basicPropertyInfo.m_propertyName);
							if (customPropElement == null)
							{
								CreateCustomProperty(rootElement, basicPropertyInfo);
								rootElementChanged = true;
							}
						}
						else
						{
							var basicPropertyElement = rootElement.Element(basicPropertyInfo.m_propertyName);
							if (basicPropertyElement == null && !SkipTheseBasicPropertyNames.Contains(basicPropertyInfo.m_propertyName) && !basicPropertyInfo.m_isVirtual)
							{
								CreateBasicProperty(rootElement, basicPropertyInfo);
								rootElementChanged = true;
							}
						}
					}
					if (!rootElementChanged)
						continue;

					dto.Xml = rootElement.ToString();
					domainObjectDtoRepository.Update(dto);
				}
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:49,代码来源:DataMigration7000066.cs

示例9: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Perform one increment migration step.
		/// </summary>
		/// <param name="domainObjectDtoRepository">
		/// Repository of all CmObject DTOs available for one migration step.
		/// </param>
		/// <remarks>
		/// The method must add/remove/update the DTOs to the repository,
		/// as it adds/removes objects as part of it work.
		///
		/// Implementors of this interface should ensure the Repository's
		/// starting model version number is correct for the step.
		/// Implementors must also increment the Repository's model version number
		/// at the end of its migration work.
		///
		/// The method also should normally modify the xml string(s)
		/// of relevant DTOs, since that string will be used by the main
		/// data migration calling client (ie. BEP).
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000061);

			// Step 1.
			foreach (var resourceDto in domainObjectDtoRepository.AllInstancesSansSubclasses("CmResource"))
			{
				var resourceElement = XElement.Parse(resourceDto.Xml);
				var resourceNameElement = resourceElement.Element("Name");
				if (resourceNameElement == null)
					continue;
				var uniElement = resourceNameElement.Element("Uni");
				if (uniElement == null)
					continue;
				string oldVersion;
				switch (uniElement.Value)
				{
					case "TeStyles":
						oldVersion = "700176e1-4f42-4abd-8fb5-3c586670085d";
						break;
					case "FlexStyles":
						oldVersion = "13c213b9-e409-41fc-8782-7ca0ee983b2c";
						break;
					default:
						continue;
				}
				var versionElement = resourceElement.Element("Version");
				if (versionElement == null)
				{
					resourceElement.Add(new XElement("Version", new XAttribute("val", oldVersion)));
				}
				else
				{
					versionElement.Attribute("val").Value = oldVersion;
				}
				resourceDto.Xml = resourceElement.ToString();
				domainObjectDtoRepository.Update(resourceDto);
			}

			// Step 2.
			DataMigrationServices.Delint(domainObjectDtoRepository);

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:65,代码来源:DataMigration7000062.cs

示例10: PerformMigration

		/// <summary>
		/// Remove all attributes from the "Uni"> element.
		/// </summary>
		/// <param name="domainObjectDtoRepository"></param>
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000066);

			foreach (var dto in domainObjectDtoRepository.AllInstances())
			{
				var element = XElement.Parse(dto.Xml);
				var uniElementsWithAttrs = element.Elements().Elements("Uni").Where(uniElement => uniElement.HasAttributes).ToList();
				if (uniElementsWithAttrs.Count == 0)
					continue;
				foreach (var uniElementWithAttrs in uniElementsWithAttrs)
				{
					uniElementWithAttrs.Attributes().Remove();
					dto.Xml = element.ToString();
					domainObjectDtoRepository.Update(dto);
				}
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:24,代码来源:DataMigration7000067.cs

示例11: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Changes Chart 'missing' markers from invalid ConstChartWordGroup references to
		/// ConstChartTag objects with null Tag property.
		/// </summary>
		/// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for
		/// one migration step.</param>
		/// ------------------------------------------------------------------------------------
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000012);

			// 1) Select the ConstChartWordGroup class objects.
			// 2) Convert any with null BeginSegment reference to ConstChartTag objects with null Tag reference.
			var objsToChangeClasses = new List<DomainObjectDTO>();
			foreach (var cellPartDto in domainObjectDtoRepository.AllInstancesSansSubclasses("ConstChartWordGroup"))
			{
				var rtElement = XElement.Parse(cellPartDto.Xml);

				// Only migrate the ones that have no BeginSegment
				var wordGrp = rtElement.Element("ConstChartWordGroup");
				if (wordGrp.Element("BeginSegment") != null)
					continue; // Don't migrate this one, it has a BeginSegment reference!

				// change its class value
				rtElement.Attribute("class").Value = "ConstChartTag";

				// Add the empty ConstChartTag element
				rtElement.Add(new XElement("ConstChartTag"));

				// Remove the old WordGroup element
				RemoveField(cellPartDto, rtElement, "ConstChartWordGroup");

				// Update the object XML
				cellPartDto.Xml = rtElement.ToString();
				cellPartDto.Classname = "ConstChartTag";
				objsToChangeClasses.Add(cellPartDto);
			}

			// Update the repository
			var startingStructure = new ClassStructureInfo("ConstituentChartCellPart", "ConstChartWordGroup");
			var endingStructure = new ClassStructureInfo("ConstituentChartCellPart", "ConstChartTag");
			foreach (var changedCellPart in objsToChangeClasses)
				domainObjectDtoRepository.Update(changedCellPart,
					startingStructure,
					endingStructure);

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:49,代码来源:DataMigration7000013.cs

示例12: PerformMigration

		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000039);

			foreach (var dto in domainObjectDtoRepository.AllInstancesSansSubclasses("LexEntryRef"))
			{
				var xElt = XElement.Parse(dto.Xml);
				var primaryLexemes = xElt.Element("PrimaryLexemes");
				if (primaryLexemes == null || primaryLexemes.Elements().Count() == 0)
					continue;
				var newElt = new XElement("ShowComplexFormsIn");
				foreach (var child in primaryLexemes.Elements())
				{
					newElt.Add(new XElement(child)); // clone all the objsur elements.
				}
				xElt.Add(newElt);
				dto.Xml = xElt.ToString();
				domainObjectDtoRepository.Update(dto);
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:22,代码来源:DataMigration7000040.cs

示例13: AddSegmentAnalyses


//.........这里部分代码省略.........
				var twficElementListForCurrentSegment = new List<byte[]>();
				var twficMap = new Dictionary<string, byte[]>();
				foreach (var twficKvp in from xficKvp in xficsForCurrentOldSegment
										 where GetAnnotationTypeGuid(xficKvp.Value) == DataMigrationServices.kTwficAnnDefnGuid
										 select xficKvp)
				{
					twficBeginOffsetListForCurrentSegment.Add(twficKvp.Key);
					var twficGuid = GetGuid(twficKvp.Value);
					twficGuidListForCurrentSegment.Add(twficGuid);
					twficElementListForCurrentSegment.Add(twficKvp.Value);
					twficMap.Add(twficGuid, twficKvp.Value);
				}

				var textTagElementsForCurrentSegment = new List<byte[]>();
				foreach (var oldTextTagAnnElement in oldTextTags)
				{
					// Find the ones that are used in the current segment,
					// and add them to textTagElementsForCurrentSegment.

					var appliesToGuids = new List<string>();
					foreach (var guid in GetAppliesToObjsurGuids(oldTextTagAnnElement))
					{
						if (twficGuidListForCurrentSegment.Contains(guid))
							appliesToGuids.Add(guid);
					}
					if (appliesToGuids.Count() <= 0)
						continue;

					// Store them for a while.
					textTagElementsForCurrentSegment.Add(oldTextTagAnnElement);

					// Get the index of the First twfic in appliesToGuids collection (which may hold pfics)
					// and the index of the Last twfic in appliesToGuids collection (which may hold pfics).
					var beginIdx = 0;
					for (var i = 0; i < appliesToGuids.Count(); ++i)
					{
						var currentXfixGuid = appliesToGuids[i].ToLower();
						byte[] currentTwficElement;
						if (!twficMap.TryGetValue(currentXfixGuid, out currentTwficElement))
							continue;

						beginIdx = xficsForCurrentOldSegment.IndexOfValue(currentTwficElement);
						break;
					}
					var endIdx = 0;
					for (var i = appliesToGuids.Count() - 1; i > -1; --i)
					{
						var currentXfixGuid = appliesToGuids[i].ToLower();
						byte[] currentTwficElement;
						if (!twficMap.TryGetValue(currentXfixGuid, out currentTwficElement))
							continue;

						endIdx = xficsForCurrentOldSegment.IndexOfValue(currentTwficElement);
						break;
					}

					var owningStText = dtoRepos.GetOwningDTO(paraDto);
					var newTextTagGuid = Guid.NewGuid().ToString().ToLower();
					var newTextTagElement = new XElement("rt",
						new XAttribute("class", "TextTag"),
						new XAttribute("guid", newTextTagGuid),
						new XAttribute("ownerguid", owningStText.Guid.ToLower()),
						new XElement("CmObject"),
						new XElement("TextTag",
							new XElement("BeginSegment", DataMigrationServices.CreateReferenceObjSurElement(newSegmentGuid)),
							new XElement("EndSegment", DataMigrationServices.CreateReferenceObjSurElement(newSegmentGuid)),
							new XElement("BeginAnalysisIndex", new XAttribute("val", beginIdx)),
							new XElement("EndAnalysisIndex", new XAttribute("val", endIdx)),
							new XElement("Tag", DataMigrationServices.CreateReferenceObjSurElement(GetInstanceOfGuid(oldTextTagAnnElement)))));

					// Add new DTO to repos.
					var newTextTagDto = new DomainObjectDTO(newTextTagGuid, "TextTag", newTextTagElement.ToString());
					dtoRepos.Add(newTextTagDto);
					// Add new TextTag to owning prop on owner as objsur element.
					var owningStTextElement = XElement.Parse(owningStText.Xml);
					var innerStTextElement = owningStTextElement.Element("StText");
					var tagsPropElement = innerStTextElement.Element("Tags");
					if (tagsPropElement == null)
					{
						tagsPropElement = new XElement("Tags");
						innerStTextElement.Add(tagsPropElement);
					}
					tagsPropElement.Add(DataMigrationServices.CreateOwningObjSurElement(newTextTagGuid));
					// Tell repos of the modification.
					owningStText.Xml = owningStTextElement.ToString();
					dtoRepos.Update(owningStText);
				}
				// Remove current text tags from input list
				foreach (var currentTextTagElement in textTagElementsForCurrentSegment)
					oldTextTags.Remove(currentTextTagElement);
			}
			//else
			//{
			//    // No xfics at all, so make sure para is set to be tokenized again.
			//    // Done globally for each Para in ProcessParagraphs
			//    //MarkParaAsNeedingTokenization(dtoRepos, paraDto, paraElement);
			//}

			return retval;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000010.cs

示例14: PerformMigration

		public void PerformMigration(IDomainObjectDTORepository repoDto)
		{
			DataMigrationServices.CheckVersionNumber(repoDto, 7000060);

			// Step 1.A. & 3.
			//var unownedGonerCandidates = new List<DomainObjectDTO>();
			//unownedGonerCandidates.AddRange(repoDto.AllInstancesSansSubclasses("CmBaseAnnotation"));
			//unownedGonerCandidates.AddRange(repoDto.AllInstancesSansSubclasses("CmIndirectAnnotation"));
			//unownedGonerCandidates.AddRange(repoDto.AllInstancesSansSubclasses("StStyle"));
			//unownedGonerCandidates.AddRange(repoDto.AllInstancesSansSubclasses("StText"));
			//var unownedGoners = new List<DomainObjectDTO>();
			//foreach (var domainObjectDto in unownedGonerCandidates)
			//{
			//    DomainObjectDTO ownerDto;
			//    repoDto.TryGetOwner(domainObjectDto.Guid, out ownerDto);
			//    if (ownerDto != null)
			//        continue;
			//    unownedGoners.Add(domainObjectDto);
			//}
			//foreach (var unownedGoner in unownedGoners)
			//{
			//    DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, unownedGoner, false);
			//}

			// Step 1.B.
			foreach (var resourceDto in repoDto.AllInstancesSansSubclasses("CmResource"))
			{
				var resourceElement = XElement.Parse(resourceDto.Xml);
				var resourceNameElement = resourceElement.Element("Name");
				if (resourceNameElement == null)
					continue;
				var uniElement = resourceNameElement.Element("Uni");
				if (uniElement == null)
					continue;
				string oldVersion;
				switch (uniElement.Value)
				{
					case "TeStyles":
						oldVersion = "700176e1-4f42-4abd-8fb5-3c586670085d";
						break;
					case "FlexStyles":
						oldVersion = "13c213b9-e409-41fc-8782-7ca0ee983b2c";
						break;
					default:
						continue;
				}
				var versionElement = resourceElement.Element("Version");
				if (versionElement == null)
				{
					resourceElement.Add(new XElement("Version", new XAttribute("val", oldVersion)));
				}
				else
				{
					versionElement.Attribute("val").Value = oldVersion;
				}
				resourceDto.Xml = resourceElement.ToString();
				repoDto.Update(resourceDto);
			}

			// Step 2.
			var mdc = repoDto.MDC;
			foreach (var clid in mdc.GetClassIds())
			{
				if (mdc.GetAbstract(clid))
					continue;

				var className = mdc.GetClassName(clid);
				foreach (var atomicPropId in mdc.GetFields(clid, true, (int)CellarPropertyTypeFilter.AllAtomic))
				{
					var propName = mdc.GetFieldName(atomicPropId);
					var isCustomProperty = mdc.IsCustom(atomicPropId);
					foreach (var dto in repoDto.AllInstancesSansSubclasses(className))
					{
						var element = XElement.Parse(dto.Xml);
						var propElement = isCustomProperty
											  ? (element.Elements("Custom").Where(customPropElement => customPropElement.Attribute("name").Value == propName)).FirstOrDefault()
											  : element.Element(propName);
						if (propElement == null || !propElement.HasElements)
							continue;

						var objsurElements = propElement.Elements("objsur").ToList();
						if (objsurElements.Count <= 1)
							continue;

						// Remove all but first one of them.
						propElement.RemoveNodes();
						propElement.Add(objsurElements[0]);
						dto.Xml = element.ToString();
						repoDto.Update(dto);
					}
				}
			}

			// Step 4.
			DataMigrationServices.Delint(repoDto);

			DataMigrationServices.IncrementVersionNumber(repoDto);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:98,代码来源:DataMigration7000061.cs

示例15: PerformMigration

		/// <summary>
		/// 1. Create the "Strong" style if it doesn't exist (FWR-741).
		/// 2. Convert direct formatting to styles (FWR-648).
		/// 3. Move the StStyle objects in LexDb.Styles to LangProject.Styles, deleting those
		///	   with the same name as one already in LangProject.Styles (FWR-1163).
		///	4. Delete the Styles field from LexDb (FWR-1163).
		///	5. Remove "External Link" and "Internal Link" styles - migrate use of these to
		///	   "Hyperlink" style (FWR-1163).
		///	6. Rename "Language Code" style to "Writing System Abbreviation" (FWR-1163).
		///	7. Ensure that built-in styles from LangProject.Styles are marked built-in.
		/// </summary>
		public void PerformMigration(IDomainObjectDTORepository repoDTO)
		{
			m_repoDTO = repoDTO;
			// Get the list of StStyle DTOs from the LexDb.Styles field, and delete the
			// LexDb.Styles field.
			string sClass = "LexDb";
			DomainObjectDTO dtoLexDb = GetFirstInstance(sClass);
			string sXmlLexDb = dtoLexDb.Xml;
			int idxStyles = sXmlLexDb.IndexOf("<Styles>");
			int idxStylesLim = sXmlLexDb.IndexOf("</Styles>") + 9;
			string sLexDbStyles = sXmlLexDb.Substring(idxStyles, idxStylesLim - idxStyles);
			List<DomainObjectDTO> stylesLexDb = new List<DomainObjectDTO>();
			foreach (string sGuid in GetGuidList(sLexDbStyles))
			{
				var dto = m_repoDTO.GetDTO(sGuid);
				stylesLexDb.Add(dto);
			}
			dtoLexDb.Xml = sXmlLexDb.Remove(idxStyles, idxStylesLim - idxStyles);
			m_repoDTO.Update(dtoLexDb);

			// Get the list of StStyle DTOs (and style names) from the LangProject.Styles field.
			m_dtoLangProj = GetFirstInstance("LangProject");
			string sXmlLangProj = m_dtoLangProj.Xml;
			idxStyles = sXmlLangProj.IndexOf("<Styles>");
			idxStylesLim = sXmlLangProj.IndexOf("</Styles>") + 9;
			m_sLangProjStyles = sXmlLangProj.Substring(idxStyles, idxStylesLim - idxStyles);
			string sLangProjStylesOrig = m_sLangProjStyles;
			int idxEnd = m_sLangProjStyles.Length - 9;
			List<string> styleNames = new List<string>();
			m_langProjStyles.Clear();
			m_mapStyleNameToGuid.Clear();
			DomainObjectDTO dtoHyperlink = null;
			DomainObjectDTO dtoExternalLink = null;
			DomainObjectDTO dtoInternalLink = null;
			DomainObjectDTO dtoLanguageCode = null;
			DomainObjectDTO dtoWrtSysAbbr = null;
			DomainObjectDTO dtoStrong = null;
			foreach (string sGuid in GetGuidList(m_sLangProjStyles))
			{
				var dto = m_repoDTO.GetDTO(sGuid);
				string sName = GetStyleName(dto.Xml);
				styleNames.Add(sName);
				m_langProjStyles.Add(dto);
				m_mapStyleNameToGuid.Add(sName, dto.Guid.ToLowerInvariant());
				switch (sName)
				{
					case "Hyperlink":
						dtoHyperlink = dto;
						break;
					case "External Link":
						dtoExternalLink = dto;
						break;
					case "Internal Link":
						dtoInternalLink = dto;
						break;
					case "Language Code":
						dtoLanguageCode = dto;
						break;
					case "Writing System Abbreviation":
						dtoWrtSysAbbr = dto;
						break;
					case "Strong":
						dtoStrong = dto;
						break;
				}
			}
			var mapLexDbStyleGuidName = new Dictionary<string, string>();
			// For each style in the ones we might delete we need to know the name of the style it is based on and its next style
			foreach (var dto in stylesLexDb)
			{
				var elt = XElement.Parse(dto.Xml);
				var name = elt.Element("Name").Element("Uni").Value;
				mapLexDbStyleGuidName[dto.Guid] = name;
			}
			Dictionary<string, string> mapStyleGuids = new Dictionary<string, string>();
			foreach (var dto in stylesLexDb)
			{
				string sXml = dto.Xml;
				string sName = GetStyleName(sXml);
				if (styleNames.Contains(sName))
				{
					var keeperGuid = m_mapStyleNameToGuid[sName];
					mapStyleGuids.Add(dto.Guid.ToLowerInvariant(), keeperGuid);
					// Duplicate between Notebook (LangProj) styles already in the dictionary,
					// and Lexicon (LexDb) ones being added. Discard the Lexicon style OBJECT, but keep its rules.
					var dtoKeeper = repoDTO.GetDTO(keeperGuid);
					var keeperElement = XElement.Parse(dtoKeeper.Xml);
					var dropElement = XElement.Parse(dto.Xml);
					var rules = dropElement.Element("Rules");
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000018.cs


注:本文中的IDomainObjectDTORepository.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。