private void ResouceCopy() { this.LastCutOrCopyResourceItems.Clear(); this.MessageExtensionInfo = this.MessageExtensionInfoTooltip = string.Empty; if (ResourceItems.Any(item => item.IsSelected)) { var tootipInfo = new StringBuilder(); foreach (var resourceItem in this.ResourceItems) { if (resourceItem.IsSelected) { this.LastCutOrCopyResourceItems.Add(resourceItem.CloneJson()); resourceItem.IsSelected = false; tootipInfo.AppendLine(resourceItem.ItemName); } } this._cutOrCopyStatus = CutOrCopyEnum.Copy; System.Windows.Forms.Clipboard.SetData(CommonConstant.ClipboardCopyResourceItemsDataFormats, "复制"); this.MessageExtensionInfo = string.Format("选定{0}个复制的资源", this.LastCutOrCopyResourceItems.Count); this.MessageExtensionInfoTooltip = tootipInfo.ToString().TrimEnd(Environment.NewLine.ToCharArray()); } }
private async void ResoucePasteAction(bool isCtrlV) { ResourceItem targetFolderResourceItem; if (isCtrlV) { targetFolderResourceItem = this.CurrentNavigateResourceItem; } else { if (this.CurrentSelectResourceItem == null) { targetFolderResourceItem = this.CurrentNavigateResourceItem; } else { targetFolderResourceItem = this.CurrentSelectResourceItem.IsFolder ? this.CurrentSelectResourceItem : this.CurrentNavigateResourceItem; } } foreach (var lastItem in this.LastCutOrCopyResourceItems) { var oldHref = WebUtility.UrlDecode(lastItem.ItemHref).TrimEnd('/'); string newHref; if (targetFolderResourceItem == null) { newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", WebDavConstant.RootPath.TrimEnd('/'), lastItem.ItemName)).TrimEnd('/'); } else { if (targetFolderResourceItem.IsFolder) { newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", targetFolderResourceItem.ItemHref.TrimEnd('/'), lastItem.ItemName)).TrimEnd('/'); } else { newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", targetFolderResourceItem.ParentHref.TrimEnd('/'), lastItem.ItemName)).TrimEnd('/'); } } if (oldHref != newHref) { var isExistSameNameItem = this.ResourceItems.All(item => item.ItemName != lastItem.ItemName); if (this.CurrentNavigateResourceItem != targetFolderResourceItem) { var selectedFolderItemList = await this._webDavClientService.GetList(targetFolderResourceItem == null?WebDavConstant.RootPath : targetFolderResourceItem.ItemHref); isExistSameNameItem = selectedFolderItemList.All(item => item.ItemName != lastItem.ItemName); } if (isExistSameNameItem) { if (lastItem.IsFolder && string.Format("{0}/", newHref).IndexOf(string.Format("{0}/", oldHref), StringComparison.CurrentCulture) == 0) { var dialogView = ServiceLocator.Current.GetInstance <IDialogView>(RegionNames.DialogWindowView); dialogView.ShowDialog(DialogEnum.Ok, "提示", "指定文件夹是移动/复制文件夹的子文件夹!"); } else { if (this._cutOrCopyStatus == CutOrCopyEnum.Cut) { this.NotifyMessageInfo(string.Format("正在移动资源:[{0}],请稍后...", lastItem.ItemName)); await this._webDavClientService.MoveItem(lastItem, oldHref, newHref); } if (this._cutOrCopyStatus == CutOrCopyEnum.Copy) { this.NotifyMessageInfo(string.Format("正在复制资源:[{0}],请稍后...", lastItem.ItemName)); await this._webDavClientService.CopyItem(lastItem, oldHref, newHref); } } } else { var dialogView = ServiceLocator.Current.GetInstance <IDialogView>(RegionNames.DialogWindowView); dialogView.ShowDialog(DialogEnum.Ok, "提示", string.Format("指定文件夹中已存在同名文件{0}:[{1}]!", lastItem.IsFolder ? "夹" : "", lastItem.ItemName)); } } else { var dialogView = ServiceLocator.Current.GetInstance <IDialogView>(RegionNames.DialogWindowView); dialogView.ShowDialog(DialogEnum.Ok, "提示", string.Format("不能{0}文件{1}:[{2}]至原目录!", this._cutOrCopyStatus == CutOrCopyEnum.Cut ? "移动" : "复制", lastItem.IsFolder ? "夹" : "", lastItem.ItemName)); } } this._cutOrCopyStatus = CutOrCopyEnum.None; this.MessageExtensionInfo = string.Empty; this.MessageExtensionInfoTooltip = string.Empty; this.LastCutOrCopyResourceItems.Clear(); RefreshCurrentResource(); }