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


C# IDomainObjectDTORepository.Add方法代码示例

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


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

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

示例2: ChangeInvalidGuid

		private void ChangeInvalidGuid(IDomainObjectDTORepository repoDto, LexTypeInfo info,
			string name, string guidStd)
		{
			var xaGuid = info.XmlElement.Attribute("guid");
			if (xaGuid == null)
				throw new Exception("The object does not have a guid -- this is impossible!");
			xaGuid.SetValue(guidStd);
			var guidBad = info.DTO.Guid;
			if (!m_mapBadGoodGuids.ContainsKey(guidBad))
				m_mapBadGoodGuids.Add(guidBad, guidStd);
			var className = info.DTO.Classname;
			repoDto.Remove(info.DTO);
			info.DTO = new DomainObjectDTO(guidStd, className, info.XmlElement.ToString());
			repoDto.Add(info.DTO);
			// Fix the owning reference (but only if it's one of the two lists, because otherwise
			// it might be contained in a LexTypeInfo that hasn't yet been processed).
			var bad = String.Format("guid=\"{0}\"", guidBad);
			var good = String.Format("guid=\"{0}\"", guidStd);
			var bad2 = String.Format("guid='{0}'", guidBad);	// probably pure paranoia...
			var good2 = String.Format("guid='{0}'", guidStd);
			DomainObjectDTO dtoOwner;
			if (repoDto.TryGetOwner(info.DTO.Guid, out dtoOwner) && dtoOwner.Classname == "CmPossibilityList")
			{
				dtoOwner.Xml = dtoOwner.Xml.Replace(bad, good).Replace(bad2, good2);
				repoDto.Update(dtoOwner);
			}
			// Fix any references from LexEntryRef objects.
			foreach (var dtoRef in repoDto.AllInstancesWithSubclasses("LexEntryRef"))
			{
				var xml = dtoRef.Xml;
				if (xml.Contains(guidBad))
				{
					dtoRef.Xml = xml.Replace(bad, good).Replace(bad2, good2);
					repoDto.Update(dtoRef);
				}
			}
			m_mapNameGuid.Remove(name);
			m_mapGuidName.Remove(guidStd);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:39,代码来源:DataMigration7000042.cs

示例3: FixOrAddMissingTypes

		private void FixOrAddMissingTypes(IDomainObjectDTORepository repoDto, IEnumerable<LexTypeInfo> extraTypes)
		{
			foreach (var info in extraTypes)
			{
				var fChanged = false;
				foreach (var xeAUni in info.XmlElement.XPathSelectElements("Name/AUni"))
				{
					var xaWs = xeAUni.Attribute("ws");
					if (xaWs == null || xaWs.Value.ToLowerInvariant() != "en")
						continue;
					var name = xeAUni.Value;
					string guidStd;
					if (!m_mapNameGuid.TryGetValue(name, out guidStd))
						continue;
					// We need to change the guid of this dto from 'guid to 'guidStd
					ChangeInvalidGuid(repoDto, info, name, guidStd);
				}
				var xeProt = info.XmlElement.XPathSelectElement("IsProtected");
				if (xeProt == null)
				{
					info.XmlElement.Add(new XElement("IsProtected", new XAttribute("val", "true")));
					fChanged = true;
				}
				else
				{
					var xaVal = xeProt.Attribute("val");
					if (xaVal == null)
					{
						xeProt.Add(new XAttribute("val", "true"));
						fChanged = true;
					}
					else if (xaVal.Value.ToLowerInvariant() != "true")
					{
						xaVal.SetValue("true");
						fChanged = true;
					}
				}
				if (fChanged)
				{
					info.DTO.Xml = info.XmlElement.ToString();
					repoDto.Update(info.DTO);
				}
			}

			if (m_mapNameGuid.Count > 0)
			{
				BuildNewTypeMaps();
				var newTypes = new HashSet<DomainObjectDTO>();
				foreach (var guid in m_mapGuidName.Keys)
				{
					// We need to create this LexEntryType!
					var rgNewDtos = m_mapGuidNewDtos[guid];
					foreach (var info in rgNewDtos)
					{
						var dto = new DomainObjectDTO(info.Guid, info.ClassName, info.Xml);
						repoDto.Add(dto);
						if (info.ClassName == "LexEntryType")
							newTypes.Add(dto);

					}
				}
				foreach (var dto in newTypes)
				{
					var dtoOwner = repoDto.GetOwningDTO(dto);
					var xeOwner = XElement.Parse(dtoOwner.Xml);
					XElement xePoss = null;
					if (dtoOwner.Classname == "CmPossibilityList")
					{
						xePoss = xeOwner.Element("Possibilities");
						if (xePoss == null)
						{
							xePoss = new XElement("Possibilities");
							xeOwner.Add(xePoss);
						}
					}
					else if (dtoOwner.Classname == "LexEntryType")
					{
						xePoss = xeOwner.Element("SubPossibilities");
						if (xePoss == null)
						{
							xePoss = new XElement("SubPossibilities");
							xeOwner.Add(xePoss);
						}
					}
					if (xePoss != null)
					{
						var fNeeded = true;
						foreach (var objsur in xePoss.Elements("objsur"))
						{
							var xaGuid = objsur.Attribute("guid");
							if (xaGuid == null)
								throw new Exception("missing guid in an objsur element");
							if (xaGuid.Value.Equals(dto.Guid, StringComparison.OrdinalIgnoreCase))
							{
								fNeeded = false;
								break;
							}
						}
						if (fNeeded)
						{
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000042.cs

示例4: PerformMigration

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

			// (WRONG) The ExcludeAsHeadword element only appears when @val="true" and
			// it is to be replaced by DoNotShowMainEntryIn with a list of all publications.
			// NB: The above statement is simply not true (RBR).
			// FW 7 writes out all primitive data properties.
			// The FW 6-FW7 migrator doesn't add them,
			// but FW 7 writes them the next time an object gets changed.

			// Make the list of publications once
			var newElt = new XElement("DoNotShowMainEntryIn");

			IEnumerable<XElement> dtoPubList = null;
			// XPATH: rt[Name/AUni='Publications']/Possibilities/objsur
			foreach (var a_list in domainObjectDtoRepository.AllInstancesSansSubclasses("CmPossibilityList"))
			{
				var xList = XElement.Parse(a_list.Xml);
				if (xList.XPathSelectElement("Name[AUni='Publications']") == null) continue;
				dtoPubList = xList.XPathSelectElements("Possibilities/objsur");
				if (dtoPubList != null && dtoPubList.Count() > 0) break;
			}

			if (dtoPubList == null || dtoPubList.Count() == 0) // add the Publications list to the project
			{   // This list is owned by LexDb
				var ieDtoLexDb = domainObjectDtoRepository.AllInstancesSansSubclasses("LexDb");
				Debug.Assert(ieDtoLexDb != null && ieDtoLexDb.Count<DomainObjectDTO>() == 1, "Project has no LexDb Dto or more than one");
				var dtoLexDb = ieDtoLexDb.First<DomainObjectDTO>();
				var xNode = XElement.Parse(dtoLexDb.Xml);
				var ksguidLexDb = xNode.Attribute("guid").Value;
				var nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
				string xmlStrPub =
"<rt guid=\"" + ksguidPubList + "\" class=\"CmPossibilityList\" ownerguid=\"" + ksguidLexDb + "\"><Name><AUni ws=\"en\">Publications</AUni></Name><DateCreated val=\"" + nowStr + "\" /><DateModified val=\"" + nowStr + "\" /><Depth val=\"1\" /><PreventChoiceAboveLevel val=\"0\" /><IsSorted val=\"True\" /><IsClosed val=\"False\" /><PreventDuplicates val=\"False\" /><PreventNodeChoices val=\"False\" /><UseExtendedFields val=\"False\" /><DisplayOption val=\"0\" /><ItemClsid val=\"7\" /><IsVernacular val=\"False\" /><WsSelector val=\"0\" /><ListVersion val=\"00000000-0000-0000-0000-000000000000\" /><Possibilities><objsur guid=\"" + ksguidMainDictionary + "\" t=\"o\" /></Possibilities></rt>";
				var dtoPub = new DomainObjectDTO(ksguidPubList, "CmPossibilityList", xmlStrPub);

				string xmlStrMD = "<rt guid=\"" + ksguidMainDictionary + "\" class=\"CmPossibility\" ownerguid=\"" + ksguidPubList + "\"><Name><AUni ws=\"en\">Main Dictionary</AUni></Name><Abbreviation><AUni ws=\"en\">Main</AUni></Abbreviation><SortSpec val=\"0\" /><DateCreated val=\"" + nowStr + "\" /><DateModified val=\"" + nowStr + "\" /><ForeColor val=\"0\" /><BackColor val=\"0\" /><UnderColor val=\"0\" /><UnderStyle val=\"0\" /><Hidden val=\"False\" /><IsProtected val=\"True\" /></rt>";
				var dtoMD = new DomainObjectDTO(ksguidMainDictionary, "CmPossibility", xmlStrMD);

				domainObjectDtoRepository.Add(dtoMD);
				domainObjectDtoRepository.Add(dtoPub);

				// Make xLexDb own dtoPub
				var xPts = xNode.Element("PublicationTypes");
				if (xPts == null)
				{   // add one to LexDb
					xPts = new XElement("PublicationTypes");
					xPts.Add(DataMigrationServices.CreateOwningObjSurElement(ksguidPubList));
					xNode.Add(xPts);
				}
				Debug.Assert(xPts != null, "LexDb has no PublicatonTypes and won't accept new ones.");
				dtoLexDb.Xml = xNode.ToString();
				domainObjectDtoRepository.Update(dtoLexDb);
				newElt.Add(DataMigrationServices.CreateReferenceObjSurElement(ksguidMainDictionary));
			}
			else
			{   // already had a publications list - add all to DoNotShowMainEntryIn
				foreach (var xElt in dtoPubList)
				{   // change the t attr to "r" reference instead of "o" own.
					var xPubRef = new XElement(xElt);
					xPubRef.SetAttributeValue("t", "r");
					newElt.Add(xPubRef);
				}
			}
			foreach (var dto in domainObjectDtoRepository.AllInstancesSansSubclasses("LexEntry"))
			{
				// (WRONG) The ExcludeAsHeadword element only appears when @val="true" unless played with in a text editor
				// NB: The above statement is simply not true (RBR).
				// FW 7 writes out all primitive data properties.
				// The FW 6-FW7 migrator doesn't add them,
				// but FW 7 writes them the next time an object gets changed.
				var xElt = XElement.Parse(dto.Xml);
				var exHeadword = xElt.Element("ExcludeAsHeadword");
				if (exHeadword == null)
					continue;
				XAttribute XAval = exHeadword.Attribute("val");
				// It must be upper-case, since that is what is output.
				if (XAval.Value == "True")
				{	// Add all publications from the list to this property
					xElt.Add(new XElement(newElt));
				}
				exHeadword.Remove(); // exHeadword.Value may be True, False or invalid
				dto.Xml = xElt.ToString();
				domainObjectDtoRepository.Update(dto);
			}
			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:87,代码来源:DataMigration7000041.cs

示例5: MakeStatus

		private string MakeStatus(IDomainObjectDTORepository domainObjectDtoRepository, string langPossListGuid,
			XElement langPossListElement, string name, string abbr)
		{
			string statusConfirmedGuid;
			statusConfirmedGuid = Guid.NewGuid().ToString();
			var confirmed = new XElement("rt",
										 new XAttribute("class", "CmPossibility"),
										 new XAttribute("guid", statusConfirmedGuid),
										 new XAttribute("ownerguid", langPossListGuid),
										 MakeMultiUnicode("Name", name),
										 MakeMultiUnicode("Abbreviation", abbr));
			var dtoConfirmed = new DomainObjectDTO(statusConfirmedGuid, "CmPossibility", confirmed.ToString());
			domainObjectDtoRepository.Add(dtoConfirmed);
			langPossListElement.Element("Possibilities").Add(MakeOwningSurrogate(statusConfirmedGuid));
			return statusConfirmedGuid;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:16,代码来源:DataMigration7000024.cs

示例6: MakeCmFile

		// Make a new CmFile element for the specified path, and an objsur child of langCmFolder to own it.
		// In this migration a typical result would be:
		//    <rt guid="c4f4760e-049e-49af-ac57-73c686100700" class="CmFile" ownerguid="3e615e09-3b86-4fae-adfe-5fc2473214b6">
		//    <InternalPath>
		//        <Uni>C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV</Uni>
		//    </InternalPath>
		//    </rt>
		private void MakeCmFile(IDomainObjectDTORepository domainObjectDtoRepository, string langCmFolderGuid,
			XElement langCmFolder, string path)
		{
			string cmFileGuid;
			cmFileGuid = Guid.NewGuid().ToString();
			var cmFileXElement = new XElement("rt",
										 new XAttribute("guid", cmFileGuid),
										 new XAttribute("class", "CmFile"),
										 new XAttribute("ownerguid", langCmFolderGuid),
										 MakeUnicode("InternalPath", path));
			var dtoConfirmed = new DomainObjectDTO(cmFileGuid, "CmFile", cmFileXElement.ToString());
			domainObjectDtoRepository.Add(dtoConfirmed);
			langCmFolder.Element("Files").Add(MakeOwningSurrogate(cmFileGuid));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:21,代码来源:DataMigration7000030.cs

示例7: MakeCmFolder

		// Creates a CmFolder whose owning guid is the langProjectGuid passed as a child of the element passed
		// and gives it the name passed. In this migration a typical result (after later code adds the Files) would be:
		// <rt guid="3e615e09-3b86-4fae-adfe-5fc2473214b6" class="CmFolder" ownerguid="b8bdad3d-9006-46f0-83e8-ae1d1726f2ad">
		//    <Name>
		//        <AUni ws="pt">File paths in TsStrings</AUni>
		//    </Name>
		//    <Files>
		//        <objsur guid="c4f3760e-049e-49af-ac57-73c686100700" t="o" />
		//        <objsur guid="c4f4760e-049e-49af-ac57-73c686100700" t="o" />
		//    </Files>
		//</rt>
		private XElement MakeCmFolder(IDomainObjectDTORepository domainObjectDtoRepository, string langProjectGuid,
			XElement filePathsInTsStringsCmFolder, string name, out DomainObjectDTO folderDto)
		{
			string cmFolderGuid;
			cmFolderGuid = Guid.NewGuid().ToString();
			var cmFolderXML = new XElement("rt",
										 new XAttribute("guid", cmFolderGuid),
										 new XAttribute("class", "CmFolder"),
										 new XAttribute("ownerguid", langProjectGuid),
										 MakeMultiUnicode("Name", name),
										 new XElement("Files"));
			folderDto = new DomainObjectDTO(cmFolderGuid, "CmFolder", cmFolderXML.ToString());
			domainObjectDtoRepository.Add(folderDto);
			filePathsInTsStringsCmFolder.Add(MakeOwningSurrogate(cmFolderGuid));
			return cmFolderXML;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:DataMigration7000030.cs

示例8: EnsurePficHasInstanceOf


//.........这里部分代码省略.........

			if (beginOffset > endOffset)
			{
				// Bad begin or end offset.
				MarkParaAsNeedingTokenization(dtoRepos, paraDto);
				return false;
			}
			if (beginOffset < 0)
			{
				// Bad begin offset.
				MarkParaAsNeedingTokenization(dtoRepos, paraDto);
				return false;
			}
			// Concatenate data from all runs.
			List<string> writingSystems;
			var runs = GetParagraphContentRuns(paraDto.XmlBytes, out writingSystems);
			Debug.Assert(runs.Count == writingSystems.Count);
			var bldr = new StringBuilder();
			for (int i = 0; i < runs.Count; ++i)
				bldr.Append(runs[i]);
			var fullParaContents = Icu.Normalize(bldr.ToString(), Icu.UNormalizationMode.UNORM_NFD);
			if (endOffset > fullParaContents.Length)
			{
				// Total string is too short (end offset beyond end of string).
				MarkParaAsNeedingTokenization(dtoRepos, paraDto);
				return false;
			}
			// Find the form of the punctuation mark.
			var newForm = fullParaContents.Substring(beginOffset, endOffset - beginOffset);
			if (newForm == String.Empty)
			{
				// No punctuation form at all.
				MarkParaAsNeedingTokenization(dtoRepos, paraDto);
				return false;
			}
			var icuLocale = String.Empty;
			// Find the ws's IcuLocale at the begin offset in whichever run it is in.
			var currentTotalLength = 0;
			for (var i = 0; i < runs.Count; ++i)
			{
				var currentRunText = Icu.Normalize(runs[i], Icu.UNormalizationMode.UNORM_NFD);
				currentTotalLength += currentRunText.Length;
				if (beginOffset >= currentTotalLength)
					continue; // Not in this run.

				if (endOffset > currentTotalLength)
				{
					// It starts in one run and ends in another, so bail out.
					MarkParaAsNeedingTokenization(dtoRepos, paraDto);
					return false;
				}
				// It's all in this run, so quit looking at runs.
				icuLocale = writingSystems[i];
				break;
			}

			if (icuLocale == String.Empty)
			{
				// Hard to say how we can get here, but something is very wrong.
				MarkParaAsNeedingTokenization(dtoRepos, paraDto);
				return false;
			}

			// If the new PF is all in one run, and we have its IcuLocale,
			// then make the new PF object, and return true.
			// Find/Create PunctuationForm object that has a Form in the matching IcuLocale & matching string.
			var key = icuLocale + "-" + newForm;
			DomainObjectDTO dtoMatchingPf;
			if (!newPunctForms.TryGetValue(key, out dtoMatchingPf))
			{
				// Create new PunctuationForm dto.
				var newPunctFormGuid = Guid.NewGuid().ToString().ToLower();
				const string className = "PunctuationForm";
				var newPfElement = new XElement("rt",
					new XAttribute("class", className),
					new XAttribute("guid", newPunctFormGuid),
					new XElement("CmObject"),
					new XElement("PunctuationForm",
						new XElement("Form",
							new XElement("Str",
								new XElement("Run", new XAttribute("ws", icuLocale), newForm)))));
				dtoMatchingPf = new DomainObjectDTO(newPunctFormGuid, className, newPfElement.ToString());
				// Add new PunctuationForm to dtoRepos.
				dtoRepos.Add(dtoMatchingPf);
				// Add new PunctuationForm to newPunctForms.
				newPunctForms.Add(key, dtoMatchingPf);
			}

			// Assign InstanceOf for pficElement to matching PunctuationForm object.
			// NB: No need to mess with registering it as modified,
			// since it gets deleted anyway later on.
			var innerBounds = new ElementBounds(pficElement, s_tagsCmAnnotation);
			Debug.Assert(innerBounds.IsValid);
			var pficBytes = new List<byte>(pficElement);
			var instanceOf = String.Format("<InstanceOf>{1}{0}{1}</InstanceOf>{1}",
				DataMigrationServices.CreateReferenceObjSurElement(dtoMatchingPf.Guid), Environment.NewLine);
			pficBytes.InsertRange(innerBounds.EndTagOffset, Encoding.UTF8.GetBytes(instanceOf));
			dtoPfic.XmlBytes = pficBytes.ToArray();
			return true;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000010.cs

示例9: PerformMigration

		/// <summary>
		/// Add a few items to the Notebook Record Type list, and rearrange the list a bit.  The original
		/// list should look something like:
		///		Conversation
		///		Interview
		///			Structured
		///			Unstructured
		///		Literature Summary
		///		Observation
		///			Performance
		///		Analysis
		///	After the migration, the list should look something like:
		///		Event
		///			Observation
		///			Conversation
		///			Interview
		///				Structured
		///				Unstructured
		///			Performance
		///		Literature Summary
		///		Analysis
		///		Methodology
		///		Weather
		/// </summary>
		/// <remarks>
		/// This implements FWR-643.  Note that users can edit this list, so any of the expected
		/// items could have been deleted or moved around in the list.  :-(
		/// </remarks>
		public void PerformMigration(IDomainObjectDTORepository repoDTO)
		{
			DataMigrationServices.CheckVersionNumber(repoDTO, 7000015);

			DomainObjectDTO dtoList = repoDTO.GetDTO(ksguidRecTypesList);
			XElement xeList = XElement.Parse(dtoList.Xml);
			XElement xeListPossibilities = xeList.XPathSelectElement("Possibilities");
			if (xeListPossibilities == null)
			{
				xeListPossibilities = new XElement("Possibilities");
				xeList.Add(xeListPossibilities);
			}
			// The user can edit the list, so these might possibly have been deleted (or moved).  :-(
			DomainObjectDTO dtoObservation = GetDTOIfItExists(repoDTO, ksguidObservation);
			DomainObjectDTO dtoConversation = GetDTOIfItExists(repoDTO, ksguidConversation);
			DomainObjectDTO dtoInterview = GetDTOIfItExists(repoDTO, ksguidInterview);
			DomainObjectDTO dtoPerformance = GetDTOIfItExists(repoDTO, ksguidPerformance);

			// Create the new Event, Methodology, and Weather record types.
			var nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

			StringBuilder sb = new StringBuilder();
			sb.AppendFormat("<rt class=\"CmPossibility\" guid=\"{0}\" ownerguid=\"{1}\">",
				ksguidEvent, ksguidRecTypesList);
			sb.Append("<Abbreviation><AUni ws=\"en\">Evnt</AUni></Abbreviation>");
			sb.Append("<Name><AUni ws=\"en\">Event</AUni></Name>");
			sb.AppendFormat("<DateCreated val=\"{0}\"/>", nowStr);
			sb.AppendFormat("<DateModified val=\"{0}\"/>", nowStr);
			sb.Append("</rt>");
			XElement xeEvent = XElement.Parse(sb.ToString());
			var dtoEvent = new DomainObjectDTO(ksguidEvent, "CmPossibility", xeEvent.ToString());
			repoDTO.Add(dtoEvent);
			xeListPossibilities.AddFirst(DataMigrationServices.CreateOwningObjSurElement(ksguidEvent));

			sb = new StringBuilder();
			sb.AppendFormat("<rt class=\"CmPossibility\" guid=\"{0}\" ownerguid=\"{1}\">",
				ksguidMethodology, ksguidRecTypesList);
			sb.Append("<Abbreviation><AUni ws=\"en\">Method</AUni></Abbreviation>");
			sb.Append("<Name><AUni ws=\"en\">Methodology</AUni></Name>");
			sb.AppendFormat("<DateCreated val=\"{0}\"/>", nowStr);
			sb.AppendFormat("<DateModified val=\"{0}\"/>", nowStr);
			sb.Append("</rt>");
			var dtoMethod = new DomainObjectDTO(ksguidMethodology, "CmPossibility", sb.ToString());
			repoDTO.Add(dtoMethod);
			xeListPossibilities.LastNode.AddAfterSelf(DataMigrationServices.CreateOwningObjSurElement(ksguidMethodology));

			sb = new StringBuilder();
			sb.AppendFormat("<rt class=\"CmPossibility\" guid=\"{0}\" ownerguid=\"{1}\">",
				ksguidWeather, ksguidRecTypesList);
			sb.Append("<Abbreviation><AUni ws=\"en\">Wthr</AUni></Abbreviation>");
			sb.Append("<Name><AUni ws=\"en\">Weather</AUni></Name>");
			sb.AppendFormat("<DateCreated val=\"{0}\"/>", nowStr);
			sb.AppendFormat("<DateModified val=\"{0}\"/>", nowStr);
			sb.Append("</rt>");
			var dtoWeather = new DomainObjectDTO(ksguidWeather, "CmPossibility", sb.ToString());
			repoDTO.Add(dtoWeather);
			xeListPossibilities.LastNode.AddAfterSelf(DataMigrationServices.CreateOwningObjSurElement(ksguidWeather));

			DataMigrationServices.UpdateDTO(repoDTO, dtoList, xeList.ToString());

			// Change the ownership links for the moved items.
			if (dtoObservation != null)
				ChangeOwner(repoDTO, dtoObservation, ksguidEvent, "SubPossibilities");
			if (dtoConversation != null)
				ChangeOwner(repoDTO, dtoConversation, ksguidEvent, "SubPossibilities");
			if (dtoInterview != null)
				ChangeOwner(repoDTO, dtoInterview, ksguidEvent, "SubPossibilities");
			if (dtoPerformance != null)
				ChangeOwner(repoDTO, dtoPerformance, ksguidEvent, "SubPossibilities");

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

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

示例11: ConvertCCAsAndAddCCRObjSurElements

		private static IEnumerable<XElement> ConvertCCAsAndAddCCRObjSurElements(
			IDomainObjectDTORepository dtoRepos,
			IDictionary<string, SortedList<int, byte[]>> paraToOldSegments,
			ICollection<KeyValuePair<byte[], XElement>> halfBakedCcwgItems,
			IDictionary<string, byte[]> oldCCAs,
			IDictionary<Guid, Guid> ccaGuidMap,
			List<string> objsurElementGuids,
			string owningCCRGuid)
		{
			// 'retval' will be put into the new CCR of the caller as owning objsur elements.
			var retval = new List<XElement>(objsurElementGuids.Count());

			// Decide which class to convert the old CCA to:
			//	1. CmBaseAnnotations -> ConstChartTag
			//	2. CmIndirectAnnotation
			//		A. 1 (or more) CCRs in AppliesTo-> ConstChartClauseMarker
			//		B. 1 (only) CCA in AppliesTo -> ConstChartMovedTextMarker
			//		C. null AppliesTo -> ConstChartWordGroup
			//		D. 1 (or more) twfics (pfics?) -> ConstChartWordGroup
			const string kChangeMe = "CHANGEME";
			foreach (var oldCCAGuid in objsurElementGuids)
			{
				var guidOldCCA = new Guid(oldCCAGuid);
				// Earlier 'SortOutMultipleXficBackRefs()' may have left a dangling reference.
				// If so, skip it.
				//XElement oldAnnElement;
				byte[] oldAnnElement;
				if (!oldCCAs.TryGetValue(oldCCAGuid, out oldAnnElement))
					continue;
				//var oldAnnElement = oldCCAs[oldCCAGuid];
				// Leave it in, so we can get at its XElement, whenever needed.
				//oldCCAs.Remove(oldCCAGuid);
				var guidNew = ccaGuidMap[guidOldCCA];
				var newGuid = guidNew.ToString().ToLowerInvariant();
				var newClassName = kChangeMe;
				// Collect up the inner class-level elements.
				var cmAnnotationBounds = new ElementBounds(oldAnnElement, s_tagsCmAnnotation);
				if (!cmAnnotationBounds.IsValid)
					continue;
				// Fix FWR-2139 crash migrating because of missing InstanceOf
				// Skip chart annotation with no column reference.
				var guidInstanceOf = GetInstanceOfGuid(oldAnnElement);
				if (String.IsNullOrEmpty(guidInstanceOf))
					continue;
				var mergesAfterElement = new XElement("MergesAfter", new XAttribute("val", "False"));
				var mergesBeforeElement = new XElement("MergesBefore", new XAttribute("val", "False"));
				// May be null.
				var compDetailsBounds = new ElementBounds(oldAnnElement, s_tagsCompDetails,
					cmAnnotationBounds.BeginTagOffset, cmAnnotationBounds.EndTagOffset);
				if (compDetailsBounds.IsValid)
				{
					var uniBounds = new ElementBounds(oldAnnElement, s_tagsUni,
						compDetailsBounds.BeginTagOffset, compDetailsBounds.EndTagOffset);
					if (uniBounds.IsValid)
					{
						// See if some optional stuff in 'oldCompDetailsElement' will change MergesAfter or MergesBefore.
						var mergeAfter = GetAttributeValue(oldAnnElement, s_mergeAfterAttr,
							uniBounds.BeginTagOffset, uniBounds.EndTagOffset);
						if (mergeAfter == "true")
							mergesAfterElement.Attribute("val").Value = "True";
						var mergeBefore = GetAttributeValue(oldAnnElement, s_mergeBeforeAttr,
							uniBounds.BeginTagOffset, uniBounds.EndTagOffset);
						if (mergeBefore == "true")
							mergesBeforeElement.Attribute("val").Value = "True";
					}
				}
				// Reset the Name and add other elements really soon now,
				// depending on which subclass of ConstituentChartCellPart is used.
				var newSpecificClassElement = new XElement(newClassName);
				var newClassAttr = new XAttribute("class", newClassName);
				var newCCAElement = new XElement("rt",
					newClassAttr,
					new XAttribute("guid", newGuid),
					new XAttribute("ownerguid", owningCCRGuid),
					new XElement("CmObject"),
					new XElement("ConstituentChartCellPart",
						new XElement("Column",
							new XElement("objsur",
								new XAttribute("t", "r"),
								new XAttribute("guid", guidInstanceOf))),
						mergesAfterElement,
						mergesBeforeElement),
					newSpecificClassElement);

				var classValue = GetClassValue(oldAnnElement);
				switch (classValue)
				{
					default:
						throw new InvalidOperationException("Unrecognized annotation class used as CCA.");
					case "CmBaseAnnotation":
						// #1.
						newClassName = "ConstChartTag";
						newSpecificClassElement.Name = newClassName;
						newClassAttr.Value = newClassName;
						// Tag is atomic ref.
						var guidBeginObject = GetBeginObjectGuid(oldAnnElement);
						if (!String.IsNullOrEmpty(guidBeginObject))
						{
							newSpecificClassElement.Add(
								new XElement("Tag",
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000010.cs

示例12: ProcessDiscourseData

		private static List<KeyValuePair<byte[], XElement>> ProcessDiscourseData(IDomainObjectDTORepository dtoRepos,
			IDictionary<string, SortedList<int, byte[]>> paraToOldSegments,
			IEnumerable<byte[]> oldCCRs,
			IDictionary<string, byte[]> oldCCAs,
			IDictionary<Guid, Guid> ccaGuidMap) // Key is old CCA guid. Value is new CCA guid.
		{
			// Make a mapping between old CCA anns and new ConstChartWordGroup objects (both XElements),
			// which are the ones where the old ann had twfics in AppliesTo.
			// These will be fed into the code that converts the twfics,
			// so as to have access to the right conversion context
			// (i.e., be able to get at the Segment and start/end indices for the twfics).
			var halfBakedCcwgItems = new List<KeyValuePair<byte[], XElement>>();

			// Map between old CCR ann guid and new CCR guid, so code in here can keep track of them.
			// Key is the original CCR guid. Value is the new CCR guid.
			//var ccrRowsGuidMap = new Dictionary<string, string>();
			// Key is the new CCR guid. Value is the guid of its new owning chart.
			var ccrOwnerGuidMap = new Dictionary<Guid, Guid>();

			// Migrate the DsConstChart(s).
			foreach (var chartDto in dtoRepos.AllInstancesSansSubclasses("DsConstChart"))
			{
				var chartElement = XElement.Parse(chartDto.Xml);

				foreach (var objsurElement in chartElement.Element("DsConstChart").Elements("Rows").Elements("objsur"))
				{
					// Change to owning.
					objsurElement.Attribute("t").Value = "o";

					// Change the guid.
					var guidAttr = objsurElement.Attribute("guid");
					var newCCRGuid = ccaGuidMap[new Guid(guidAttr.Value)];
					// Remember the owner guid (Chart) for the new CCR guid.
					// Key is the new guid for the new CCR.
					// Value is the owning chart.
					ccrOwnerGuidMap.Add(newCCRGuid, new Guid(chartDto.Guid));
					guidAttr.Value = newCCRGuid.ToString().ToLowerInvariant();
				}

				// Tell dto repos of the modification of the chart.
				chartDto.Xml = chartElement.ToString();
				dtoRepos.Update(chartDto);
			}

			// Migrate the CCR and CCA annotations.
			foreach (var oldCCR in oldCCRs)
			{
				// Collect up the inner class-level elements.
				var cmAnnotationBounds = new ElementBounds(oldCCR, s_tagsCmAnnotation);
				// May be null.
				var oldCompDetailsBounds = new ElementBounds(oldCCR, s_tagsCompDetails,
					cmAnnotationBounds.BeginTagOffset, cmAnnotationBounds.EndTagOffset);
				var oldTextBounds = new ElementBounds(oldCCR, s_tagsText,
					cmAnnotationBounds.BeginTagOffset, cmAnnotationBounds.EndTagOffset);
				// oldCommentBounds is unused. Hopefully by design?!
				//var oldCommentBounds = new ElementBounds(oldCCR, s_tagsComment,
				//    cmAnnotationBounds.BeginTagOffset, cmAnnotationBounds.EndTagOffset);
				// May be null, or at least have no 'objsur' elements.
				var refsFromAppliesTo = GetAppliesToObjsurGuids(oldCCR);

				// Try to make a Notes element. It may be null.
				XElement notesElement = null;
				if (oldTextBounds.IsValid)
				{
					// Get the StText dto and element.
					var stTextGuid = GetObjsurGuid(oldCCR, oldTextBounds.BeginTagOffset, oldTextBounds.EndTagOffset);
					if (!String.IsNullOrEmpty(stTextGuid))
					{
						var stTextDto = dtoRepos.GetDTO(stTextGuid);
						var stTextBounds = new ElementBounds(stTextDto.XmlBytes, s_tagsStText);
						var paragraphsBounds = new ElementBounds(stTextDto.XmlBytes, s_tagsParagraphs,
							stTextBounds.BeginTagOffset, stTextBounds.EndTagOffset);
						// See if stTextElement has any paras (StTxtPara)
						if (paragraphsBounds.IsValid)
						{
							// Get the first para.
							var firstParaGuid = GetObjsurGuid(stTextDto.XmlBytes,
								paragraphsBounds.BeginTagOffset, paragraphsBounds.EndTagOffset);
							if (!String.IsNullOrEmpty(firstParaGuid))
							{
								var firstParaDto = dtoRepos.GetDTO(firstParaGuid);
								var stTxtParaBounds = new ElementBounds(firstParaDto.XmlBytes,
									s_tagsStTxtPara);
								var contentsBounds = new ElementBounds(firstParaDto.XmlBytes,
									s_tagsContents,
									stTxtParaBounds.BeginTagOffset, stTxtParaBounds.EndTagOffset);
								var strBounds = new ElementBounds(firstParaDto.XmlBytes, s_tagsStr,
									contentsBounds.BeginTagOffset, contentsBounds.EndTagOffset);
								// See if it has any Contents.
								if (strBounds.IsValid)
								{
									// Move the Contents into a new Notes element.
									notesElement = new XElement("Notes",
										XElement.Parse(Encoding.UTF8.GetString(firstParaDto.XmlBytes,
											strBounds.BeginTagOffset, strBounds.Length)));
								}
							}
						}
					}
				}
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000010.cs

示例13: AddSegmentAnalyses

		private static XElement AddSegmentAnalyses(
			IDomainObjectDTORepository dtoRepos,
			IEnumerable<KeyValuePair<byte[], XElement>> halfBakedCcwgItemsForCurrentPara,
			byte[] oldSegElement,
			IDictionary<int, byte[]> xficsForCurrentPara,
			ICollection<byte[]> oldTextTags,
			string newSegmentGuid,
			bool isLastOldSegment,
			DomainObjectDTO paraDto)
		{
			XElement retval = null;

			var oldSegBeginOffset = GetBeginOffset(oldSegElement);
			var oldSegEndOffset = GetEndOffset(oldSegElement);

			var xficsForCurrentOldSegment = new SortedList<int, byte[]>();
			var halfBakedCcwgsForCurrentOldSegment = new List<XElement>();
			if (xficsForCurrentPara != null)
			{
				foreach (var kvp in xficsForCurrentPara)
				{
					var xficGuid = GetGuid(kvp.Value);
					var beginOffset = kvp.Key;

					// Try to find a CCWG that has a matching instanceOfGuid.
					XElement halfBakedCcwg = null;
					foreach (var halfBakedKvp in halfBakedCcwgItemsForCurrentPara)
					{
						// NB: halfBakedKvp.Value.Element("ConstChartWordGroup").Element("BeginAnalysisIndex").Attribute("val").Value.ToLower()
						// This is the 'InstanceOf' guid of the xfic, not the xfic's guid.
						if (
							halfBakedKvp.Value.Element("ConstChartWordGroup").Element("BeginAnalysisIndex").Attribute(
								"val").Value.ToLower() != xficGuid)
							continue;

						// If there happen to be more than one CCWG pointing to the same xfic, only one gets 'finished'!
						halfBakedCcwg = halfBakedKvp.Value;
						break;
					}

					if (beginOffset >= oldSegBeginOffset && beginOffset < oldSegEndOffset)
					{
						xficsForCurrentOldSegment.Add(beginOffset, kvp.Value);
						if (halfBakedCcwg != null)
							halfBakedCcwgsForCurrentOldSegment.Add(halfBakedCcwg);
					}
					else if (isLastOldSegment)
					{
						if (halfBakedCcwg != null)
							halfBakedCcwgsForCurrentOldSegment.Add(halfBakedCcwg);
						xficsForCurrentOldSegment.Add(beginOffset, kvp.Value);
					}
				}
			}

			if (xficsForCurrentOldSegment.Count > 0)
			{
				foreach (var key in xficsForCurrentOldSegment.Keys)
					xficsForCurrentPara.Remove(key);

				// The one returned element is "Analyses" (or null, if no twfics/pfics).
				// It will have one, or more, 'objsur' type 'r' elements in it.
				// The 'Analyses' property is a seq,
				// which is why is xficsForCurrentOldSegment is sorted the BeginOffset of the contained twfics/pfics.

				// All xfics will have an 'InstanceOf' by now, even pfics.
				// The pfics had a new InstanceOf prop set earlier
				// (or were removed, if InstanceOf could not be set),
				// and twfics with no InstanceOf prop were filtered out earlier.
				retval = new XElement("Analyses",
					from xfix in xficsForCurrentOldSegment.Values
					select DataMigrationServices.CreateReferenceObjSurElement(GetInstanceOfGuid(xfix)));

				// Finish converting half-baked CCWG stuff.
				if (halfBakedCcwgsForCurrentOldSegment.Count > 0)
				{
					var allOldXficGuids = (from xfix in xficsForCurrentOldSegment.Values
										   select GetGuid(xfix).ToLower()).ToList();
					foreach (var halfBakedCcwg in halfBakedCcwgsForCurrentOldSegment)
					{
						// Fix up halfbaked CCWG items here.
						var innerElement = halfBakedCcwg.Element("ConstChartWordGroup");
						// NB: The guids temporarily stored in the begin/end index props are for
						// the xfic guid, but we want to look up the index of its InstanceOf property,
						// which will be what is actually in the new "Analyses" prop of the new Segment.
						var guidAttr = innerElement.Element("BeginAnalysisIndex").Attribute("val");
						guidAttr.Value = allOldXficGuids.IndexOf(guidAttr.Value.ToLower()).ToString();
						guidAttr = innerElement.Element("EndAnalysisIndex").Attribute("val");
						guidAttr.Value = allOldXficGuids.IndexOf(guidAttr.Value.ToLower()).ToString();
						// NB: The recently created CCWG has already been added to dto repos,
						// so the only remaining task is to update the xml on the CCWG dto.
						var dto = dtoRepos.GetDTO(GetGuid(halfBakedCcwg));
						dto.Xml = halfBakedCcwg.ToString();
					}
				}

				// Find and convert any any old Text Tag indirect annotations for this segment.
				// NB: xficsForCurrentOldSegment.Values may have pfics,
				// and we don't want those here.
				// oldTextTags is all old TextTag annotations for everything.
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:DataMigration7000010.cs

示例14: AddNotes

		private static XElement AddNotes(IDomainObjectDTORepository dtoRepos, string newSegGuid, string oldSegGuid, Dictionary<string, List<byte[]>> notes)
		{
			// This method will create zero, or more, new Nt
			// instances, which will be owned by the new segment.
			// (Added to the new segment, when returned.)
			// Each new Nt object needs to be added to the repos,
			// and added as an owned object in the Notes prop of the new Segment.
			XElement retval = null;
			List<byte[]> oldNotes;
			if (notes.TryGetValue(oldSegGuid, out oldNotes))
			{
				retval = new XElement("Notes");
				foreach (var oldNotePair in oldNotes)
				{
					var newNoteGuid = Guid.NewGuid().ToString().ToLower();

					// Add to Notes element as owned objsur element.
					retval.Add(DataMigrationServices.CreateOwningObjSurElement(newNoteGuid));

					// Create the new Nt object.
					var newNoteElement = new XElement("rt",
						new XAttribute("class", "Note"),
						new XAttribute("guid", newNoteGuid),
						new XAttribute("ownerguid", newSegGuid.ToLower()),
						new XElement("CmObject"),
						new XElement("Note", GetOptionalComment(oldNotePair, "Content")));
					// Create new dto and add to repos.
					var newNoteDto = new DomainObjectDTO(newNoteGuid, "Note", newNoteElement.ToString());
					dtoRepos.Add(newNoteDto);
				}
			}
			return retval;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:DataMigration7000010.cs

示例15: MakeEvaluation

		private static DomainObjectDTO MakeEvaluation(string ownerGuid, IDomainObjectDTORepository domainObjectDtoRepository, XElement agentElement, string owningAttr)
		{
			var newGuid = Guid.NewGuid().ToString().ToLower();
			var newEvalElt = new XElement("rt",
				new XAttribute("class", "CmAgentEvaluation"),
				new XAttribute("guid", newGuid),
				new XAttribute("ownerguid", ownerGuid),
				new XElement("CmObject"),
				new XElement("CmAgentEvaluation"));
			// Create new dto and add to repos.
			var newEval = new DomainObjectDTO(newGuid, "CmAgentEvaluation", newEvalElt.ToString());
			domainObjectDtoRepository.Add(newEval);
			agentElement.Add(new XElement(owningAttr,
				new XElement("objsur", new XAttribute("t", "o"), new XAttribute("guid", newGuid))));

			return newEval;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:DataMigration7000014.cs


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