Пример #1
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //If the user has closed, ignore any results
            if (!this.Visible)
            {
                return;
            }

            if (e.Cancelled)
            {
                this.Close();
            }
            else if (e.Error != null || e.Result == null)
            {
                Exception ex = e.Error;
                if (ex == null)
                {
                    ex = new Exception(Strings.ListBackupFiles.NoDataError);
                }

                MessageBox.Show(this, string.Format(Strings.Common.GenericError, ex.ToString()), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            else
            {
                try
                {
                    ContentTree.BeginUpdate();
                    KeyValuePair <IList <string>, List <KeyValuePair <Library.Main.RSync.RSyncDir.PatchFileType, string> > > res = (KeyValuePair <IList <string>, List <KeyValuePair <Library.Main.RSync.RSyncDir.PatchFileType, string> > >)e.Result;

                    IList <string> sourcefolders = res.Key;
                    List <KeyValuePair <Library.Main.RSync.RSyncDir.PatchFileType, string> > entries = res.Value;

                    List <string> addedfolders        = new List <string>();
                    List <string> removedfolders      = new List <string>();
                    List <string> addedOrUpdatedfiles = new List <string>();
                    List <string> updatedfiles        = new List <string>();
                    List <string> addedfiles          = new List <string>();
                    List <string> incompletefiles     = new List <string>();
                    List <string> deletedfiles        = new List <string>();
                    List <string> controlfiles        = new List <string>();

                    foreach (KeyValuePair <Library.Main.RSync.RSyncDir.PatchFileType, string> x in entries)
                    {
                        switch (x.Key)
                        {
                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.AddedFolder:
                            addedfolders.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.DeletedFolder:
                            removedfolders.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.AddedOrUpdatedFile:
                            addedOrUpdatedfiles.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.AddedFile:
                            addedfiles.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.UpdatedFile:
                            updatedfiles.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.IncompleteFile:
                            incompletefiles.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.ControlFile:
                            controlfiles.Add(x.Value);
                            break;

                        case Duplicati.Library.Main.RSync.RSyncDir.PatchFileType.DeletedFile:
                            deletedfiles.Add(x.Value);
                            break;
                        }
                    }


                    addedfolders.Sort();
                    removedfolders.Sort();
                    deletedfiles.Sort();
                    addedOrUpdatedfiles.Sort();
                    addedfiles.Sort();
                    updatedfiles.Sort();
                    incompletefiles.Sort();
                    controlfiles.Sort();

                    foreach (string s in addedfolders)
                    {
                        AddTreeItem(s, NEW_FOLDER_IMAGE_KEY);
                    }
                    foreach (string s in removedfolders)
                    {
                        AddTreeItem(s, REMOVED_FOLDER_IMAGE_KEY);
                    }
                    foreach (string s in addedOrUpdatedfiles)
                    {
                        AddTreeItem(s, ADDED_OR_MODIFIED_FILE_IMAGE_KEY);
                    }
                    foreach (string s in addedfiles)
                    {
                        AddTreeItem(s, ADDED_FILE_IMAGE_KEY);
                    }
                    foreach (string s in updatedfiles)
                    {
                        AddTreeItem(s, MODIFIED_FILE_IMAGE_KEY);
                    }
                    foreach (string s in incompletefiles)
                    {
                        AddTreeItem(s, INCOMPLETE_FILE_IMAGE_KEY);
                    }
                    foreach (string s in controlfiles)
                    {
                        AddTreeItem(s, CONTROL_FILE_IMAGE_KEY);
                    }
                    foreach (string s in deletedfiles)
                    {
                        AddTreeItem(s, DELETED_FILE_IMAGE_KEY);
                    }

                    //Patch display to show actual source folder rather than the internal enumeration system
                    if (sourcefolders != null && sourcefolders.Count > 1)
                    {
                        foreach (TreeNode t in ContentTree.Nodes)
                        {
                            int ix;
                            if (int.TryParse(t.Text, out ix))
                            {
                                if (ix >= 0 && ix < sourcefolders.Count)
                                {
                                    t.Text = sourcefolders[ix];
                                }
                            }
                        }
                    }
                }
                finally
                {
                    ContentTree.EndUpdate();
                    ContentPanel.Visible = true;
                }
            }
        }