Files
ayanova7/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/CheckForUpdate.cs
2018-08-22 23:28:09 +00:00

53 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Data;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Class used to check for updates
/// </summary>
[Serializable]
public class CheckForUpdate
{
/// <summary>
/// Checks the AyaNova web server for available
/// updates to the product indicated
/// </summary>
/// <param name="sProductName">Name of product i.e. "AyaNovaFull", "AyaNovaLite"</param>
/// <param name="sVersion">Version to check (current version)</param>
/// <returns>url to update page or empty string if no update available</returns>
static public string UpdateUrl(string sProductName, string sVersion)
{
try
{
//download the update xml
WebClient wc = new WebClient();
Stream strm = wc.OpenRead("https://www.ayanova.com/updates/updates.xml");//case 3649
DataSet ds = new DataSet();
ds.ReadXml(strm);
strm.Close();
//find matching product and version
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["Product"].ToString() == sProductName && dr["Version"].ToString() == sVersion)
return dr["UpgradeInfoUrl"].ToString();
}
return "";
}
catch (System.Net.WebException e)
{
return e.Message;
}
}
}
}