Compare commits
No commits in common. "c4ec37a23b97c59684197c8db07a399ac1cd7546" and "1c65b3af9d1a1da2066dcaa19ae9e2f5ab18e7e7" have entirely different histories.
c4ec37a23b
...
1c65b3af9d
57
App.xaml
57
App.xaml
|
|
@ -3,66 +3,11 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:h="https://github.com/HeBianGu"
|
||||
xmlns:local="clr-namespace:HeBianGu.App.Disk"
|
||||
xmlns:provider="clr-namespace:Hopetry.Provider"
|
||||
xmlns:models="clr-namespace:Hopetry.Models">
|
||||
xmlns:provider="clr-namespace:Hopetry.Provider">
|
||||
<h:ApplicationBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries />
|
||||
<provider:ViewModelLocator x:Key="S.ViewModelLocator.Locator" />
|
||||
<DataTemplate DataType="{x:Type models:DownFolderSelect}">
|
||||
<Grid Margin="100">
|
||||
<Border Background="{DynamicResource {x:Static h:BrushKeys.BackgroundDefault}}"
|
||||
CornerRadius="{DynamicResource {x:Static h:CornerRadiusKeys.CornerRadius}}" />
|
||||
|
||||
<DockPanel Margin="10" TextBlock.FontSize="18"
|
||||
TextBlock.Foreground="{DynamicResource {x:Static h:BrushKeys.ForegroundDefault}}">
|
||||
<TextBlock Margin="10"
|
||||
HorizontalAlignment="Left"
|
||||
DockPanel.Dock="Top"
|
||||
FontSize="{StaticResource {x:Static h:FontSizeKeys.Header2}}"
|
||||
FontWeight="Bold"
|
||||
Text="设置下载路径" />
|
||||
<h:Row>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox h:Cattach.Title="下载目录"
|
||||
Style="{StaticResource {x:Static h:TextBoxKeys.LabelNone}}"
|
||||
Text="{Binding Path=DownFolder, Mode=TwoWay}"
|
||||
VerticalAlignment="Center" Width="250" />
|
||||
<Button h:Cattach.Icon=""
|
||||
Command="{Binding Source={StaticResource S.ViewModelLocator.Locator},
|
||||
Path= LoyoutViewModel.SelectDirCommand }"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</h:Row>
|
||||
<Grid
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Bottom">
|
||||
|
||||
<Button Width="Auto"
|
||||
Command="{x:Static h:ObjectContentDialog.Close}"
|
||||
Content="kkkk" />
|
||||
<Button Width="Auto"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{x:Static h:ObjectContentDialog.Sumit}"
|
||||
Content="确认" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
<Button Width="30"
|
||||
Height="30"
|
||||
Margin="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
h:Cattach.AllowsAnimation="True"
|
||||
h:Cattach.Icon=""
|
||||
h:Cattach.IconSize="14"
|
||||
h:Cattach.MouseOverForeground="{DynamicResource {x:Static h:BrushKeys.Red}}"
|
||||
Command="{x:Static h:ObjectContentDialog.Close}"
|
||||
Style="{DynamicResource {x:Static h:ButtonKeys.Transparent}}"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<Style
|
||||
x:Key="{ComponentResourceKey ResourceId=S.ProgressBar.Custom, TypeInTargetAssembly={x:Type h:ProgressBarKeys}}"
|
||||
BasedOn="{StaticResource {x:Static h:ProgressBarKeys.Dynamic}}" TargetType="ProgressBar">
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
using System.ComponentModel;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
|
||||
namespace Hopetry.Models;
|
||||
|
||||
public class DownFolderSelect : NotifyPropertyChangedBase
|
||||
{
|
||||
private bool _isSelect;
|
||||
|
||||
public bool IsSelect
|
||||
{
|
||||
get => _isSelect;
|
||||
set
|
||||
{
|
||||
_isSelect = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private string _downFolder;
|
||||
|
||||
public string DownFolder
|
||||
{
|
||||
get => _downFolder;
|
||||
set
|
||||
{
|
||||
_downFolder = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using HeBianGu.App.Disk;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
using Hopetry.ViewModel.Send;
|
||||
using Hopetry.ViewModel.Sync;
|
||||
|
||||
|
|
@ -11,11 +10,9 @@ namespace Hopetry.Provider
|
|||
{
|
||||
ServiceRegistry.Instance.Register<SyncViewModel>();
|
||||
ServiceRegistry.Instance.Register<DownViewModel>();
|
||||
ServiceRegistry.Instance.Register<LoyoutViewModel>();
|
||||
}
|
||||
|
||||
public static SyncViewModel SyncViewModel => ServiceRegistry.Instance.GetInstance<SyncViewModel>();
|
||||
public static DownViewModel DownViewModel => ServiceRegistry.Instance.GetInstance<DownViewModel>();
|
||||
public static LoyoutViewModel LoyoutViewModel => ServiceRegistry.Instance.GetInstance<LoyoutViewModel>();
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@ using Minio;
|
|||
using HeBianGu.Control.Explorer;
|
||||
using Hopetry.Provider.Behaviors;
|
||||
using System.Text;
|
||||
using HeBianGu.Control.Message;
|
||||
using Hopetry.Provider;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
|
|
@ -29,7 +28,6 @@ namespace HeBianGu.App.Disk
|
|||
internal class LoyoutViewModel : MvcViewModelBase
|
||||
{
|
||||
#region 参数定义及初始化
|
||||
|
||||
private readonly FileUploadService _uploadService;
|
||||
private string _path;
|
||||
|
||||
|
|
@ -69,7 +67,6 @@ namespace HeBianGu.App.Disk
|
|||
RaisePropertyChanged("SharePath");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
Path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
|
||||
|
|
@ -93,19 +90,16 @@ namespace HeBianGu.App.Disk
|
|||
|
||||
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
|
||||
new Action(() => { SelectLink = LinkActions[0]; }));
|
||||
}
|
||||
|
||||
}
|
||||
protected override void Loaded(string args)
|
||||
{
|
||||
GetCompletedFiles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 文件上传
|
||||
|
||||
#region 参数定义
|
||||
|
||||
private SendViewModel _sendViewModel;
|
||||
private IConfiguration config;
|
||||
private SemaphoreSlim _semaphore = new SemaphoreSlim(5);
|
||||
|
|
@ -120,7 +114,7 @@ namespace HeBianGu.App.Disk
|
|||
private int regionCount = 0;
|
||||
private ExplorerMinIOBehavior _explorerBehavior;
|
||||
private MinIOSearchBehavior _minioBehavior;
|
||||
|
||||
|
||||
|
||||
public ICommand UploadCommand { get; }
|
||||
public ICommand UploadCommand1 { get; }
|
||||
|
|
@ -139,7 +133,6 @@ namespace HeBianGu.App.Disk
|
|||
CreateFolderCommand = new AsyncRelayCommand(async () => await CreateNewFolderAsync());
|
||||
DeleteFolderCommand = new AsyncRelayCommand(async () => await DeleteSelectedItemsAsync());
|
||||
DownloadCommand = new AsyncRelayCommand(async () => await DoDownloadCommand());
|
||||
SelectDirCommand = new CustomCommand(async () => await DoSelectDirCommand());
|
||||
//SelectItemsCommand = new AsyncRelayCommand(async () => await RelayCommand<SystemInfoModel>(SelectItem)SelectItem());
|
||||
// 初始化Timer
|
||||
_progressTimer = new Timer(1000);
|
||||
|
|
@ -148,32 +141,9 @@ namespace HeBianGu.App.Disk
|
|||
//加载上传完成列表
|
||||
GetCompletedFiles();
|
||||
}
|
||||
|
||||
private async Task DoSelectDirCommand()
|
||||
{
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog
|
||||
{
|
||||
IsFolderPicker = true
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
{
|
||||
var folderPath = dialog.FileName; // 获取选中的文件夹路径
|
||||
// todo 设置文件夹
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
DownFolderSelect.DownFolder = folderPath;
|
||||
Console.WriteLine($"选择文件夹:{folderPath}");
|
||||
});
|
||||
|
||||
// 处理选中的文件夹路径
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 行为方法
|
||||
|
||||
#region 行为方法
|
||||
// 添加设置Behavior的方法
|
||||
public void SetExplorerBehavior(ExplorerMinIOBehavior behavior)
|
||||
{
|
||||
|
|
@ -184,11 +154,9 @@ namespace HeBianGu.App.Disk
|
|||
{
|
||||
_minioBehavior = behavior;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 更新总进度条 每隔1s更新一次
|
||||
|
||||
private void UpdateProgress(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
lock (_timerLock)
|
||||
|
|
@ -226,11 +194,9 @@ namespace HeBianGu.App.Disk
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 上传执行
|
||||
|
||||
#region 上传执行
|
||||
//多文件上传
|
||||
private async Task UploadFile()
|
||||
{
|
||||
|
|
@ -261,16 +227,14 @@ namespace HeBianGu.App.Disk
|
|||
MessageBox.Show("请选择上传路径");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string filePath in newFiles)
|
||||
{
|
||||
var fix = GetCurrentPrefix(); //获取当前所在的文件夹路径,除桶之外的
|
||||
var fix = GetCurrentPrefix(); //获取当前所在的文件夹路径,除桶之外的
|
||||
string str = System.IO.Path.GetFileName(filePath);
|
||||
if (!string.IsNullOrEmpty(fix))
|
||||
{
|
||||
str = fix + "/" + System.IO.Path.GetFileName(filePath);
|
||||
}
|
||||
|
||||
var ut = CreateUploadItem(filePath, str);
|
||||
_sendViewModel.UpLoadItems.Add(ut);
|
||||
}
|
||||
|
|
@ -312,7 +276,6 @@ namespace HeBianGu.App.Disk
|
|||
MessageBox.Show("没有新文件需要上传或文件已在上传队列中");
|
||||
return;
|
||||
}
|
||||
|
||||
//判断是否存在上传路径
|
||||
string bucketName = GetCurrentBucket();
|
||||
if (string.IsNullOrEmpty(bucketName))
|
||||
|
|
@ -320,18 +283,16 @@ namespace HeBianGu.App.Disk
|
|||
MessageBox.Show("请选择上传路径");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string filePath in files)
|
||||
{
|
||||
var fix = GetCurrentPrefix(); //获取当前所在的文件夹路径,除桶之外的
|
||||
var fix = GetCurrentPrefix(); //获取当前所在的文件夹路径,除桶之外的
|
||||
string relativePath =
|
||||
folderName + "/" + filePath.Substring(folderPath.Length + 1).Replace('\\', '/');
|
||||
if (!string.IsNullOrEmpty(fix))
|
||||
{
|
||||
relativePath = fix + "/" + folderName + "/" +
|
||||
filePath.Substring(folderPath.Length + 1).Replace('\\', '/');
|
||||
relativePath = fix + "/" + folderName + "/" + filePath.Substring(folderPath.Length + 1).Replace('\\', '/');
|
||||
}
|
||||
|
||||
|
||||
var ut = CreateUploadItem(filePath, relativePath);
|
||||
_sendViewModel.UpLoadItems.Add(ut);
|
||||
}
|
||||
|
|
@ -374,8 +335,8 @@ namespace HeBianGu.App.Disk
|
|||
Value = System.IO.Path.GetFileName(filePath),
|
||||
Value3 = "等待上传",
|
||||
Value4 = fp.Id, //唯一标识,与数据库一致
|
||||
Value5 = filePath, //文件名称
|
||||
Value6 = objectName, //文件地址
|
||||
Value5 = filePath, //文件名称
|
||||
Value6 = objectName, //文件地址
|
||||
Double1 = fileInfo.Length,
|
||||
Double2 = 0.0,
|
||||
Bool1 = false,
|
||||
|
|
@ -520,11 +481,9 @@ namespace HeBianGu.App.Disk
|
|||
Application.Current.Dispatcher.Invoke(() => { ut.Value3 = $"上传失败: {ex.Message}"; });
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 其他
|
||||
|
||||
//关机
|
||||
private void Shutdown()
|
||||
{
|
||||
|
|
@ -548,7 +507,7 @@ namespace HeBianGu.App.Disk
|
|||
//加载初始完成文件
|
||||
public void GetCompletedFiles()
|
||||
{
|
||||
var files = _uploadService.GetAllFiles().Where(r => r.IsComplete == true).ToList();
|
||||
var files= _uploadService.GetAllFiles().Where(r=>r.IsComplete==true).ToList();
|
||||
ObservableCollection<UpLoadItems> up = new ObservableCollection<UpLoadItems>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
|
|
@ -557,83 +516,46 @@ namespace HeBianGu.App.Disk
|
|||
upLoadItems.Value4 = file.Id;
|
||||
upLoadItems.Value5 = file.FilePath;
|
||||
upLoadItems.Value1 = file.FileSizeText;
|
||||
upLoadItems.Value6 = file.FileName;
|
||||
upLoadItems.Value7 = file.CompleteTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
upLoadItems.Value6=file.FileName;
|
||||
upLoadItems.Value7=file.CompleteTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
up.Add(upLoadItems);
|
||||
}
|
||||
|
||||
_sendViewModel.CompleteItems.Clear();
|
||||
_sendViewModel.CompleteItems.AddRange(up);
|
||||
regionCount = up.Count;
|
||||
_sendViewModel.CompleteCount = regionCount;
|
||||
_sendViewModel.CompleteCount=regionCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 文件下载
|
||||
|
||||
private DownFolderSelect _downFolderSelect = new DownFolderSelect();
|
||||
|
||||
public DownFolderSelect DownFolderSelect
|
||||
{
|
||||
get => _downFolderSelect;
|
||||
set
|
||||
{
|
||||
_downFolderSelect = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoDownloadCommand()
|
||||
{
|
||||
// todo 当为文件时,处理
|
||||
var tempSelectedItems = new ObservableCollection<SystemInfoModel>(SelectedItems);
|
||||
SelectedItems.Clear();
|
||||
if (tempSelectedItems.Count > 0)
|
||||
var selectedItems = _selectedItems;
|
||||
// 清除选中
|
||||
//SelectedItems = [];
|
||||
foreach (var item in selectedItems)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DownFolderSelect.DownFolder))
|
||||
if (item is MinIOFileModel file)
|
||||
{
|
||||
DownFolderSelect.DownFolder = "d:/abc";
|
||||
var temp = (MinIOFileInfo)file.Model;
|
||||
var objectKey = temp.FullName.Replace(temp.BucketName + "/", "");
|
||||
ViewModelLocator.DownViewModel.AddTask(temp.BucketName, objectKey, temp.Size);
|
||||
}
|
||||
bool r = await MessageProxy.Presenter.Show(DownFolderSelect, x => true, "下载目录选择", x =>
|
||||
{
|
||||
x.Width = 800;
|
||||
x.Height = 450;
|
||||
//x.Padding = new System.Windows.Thickness(10);
|
||||
//x.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
|
||||
//x.VerticalAlignment = System.Windows.VerticalAlignment.Center;
|
||||
}, ObjectContentDialog.ClearKey);
|
||||
if (r)
|
||||
{
|
||||
// todo 开始下载
|
||||
foreach (var item in tempSelectedItems)
|
||||
{
|
||||
if (item is MinIOFileModel file)
|
||||
{
|
||||
var temp = (MinIOFileInfo)file.Model;
|
||||
var objectKey = temp.FullName.Replace(temp.BucketName + "/", "");
|
||||
ViewModelLocator.DownViewModel.AddTask(temp.BucketName, objectKey, temp.Size);
|
||||
MessageProxy.Snacker.Show($"{temp.Name} 加入下载队列");
|
||||
}
|
||||
|
||||
if (item is MinIODirectoryModel dir)
|
||||
{
|
||||
Console.WriteLine("建设中...");
|
||||
//return ((MinIODirectoryInfo)dir.Model).BucketName;
|
||||
}
|
||||
}
|
||||
if (item is MinIODirectoryModel dir)
|
||||
{
|
||||
Console.WriteLine("建设中...");
|
||||
//return ((MinIODirectoryInfo)dir.Model).BucketName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 文件列表
|
||||
|
||||
private string _currentMinIOPath;
|
||||
|
||||
/// <summary> 说明CurrentMinIOPath </summary>
|
||||
public string CurrentMinIOPath
|
||||
{
|
||||
|
|
@ -779,8 +701,6 @@ namespace HeBianGu.App.Disk
|
|||
public ICommand SelectItemsCommand => _selectItemsCommand ??
|
||||
(_selectItemsCommand = new RelayCommand<SystemInfoModel>(SelectItem));
|
||||
|
||||
public ICommand SelectDirCommand { get; set; }
|
||||
|
||||
private void SelectItem(SystemInfoModel item)
|
||||
{
|
||||
if (item == null) return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue