下载目录设置
parent
d29116d9aa
commit
c270561920
|
|
@ -70,14 +70,14 @@ public class MinioDownloadTask : INotifyPropertyChanged
|
||||||
CancelCommand = new CustomCommand(OnCancel);
|
CancelCommand = new CustomCommand(OnCancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinioDownloadTask(MinioService minio, string bucket, string objectKey)
|
public MinioDownloadTask(MinioService minio, string bucket, string objectKey,string downDir)
|
||||||
{
|
{
|
||||||
Status = "等待中";
|
Status = "等待中";
|
||||||
_minio = minio;
|
_minio = minio;
|
||||||
Bucket = bucket;
|
Bucket = bucket;
|
||||||
ObjectKey = objectKey;
|
ObjectKey = objectKey;
|
||||||
FileName = Path.GetFileName(objectKey);
|
FileName = Path.GetFileName(objectKey);
|
||||||
FilePath = "f:\\dest";
|
FilePath = downDir;
|
||||||
PauseCommand = new CustomCommand(OnPause);
|
PauseCommand = new CustomCommand(OnPause);
|
||||||
CancelCommand = new CustomCommand(OnCancel);
|
CancelCommand = new CustomCommand(OnCancel);
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +104,7 @@ public class MinioDownloadTask : INotifyPropertyChanged
|
||||||
await client.Updateable(updateTask).IgnoreNullColumns().ExecuteCommandAsync();
|
await client.Updateable(updateTask).IgnoreNullColumns().ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"{ObjectKey}文件下载中...");
|
Console.WriteLine($"id {TaskId} path: {FilePath} key: {ObjectKey}文件下载中...");
|
||||||
updateTask.Status = "下载中";
|
updateTask.Status = "下载中";
|
||||||
await _minio.DownLoadObject(Bucket, ObjectKey, FilePath, "");
|
await _minio.DownLoadObject(Bucket, ObjectKey, FilePath, "");
|
||||||
Status = "已完成";
|
Status = "已完成";
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,8 @@ namespace HeBianGu.App.Disk
|
||||||
{
|
{
|
||||||
// todo 当为文件时,处理
|
// todo 当为文件时,处理
|
||||||
var selectedItems = _selectedItems;
|
var selectedItems = _selectedItems;
|
||||||
|
// 清除选中
|
||||||
|
//SelectedItems = [];
|
||||||
foreach (var item in selectedItems)
|
foreach (var item in selectedItems)
|
||||||
{
|
{
|
||||||
if (item is MinIOFileModel file)
|
if (item is MinIOFileModel file)
|
||||||
|
|
@ -173,6 +175,7 @@ namespace HeBianGu.App.Disk
|
||||||
//return ((MinIODirectoryInfo)dir.Model).BucketName;
|
//return ((MinIODirectoryInfo)dir.Model).BucketName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加设置Behavior的方法
|
// 添加设置Behavior的方法
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using HeBianGu.Base.WpfBase;
|
using HeBianGu.Base.WpfBase;
|
||||||
|
|
@ -11,7 +10,6 @@ using Hopetry.Models;
|
||||||
using Hopetry.Provider;
|
using Hopetry.Provider;
|
||||||
using Hopetry.Services;
|
using Hopetry.Services;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace Hopetry.ViewModel.Send;
|
namespace Hopetry.ViewModel.Send;
|
||||||
|
|
||||||
|
|
@ -27,6 +25,7 @@ public class DownViewModel : MvcViewModelBase
|
||||||
private CancellationTokenSource _processingCts = new();
|
private CancellationTokenSource _processingCts = new();
|
||||||
public int count { get; set; }
|
public int count { get; set; }
|
||||||
private readonly ReaderWriterLockSlim _lock = new();
|
private readonly ReaderWriterLockSlim _lock = new();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 全部任务动态标题
|
/// 全部任务动态标题
|
||||||
|
|
@ -104,14 +103,15 @@ public class DownViewModel : MvcViewModelBase
|
||||||
// 命令
|
// 命令
|
||||||
public ICommand AddTaskCommand { get; set; }
|
public ICommand AddTaskCommand { get; set; }
|
||||||
public ICommand ClearFinishedCommand { get; }
|
public ICommand ClearFinishedCommand { get; }
|
||||||
|
private readonly ISerializerService _serializerService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="minioService"></param>
|
/// <param name="minioService"></param>
|
||||||
public DownViewModel(MinioService minioService)
|
public DownViewModel(MinioService minioService, ISerializerService serializerService)
|
||||||
{
|
{
|
||||||
|
_serializerService = serializerService;
|
||||||
_minioService = minioService;
|
_minioService = minioService;
|
||||||
Console.WriteLine("初始化DownViewModel");
|
Console.WriteLine("初始化DownViewModel");
|
||||||
using var client = SqlSugarConfig.GetSqlSugarScope();
|
using var client = SqlSugarConfig.GetSqlSugarScope();
|
||||||
|
|
@ -178,17 +178,18 @@ public class DownViewModel : MvcViewModelBase
|
||||||
{
|
{
|
||||||
Console.WriteLine($"我进入的异常下载{c1++}");
|
Console.WriteLine($"我进入的异常下载{c1++}");
|
||||||
// 启动新线程执行下载任务
|
// 启动新线程执行下载任务
|
||||||
// _ = Task.Run(() => ExecuteTaskAsync(task));
|
// _ = Task.Run(() => ExecuteTaskAsync(task));
|
||||||
_ = ExecuteTaskAsync(task).ContinueWith(_ => _semaphore.Release());
|
_ = ExecuteTaskAsync(task).ContinueWith(_ => _semaphore.Release());
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTask(string bucketName,string objectKey)
|
public void AddTask(string bucketName, string objectKey)
|
||||||
{
|
{
|
||||||
var task = new MinioDownloadTask(_minioService, bucketName,objectKey);
|
var downDir = ViewModelLocator.SyncViewModel.SyncDir;
|
||||||
|
var task = new MinioDownloadTask(_minioService, bucketName, objectKey,downDir);
|
||||||
using var client = SqlSugarConfig.GetSqlSugarScope();
|
using var client = SqlSugarConfig.GetSqlSugarScope();
|
||||||
client.Insertable(task).ExecuteCommandIdentityIntoEntity();
|
client.Insertable(task).ExecuteCommandIdentityIntoEntity();
|
||||||
AllTasks.Add(task);
|
AllTasks.Add(task);
|
||||||
|
|
@ -202,7 +203,8 @@ public class DownViewModel : MvcViewModelBase
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await task.StartDownload();
|
await task.StartDownload();
|
||||||
// todo 任务完成下载
|
var x = AllTasks.IndexOf(task);
|
||||||
|
Console.WriteLine($"完成任务在全部任务中的位置 :{x}");
|
||||||
RefreshViewHeader();
|
RefreshViewHeader();
|
||||||
Console.WriteLine($"异步下载完成:{task.FileName}");
|
Console.WriteLine($"异步下载完成:{task.FileName}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue