예제 #1
0
        /// <summary>
        /// Apply downloaded updates. Method will execute behavior method after files are unpacked.
        /// </summary>
        /// <param name="behavior">Defines behavior of update method after files are unpacked. For example you can backup your database etc.</param>
        /// <param name="publicToken">Public token is used to unpack files in UpdatePackage. Public token can be obtained while using BitsUpdatePacker app and creating package.</param>
        /// <returns>True if everything went well.</returns>
        public bool Update(IUpdateBehavior behavior, string publicToken)
        {
            if (_status.NextVersion > Assembly.GetEntryAssembly().GetName().Version&& File.Exists(GetUpdateSaveLocation()))
            {
                UpdatePackage.Extract(new DirectoryInfo(string.Format(_updateDirectory, _status.NextVersion)), _status.NextVersion, publicToken);

                if (behavior != null)
                {
                    behavior.Execute();
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
 private void CreatePackageExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (IsValid((Grid)sender))
     {
         var package = new UpdatePackage(_package.CertificatePath, _package.NextVersion, _package.IsDifferential);
         foreach (var item in UIUpdatePackage.ConvertFileTemplates(_package.IncludedFiles))
         {
             package.IncludedFiles.Add(item);
         }
         foreach (var item in UIUpdatePackage.ConvertFileTemplates(_package.ExcludedFiles))
         {
             package.ExcludedFiles.Add(item);
         }
         _package.TokenString = package.Create(new DirectoryInfo(_package.OutputDirectory));
         CreateManifest();
         MessageBox.Show(this
                       , "Update package was successfully completed."
                       , "Package Completed!"
                       , MessageBoxButton.OK
                       , MessageBoxImage.Asterisk);
     }
 }