Compare commits
2 Commits
a603d7aa41
...
71194a02b6
| Author | SHA1 | Date |
|---|---|---|
|
|
71194a02b6 | |
|
|
f22ef256eb |
|
|
@ -45,7 +45,7 @@ namespace Hopetry.Provider
|
|||
{
|
||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
||||
// Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,9 @@ namespace HeBianGu.App.Disk
|
|||
#region 参数定义
|
||||
|
||||
private SendViewModel _sendViewModel;
|
||||
|
||||
private IConfiguration config;
|
||||
|
||||
//private Task _currentUploadTask = null; // 新增:当前上传任务
|
||||
//private CancellationTokenSource _uploadCancellation = new CancellationTokenSource();
|
||||
//private int _uploadCount = 0;
|
||||
|
|
@ -221,13 +223,14 @@ namespace HeBianGu.App.Disk
|
|||
{
|
||||
await _sendViewModel.ProcessUploadTasks();
|
||||
}*/
|
||||
|
||||
Console
|
||||
.WriteLine($"弹窗返回文件数:{openFileDialog.FileNames.Length}");
|
||||
// 过滤掉已经存在的文件
|
||||
var newFiles = openFileDialog.FileNames
|
||||
.Where(filePath => !_sendViewModel.UpLoadItems.Any(item =>
|
||||
item.Value5.Equals(filePath, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToList();
|
||||
|
||||
Console.WriteLine($"过滤后的文件数:{newFiles.Count}");
|
||||
if (newFiles.Count == 0)
|
||||
{
|
||||
MessageBox.Show("没有新文件需要上传或文件已在上传队列中");
|
||||
|
|
@ -253,7 +256,6 @@ namespace HeBianGu.App.Disk
|
|||
str = fix + System.IO.Path.GetFileName(filePath);
|
||||
}
|
||||
|
||||
// todo 应该创建一个在数据库里,一个放到上传队列中
|
||||
var ut = CreateUploadItem(filePath, str, bucketName);
|
||||
_sendViewModel.AddUploadTask(ut);
|
||||
}
|
||||
|
|
@ -274,11 +276,14 @@ namespace HeBianGu.App.Disk
|
|||
{
|
||||
string folderPath = dialog.FileName;
|
||||
string folderName = new DirectoryInfo(folderPath).Name; // 获取选中的文件夹名称
|
||||
var files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories)
|
||||
.Where(filePath => !_sendViewModel.UpLoadItems.Any(item =>
|
||||
item.Value5.Equals(filePath, StringComparison.OrdinalIgnoreCase)))
|
||||
var beforeFiles = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
|
||||
Console.WriteLine($"文件夹上传选中文件数:{beforeFiles.Length}");
|
||||
var files = beforeFiles
|
||||
.Where(filePath => !_sendViewModel.UpLoadItems
|
||||
.Any(item =>
|
||||
item.Value5.Equals(filePath, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToList();
|
||||
|
||||
Console.WriteLine($"过滤后的文件数:{files.Count}");
|
||||
if (files.Count == 0)
|
||||
{
|
||||
MessageBox.Show("没有新文件需要上传或文件已在上传队列中");
|
||||
|
|
@ -294,8 +299,7 @@ namespace HeBianGu.App.Disk
|
|||
}
|
||||
|
||||
MessageProxy.Snacker.Show("正在上传列表中可查看进度");
|
||||
|
||||
|
||||
MessageProxy.Snacker.Show($"添加上传{files.Count}个文件");
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach (string filePath in files)
|
||||
|
|
@ -335,7 +339,7 @@ namespace HeBianGu.App.Disk
|
|||
fp.IsComplete = false;
|
||||
fp.FileSizeText = sizeText;
|
||||
fp.BucketName = bucketname;
|
||||
if (_uploadService.AddFile(fp))
|
||||
if (_uploadService.AddFile(fp)) //添加到数据库,成功后,添加到下载队列
|
||||
{
|
||||
return new UpLoadItems
|
||||
{
|
||||
|
|
@ -351,10 +355,8 @@ namespace HeBianGu.App.Disk
|
|||
Value1 = $"0{(fileInfo.Length < 1024 * 1024 ? "KB" : "MB")}/{sizeText}"
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("文件载入失败");
|
||||
}
|
||||
|
||||
throw new Exception("文件载入失败");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -416,6 +418,7 @@ namespace HeBianGu.App.Disk
|
|||
}
|
||||
|
||||
SelectedItems.Clear();
|
||||
// 刷新界面(网盘空间)
|
||||
_explorerBehavior.RefreshMinIOPath(CurrentMinIOPath);
|
||||
Task.Run(() => AddTaskToDownLoad(tempSelectedItems, downDir));
|
||||
}
|
||||
|
|
@ -613,15 +616,23 @@ namespace HeBianGu.App.Disk
|
|||
// 处理上传完成事件
|
||||
private void OnFileUploadCompleted(string currentPath)
|
||||
{
|
||||
// 检查当前路径是否匹配,如果是则刷新显示
|
||||
// 检查当前路径是否匹配,如果是则更新显示
|
||||
if (CurrentMinIOPath == currentPath || string.IsNullOrEmpty(currentPath))
|
||||
{
|
||||
Application.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
_explorerBehavior?.RefreshMinIOPath(CurrentMinIOPath);
|
||||
// 延迟一小段时间以确保服务器端数据同步完成
|
||||
Task.Delay(1000).ContinueWith(_ =>
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 只触发Explorer控件的更新而不完全刷新整个页面
|
||||
_explorerBehavior?.RefreshMinIOPath(CurrentMinIOPath);
|
||||
|
||||
// 更新状态信息
|
||||
UpdateStatus("文件上传完成,已刷新列表");
|
||||
// 更新状态信息
|
||||
UpdateStatus("文件上传完成,已更新列表");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace HeBianGu.App.Disk
|
|||
_uploadService = new FileUploadService();
|
||||
// 初始化Timer
|
||||
_progressTimer = new System.Timers.Timer(1000);
|
||||
_progressTimer.Elapsed += UpdateProgress;
|
||||
//_progressTimer.Elapsed += UpdateProgress;
|
||||
_heartbeatTimer = new System.Timers.Timer(30_000);
|
||||
//_heartbeatTimer.Elapsed += async (s, e) => await SendHeartbeatAsync();
|
||||
DeleteWaitUpLoadCommand = new AsyncRelayCommand(async () => await DeleteFile());
|
||||
|
|
@ -213,7 +213,7 @@ namespace HeBianGu.App.Disk
|
|||
if (_progress != value)
|
||||
{
|
||||
_progress = value;
|
||||
RaisePropertyChanged("Progress");
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ namespace HeBianGu.App.Disk
|
|||
IsAllSelected = false;
|
||||
WaitCount = WaitUpLoadItems.Count;
|
||||
// 如果没有上传任务在运行,则启动上传
|
||||
if (!_isUploading)
|
||||
/*if (!_isUploading)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -403,7 +403,7 @@ namespace HeBianGu.App.Disk
|
|||
{
|
||||
MessageBox.Show("上传失败");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -643,7 +643,7 @@ namespace HeBianGu.App.Disk
|
|||
var batchTasks = batch.Select(async item =>
|
||||
{
|
||||
// 使用带超时的信号量等待
|
||||
if (await _semaphore.WaitAsync(30000, _uploadCancellation.Token)) // 30秒超时
|
||||
if (await _semaphore.WaitAsync(-1, _uploadCancellation.Token)) // 30秒超时
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -698,8 +698,8 @@ namespace HeBianGu.App.Disk
|
|||
Shutdown();
|
||||
}
|
||||
|
||||
// 刷新网盘空间页面以显示新上传的文件
|
||||
//_explorerBehavior?.RefreshMinIOPath(CurrentMinIOPath);
|
||||
// 触发上传完成事件,让网盘空间更新数据
|
||||
FileUploadCompleted?.Invoke(CurrentMinIOPath);
|
||||
|
||||
// 执行垃圾回收以释放内存
|
||||
GC.Collect();
|
||||
|
|
@ -712,7 +712,6 @@ namespace HeBianGu.App.Disk
|
|||
private async Task UploadFileToMinIOWithProgress(UpLoadItems ut)
|
||||
{
|
||||
ut.Bool1 = true;
|
||||
|
||||
try
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
|
|
@ -831,7 +830,7 @@ namespace HeBianGu.App.Disk
|
|||
//_explorerBehavior?.RefreshMinIOPath(CurrentMinIOPath);
|
||||
|
||||
// 触发上传完成事件
|
||||
//FileUploadCompleted?.Invoke(CurrentMinIOPath);
|
||||
FileUploadCompleted?.Invoke(CurrentMinIOPath);
|
||||
Progress = (CompleteItems.Count) / (UpLoadItems.Count + CompleteItems.Count);
|
||||
// 更新网盘空间页面状态
|
||||
/*if (_explorerBehavior != null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue