Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/SIL.LCModel/Application/ApplicationServices/XmlImportData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ internal string XmlState
private ReferenceTracker m_rglinks = new ReferenceTracker();
private TextWriter m_wrtrLog;
private bool m_createLinks;
private DateTime m_importDate = DateTime.Now;


/// ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -470,6 +471,7 @@ private void MergeRedundantEntries(ILexEntry leOld, ILexEntry leNew)
ILexSense[] rgls = leOld.SensesOS.ToArray();
for (int i = 0; i < rgls.Length; ++i)
leNew.SensesOS.Add(rgls[i]);
MergeDates(leOld, leNew);
MergeEntryRefs(leOld, leNew);
CopyCustomFieldData(leOld, leNew);

Expand All @@ -479,6 +481,23 @@ private void MergeRedundantEntries(ILexEntry leOld, ILexEntry leNew)
m_mapIdGuid[id] = leNew.Guid;
}

/// Use the newest date between the two dates, as long as it is different from the importDate
private void MergeDates(ILexEntry leOld, ILexEntry leNew)
{
if (leOld.DateCreated == m_importDate)
{
return;
}
if (leNew.DateCreated == m_importDate)
{
leNew.DateCreated = leOld.DateCreated;
}
else if (leOld.DateCreated > leNew.DateCreated)
{
leNew.DateCreated = leOld.DateCreated;
}
}

private void MergeEntryRefs(ILexEntry leOld, ILexEntry leNew)
{
if (leOld.EntryRefsOS.Count == 0)
Expand Down Expand Up @@ -1089,6 +1108,7 @@ private void ReadXmlObject(XmlReader xrdr, FieldInfo fi, ICmObject objToUse)
if (m_factLexEntry == null)
m_factLexEntry = m_cache.ServiceLocator.GetInstance<ILexEntryFactory>();
cmo = m_factLexEntry.Create();
((LexEntry)cmo).DateCreated = m_importDate;
m_nHomograph = 0;
break;
case TextTags.kClassId:
Expand Down
Loading
Loading