49 lines
1.8 KiB
Plaintext
49 lines
1.8 KiB
Plaintext
|
|
using DTS.Common.Import.Interfaces;
|
||
|
|
using DTS.Common.Utils;
|
||
|
|
using DTS.Slice.Users;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace DTS.Common.Import
|
||
|
|
{
|
||
|
|
public class DTSXMLParseImport : IParseImport
|
||
|
|
{
|
||
|
|
|
||
|
|
private ImportObject _importObject;
|
||
|
|
private readonly Func<bool> _isCancelled;
|
||
|
|
private readonly IImportNotification _importNotification;
|
||
|
|
public List<IUIItems> UIItems { get; set; }
|
||
|
|
public DTSXMLParseImport(ImportObject importObject, IImportNotification importNotification, Func<bool> isCancelled = null)
|
||
|
|
{
|
||
|
|
_isCancelled = isCancelled;
|
||
|
|
_importObject = importObject;
|
||
|
|
_importNotification = importNotification;
|
||
|
|
}
|
||
|
|
public ImportObject Parse(IEnumerable<string> importFiles)
|
||
|
|
{
|
||
|
|
XMLParseProcessor parseProcesser = new XMLParseProcessor(_importObject, _importNotification, importFiles, _isCancelled);
|
||
|
|
parseProcesser.UIItems = UIItems;
|
||
|
|
_importObject = parseProcesser.Process();
|
||
|
|
AssignLinkedDASSerials(ref _importObject);
|
||
|
|
return _importObject;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void AssignLinkedDASSerials(ref ImportObject importObject)
|
||
|
|
{
|
||
|
|
foreach (var h in importObject.Hardware())
|
||
|
|
{
|
||
|
|
if (!h.IsPseudoRack()) continue;
|
||
|
|
var matches = from hw in importObject.Hardware() where hw.ParentDAS == h.SerialNumber select hw.SerialNumber;
|
||
|
|
var enumerable = matches as string[] ?? matches.ToArray();
|
||
|
|
if (enumerable.Any())
|
||
|
|
{
|
||
|
|
h.LinkedDASSerials = enumerable.ToArray();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|