public static Models.ClickonceSettings Load() { var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Models.ClickonceSettings)); var settingFile = System.IO.Path.Combine(System.Environment.CurrentDirectory, "settings.xml"); Models.ClickonceSettings result = null; if (!System.IO.File.Exists(settingFile)) { result = CreateDefault(); } else { try { using (var fs = System.IO.File.Open(settingFile, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { result = (Models.ClickonceSettings)xmlSerializer.Deserialize(fs); fs.Close(); } } catch { result = CreateDefault(); } } return(result); }
public MainView(Models.ClickonceSettings settings) { InitializeComponent(); this.Settings = settings; this.DownloadService = new Services.DownloaderService(); this.DownloadService.DownloadStarted += (s, arg) => { WriteLog(PCResource.StartDownloadLogMessage); }; this.DownloadService.DownloadProgress += new EventHandler <Services.EventArgs <KeyValuePair <int, object> > >(DownloadService_DownloadProgress); this.DownloadService.DownloadFinished += new EventHandler <EventArgs>(DownloadService_DownloadFinished); this.DownloadService.DownloadFailed += (s, arg) => { WriteLog(arg.Data.ToString()); uxCancelButton.Text = PCResource.CloseButtonText; }; // Localization uxCancelButton.Text = PCResource.CancelButtonText; uxChooseDirectoryButton.Text = PCResource.ChooseDirectoryButtonText; uxClickonceUrlLabel.Text = PCResource.ClickonceUrlLabelText; uxDownloadButton.Text = PCResource.DownloadButtonText; uxLocalInstallationFolderLabel.Text = PCResource.LocalInstallationFolderLabelText; uxLogLabel.Text = PCResource.LogLabelText; }
private static Models.ClickonceSettings CreateDefault() { var result = new Models.ClickonceSettings(); result.DestinationDirectory = System.Environment.CurrentDirectory; result.ClickonceUrl = "http://www.sample.net/my.application"; return(result); }
public void StartFullDownload(Models.ClickonceSettings settings) { if (m_BgWorker.IsBusy) { throw new Exception(PCResource.DownloadAlreadyInProgressMessage); } Settings = settings; settings.ClickonceUrl = settings.ClickonceUrl.Trim('/'); if (DownloadStarted != null) { DownloadStarted(this, new EventArgs <string>("Go")); } m_BgWorker.RunWorkerAsync(); }
public static void SaveSettings(Models.ClickonceSettings settings) { var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Models.ClickonceSettings)); var settingFile = System.IO.Path.Combine(System.Environment.CurrentDirectory, "settings.xml"); try { using (var fs = System.IO.File.Open(settingFile, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { xmlSerializer.Serialize(fs, settings); fs.Close(); } } catch (Exception ex) { // Flush error to disk } }
public int IsLatestVersion(Models.ClickonceSettings settings) { if (settings == null) { return(-1); } if (!settings.LastRunSuccess) { return(-1); } if (settings.FullExeFileName == null) { return(-1); } if (!System.IO.File.Exists(settings.FullExeFileName)) { return(-1); } DeployManifest deployManifest = null; try { string urlRedirect = null; deployManifest = DownloadDeployManifest(settings.ClickonceUrl, out urlRedirect); if (urlRedirect != settings.ClickonceUrl) { settings.ClickonceUrl = urlRedirect; } } catch (Exception ex) { return(-2); } return(deployManifest.AssemblyIdentity.Version == settings.Version ? 0 : -1); }