init
This commit is contained in:
62
Common/DTS.Common.Import/XML/XMLParseGroupTemplates.cs
Normal file
62
Common/DTS.Common.Import/XML/XMLParseGroupTemplates.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using DTS.Common.Import.Interfaces;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace DTS.Common.Import.XML
|
||||
{
|
||||
public class XMLParseGroupTemplates : XMLParseBase
|
||||
{
|
||||
private ISO.ISO13499FileDb _iSO13499FileDb;
|
||||
public XMLParseGroupTemplates(XmlElement root, double importedVersion, ISO.ISO13499FileDb iSO13499FileDb,
|
||||
Func<bool> isCancelled = null) : base(root, importedVersion, isCancelled)
|
||||
{
|
||||
_iSO13499FileDb = iSO13499FileDb;
|
||||
}
|
||||
public override void Parse(ref ImportObject importObject)
|
||||
{
|
||||
var groupTemplates = ParseGroupTemplates(ref importObject, _root);
|
||||
importObject.AddGroupTemplates(groupTemplates);
|
||||
}
|
||||
public IEnumerable<DataPROWin7.DataModel.TestObjectTemplate> ParseGroupTemplates(ref ImportObject importObject, XmlElement root)
|
||||
{
|
||||
List<DataPROWin7.DataModel.TestObjectTemplate> groupTemplates = new List<DataPROWin7.DataModel.TestObjectTemplate>();
|
||||
|
||||
var importChannels = new Dictionary<long, ISO.MMEPossibleChannels>();
|
||||
foreach (var channel in importObject.CustomChannels())
|
||||
{
|
||||
if (IsCancelled())
|
||||
{
|
||||
return groupTemplates;
|
||||
}
|
||||
importChannels[channel.Id] = channel;
|
||||
}
|
||||
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (IsCancelled())
|
||||
{
|
||||
return groupTemplates;
|
||||
}
|
||||
if (!(node is XmlElement)) continue;
|
||||
var template = DataPROWin7.DataModel.TestObjectTemplate.ReadXML(node as XmlElement, importChannels);
|
||||
template.Embedded = template.SysBuilt || template.Embedded; // If this is an old Dynamic Group or a new Added Group, by definition it's embedded.
|
||||
if (template.SysBuilt)
|
||||
{
|
||||
template.OriginalTemplateName = template.TemplateName;
|
||||
}
|
||||
groupTemplates.Add(new DataPROWin7.DataModel.TestObjectTemplate(template, ref _iSO13499FileDb, importObject.TestObjects()?.ToList()));
|
||||
if (null == groupTemplates.Last().TestObject)
|
||||
{
|
||||
//FB8790 - TestSetup with a custom ISO testobject that is not available in the export file has an ambiguous error message.
|
||||
throw new NotSupportedException(string.Format(StringResources.ImportTestSetup_ISOTestObjectNotFoundInImportFile, template.TemplateNameOrOriginalTemplateName, template.TestObject));
|
||||
}
|
||||
}
|
||||
return groupTemplates;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user