Files
ayanova7/source/ri/ri/util/RIIntegrationData.cs
2018-06-29 19:47:36 +00:00

147 lines
4.2 KiB
C#

using System;
using System.Xml;
using System.IO;
namespace ri.util
{
/// <summary>
/// Persistence of RI specific application settings
/// used with the IntegrationSimple object
/// </summary>
[Serializable]
public class RIIntegrationData
{
public RIIntegrationData() { }
#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("RISettings");
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
{
XmlDocument xmldoc = new XmlDocument();
try
{
xmldoc.LoadXml(value);
}
catch (Exception ex)
{
throw new ApplicationException("Error: exception in RIIntegrationData::XMLData.set()->LoadXml:\r\n." + ex.Message, ex.InnerException);
}
_ClientWorkorderReportID = XmlConvert.ToGuid(xmldoc.SelectSingleNode("/RISettings/ClientWorkorderReportID").InnerText);
_CSRInfoText = xmldoc.SelectSingleNode("/RISettings/CSRInfoText").InnerText;
//FUTURE: items are going to have to check for presence of nodes before attempting to retrieve them...
//case 1169
if (xmldoc.SelectSingleNode("/RISettings/ClientViewWorkorderWiki") != null)
_ClientViewWorkorderWiki = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/RISettings/ClientViewWorkorderWiki").InnerText);
else
_ClientViewWorkorderWiki = false;
}
}
#endregion
}
}//end namespace