47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
using DTS.Common.Enums.DBExport;
|
|
using DTS.Common.Import.Interfaces;
|
|
using DTS.Common.Interface.Groups.GroupList;
|
|
using DTS.Slice.Users;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
namespace DTS.Common.Import.XML
|
|
{
|
|
public class XMLParseUsers : XMLParseBase
|
|
{
|
|
private readonly IEnumerable<IUIItems> _uiItems;
|
|
public XMLParseUsers(XmlElement root, double importedVersion, IEnumerable<IUIItems> uiItems, Func<bool> isCancelled = null) : base(root, importedVersion, isCancelled)
|
|
{
|
|
_uiItems = uiItems;
|
|
}
|
|
public IImportNotification ImportNotification { get; set; }
|
|
public override void Parse(ref ImportObject importObject)
|
|
{
|
|
ImportNotification?.SetStatus(new ImportStatus { PossibleStatus = Enums.PossibleStatus.Reading, ExtraStatus = Enums.ImportExtraStatus.ReadingUsers });
|
|
importObject.AddUsers(ParseUsers(_root, _uiItems));
|
|
}
|
|
|
|
private IEnumerable<User> ParseUsers(XmlElement root, IEnumerable<IUIItems> iUItems)
|
|
{
|
|
List<User> users = new List<User>();
|
|
|
|
foreach (var node in root.ChildNodes)
|
|
{
|
|
if (IsCancelled()) { return users; }
|
|
if (node is XmlElement)
|
|
{
|
|
users.Add(User.ReadXML(node as XmlElement, iUItems?.ToArray()));
|
|
}
|
|
}
|
|
return users;
|
|
}
|
|
}
|
|
}
|
|
|
|
|