Esempio n. 1
0
        private void OnPatchingProgressCompleted(object sender, ProgressCompletedEventArgs e)
        {
            PatchingTask task = e.State as PatchingTask;

            if (task != null)
            {
                string status = "Patching Complete";

                if (e.ExceptionObject != null)
                {
                    _errorMessages.Add(string.Format("Patching Manager reporting the following error: {0} - {1}", task.PatchType,
                                                     ((Exception)e.ExceptionObject).Message));

                    status = String.Format("Failed: {0}", ((Exception)e.ExceptionObject).Message);
                }

                Invoke((MethodInvoker) delegate()
                {
                    ListViewItem item = _patchTable[task];
                    UpdatePatchingStatus(task, item, e.Current, e.Max, e.ProgressPercentage, status);
                });

                _patchesComplete++;

                if (_patchesComplete == _patchCount)
                {
                    Complete();
                }
            }
        }
Esempio n. 2
0
 private void UpdatePatchingStatus(PatchingTask task, ListViewItem item, int current, int total, int completed, string status)
 {
     item.SubItems[0].Text = task.PatchType;
     item.SubItems[1].Text = "100";
     item.SubItems[2].Text = string.Format("{0}", current);
     item.SubItems[3].Text = string.Format("{0:00}%", completed);
     item.SubItems[4].Text = status;
 }
Esempio n. 3
0
        private void OnPatchingProgressUpdate(object sender, ProgressUpdateEventArgs e)
        {
            PatchingTask task = e.State as PatchingTask;

            if (task != null)
            {
                Invoke((MethodInvoker) delegate()
                {
                    ListViewItem item = _patchTable[task];
                    UpdatePatchingStatus(task, item, e.Current, e.Max, e.ProgressPercentage, "Patching...");
                });
            }
        }
Esempio n. 4
0
        private void InitializePatchingProcess()
        {
            Invoke((MethodInvoker) delegate()
            {
                lblStatus.Text = "Status: Gathering patching information...";
            });

            DirectoryInfo   directory = new DirectoryInfo(_serverDirectory);
            List <FileInfo> files     = new List <FileInfo>();

            FileInfo[] muoFiles = directory.GetFiles("*.muo");
            FileInfo[] uopFiles = directory.GetFiles("*.uop");
            FileInfo[] mulFiles = directory.GetFiles("verdata.mul");

            List <FileInfo> patchFiles = new List <FileInfo>();

            patchFiles.AddRange(muoFiles);
            patchFiles.AddRange(uopFiles);
            patchFiles.AddRange(mulFiles);

            List <Patch> patches = new List <Patch>();

            for (int i = 0; i < patchFiles.Count; i++)
            {
                PatchReader reader = new PatchReader(
                    File.OpenRead(patchFiles[i].FullName), PatchReader.ExtensionToPatchFileType(patchFiles[i].FullName));

                patches.AddRange(reader.ReadPatches());
                reader.Close();
            }

            for (int i = 0; i < muoFiles.Length; i++)
            {
                muoFiles[i].Delete();
            }
            for (int i = 0; i < uopFiles.Length; i++)
            {
                uopFiles[i].Delete();
            }
            for (int i = 0; i < mulFiles.Length; i++)
            {
                mulFiles[i].Delete();
            }

            if (patches.Count <= 0)
            {
                Complete();
                return;
            }

            Dictionary <int, List <Patch> > typedPatchTable = new Dictionary <int, List <Patch> >();

            for (int i = 0; i < patches.Count; i++)
            {
                if (!typedPatchTable.ContainsKey(patches[i].FileId))
                {
                    typedPatchTable.Add(patches[i].FileId, new List <Patch>());
                }

                typedPatchTable[patches[i].FileId].Add(patches[i]);
            }

            Invoke((MethodInvoker) delegate()
            {
                lvDownloads.Items.Clear();

                columnHeader1.Text = "Mul File";
                columnHeader2.Text = "Total";
                columnHeader3.Text = "Completed";
                columnHeader4.Text = "Progress";
                columnHeader7.Text = "Status";
            });

            List <int> keys = new List <int>(typedPatchTable.Keys);

            _patchCount = keys.Count;

            for (int i = 0; i < keys.Count; i++)
            {
                int key = keys[i];
                patches = typedPatchTable[keys[i]];

                if (patches.Count > 0)
                {
                    FileId id = (FileId)i;

                    PatchingTask task = new PatchingTask(patches.ToArray(), _serverDirectory, id.ToString().Replace('_', '.'));

                    task.ProgressUpdate    += new EventHandler <ProgressUpdateEventArgs>(OnPatchingProgressUpdate);
                    task.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(OnPatchingProgressCompleted);

                    ListViewItem item = new ListViewItem(new string[5]);

                    Invoke((MethodInvoker) delegate()
                    {
                        lvDownloads.Items.Add(item);
                        UpdatePatchingStatus(task, item, 0, 100, 0, "Patching Queued");
                    });

                    _patchTable.Add(task, item);
                    _patchManager.Queue(task);
                }
            }

            _patchManager.Begin();
        }