94 lines
2.4 KiB
C#
94 lines
2.4 KiB
C#
//
|
|
// Class: VisitId
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 14.0
|
|
// Author: dani
|
|
// Created: 29/2/2016 18:27:03 AM
|
|
//
|
|
// Copyright (c) 2016 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Xml;
|
|
using System.Xml.Serialization;
|
|
|
|
using log4net;
|
|
|
|
namespace bsmd.hisnord
|
|
{
|
|
[Serializable]
|
|
public class TransitId
|
|
{
|
|
private readonly string _transitId = null;
|
|
private static readonly ILog _log = LogManager.GetLogger(typeof(bsmd.hisnord.TransitId));
|
|
|
|
#region Construction
|
|
|
|
public TransitId(string transitId)
|
|
{
|
|
this._transitId = transitId;
|
|
}
|
|
|
|
public TransitId() { }
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
[XmlAttribute]
|
|
public string ConveyanceCode { get; set; }
|
|
|
|
[XmlText]
|
|
public string Value { get; set; }
|
|
|
|
/// <summary>
|
|
/// Extract Guid aus ConveyanceCode
|
|
/// </summary>
|
|
public Guid? MessageCoreId
|
|
{
|
|
get
|
|
{
|
|
Guid? result = null;
|
|
if (this.ConveyanceCode != null)
|
|
{
|
|
int startIndex = this.ConveyanceCode.IndexOf('-');
|
|
if (startIndex > 0)
|
|
{
|
|
if (Guid.TryParse(this.ConveyanceCode.Substring(startIndex + 1), out Guid tmpGuid))
|
|
result = tmpGuid;
|
|
else if (Guid.TryParse(this.ConveyanceCode, out tmpGuid))
|
|
result = tmpGuid;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Deserialization
|
|
|
|
public static TransitId ReadTransitId(string filename)
|
|
{
|
|
TransitId aTransitId = null;
|
|
try
|
|
{
|
|
XmlSerializer serializer = new XmlSerializer(typeof(bsmd.hisnord.TransitId));
|
|
using (FileStream fs = new FileStream(filename, FileMode.Open))
|
|
{
|
|
aTransitId = (TransitId)serializer.Deserialize(fs);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_log.ErrorFormat("Exception occurred during deserialization: {0}", ex.Message);
|
|
|
|
}
|
|
return aTransitId;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|