Пример #1
0
 private void OnPatchingComplete(IAsyncResult ar)
 {
     AsyncResult result = (AsyncResult)ar;
     Action caller = (Action)result.AsyncDelegate;
     caller.EndInvoke(ar);
     Progress1.Value = Progress1.Maximum;
     Progress2.Value = Progress2.Maximum;
     if (m_tasks.numErrors == 0)
     {
         SetIsPatching(false, true);
         Log("Downloads complete");
         m_taskStatus.Content = "Ready to launch";
         m_tabs.SelectedItem = m_tabLaunch;
     }
     else
     {
         SetIsPatching(false, false);
         m_taskStatus.Content = String.Format("There were {0} errors while attempting to update", m_tasks.numErrors);
     }
     m_tasks = null;
 }
Пример #2
0
 private void OnInstallationCheckComplete(IAsyncResult ar)
 {
     AsyncResult result = (AsyncResult)ar;
     Action<List<FileInfo>> caller = (Action<List<FileInfo>>)result.AsyncDelegate;
     caller.EndInvoke(ar);
     Debug.Assert(m_tasks != null);
     if (m_tasks.toDelete.Count > 0 || m_tasks.toDownload.Count > 0)
     {
         Log("Beginning patch process");
         m_tasks.countPatchTasks = 0;
         m_tasks.totalPatchTasks = m_tasks.toDelete.Count + m_tasks.toDownload.Count;
         Progress1.Value = Progress1.Minimum;
         Progress2.Value = Progress2.Minimum;
         Action task = new Action(this.DoPatchTasks);
         task.BeginInvoke(new AsyncCallback(OnPatchingComplete_ThreadSafe), this);
     }
     else
     {
         m_tasks = null;
         Log("Installation is up to date");
         m_taskStatus.Content = "Ready to launch";
         SetIsPatching(false, true);
         m_tabs.SelectedItem = m_tabLaunch;
     }
 }
Пример #3
0
        private void DirectoryScanComplete(List<FileInfo> results, bool error)
        {
            if (error)
            {
                Log("Something went wrong when scanning installation directory");
                m_taskStatus.Content = "Update failed";
                SetIsPatching(false, false);
                return;
            }
            if( results.Count == 0 )
            {
                MessageBoxResult r = MessageBox.Show("DayZRP is not currently installed!\nWould you like to use BitTorrent for the initial installation (faster)?", "Couldn't find existing DayZRP installation", MessageBoxButton.YesNo);
                if (r == MessageBoxResult.Yes)
                {
                    ProcessOutput.RunSafe("http://www.dayzrp.com/t-dayzrp-mod-download", "", "", null, false, true);
                    SetIsPatching(false, false);
                    return;
                }
            }

            if( m_patch.assets.Count == 0 )
            {
                Log("No files listed in patch manifest...");
                m_taskStatus.Content = "Patching failed";
                SetIsPatching(false, true);
                return;
            }

            Debug.Assert(m_tasks == null);
            m_tasks = new PatchTasks
            {
                countPatchTasks = 0,
                totalPatchTasks = results.Count + m_patch.assets.Count,
                toDelete = new List<FileInfo>(),
                toDownload = new Dictionary<DownloadLocation, Uri>(),
                numErrors = 0
            };
            Progress1.Value = Progress1.Minimum;
            Progress2.Value = Progress2.Minimum;
            Action<List<FileInfo>> task = new Action<List<FileInfo>>(this.DoInstallationChecks);
            task.BeginInvoke(results, new AsyncCallback(OnInstallationCheckComplete_ThreadSafe), this);
        }
Пример #4
0
        private void LauncherDownloadComplete(IAsyncResult ar)
        {
            AsyncResult result = (AsyncResult)ar;
            Action caller = (Action)result.AsyncDelegate;
            caller.EndInvoke(ar);
            Debug.Assert(m_tasks != null);

            if (m_tasks.numErrors != 0)
            {
                Log("Error updating launcher");
            }
            else
            {
                string currentExe = System.Reflection.Assembly.GetExecutingAssembly().Location;
                try
                {
                    string args = "-move \"" + currentExe + "\"";
                    if (ProcessOutput.RunSafe(m_tempNewPatcher.FullName, args, Path.GetDirectoryName(currentExe), null, true, true) == null)
                        Log("Trouble starting new launcher version!");
                    else
                        Application.Current.Shutdown();
                }
                catch (Exception)
                {
                    Log("Trouble restarting new launcher version!");
                }
            }
            SetIsPatching(false, false);
            m_tasks = null;
            m_tempNewPatcher = null;
        }
Пример #5
0
        private void StartLauncherDownload()
        {
            Debug.Assert(m_tasks == null);
            m_tasks = new PatchTasks
            {
                countPatchTasks = 0,
                totalPatchTasks = 1,
                toDelete = new List<FileInfo>(),
                toDownload = new Dictionary<DownloadLocation, Uri>(),
                numErrors = 0
            };

            m_tempNewPatcher = new FileInfo(Path.GetTempFileName()+"_launcher_update.exe");
            m_tasks.toDownload.Add(new DownloadLocation(m_tempNewPatcher), m_patch.launcherUri);

            Progress1.Value = Progress1.Minimum;
            Progress2.Value = Progress2.Minimum;
            Action task = new Action(DoPatchTasks);
            task.BeginInvoke(new AsyncCallback(LauncherDownloadComplete_ThreadSafe), this);
        }