private void updatecheck()
{
string URLString="";
string XMLResult="";
//string VehicleString;
bool m_updateavailable = false;
bool m_version_toohigh = false;
bool _info = false;
Version maxversion = new Version("1.0.0.0");
File.Delete(Apppath + "\\input.xml");
File.Delete(Apppath + "\\Notes.xml");
try
{
if (m_customer.Length > 0)
{
URLString = "http://trionic.mobixs.eu/vagedcsuite/version.xml";
XMLResult = GetPageHTML(URLString, 10);
using (StreamWriter xmlfile = new StreamWriter(Apppath + "\\input.xml", false, System.Text.Encoding.ASCII, 2048))
{
xmlfile.Write(XMLResult);
xmlfile.Close();
}
URLString = "http://trionic.mobixs.eu/vagedcsuite/Notes.xml";
XMLResult = GetPageHTML(URLString, 10);
using (StreamWriter xmlfile = new StreamWriter(Apppath + "\\Notes.xml", false, System.Text.Encoding.ASCII, 2048))
{
xmlfile.Write(XMLResult);
xmlfile.Close();
}
}
XmlDocument doc;
try
{
doc = new XmlDocument();
doc.LoadXml(FileToString(Apppath + "\\input.xml"));
// Add any other properties that would be useful to store
//foreach (
System.Xml.XmlNodeList Nodes;
Nodes = doc.GetElementsByTagName("vagedcsuite");
foreach (System.Xml.XmlNode Item in Nodes)
{
System.Xml.XmlAttributeCollection XMLColl;
XMLColl = Item.Attributes;
foreach (System.Xml.XmlAttribute myAttr in XMLColl)
{
if (myAttr.Name == "version")
{
Version v = new Version(myAttr.Value);
if (v > m_currentversion)
{
if (v > maxversion) maxversion = v;
m_updateavailable = true;
PumpString("Available version: " + myAttr.Value, false, false, new Version(), false, Apppath + "\\Notes.xml");
}
else if (v.Major < m_currentversion.Major || (v.Major == m_currentversion.Major && v.Minor < m_currentversion.Minor) || (v.Major == m_currentversion.Major && v.Minor == m_currentversion.Minor && v.Build < m_currentversion.Build))
{
// mmm .. gebruiker draait een versie die hoger is dan dat is vrijgegeven...
if (v > maxversion) maxversion = v;
m_updateavailable = false;
m_version_toohigh = true;
}
}
else if (myAttr.Name == "info")
{
try
{
_info = Convert.ToBoolean(myAttr.Value);
}
catch (Exception sendIE)
{
Console.WriteLine(sendIE.Message);
}
}
}
}
}
catch (Exception E)
{
PumpString(E.Message, false, false, new Version(), false, "");
}
if (m_updateavailable)
{
//Console.WriteLine("An update is available: " + maxversion.ToString());
PumpString("A newer version is available: " + maxversion.ToString(), m_updateavailable, m_version_toohigh, maxversion, _info, Apppath + "\\Notes.xml");
m_NewVersion = maxversion;
}
else if (m_version_toohigh)
{
PumpString("Versionnumber is too high: " + maxversion.ToString(), m_updateavailable, m_version_toohigh, maxversion, _info, Apppath + "\\Notes.xml");
m_NewVersion = maxversion;
}
else
{
PumpString("No new version(s) found...", false, false, new Version(), _info, Apppath + "\\Notes.xml");
}
}
catch (Exception tuE)
{
PumpString(tuE.Message, false, false, new Version(), _info, "");
}
}