init
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Import.Interfaces;
|
||||
using DTS.Common.Interface.Groups.GroupList;
|
||||
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 XMLParseLabDetails : XMLParseBase
|
||||
{
|
||||
public XMLParseLabDetails(XmlElement root, double importedVersion, Func<bool> isCancelled = null) : base(root, importedVersion, isCancelled)
|
||||
{
|
||||
}
|
||||
public IImportNotification ImportNotification { get; set; }
|
||||
|
||||
public override void Parse(ref ImportObject importObject)
|
||||
{
|
||||
ImportNotification?.SetStatus(new ImportStatus { PossibleStatus = Enums.PossibleStatus.Reading, ExtraStatus = Enums.ImportExtraStatus.ReadingLabDetails });
|
||||
var details = ParseLabDetails(_root);
|
||||
var newRoot = ConvertLabDetails(details);
|
||||
details = ParseLabDetails(newRoot);
|
||||
importObject.AddLabDetailsList(details);
|
||||
}
|
||||
|
||||
private XmlElement ConvertLabDetails(IEnumerable<ISO.LabratoryDetails> details)
|
||||
{
|
||||
_writer.WriteStartElement(TopLevelFields.LabDetails.ToString());
|
||||
foreach (var c in details)
|
||||
{
|
||||
_writer.Flush();
|
||||
c.WriteXML(ref _writer);
|
||||
_writer.Flush();
|
||||
}
|
||||
|
||||
_writer.WriteEndElement();
|
||||
return GetXmlElement();
|
||||
}
|
||||
private List<ISO.LabratoryDetails> ParseLabDetails(XmlElement root)
|
||||
{
|
||||
List<ISO.LabratoryDetails> details = new List<ISO.LabratoryDetails>();
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (IsCancelled()) { return details; }
|
||||
if (node is XmlElement)
|
||||
{
|
||||
details.Add(ISO.LabratoryDetails.ReadXML(node as XmlElement));
|
||||
}
|
||||
}
|
||||
return details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Import.Enums;
|
||||
|
||||
namespace DTS.Common.Import
|
||||
{
|
||||
public class ImportStatus
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public PossibleStatus PossibleStatus { get; set; }
|
||||
public ImportExtraStatus ExtraStatus { get; set; }
|
||||
}
|
||||
public interface IImportNotification
|
||||
{
|
||||
Action ImportDone { get; }
|
||||
Action<List<string>> ReportErrors { get; }
|
||||
Action<double> SetProgress { get; }
|
||||
Action<ImportStatus> SetStatus { get; }
|
||||
}
|
||||
|
||||
public class ImportNotification : IImportNotification
|
||||
{
|
||||
public ImportNotification(Action<List<string>> reportErrors, Action<ImportStatus> setStatus, Action<double> setProgress, Action importDone)
|
||||
{
|
||||
ReportErrors = reportErrors;
|
||||
SetStatus = setStatus;
|
||||
SetProgress = setProgress;
|
||||
ImportDone = importDone;
|
||||
}
|
||||
|
||||
public ImportNotification()
|
||||
{
|
||||
ReportErrors = (x) => { };
|
||||
SetStatus = (x) => { };
|
||||
SetProgress = (x) => { };
|
||||
ImportDone = () => { };
|
||||
}
|
||||
|
||||
public Action<List<string>> ReportErrors { get; private set; }
|
||||
public Action<ImportStatus> SetStatus { get; private set; }
|
||||
public Action<double> SetProgress { get; private set; }
|
||||
public Action ImportDone { get; private set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user