예제 #1
0
        public override void Update(Updater updater, string tangra3Path, bool acceptBetaUpdates, IProgressUpdate progress)
        {
            string newVerFileLocalFileName = System.IO.Path.GetFullPath(System.IO.Path.GetTempPath() + "\\" + SharedUpdateConstants.MAIN_UPDATER_EXECUTABLE_NAME);

            if (System.IO.File.Exists(newVerFileLocalFileName))
            {
                System.IO.File.Delete(newVerFileLocalFileName);
            }

            // Download the new AutoUpdate version under newVerFileLocalFileName
            string fileLocation = null;

            if (string.IsNullOrEmpty(ArchivedPath))
            {
                fileLocation = Path;
            }
            else
            {
                fileLocation = ArchivedPath;
            }

            try
            {
                progress.RefreshMainForm();
                updater.UpdateFile(fileLocation, newVerFileLocalFileName, !string.IsNullOrEmpty(ArchivedPath), progress);
            }
            catch (WebException wex)
            {
                progress.OnError(wex);

                return;
            }

            string selfUpdaterExecutable = Config.Instance.PrepareTangra3SelfUpdateTempFile(tangra3Path, acceptBetaUpdates, newVerFileLocalFileName);

            using (Stream selfUpdater = Shared.AssemblyHelper.GetEmbededResourceStreamThatClientMustDispose("AutoUpdate.SelfUpdate", "AutoUpdateSelfUpdate.bin"))
            {
                byte[] buffer = new byte[selfUpdater.Length];
                selfUpdater.Read(buffer, 0, buffer.Length);
                System.IO.File.WriteAllBytes(selfUpdaterExecutable, buffer);
            }

            // Run the copyFileName passing as argument current process ID and then terminate the current process fast!
            var currProcess = Process.GetCurrentProcess();
            var pi          = new ProcessStartInfo(selfUpdaterExecutable, currProcess.Id.ToString());

            if (System.Environment.OSVersion.Version.Major > 5)
            {
                // UAC Elevate as Administrator for Windows Vista, Win7 and later
                pi.Verb = "runas";
            }

            pi.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(pi);

            currProcess.Kill();
        }
예제 #2
0
        private void UpdateWorkerThread(object status)
        {
            KeyValuePair <UpdateObject, IProgressUpdate> data = (KeyValuePair <UpdateObject, IProgressUpdate>)status;
            UpdateObject    module = data.Key;
            IProgressUpdate ipu    = data.Value;

            try
            {
                module.Update(updater, tangra3Path, acceptBetaUpdates, ipu);
            }
            catch (Exception ex)
            {
                ipu.OnError(ex);
            }
        }
예제 #3
0
        public virtual void Update(Updater updater, string tangra3Path, bool acceptBetaUpdates, IProgressUpdate progress)
        {
            foreach (Schema.File fileToUpdate in AllFiles)
            {
                try
                {
                    string localFilePath;

                    if (fileToUpdate.Action == "DeleteIfExists")
                    {
                        localFilePath = updater.GetLocalFileName(fileToUpdate);
                        if (System.IO.File.Exists(localFilePath))
                        {
                            try
                            {
                                System.IO.File.Delete(localFilePath);
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(ex);
                            }
                        }
                        return;
                    }

                    localFilePath = updater.UpdateFile(fileToUpdate, progress);

                    OnFileUpdated(fileToUpdate, localFilePath);

                    if (!string.IsNullOrEmpty(fileToUpdate.Action))
                    {
                        ExecutePostUpdateAction(fileToUpdate, localFilePath);
                    }
                }
                catch (Exception ex)
                {
                    progress.OnError(ex);
                    return;
                }
            }
        }
예제 #4
0
        public override void Update(Updater updater, string occuRecPath, bool acceptBetaUpdates, IProgressUpdate progress)
        {
            string newVerFileLocalFileName = System.IO.Path.GetFullPath(System.IO.Path.GetTempPath() + "\\OccuRecUpdate.exe");

            if (System.IO.File.Exists(newVerFileLocalFileName))
                System.IO.File.Delete(newVerFileLocalFileName);

            // Download the new OccuRecUpdate version under newVerFileLocalFileName
            string fileLocation = null;
            if (string.IsNullOrEmpty(ArchivedPath))
                fileLocation = Path;
            else
                fileLocation = ArchivedPath;

            try
            {
                progress.RefreshMainForm();
                updater.UpdateFile(fileLocation, newVerFileLocalFileName, !string.IsNullOrEmpty(ArchivedPath), progress);
            }
            catch (WebException wex)
            {
                progress.OnError(wex);

                return;
            }

            string selfUpdaterExecutable = Config.Instance.PrepareOccuRecSelfUpdateTempFile(occuRecPath, acceptBetaUpdates, newVerFileLocalFileName);

            using (Stream selfUpdater = Shared.AssemblyHelper.GetEmbededResourceStreamThatClientMustDispose("OccuRecUpdate.SelfUpdate", "OccuRecSelfUpdate.bin"))
            {
                byte[] buffer = new byte[selfUpdater.Length];
                selfUpdater.Read(buffer, 0, buffer.Length);
                System.IO.File.WriteAllBytes(selfUpdaterExecutable, buffer);
            }

            // Run the copyFileName passing as argument current process ID and then terminate the current process fast!
            Process currProcess = Process.GetCurrentProcess();
            ProcessStartInfo pi = new ProcessStartInfo(selfUpdaterExecutable, currProcess.Id.ToString());

            if (System.Environment.OSVersion.Version.Major > 5)
                // UAC Elevate as Administrator for Windows Vista, Win7 and later
                pi.Verb = "runas";

            pi.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(pi);

            currProcess.Kill();
        }
예제 #5
0
        public virtual void Update(Updater updater, string occuRecPath, bool acceptBetaUpdates, IProgressUpdate progress)
        {
            foreach (Schema.File fileToUpdate in AllFiles)
            {
                try
                {
                    string localFilePath;

                    if (fileToUpdate.Action == "DeleteIfExists")
                    {
                        localFilePath = updater.GetLocalFileName(fileToUpdate);
                        if (System.IO.File.Exists(localFilePath))
                        {
                            try
                            {
                                System.IO.File.Delete(localFilePath);
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(ex);
                            }
                        }
                        return;
                    }

                    localFilePath = updater.UpdateFile(fileToUpdate, progress);

                    OnFileUpdated(fileToUpdate, localFilePath);

                    if (!string.IsNullOrEmpty(fileToUpdate.Action))
                        ExecutePostUpdateAction(fileToUpdate, localFilePath);
                }
                catch (Exception ex)
                {
                    progress.OnError(ex);
                    return;
                }
            }
        }