Files
ayanova7/source/WBI/App_Code/WBIIntegrationData.cs
2018-06-29 19:47:36 +00:00

144 lines
3.8 KiB
C#

using System;
using System.Xml;
using System.IO;
/// <summary>
/// Persistence of WBI specific application settings
/// used with the Integration object
/// </summary>
[Serializable]
public class WBIIntegrationData
{
public WBIIntegrationData(){}
#region fields
private Guid _ClientWorkorderReportID = Guid.Empty;
private string _CSRInfoText = "";
//case 1169
private bool _ClientViewWorkorderWiki = false;
public bool IsDirty = false;
#endregion
#region Properties
public Guid ClientWorkorderReportID
{
get { return _ClientWorkorderReportID; }
set
{
if (_ClientWorkorderReportID != value)
{
_ClientWorkorderReportID = value;
IsDirty = true;
}
}
}
public string CSRInfoText
{
get { return _CSRInfoText; }
set
{
if (_CSRInfoText != value)
{
_CSRInfoText = value;
IsDirty = true;
}
}
}
public bool HasCSRInfoText
{
get
{
return !(string.IsNullOrEmpty(_CSRInfoText));
}
}
//case 1169
public bool ClientViewWorkorderWiki
{
get { return _ClientViewWorkorderWiki; }
set
{
if (_ClientViewWorkorderWiki != value)
{
_ClientViewWorkorderWiki = value;
IsDirty = true;
}
}
}
#endregion props
#region XML in/out
/// <summary>
/// Set - Sets the fields in this object based on the contents of the xml string
/// Get - Get's the fields of this object in the format of an xml string
/// </summary>
public string XMLData
{
get
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(new StringWriter(sb));
w.Formatting = System.Xml.Formatting.Indented;
w.WriteStartDocument(true);
w.WriteStartElement("WBISettings");
w.WriteElementString("ClientWorkorderReportID", XmlConvert.ToString(_ClientWorkorderReportID));
w.WriteElementString("CSRInfoText", _CSRInfoText);
//case 1169
w.WriteElementString("ClientViewWorkorderWiki", XmlConvert.ToString(_ClientViewWorkorderWiki));
w.WriteEndElement();
w.WriteEndDocument();
w.Flush();
w.Close();
return sb.ToString();
}
set
{
// Load the signed XML license file.
XmlDocument xmldoc = new XmlDocument();
try
{
xmldoc.LoadXml(value);
}
catch (Exception ex)
{
throw new ApplicationException("Error: exception in WBIIntegrationData::XMLData.set()->LoadXml:\r\n." + ex.Message, ex.InnerException);
}
_ClientWorkorderReportID = XmlConvert.ToGuid(xmldoc.SelectSingleNode("/WBISettings/ClientWorkorderReportID").InnerText);
_CSRInfoText = xmldoc.SelectSingleNode("/WBISettings/CSRInfoText").InnerText;
//FUTURE: items are going to have to check for presence of nodes before attempting to retrieve them...
//case 1169
if (xmldoc.SelectSingleNode("/WBISettings/ClientViewWorkorderWiki") != null)
_ClientViewWorkorderWiki = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/WBISettings/ClientViewWorkorderWiki").InnerText);
else
_ClientViewWorkorderWiki = false;
}
}
#endregion
}