예제 #1
0
        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
                                    ));
            }
        }
예제 #2
0
        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
                );
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string baseDir = Properties.Settings.Default.LastBaseDir;

            if (String.IsNullOrEmpty(baseDir))
            {
                baseDir = Environment.CurrentDirectory;
            }
            using (var dialog = new FolderBrowserDialog {
                SelectedPath = baseDir,
                ShowNewFolderButton = false,
                Description = "Select the folder containing an update"
            }) {
                if (dialog.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                baseDir = Properties.Settings.Default.LastBaseDir = dialog.SelectedPath;
            }
            Properties.Settings.Default.Save();

            var product = Directory.GetFiles(baseDir, "*.exe")
                          .Select(p => Assembly.LoadFile(p).GetCustomAttribute <UpdatableAttribute>())
                          .FirstOrDefault(a => a != null);

            if (product == null)
            {
                XtraMessageBox.Show(baseDir + " does not contain any updatable assemblies.",
                                    "Shomrei Torah Update Publisher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            UpdateInfo oldUpdate = UpdateChecker.Create(product.ProductName, new Version()).FindUpdate();               //We want to find the last update, so I search for an update for version 0.

            if (oldUpdate != null && product.CurrentVersion == oldUpdate.NewVersion &&
                DialogResult.No == XtraMessageBox.Show("The version number has not changed.\r\nCurrent clients will not download this update.\r\nDo you wish to continue?",
                                                       "Shomrei Torah Update Publisher", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
            {
                return;
            }

            ReadOnlyCollection <string> updateFiles = GetUpdateFiles(baseDir).ReadOnlyCopy();
            var element = EntryForm.Show(product, oldUpdate, updateFiles, baseDir);

            if (element == null)
            {
                return;
            }
            if (new Publisher(product, oldUpdate, element, updateFiles, baseDir).Publish())
            {
                XtraMessageBox.Show("The update has been uploaded to the server.",
                                    "Shomrei Torah Update Publisher", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }