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


C# IDomainObjectDTORepository.GetDTO方法代码示例

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


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

示例1: VerifyReplace

		private void VerifyReplace(IDomainObjectDTORepository dtoRepos, string guid, bool expectReplace, int numOfPubs)
		{
			var dto = dtoRepos.GetDTO(guid);
			var xElt = XElement.Parse(dto.Xml);
			Assert.That(xElt.Attribute("class").Value == "LexEntry", "Giud not representing a LexEntry after migration to 7000041.");
			var hasDoNotShow = xElt.Element("DoNotShowMainEntryIn");
			string expect = "";
			if (!expectReplace)
				expect = "not ";
			Assert.That(expectReplace == (hasDoNotShow != null),
				"LexEntry " + guid + " did " + expect + "expect ExcludeAsHeadword to be replaced by DoNotShowMainEntryIn, but it didn't happen in migration to 7000041.");
			if (expectReplace)
			{ // Check that each publication is referenced
				var noShows = SurrogatesIn(xElt, "DoNotShowMainEntryIn", numOfPubs);
				var dtoPubist = dtoRepos.GetDTO(CmPossibilityListTags.kguidPublicationsList.ToString());
				Assert.That(dtoPubist != null, "This project has no Publications list after migration 7000041");
				var xPubist = XElement.Parse(dtoPubist.Xml);
				var cfElements = SurrogatesIn(xPubist, "Possibilities", numOfPubs);
				foreach (var xObj in cfElements)
				{	// there must be 1 to 1 map of objsur's in hasDoNotShow and xPubist
					string pubGuid = xObj.Attribute("guid").Value;
					int n = 0;
					foreach (var yObj in noShows)
					{
						if (pubGuid == yObj.Attribute("guid").Value)
						{
							Assert.That(yObj.Attribute("t").Value == "r", "7000041 Migrated test XML pub list items are not references");
							break;
						}
					}
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:DataMigration7000041Tests.cs

示例2: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Looks for CmFile objects included in LangProject. If found, will look for CmFile in
		/// correct location and replace reference on CmPicture with that new CmFile.
		/// </summary>
		/// <param name="repoDto">
		/// Repository of all CmObject DTOs available for one migration step.
		/// </param>
		/// <remarks>
		/// 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 repoDto)
		{
			DataMigrationServices.CheckVersionNumber(repoDto, 7000033);
			var langProj = repoDto.AllInstancesSansSubclasses("LangProject").First();
			var langProjElement = XElement.Parse(langProj.Xml);
			var pictures = langProjElement.Element("Pictures");

			if (pictures != null && pictures.Elements().Count() > 1)
			{
				DomainObjectDTO folder = null;
				bool foundFiles = false;
				foreach (var x in pictures.Elements())
				{
					var xObj = repoDto.GetDTO(x.Attribute("guid").Value);
					if (xObj.Classname == "CmFolder")
					{
						// empty folders can just be removed
						var xObjElement = XElement.Parse(xObj.Xml);
						if (xObjElement.Element("Files") == null)
							DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
						else if (folder == null)
							folder = xObj;
						else
							MoveFileReferences(repoDto, langProj, xObj, folder);
					}
					else
						foundFiles = true;
				}

				if (folder != null && foundFiles)
					RemoveInvalidFiles(repoDto, langProj, folder);

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

示例3: VerifyEntryRef

		private XElement[] VerifyEntryRef(IDomainObjectDTORepository dtoRepos, string guid, int cfCount, int showComplexFormsInCount)
		{
			var dto = dtoRepos.GetDTO(guid);
			var xElt = XElement.Parse(dto.Xml);
			SurrogatesIn(xElt, "ComponentLexemes", cfCount);
			SurrogatesIn(xElt, "PrimaryLexemes", showComplexFormsInCount);
			var cfElements = SurrogatesIn(xElt, "ShowComplexFormsIn", showComplexFormsInCount);
			return cfElements.ToArray();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:DataMigration7000040Tests.cs

示例4: PerformMigration

		/// <summary>
		/// Updates the Data Notebook RecordTypes possibilities to use specific GUIDs.
		/// </summary>
		/// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for one migration step.</param>
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000010);

			DomainObjectDTO nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
			XElement nbkElem = XElement.Parse(nbkDto.Xml);
			var recTypesGuid = (string) nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid");
			var stack = new Stack<DomainObjectDTO>(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid));
			IEnumerable<DomainObjectDTO> recDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec");
			IEnumerable<DomainObjectDTO> overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay");
			while (stack.Count > 0)
			{
				DomainObjectDTO dto = stack.Pop();
				foreach (DomainObjectDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid))
					stack.Push(childDto);
				XElement posElem = XElement.Parse(dto.Xml);
				XElement uniElem = posElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']");
				if (uniElem != null)
				{
					string newGuid = null;
					switch (uniElem.Value)
					{
						case "Con":
							newGuid = "B7B37B86-EA5E-11DE-80E9-0013722F8DEC";
							break;
						case "Intv":
							newGuid = "B7BF673E-EA5E-11DE-9C4D-0013722F8DEC";
							break;
						case "Str":
							newGuid = "B7C8F092-EA5E-11DE-8D7D-0013722F8DEC";
							break;
						case "Uns":
							newGuid = "B7D4DC4A-EA5E-11DE-867C-0013722F8DEC";
							break;
						case "Lit":
							newGuid = "B7E0C7F8-EA5E-11DE-82CC-0013722F8DEC";
							break;
						case "Obs":
							newGuid = "B7EA5156-EA5E-11DE-9F9C-0013722F8DEC";
							break;
						case "Per":
							newGuid = "B7F63D0E-EA5E-11DE-9F02-0013722F8DEC";
							break;
						case "Ana":
							newGuid = "82290763-1633-4998-8317-0EC3F5027FBD";
							break;
					}
					if (newGuid != null)
						DataMigrationServices.ChangeGuid(domainObjectDtoRepository, dto, newGuid, recDtos.Concat(overlayDtos));
				}
			}

			DomainObjectDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid);
			DataMigrationServices.ChangeGuid(domainObjectDtoRepository, recTypesDto, "D9D55B12-EA5E-11DE-95EF-0013722F8DEC", overlayDtos);
			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:60,代码来源:DataMigration7000011.cs

示例5: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Change model for Data Notebook to combine the RnEvent and RnAnalysis classes
		/// into RnGenericRec
		/// </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 its 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, 7000004);

			// 1. Change EventTypes field to RecTypes
			var nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
			var nbkElement = XElement.Parse(nbkDto.Xml);
			var nbkClsElement = nbkElement.Element("RnResearchNbk");
			var typesFieldElement = nbkClsElement.Element("EventTypes");
			var typesSurElement = typesFieldElement.Element("objsur");
			nbkClsElement.Add(new XElement("RecTypes", typesSurElement));
			typesFieldElement.Remove();
			DataMigrationServices.UpdateDTO(domainObjectDtoRepository, nbkDto, nbkElement.ToString());

			// 2. Add Analysis possibility to Record Types list
			var typesGuid = typesSurElement.Attribute("guid").Value;
			var typesDto = domainObjectDtoRepository.GetDTO(typesGuid);
			var typesElement = XElement.Parse(typesDto.Xml);
			typesElement.XPathSelectElement("CmMajorObject/Name/AUni[@ws='en']").SetValue("Entry Types");
			var posElement = typesElement.XPathSelectElement("CmPossibilityList/Possibilities");
			posElement.Add(
				DataMigrationServices.CreateOwningObjSurElement("82290763-1633-4998-8317-0EC3F5027FBD"));
			DataMigrationServices.UpdateDTO(domainObjectDtoRepository, typesDto,
				typesElement.ToString());
			var ord = posElement.Elements().Count();

			var nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
			var typeElement = new XElement("rt", new XAttribute("class", "CmPossibility"),
				new XAttribute("guid", "82290763-1633-4998-8317-0EC3F5027FBD"),
				new XAttribute("ownerguid", typesGuid),
				new XAttribute("owningflid", "8008"), new XAttribute("owningord", ord.ToString()),
				new XElement("CmObject"),
				new XElement("CmPossibility",
					new XElement("Abbreviation",
						new XElement("AUni", new XAttribute("ws", "en"), "Ana")),
					new XElement("BackColor", new XAttribute("val", "16711680")),
					new XElement("DateCreated", new XAttribute("val", nowStr)),
					new XElement("DateModified", new XAttribute("val", nowStr)),
					new XElement("Description",
						new XElement("AStr", new XAttribute("ws", "en"),
							new XElement("Run", new XAttribute("ws", "en"), "Reflection on events and other types of data, such as literature summaries or interviews. An analysis does not add data; it interprets and organizes data. An analysis entry may synthesize emerging themes. It may draw connections between observations. It is a place to speculate and hypothesize, or document moments of discovery and awareness. Analytic notes can be turned into articles. Or, they may just be steps on the stairway toward greater understanding."))),
					new XElement("ForeColor", new XAttribute("val", "16777215")),
					new XElement("Name",
						new XElement("AUni", new XAttribute("ws", "en"), "Analysis")),
					new XElement("UnderColor", new XAttribute("val", "255")),
					new XElement("UnderStyle", new XAttribute("val", "1"))));
			domainObjectDtoRepository.Add(new DomainObjectDTO("82290763-1633-4998-8317-0EC3F5027FBD",
				"CmPossibility", typeElement.ToString()));

			// 3. Move the attributes that are in RnEvent and RnAnalysis into RnGenericRec.
			MigrateSubclassOfGenRec(domainObjectDtoRepository, "RnEvent");
			MigrateSubclassOfGenRec(domainObjectDtoRepository, "RnAnalysis");

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

示例6: PerformMigration

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

			var newGuidValue = Guid.NewGuid().ToString().ToLowerInvariant();
			const string className = "WfiMorphBundle";
			var wmbList = domainObjectDtoRepository.AllInstancesSansSubclasses(className);
			foreach (var wmb in wmbList)
			{
				XElement wmbElt = XElement.Parse(wmb.Xml);
				var morphElt = wmbElt.Element("Morph");
				// if we don't have a morph reference,
				// then there's nothing to copy into the form field.
				if (morphElt == null)
					continue;
				var objsurElt = morphElt.Element("objsur");
				var dtoMorphTarget = domainObjectDtoRepository.GetDTO(objsurElt.Attribute("guid").Value);
				// for each form alternative, copy the writing system

				// if for some reason there is a morphbundle form that already exists, delete it before inserting another.
				var formElt = wmbElt.Element("Form");
				if (formElt != null)
					formElt.Remove();

				var morphTargetElt = XElement.Parse(dtoMorphTarget.Xml);
				var morphTargetFormElt = morphTargetElt.Element("Form");
				if (morphTargetFormElt == null)
					continue;
				formElt = XElement.Parse("<Form/>");
				wmbElt.AddFirst(formElt);
				foreach (var aUniElt in morphTargetFormElt.Elements("AUni"))
				{
					string ws = aUniElt.Attribute("ws").Value;
					string form = aUniElt.Value;
					var newFormAltElt = XElement.Parse(String.Format("<AStr ws=\"{0}\"/>", ws));
					formElt.Add(newFormAltElt);
					var newRunElt = XElement.Parse(String.Format("<Run ws=\"{0}\">{1}</Run>", ws, XmlUtils.MakeSafeXml(form)));
					newFormAltElt.Add(newRunElt);
				}
				DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wmb, wmbElt.ToString());
			}

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

示例7: 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

示例8: GetPossibilityListNameElement

		private static XElement GetPossibilityListNameElement(IDomainObjectDTORepository dtoRepos,
			XElement ownerElement, string flidName)
		{
			Assert.IsNotNull(ownerElement.XPathSelectElement(flidName));
			var xPath = flidName+"/objsur";
			var dto = dtoRepos.GetDTO(ownerElement.XPathSelectElement(xPath).Attribute("guid").Value);
			return XElement.Parse(dto.Xml).XPathSelectElement("Name");
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:8,代码来源:DataMigration7000022Tests.cs

示例9: PerformMigration

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

			var revIndexList = domainObjectDtoRepository.AllInstancesSansSubclasses("ReversalIndex");
			foreach (var revIndexDto in revIndexList)
			{
				var dirty = false;
				// grab ws name(s) from each Reversal Index
				var wsCodeNameDict = new Dictionary<string, string>();
				GetWsNamesFromReversalIndex(revIndexDto, wsCodeNameDict);

				// Find PartsOfSpeech possibility list
				string possListGuid;
				if (!GetGuidForPosListSafely(revIndexDto, out possListGuid))
					continue; // Can't find the PartsOfSpeech list without a guid!
				var posListDto = domainObjectDtoRepository.GetDTO(possListGuid);
				var listElt = XElement.Parse(posListDto.Xml);

				// Check for the right Depth, ItemClsid and IsSorted values
				var depthElt = listElt.Element(DepthProp);
				if (depthElt != null)
					depthElt.Remove(); // Don't want the old one, it was wrong!
				// Replace with a new Property
				var sbDepth = new StringBuilder();
				sbDepth.Append(OpenCloseTagWithValAttr(DepthProp, "127"));
				depthElt = XElement.Parse(sbDepth.ToString());
				listElt.Add(depthElt);
				var clsIdElt = listElt.Element(ClsProp);
				if (clsIdElt == null) // Don't replace an existing value
				{
					// Create the new property
					var sb = new StringBuilder();
					sb.Append(OpenCloseTagWithValAttr(ClsProp, Convert.ToString(PosClsId)));
					clsIdElt = XElement.Parse(sb.ToString());
					listElt.Add(clsIdElt);
					dirty = true;
				}
				var sortedElt = listElt.Element(SortProp);
				if (sortedElt == null)
				{
					var sb = new StringBuilder();
					sb.Append(OpenCloseTagWithValAttr(SortProp, Truth));
					sortedElt = XElement.Parse(sb.ToString());
					listElt.Add(sortedElt);
					dirty = true;
				}
				if (sortedElt.Attribute("val").Value != Truth)
				{
					sortedElt.SetAttributeValue("val", Truth);
					dirty = true;
				}

				// If Name exists skip it, otherwise put a valid name in for each ws that RI Name had.
				var nameElt = listElt.Element(Name);
				if (nameElt == null || nameElt.Element(Auni) == null)
				{
					if (nameElt != null)
						nameElt.Remove(); // Just in case we end up with an empty name element
					var sb = new StringBuilder();
					sb.Append(OpenTag(Name));
					foreach (var kvp in wsCodeNameDict)
					{
						var wsCode = kvp.Key;
						var wsName = kvp.Value;
						sb.AppendFormat(OpenTagWithWsAttr(Auni, wsCode));
						sb.AppendFormat(Strings.ksReversalIndexPOSListName, wsName);
						sb.Append(EndTag(Auni));
					}
					sb.Append(EndTag(Name));
					nameElt = XElement.Parse(sb.ToString());
					listElt.Add(nameElt);
					dirty = true;
				}
				if (dirty)
					DataMigrationServices.UpdateDTO(domainObjectDtoRepository, posListDto, listElt.ToString());
			}

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

示例10: RemoveInvalidFiles

		private void RemoveInvalidFiles(IDomainObjectDTORepository repoDto,
			DomainObjectDTO langProj, DomainObjectDTO folder)
		{
			var langProjElement = XElement.Parse(langProj.Xml);
			var pictures = langProjElement.Element("Pictures");
			var fileMap = CreateFilePathToGuidMap(repoDto, folder);
			var pictureMap = CreateFileGuidToPictureMap(repoDto);
			foreach (var x in pictures.Elements())
			{
				var xObj = repoDto.GetDTO(x.Attribute("guid").Value);
				if (xObj.Classname == "CmFile")
				{
					string replacementFileGuid;
					string filePath = GetFilePath(xObj);
					if (filePath != null &&
						fileMap.TryGetValue(filePath.ToLowerInvariant(), out replacementFileGuid))
					{
						UpdatePictureReferences(repoDto, xObj, replacementFileGuid, pictureMap);
						DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
					}
					else if (!pictureMap.ContainsKey(xObj.Guid))
						DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
					else
					{
						MoveFileToFolder(repoDto, folder, xObj);
						RemoveReferenceFromPictures(repoDto, langProj, xObj.Guid);
					}
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:30,代码来源:DataMigration7000034.cs

示例11: IsWeatherUsed

		private bool IsWeatherUsed(IDomainObjectDTORepository repoDTO, List<DomainObjectDTO> collectOverlaysToRemove)
		{
			DomainObjectDTO dtoLP = GetDtoLangProj(repoDTO);
			string sLpXml = dtoLP.Xml;
			int idxW = sLpXml.IndexOf("<WeatherConditions>");
			var sguidWeather = ExtractFirstGuid(sLpXml, idxW, " guid=\"");
			DomainObjectDTO dtoWeather = repoDTO.GetDTO(sguidWeather);
			var weatherItems = new HashSet<string>();
			CollectItems(repoDTO, dtoWeather, weatherItems);
			foreach (var dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec"))
			{
				string sXml = dto.Xml;
				int idx = sXml.IndexOf("<Weather>");
				if (idx > 0)
				{
					int idxEnd = sXml.IndexOf("</Weather>");
					if (idxEnd > idx)
					{
						string s = sXml.Substring(idx, idxEnd - idx);
						if (s.Contains("<objsur "))
						{
							return true;
						}
					}
				}
				bool dummy = false;
				if (StringContainsRefToItemInList("PhraseTags", weatherItems, sXml, ref dummy)) return true;
			}
			foreach (var dto in repoDTO.AllInstancesSansSubclasses("CmOverlay"))
			{
				string sXml = dto.Xml;
				bool hasOtherItems = false;
				bool hasWeatherRef = StringContainsRefToItemInList("PossItems", weatherItems, sXml, ref hasOtherItems);
				var weatherListSet = new HashSet<string>();
				weatherListSet.Add(sguidWeather.ToLowerInvariant());
				hasWeatherRef |= StringContainsRefToItemInList("PossList", weatherListSet, sXml, ref hasOtherItems);
				if (hasWeatherRef)
				{
					if (hasOtherItems)
						return true; // an overlay with a mixture of weather and non-weather items is a problem
					// One with only weather refs (and not used, since we know nothing is tagged to weather)
					// will be deleted.
					collectOverlaysToRemove.Add(dto);
				}
			}
			return false;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:47,代码来源:DataMigration7000017.cs

示例12: PerformMigration

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Combine Sense and Sense Status lists into the Sense list.
		/// </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 its 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, 7000023);

			// 1. Change the owning property from LangProject_AnalysisStatus to LangProject_Status

			string statusConfirmedGuid = "";
			IEnumerable<XElement> langPossList = null;
			var langProjDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
			var langProjElement = XElement.Parse(langProjDto.Xml);
			var statusElement = langProjElement.Element("AnalysisStatus");
			if (statusElement != null)
				statusElement.Name= "Status";
			UpdateDto(domainObjectDtoRepository,langProjDto,langProjElement);

			var langPossListGuid = GetGuidOfObjSurChild(statusElement);

			var langPossListDto = domainObjectDtoRepository.GetDTO(langPossListGuid);
			var langPossListElement = XElement.Parse(langPossListDto.Xml);

			var langPossListPossibilities = langPossListElement.Element("Possibilities");
			if (langPossListPossibilities == null)
			{
				langPossListElement.Add(XElement.Parse("<Possibilities></Possibilities>"));
				UpdateDto(domainObjectDtoRepository,langPossListDto,langPossListElement);
				// Put the 'Confirmed' status into the list.
				statusConfirmedGuid = MakeStatus(domainObjectDtoRepository, langPossListGuid, langPossListElement,
					"Confirmed", "Conf");
				langPossList = GetPossibilitiesInList(domainObjectDtoRepository, langPossListElement);
				UpdateDto(domainObjectDtoRepository,langPossListDto,langPossListElement);
			}
			else
			{
				// Get the actual elements that represent the possibility items in the AnalysisStatus possibility list.
				langPossList = GetPossibilitiesInList(domainObjectDtoRepository, langPossListElement);

				// 1a.  Verify the 'Confirmed' status exists in the list.
				statusConfirmedGuid = IsStatusInList(langPossList, "Confirmed");
				if (statusConfirmedGuid == null) //if not, add it
				{
					statusConfirmedGuid = MakeStatus(domainObjectDtoRepository, langPossListGuid, langPossListElement,
						"Confirmed", "Conf");
				}
				UpdateDto(domainObjectDtoRepository,langPossListDto,langPossListElement);
			}

			// 1b.  If any rnGeneric records point to the 'Approved' status, point them to 'Confirnmed'.
			var approvedGuid = IsStatusInList(langPossList, "Approved");
			if (approvedGuid != null)
				ReassignStatuses(domainObjectDtoRepository, approvedGuid, statusConfirmedGuid);

			// 2. Get the pointers to the Lexdb Status list (sense status)
			var lexDbElement = langProjElement.Element("LexDb");
			if (lexDbElement != null)
			{
				var lexDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LexDb").First();
				var lexElement = XElement.Parse(lexDto.Xml);
				var lexPossListGuid = GetGuidOfObjSurChild(lexElement.Element("Status"));

				var lexPossListDto = domainObjectDtoRepository.GetDTO(lexPossListGuid);
				var lexPossListElement = XElement.Parse(lexPossListDto.Xml);

				var lexPossList = GetPossibilitiesInList(domainObjectDtoRepository, lexPossListElement).ToList();

				var statusMap = new Dictionary<string, string>();

				// figure out the status substitutions we need to do.
				var langPossibilitiesElt = langPossListElement.Element("Possibilities");
				var lexPossibilitiesElt = lexPossListElement.Element("Possibilities");

				foreach (var lexStatus in lexPossList)
				{
					var nameElt = lexStatus.XPathSelectElement("Name/AUni[@ws='en']");
					var name = nameElt == null ? "" : nameElt.Value; // may have no English name
					if (name == "Approved") name = "Confirmed";
					var lexStatusGuid = lexStatus.Attribute("guid").Value;
					var langStatusGuid = IsStatusInList(langPossList, name);
					if (langStatusGuid == null)
					{
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000024.cs

示例13: CheckPara

		private static DomainObjectDTO CheckPara(IDomainObjectDTORepository dtoRepos, string paraGuid,
			int segmentCount, bool checkForParseIsCurrent, bool expectedParseIsCurrentValue,
			out List<XElement> newSegmentObjSurElements)
		{
			var currentParaDto = dtoRepos.GetDTO(paraGuid);
			var newParaElement = XElement.Parse(currentParaDto.Xml);
			var stTxtParaInnerElement = newParaElement.Element("StTxtPara");
			var segmentsElement = stTxtParaInnerElement.Element("Segments");
			if (segmentCount == 0)
			{
				newSegmentObjSurElements = null;
				Assert.IsNull(segmentsElement, "Existing Segments element.");
			}
			else
			{
				Assert.IsNotNull(segmentsElement, "Missing Segments element.");
				// Check that it has correct number of new segments.
				newSegmentObjSurElements = segmentsElement.Elements("objsur").ToList();
				Assert.IsNotNull(newSegmentObjSurElements, "Missing objsur elements.");
				Assert.AreEqual(segmentCount, newSegmentObjSurElements.Count(), "Wrong number of new segments.");
			}

			if (checkForParseIsCurrent)
			{
				Assert.AreEqual(expectedParseIsCurrentValue,
					bool.Parse(stTxtParaInnerElement.Element("ParseIsCurrent").Attribute("val").Value),
					"Wrong value for ParseIsCurrent.");
			}

			return currentParaDto;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:31,代码来源:DataMigration7000010Tests.cs

示例14: CheckNotes

		private static void CheckNotes(IDomainObjectDTORepository dtoRepos, DomainObjectDTO newSegmentDto, ICollection noteGuids, XContainer newSegmentInnerElement, bool expectedToHaveNotes, int expectedNumberOfNotes)
		{
			// Check Nts.
			var notesElements = newSegmentInnerElement.Elements("Notes");
			if (!expectedToHaveNotes)
			{
				Assert.AreEqual(0, notesElements.Count(), "Had unexpected number of notes.");
				return;
			}

			var objsurElements = notesElements.Elements("objsur");
			Assert.AreEqual(expectedNumberOfNotes, objsurElements.Count(), "Wrong number of Notes.");
			foreach (var objsurElement in objsurElements)
			{
				// Make sure the objsur guid is in 'noteGuids'.
				var objsurGuid = objsurElement.Attribute("guid").Value;
				Assert.Contains(objsurGuid, noteGuids);

				// Make sure the objsur element is t="o" (owning).
				var type = objsurElement.Attribute("t").Value;
				Assert.AreEqual("o", type, "Not an owning property.");

				// Make sure the owner of the objsur guid is the new Segment.
				var noteDto = dtoRepos.GetDTO(objsurGuid);
				Assert.AreSame(newSegmentDto, dtoRepos.GetOwningDTO(noteDto));

				// Each Nt should have two alts.
				var noteElement = XElement.Parse(noteDto.Xml);
				var contentElement = noteElement.Element("Note").Element("Content");
				Assert.IsNotNull(contentElement, "No Nt Content element.");
				CheckAlternatives(contentElement, 2);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:DataMigration7000010Tests.cs

示例15: CheckXfics

		private static void CheckXfics(IDomainObjectDTORepository dtoRepos,
			XContainer newSegmentInnerElement, int expectedAnalysesCount,
			IList<string> analysesGuids)
		{
			var analysesElement = newSegmentInnerElement.Element("Analyses");
			if (expectedAnalysesCount == 0)
			{
				if (analysesElement != null)
					Assert.AreEqual(expectedAnalysesCount, analysesElement.Elements("objsur").Count(), "Unexpected analyses.");
				return; // nothing else to check (and it's OK if the element is null
			}
			Assert.IsNotNull(analysesElement, "Missing Analyses Element in the new Segment object.");
			var analObjSurElements = analysesElement.Elements("objsur");
			Assert.AreEqual(expectedAnalysesCount, analObjSurElements.Count(), "Wrong Analyses count.");
			for (var i = 0; i < expectedAnalysesCount; ++i)
			{
				var newAnalObjsurElement = analObjSurElements.ElementAt(i);
				Assert.IsNotNull(newAnalObjsurElement, "Missing objsur Element in the new Analyses element.");
				Assert.AreEqual("r", newAnalObjsurElement.Attribute("t").Value, "Not a reference property.");
				var analysisDto = dtoRepos.GetDTO(newAnalObjsurElement.Attribute("guid").Value);
				Assert.IsNotNull(analysisDto, "Missing analysis dto.");

				// Make sure the right analysis guid is used.
				Assert.AreEqual(analysesGuids[i].ToLower(), analysisDto.Guid.ToLower(), "Wrong guid.");
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:26,代码来源:DataMigration7000010Tests.cs


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