public static XElement Show(UpdatableAttribute product, UpdateInfo oldUpdate, ReadOnlyCollection<string> updateFiles, string baseDir) { using (var form = new EntryForm()) { if (oldUpdate == null) { form.ClientSize = new Size(form.splitContainerControl1.Panel2.Width, form.ClientSize.Height); form.splitContainerControl1.PanelVisibility = SplitPanelVisibility.Panel2; } else { form.oldUpdate.ShowOldFiles(oldUpdate, updateFiles, baseDir); } form.newUpdate.ShowNewFiles(product.CurrentVersion, DefaultDescription, updateFiles, baseDir, oldUpdate); form.Text = "Update " + product.ProductName; if (form.ShowDialog() == DialogResult.Cancel) return null; var newVersion = new UpdateVersion(DateTime.Now, product.CurrentVersion, form.newUpdate.Description); return new XElement("Update", new XAttribute("Name", product.ProductName), new XElement("Versions", newVersion.ToXml(), oldUpdate == null ? null : oldUpdate.Versions.Select(v => v.ToXml()) ) //The new files are added later ); } }
public UpdateInfo FindUpdate() { try { var document = XDocument.Load(new Uri(UpdateConfig.Standard.BaseUri, new Uri(ProductName + "/Manifest.xml", UriKind.Relative)).ToString()); if (document == null) return null; var newUpdate = new UpdateInfo(document.Root); return newUpdate.NewVersion > CurrentVersion ? newUpdate : null; } catch { return null; } }
public Publisher(UpdatableAttribute product, UpdateInfo oldUpdate, XElement xml, ReadOnlyCollection<string> updateFiles, string basePath) { this.oldUpdate = oldUpdate; this.xml = xml; this.updateFiles = updateFiles; this.basePath = basePath; this.product = product; remoteBaseFolder = Combine(UpdateConfig.Standard.RemotePath, product.ProductName + "/"); }
public void ShowNewFiles(Version version, string description, ReadOnlyCollection<string> updateFiles, string basePath, UpdateInfo oldUpdate) { caption.Text = "New version: " + version.ToString(); descriptionText.Text = description; descriptionText.Properties.ReadOnly = false; //If there are old files, set everything to Added, then refine later. int defaultState = (int)(oldUpdate == null ? FileState.None : FileState.Added); var filesData = new List<TreeFile>( updateFiles .Select(p => new TreeFile(p, isFolder: false) { State = defaultState }) .OrderBy(tf => tf.Name) ); if (oldUpdate != null) { foreach (var oldFile in oldUpdate.Files) { var newPath = Path.Combine(basePath, oldFile.RelativePath); var newFile = filesData.FirstOrDefault(f => f.FullPath.Equals(newPath, StringComparison.OrdinalIgnoreCase)); if (newFile == null) continue; if (oldFile.Matches(basePath)) newFile.State = (int)FileState.Identical; else newFile.State = (int)FileState.Changed; } } //The directories must be added after setting the State properties so I don't set their's too. filesData.AddRange(Directory.EnumerateDirectories(basePath, "*.*", SearchOption.AllDirectories).Select(p => new TreeFile(p, isFolder: true))); files.RootValue = basePath; files.DataSource = filesData; files.ExpandAll(); }
public void ShowOldFiles(UpdateInfo oldUpdate, ReadOnlyCollection<string> updateFiles, string newBasePath) { caption.Text = "Existing version: " + oldUpdate.NewVersion.ToString(); descriptionText.Text = String.Format(CultureInfo.CurrentCulture, "Published: {0:F}\r\n\r\n{1}", oldUpdate.PublishDate, oldUpdate.GetChanges(new Version())); descriptionText.Properties.ReadOnly = true; var filesData = new List<TreeFile>(oldUpdate.Files.Select(uf => new TreeFile(uf, updateFiles, newBasePath)).OrderBy(tf => tf.Name)); filesData.AddRange( GetFolders(filesData.Select(f => f.FullPath)) .Select(d => new TreeFile(d, isFolder: true)) .OrderBy(tf => tf.Name) ); files.RootValue = "/"; files.DataSource = filesData; files.ExpandAll(); }