Esempio n. 1
0
        /// <summary>
        /// Applies the update.
        /// </summary>
        /// <param name="package">The package.</param>
        public void SaveUpdatePackage(UpdatePackage package)
        {
            if (!package.IsAvailable)
             	return;

             var versionDirectory = finder.GetVersionDirectory(parameters.RootFolder, package.Version);
             if (versionDirectory != null)
                 return;

             var mutex = new Mutex(false, parameters.RootFolder.Replace("\\", "|"));
             mutex.WaitOne();

             try
             {
                 using (Stream tempStream = SaveUpdatePackageAsFile(package))
                 {
                     versionDirectory = finder.GetVersionDirectory(parameters.RootFolder, package.Version);
                     if (versionDirectory != null)
                         return;

                     var targetDir = parameters.RootFolder;
                     if (!Directory.Exists(targetDir))
                         Directory.CreateDirectory(targetDir);

                     zip.UnpackFolder(tempStream, targetDir);
                 }
             }
             finally
             {
                 mutex.ReleaseMutex();
             }
        }
Esempio n. 2
0
 private Stream SaveUpdatePackageAsFile(UpdatePackage package)
 {
     var fileStream = File.Create(Path.GetTempFileName(), 1024 * 1024,
                                 FileOptions.DeleteOnClose | FileOptions.SequentialScan);
     package.UpdateZipStream.CopyTo(fileStream);
     fileStream.Seek(0, SeekOrigin.Begin);
     return fileStream;
 }
 public void SaveUpdatePackage(UpdatePackage package)
 {
     updatePackage = package;
 }
 /// <summary>
 /// Receives the update pakage.
 /// </summary>
 /// <param name="updatePackage"></param>
 public void ReceiveUpdatePackage(UpdatePackage updatePackage)
 {
     throw new CommunicationException();
 }
Esempio n. 5
0
        /// <summary>
        /// Receives the update pakage.
        /// </summary>
        /// <param name="updatePackage"></param>
        public void ReceiveUpdatePackage(UpdatePackage updatePackage)
        {
            if (IsStarted)
            {
                TestRunner.ReceiveUpdatePackage(updatePackage);

                // emulate, that an updates monitor has detected an update
                // and triggered system restart
                new Action(() =>
                               {
                                   Thread.Sleep(50);
                                   ShutDownInExpectedWay();
                                   versionProvider.SetVersion(updatePackage.Version);
                                   Start();
                               }).BeginInvoke(null, null);
                return;
            }

            throw new CommunicationException("Agent seems to be not available");
        }