#region smart client
public static int returnCode=0;
private bool appUpdater1_OnCheckForUpdate(object sender, System.EventArgs e)
{
bool updateAvailable;
string updateUrl;
// Instantiate a web service to check for updates
UpdateWeb.UpdateService updateService = new UpdateWeb.UpdateService();
//Change the Url as appropriate for your web server
string sUrl=ConfigurationSettings.AppSettings["updateurl"];
updateService.Url = sUrl;//"http://10.157.34.80/AdvancedSample_WebService/UpdateService.asmx";
//Call the web service. Notice that this is a sync call, but it is still async since we're on
//a seperate thread.
updateAvailable = updateService.CheckForUpdate(
Microsoft.Samples.AppUpdater.AppUpdater.GetLatestInstalledVersion().ToString(), out updateUrl);
//Set the UpdateUrl to the location of the current update
if (updateAvailable == true)
appUpdater2.UpdateUrl = updateUrl;
//Indicate whether an update was found or not.
return updateAvailable;
}
private void appUpdater1_OnUpdateComplete(object sender, Microsoft.Samples.AppUpdater.UpdateCompleteEventArgs e)
{
//If the udpate succeeded...
if ( e.UpdateSucceeded)
{
string message = "更新完成,需要重新启动程序,否则会容易造成错误,是否重新启动程序?";
if (MessageBox.Show(this,message,"更新完成", MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
{
//The return code must be set to tell appstart to restart the app
//returnCode = Microsoft.Samples.AppUpdater.AppUpdater.RestartAppReturnValue;
MES.MainStart.nRet = Microsoft.Samples.AppUpdater.AppUpdater.RestartAppReturnValue;
//The app must shut itself down. Note: Don't use methods like Environment.Exit that
//will shut down the entire process, when using appstart in appdomain mode.
this.Close();
}
}
//If the update failed....
else
{
string message = "程序更新失败!";
MessageBox.Show(this,message,"更新", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void appUpdater1_OnUpdateDetected(object sender, System.EventArgs e)
{
string message = "一个新的更新被检测到,是否进行更新?";
if (MessageBox.Show(this,message,"更新",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
{
appUpdater2.DownloadUpdate();
}
}
#endregion smart client
public static int nRet=0;
[STAThread]
static int Main()
{
RemotingConfiguration.Configure("MesApp.exe.config");
Application.Run(new frmLogin());
return BaseSystemForm.returnCode;
}
浙公网安备 33010602011771号