Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            switch (Type)
            {
            case LockErrorType.Temp:
                //button2.Text = "Delete";

                foreach (LockError error in Errors)
                {
                    if (error.IsFile)
                    {
                        Storages.DeleteFile(error.Path, NewErrors, true);
                    }
                    else
                    {
                        Storages.DeleteFolder(error.Path, NewErrors, null);
                    }
                }

                break;

            case LockErrorType.Blocked:
                //button2.Text = "Retry";

                foreach (LockError error in Errors)
                {
                    if (error.IsFile)
                    {
                        Storages.DeleteFile(error.Path, NewErrors, true);
                    }
                    else
                    {
                        Storages.DeleteFolder(error.Path, NewErrors, null);
                    }
                }

                break;

            case LockErrorType.Unexpected:
                //button2.Text = "Retry";

                // try to unlock again
                Cursor = Cursors.WaitCursor;

                foreach (LockError error in Errors)
                {
                    if (error.IsFile)
                    {
                        string path = Path.GetDirectoryName(error.Path);
                        Storages.UnlockFile(ParentView.UserID, ParentView.ProjectID, path.Replace(RootPath, ""), error.File, error.History, NewErrors);
                    }
                    // dont know to unlock subs or not
                    else
                    {
                        ParentView.UnlockFolder(ParentView.GetFolderNode(error.Path.Replace(RootPath, "")), error.Subs, NewErrors);
                    }
                }

                Cursor = Cursors.Default;

                break;

            case LockErrorType.Existing:
                //button2.Text = "Use";

                if (ParentView.Working != null)
                {
                    foreach (LockError error in Errors)
                    {
                        string path = error.Path.Replace(RootPath, "");

                        LocalFolder folder = ParentView.Working.GetLocalFolder(Utilities.StripOneLevel(path));

                        if (folder == null)
                        {
                            return;
                        }

                        LocalFile file = folder.GetFile(error.File.Name);

                        file.Info.SetFlag(StorageFlags.Unlocked);
                        Storages.MarkforHash(file, error.Path, ParentView.ProjectID, folder.GetPath());
                    }
                }

                break;

            case LockErrorType.Missing:
                //button2.Text = "Download";

                foreach (LockError error in Errors)
                {
                    Storages.DownloadFile(ParentView.UserID, error.File);
                }

                ParentView.WatchTransfers = true;

                break;
            }

            Close();
        }