/// <summary>
        /// プロパティボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Proparties_Click(object sender, EventArgs e)
        {
            if (!CheckSelectItem())
            {
                DialogManagement.ShowMessageDialog("警告", "アイテムを指定してください", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if ((SelectObject.Tag as string) == "Object")
            {
                var            head           = OciResources.GetObjectHead(NameSpaceName, NowBucket, FullPath + SelectObject.Text, SelectObject.SubItems[1].Text);
                PropartiesForm propartiesForm = new PropartiesForm();
                propartiesForm.SetObject(head, SelectObject.Text, SelectObject.SubItems[1].Text);
                propartiesForm.Show();
            }
            else if ((SelectObject.Tag as string) == "Bucket")
            {
                var            head           = OciResources.GetBucketHead(NameSpaceName, SelectObject.Text, SelectObject.SubItems[1].Text);
                PropartiesForm propartiesForm = new PropartiesForm();
                propartiesForm.SetBucket(head, SelectObject.Text, SelectObject.SubItems[1].Text);
                propartiesForm.Show();
            }
            else if ((SelectObject.Tag as string) == "Directory")
            {
                PropartiesForm propartiesForm = new PropartiesForm();
                propartiesForm.SetDirectory(SelectObject.Text, FullPath, SelectObject.SubItems[1].Text);
                propartiesForm.Show();
            }
        }
        /// <summary>
        /// 削除ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Delete_Click(object sender, EventArgs e)
        {
            if (!CheckSelectItem())
            {
                DialogManagement.ShowMessageDialog("警告", "アイテムを指定してください", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            bool res = true;

            if (ObjectList.SelectedItems.Count > 1)
            {
                DialogResult resulet = DialogManagement.ShowMessageDialog("確認", $"選択されたすべてを削除します。よろしいですか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (resulet != DialogResult.Yes)
                {
                    return;
                }

                var targets = ObjectList.SelectedItems.Cast <ListViewItem>();
                foreach (var item in targets)
                {
                    DeleteItem(item, true);
                }

                if (string.IsNullOrEmpty(NowBucket))
                {
                    SetAllBucket(NowCompartmentId);
                }
                else
                {
                    SetDir(FullPath);
                }
            }
            else if (ObjectList.SelectedItems.Count == 1)
            {
                string target = (SelectObject.Tag as string);

                DialogResult resulet = DialogManagement.ShowMessageDialog("確認", $"{target} [ {SelectObject.Text} ] を削除しますか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (resulet != DialogResult.Yes)
                {
                    return;
                }

                res = DeleteItem(SelectObject, false);
            }

            if (res)
            {
                if (string.IsNullOrEmpty(NowBucket))
                {
                    SetAllBucket(NowCompartmentId);
                }
                else
                {
                    SetDir(FullPath);
                }
            }
        }
        private void PathBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (!IsConnection || string.IsNullOrEmpty(NowBucket))
            {
                return;
            }

            if (e.KeyCode == Keys.Return)
            {
                var path = PathBox.Text;
                if (!path.EndsWith("/"))
                {
                    path += "/";
                }
                var checkDir = new ObjectStorageDirectoryInfo(OciResources.GetObjectStorageClient(), NameSpaceName, NowBucket, path);
                if (checkDir.Exists)
                {
                    SetPath(path);
                    SetDir(path);
                }
                else
                {
                    DialogManagement.ShowMessageDialog("エラー", $"{path} が見つかりませんでした", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    PathBox.SelectAll();
                }
            }
        }
예제 #4
0
        private void SetListFiles(string path)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            if (CheckFolder(path))
            {
                SearchOption searchOption = SearchOption.AllDirectories;
                if (TopDirectoryCheck.Checked)
                {
                    searchOption = SearchOption.TopDirectoryOnly;
                }
                try
                {
                    var files = directoryInfo.EnumerateFiles("*", searchOption);

                    foreach (var file in files)
                    {
                        string[] itemView = new string[] { file.FullName, "waiting" };
                        FileListView.Items.Add(new ListViewItem(itemView));
                    }
                    FileListView.Refresh();
                }
                catch (Exception e)
                {
                    DialogManagement.ShowMessageDialog("エラー", e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                DialogManagement.ShowMessageDialog("エラー", "フォルダーが見つかりませんでした", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        private void DownloadButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(SavePathBox.Text))
            {
                DialogManagement.ShowMessageDialog("エラー", "保存先を指定してください", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            CancelBtn.Enabled = false;

            bool res;

            if (IsFile)
            {
                res = OneDownloadFile();
            }
            else
            {
                res = DirectoryDownloadFile();
            }

            CancelBtn.Enabled = true;

            if (res)
            {
                DialogManagement.ShowMessageDialog("完了", "ダウンロードが完了しました", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (AutoCloseCheck.Checked)
                {
                    this.Close();
                }
            }
        }
예제 #6
0
        private string GetSavePath(string originName, bool isDirMode, bool isForceSave)
        {
            var newName = originName;

            if (!isDirMode)
            {
                newName = newName.Replace("/", "_");
            }
            var pathBoxText = SavePathBox.Text;

            if (IsBucket)
            {
                pathBoxText += BucketName + "\\";
            }
            var savePath = DecodeKey(pathBoxText + newName);

            if (!isForceSave)
            {
                FileInfo fileInfo = new FileInfo(savePath);
                if (fileInfo.Exists)
                {
                    DialogResult resulet = DialogManagement.ShowMessageDialog("確認", $"{savePath}を上書きしますか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (resulet == DialogResult.No)
                    {
                        return("");
                    }
                }
            }

            return(savePath);
        }
예제 #7
0
        private void FolderSelectBtn_Click(object sender, EventArgs e)
        {
            FileListView.Items.Clear();
            var path = DialogManagement.FolderSelectDialogShow();

            SetListFiles(path);
        }
        private bool DeleteItem(ListViewItem targetItem, bool force)
        {
            bool res  = false;
            var  name = targetItem.Text;

            if ((targetItem.Tag as string) == "Object")
            {
                res = OciResources.DeleteObject(NameSpaceName, NowBucket, FullPath + name, NowRegion);
            }
            else if ((targetItem.Tag as string) == "Bucket")
            {
                if (!force)
                {
                    DialogResult resulet = DialogManagement.ShowMessageDialog("確認", $"バケット {name} 内すべてのオブジェクトが削除されます。よろしいですか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (resulet != DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                var region = targetItem.SubItems[1].Text;
                res = OciResources.DeleteBucket(NameSpaceName, name, region);
                if (res)
                {
                    SetAllBucket(NowCompartmentId);
                }
            }
            else if ((targetItem.Tag as string) == "Directory")
            {
                if (!force)
                {
                    DialogResult resulet = DialogManagement.ShowMessageDialog("確認", $"ディレクトリ {name} 内すべてのオブジェクトが削除されます。よろしいですか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (resulet != DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                res = OciResources.DeleteDirectory(NameSpaceName, NowBucket, FullPath + name, NowRegion);
            }

            if (res)
            {
                return(true);
            }
            else
            {
                DialogManagement.ShowMessageDialog("エラー", $"{name} の削除に失敗しました", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
예제 #9
0
 private void SelectButton_Click(object sender, EventArgs e)
 {
     if (IsFile && OptionFilenameSetButton.Checked)
     {
         var defaultPath = @"C:\";
         if (!string.IsNullOrEmpty(SavePathBox.Text))
         {
             defaultPath = SavePathBox.Text;
         }
         SavePathBox.Text = DialogManagement.SaveDialogShow(defaultPath);
     }
     else
     {
         SavePathBox.Text = DialogManagement.FolderSelectDialogShow();
     }
 }
예제 #10
0
        private void MakeBtn_Click(object sender, EventArgs e)
        {
            bool res;

            if (IsBucket)
            {
                if (RegionsBox.SelectedItem == null || string.IsNullOrEmpty(RegionsBox.SelectedItem.ToString()))
                {
                    DialogManagement.ShowMessageDialog("エラー", "リージョンを指定してください", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                res = OciResources.CreateBucket(NamespaceName, NameTextBox.Text, CompartmentId, RegionsBox.SelectedItem.ToString());
            }
            else
            {
                if (NameTextBox.Text.StartsWith("/"))
                {
                    DialogManagement.ShowMessageDialog("エラー", "名称の先頭に / を入れないでください", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!NameTextBox.Text.EndsWith("/"))
                {
                    NameTextBox.Text += "/";
                }

                if (NameTextBox.Text.Contains("//"))
                {
                    DialogManagement.ShowMessageDialog("エラー", $"不正なパスを指定しています。\n[{NameTextBox.Text}]", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                res = OciResources.CreateDirectory(NamespaceName, BucketName, DirectoryName + NameTextBox.Text, RegionName);
            }

            if (!res)
            {
                DialogManagement.ShowMessageDialog("エラー", $"{(IsBucket ? "バケット" : "ディレクトリ")}作成に失敗しました", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }
예제 #11
0
        private void FileSelectBtn_Click(object sender, EventArgs e)
        {
            var paths = DialogManagement.MultipleFileOpenDialogShow(@"C:\");

            foreach (var path in paths)
            {
                if (string.IsNullOrEmpty(path))
                {
                    continue;
                }
                FileInfo fileInfo = new FileInfo(path);
                if (fileInfo.Exists)
                {
                    string[] itemView = new string[] { fileInfo.FullName, "waiting" };
                    FileListView.Items.Add(new ListViewItem(itemView));
                }
            }
        }
예제 #12
0
        private bool DirectoryDownloadFile()
        {
            var isDirMode   = OptionRadioButtonA.Checked;
            var isForceSave = OptionForceSaveButton.Checked;

            if (!SavePathBox.Text.EndsWith("\\"))
            {
                SavePathBox.Text += "\\";
            }

            var files = GetDireftoryInfo(TargetName);

            progressBar1.Maximum = files.Count();
            List <string> failedNames = new List <string>();

            foreach (var file in files)
            {
                DownloadNowLab.Text = "download...[" + file.OriginalKey + "]";
                var savePath = GetSavePath(file.OriginalKey, isDirMode, isForceSave);
                var res      = OciResources.DownloadObject(NamespaceName, BucketName, file.OriginalKey, RegionName, savePath);
                if (!res)
                {
                    failedNames.Add(file.OriginalKey);
                }
                progressBar1.Value++;
                DownloadNowLab.Refresh();
                progressBar1.Refresh();
            }
            ;

            if (failedNames.Count() > 0)
            {
                var message = "";
                foreach (var name in failedNames)
                {
                    message += $"{name}\n";
                }
                DialogManagement.ShowMessageDialog("エラー", message + "のダウンロードができませんでした", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            progressBar1.Value  = 0;
            DownloadNowLab.Text = "";
            return(true);
        }
        /// <summary>
        /// アップロードボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Upload_Click(object sender, EventArgs e)
        {
            if (!IsConnection)
            {
                return;
            }

            if (string.IsNullOrEmpty(NowBucket))
            {
                DialogManagement.ShowMessageDialog("警告", "バケットを選択してください", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            UploadForm uploadForm = new UploadForm(OciResources, NameSpaceName, NowBucket, FullPath, NowRegion);

            if (uploadForm.ShowDialog() == DialogResult.OK)
            {
                SetDir(FullPath);
            }
        }
        /// <summary>
        /// ダウンロードボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuDownload_Click(object sender, EventArgs e)
        {
            if (!CheckSelectItem())
            {
                DialogManagement.ShowMessageDialog("警告", "アイテムを指定してください", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if ((SelectObject.Tag as string) == "Object")
            {
                DownloadForm downloadForm = new DownloadForm(OciResources, NameSpaceName, NowBucket, FullPath + SelectObject.Text, SelectObject.SubItems[1].Text);
                downloadForm.Show();
            }
            else if ((SelectObject.Tag as string) == "Bucket")
            {
                DownloadForm downloadForm = new DownloadForm(OciResources, NameSpaceName, SelectObject.Text, "", SelectObject.SubItems[1].Text);
                downloadForm.Show();
            }
            else if ((SelectObject.Tag as string) == "Directory")
            {
                DownloadForm downloadForm = new DownloadForm(OciResources, NameSpaceName, NowBucket, FullPath + SelectObject.Text + "/", SelectObject.SubItems[1].Text);
                downloadForm.Show();
            }
        }
        /// <summary>
        /// 名前変更
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuRename_Click(object sender, EventArgs e)
        {
            if ((SelectObject.Tag as string) == "Bucket")
            {
                DialogManagement.ShowMessageDialog("警告", "バケットの名称は変更できません", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            if ((SelectObject.Tag as string) == "Object")
            {
                InputForm inputForm = new InputForm("オブジェクト名を入力してください", SelectObject.Text);
                inputForm.ShowDialog(this);
                if (inputForm.DialogResult == DialogResult.OK)
                {
                    var text = inputForm.TextValue;
                    if (text != SelectObject.Text)
                    {
                        string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                        if (OciResources.RenameObject(NameSpaceName, NowBucket, FullPath + SelectObject.Text, NowRegion, FullPath + text))
                        {
                            if (text.Contains("/"))
                            {
                                SetDir(FullPath);
                            }
                            else
                            {
                                SelectObject.Text             = text;
                                SelectObject.SubItems[3].Text = now;
                            }
                        }
                        else
                        {
                            DialogManagement.ShowMessageDialog("エラー", "名前の変更に失敗しました", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else if ((SelectObject.Tag as string) == "Directory")
            {
                InputForm inputForm = new InputForm("ディレクトリ名を入力してください", SelectObject.Text);
                inputForm.ShowDialog(this);
                if (inputForm.DialogResult == DialogResult.OK)
                {
                    var text = inputForm.TextValue;
                    if (text == SelectObject.Text)
                    {
                        return;
                    }
                    if (text.StartsWith("/"))
                    {
                        text = text.Remove(0, 1);
                    }
                    if (!text.EndsWith("/"))
                    {
                        text += "/";
                    }
                    List <string> failedFiles = new List <string>();
                    OciResources.GetObjectStorageClient().SetRegion(NowRegion);
                    var directoryInfo = new ObjectStorageDirectoryInfo(OciResources.GetObjectStorageClient(), NameSpaceName, NowBucket, FullPath + SelectObject.Text);
                    var files         = directoryInfo.EnumerateFiles("*", System.IO.SearchOption.AllDirectories);
                    var result        = DialogManagement.ShowMessageDialog("警告", "ディレクトリ下のすべてのファイルとディレクトリが変更されます。\nこの処理にはしばらくかかります。\n実行しますか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                    LoadingPanelVisible(true);
                    foreach (var file in files)
                    {
                        var sourceName = file.OriginalKey;
                        var newName    = text + file.OriginalKey.Replace(FullPath + SelectObject.Text + "/", "");
                        if (!OciResources.RenameObject(NameSpaceName, NowBucket, sourceName, NowRegion, newName))
                        {
                            failedFiles.Add(file.FullName);
                        }
                    }
                    LoadingPanelVisible(false);
                    if (failedFiles.Count > 0)
                    {
                        var message = "";
                        foreach (var name in failedFiles)
                        {
                            message += $"{name}\n";
                        }
                        DialogManagement.ShowMessageDialog("エラー", message + "の名前変更ができませんでした", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    if (ObjectList.Items.Find(inputForm.TextValue, false).Length > 0)
                    {
                        ObjectList.Items.Remove(SelectObject);
                    }
                    else
                    {
                        SelectObject.Text = inputForm.TextValue;
                    }
                    inputForm.Dispose();
                }
            }
        }
예제 #16
0
        private void UploadFiles(List <ListViewItem> targets, bool isForce)
        {
            ParallelOptions po = new ParallelOptions();

            CancellationTokenSource   = new CancellationTokenSource();
            po.CancellationToken      = CancellationTokenSource.Token;
            po.MaxDegreeOfParallelism = System.Environment.ProcessorCount;
            try
            {
                Parallel.ForEach(targets, po, item =>
                {
                    var paths               = item.Text.Split('\\');
                    var filename            = paths[paths.Length - 1];
                    DialogResult resulet    = DialogResult.Yes;
                    HeadObjectResponse head = null;
                    if (!isForce)
                    {
                        try
                        {
                            head = OciResources.GetObjectHead(NamespaceName, BucketName, TargetPath + filename, RegionName);
                        }
                        catch (WebException we)
                        {
                            if (we.Status.Equals(WebExceptionStatus.ProtocolError) && ((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.NotFound)
                            {
                                head = null;
                            }
                            else
                            {
                                throw;
                            }
                        }
                        if (head != null)
                        {
                            resulet = DialogManagement.ShowMessageDialog("確認", "オブジェクト [" + TargetPath + filename + "] を上書きしますか?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        }
                    }
                    if (resulet == DialogResult.Yes)
                    {
                        if (!OciResources.PutObject(NamespaceName, BucketName, TargetPath + filename, RegionName, item.Text))
                        {
                            DialogManagement.ShowMessageDialog("エラー", "ファイル [" + item.Text + "] のアップロードに失敗しました", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            FileListView.Invoke((MethodInvoker) delegate {
                                item.SubItems[1].Text = "Failed";
                            });
                        }
                        else
                        {
                            FileListView.Invoke((MethodInvoker) delegate {
                                item.SubItems[1].Text = "Successed";
                            });
                        }

                        ProgressBar.Invoke((MethodInvoker) delegate {
                            ProgressBar.Value++;
                        });
                    }
                });
            }
            catch (OperationCanceledException oce)
            {
                DialogManagement.ShowMessageDialog("警告", "アップロードはキャンセルされました。\nMessage:" + oce.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                CancellationTokenSource.Dispose();

                ProgressBar.Invoke((MethodInvoker) delegate {
                    ProgressBar.Value = 0;
                });

                UploadMode(false);

                DialogManagement.ShowMessageDialog("完了", "アップロードが完了しました", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }