Compare commits

...

2 Commits

Author SHA1 Message Date
洁 任 821658b06a Merge branch 'dev' of http://123.132.248.154:10000/chenwei/FieldWorkClient into dev 2025-03-27 09:32:07 +08:00
洁 任 a4b5c8a3d5 第一次测试完修改 2025-03-27 09:32:04 +08:00
3 changed files with 63 additions and 31 deletions

View File

@ -371,7 +371,7 @@ namespace HeBianGu.App.Disk
UploadCommand = new AsyncRelayCommand(async () => await UploadFile());
UploadCommand1 = new AsyncRelayCommand(async () => await UploadFile1());
// 初始化Timer
// 初始化Timer
_progressTimer = new System.Timers.Timer(1000);
_progressTimer.Elapsed += UpdateProgress;
}
@ -444,7 +444,7 @@ namespace HeBianGu.App.Disk
var ut = CreateUploadItem(filePath, System.IO.Path.GetFileName(filePath));
_sendViewModel.UpLoadItems.Add(ut);
}
MessageBox.Show("传输列表中可查看进度");
// 如果没有上传任务在运行,则启动上传
if (!_isUploading)
{
@ -464,6 +464,7 @@ namespace HeBianGu.App.Disk
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
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)))
@ -477,11 +478,11 @@ namespace HeBianGu.App.Disk
foreach (string filePath in files)
{
string relativePath = filePath.Substring(folderPath.Length + 1).Replace('\\', '/');
string relativePath = folderName + "/" + filePath.Substring(folderPath.Length + 1).Replace('\\', '/');
var ut = CreateUploadItem(filePath, relativePath);
_sendViewModel.UpLoadItems.Add(ut);
}
MessageBox.Show("传输列表中可查看进度");
// 如果没有上传任务在运行,则启动上传
if (!_isUploading)
{
@ -495,8 +496,8 @@ namespace HeBianGu.App.Disk
{
FileInfo fileInfo = new FileInfo(filePath);
string sizeText = fileInfo.Length < 1024 * 1024 ?
$"{Math.Round((double)(fileInfo.Length / 1024), 2)}KB" :
$"{Math.Round((double)(fileInfo.Length / (1024 * 1024)), 2)}MB";
$"{Math.Ceiling((decimal)fileInfo.Length / 1024)}KB" :
$"{Math.Ceiling((decimal)fileInfo.Length / (1024 * 1024))}MB";
return new UpLoadItems
{
@ -583,25 +584,6 @@ namespace HeBianGu.App.Disk
{
string bucketName = "test";
//// 检查文件是否已存在
//var statArgs = new StatObjectArgs()
// .WithBucket(bucketName)
// .WithObject(ut.Value6);
//try
//{
// await client.StatObjectAsync(statArgs);
// // 文件已存在,跳过上传
// ut.Value3 = "已存在";
// ut.Bool1 = true;
// ut.Double2 = ut.Double1; // 设置已传输大小为总大小
// return;
//}
//catch (Exception)
//{
// // 文件不存在,继续上传
//}
// 确保桶存在
var beArgs = new BucketExistsArgs().WithBucket(bucketName);
bool found = await client.BucketExistsAsync(beArgs).ConfigureAwait(false);
@ -622,11 +604,20 @@ namespace HeBianGu.App.Disk
int slashIndex = ut.Value1.IndexOf('/');
string sizePart = ut.Value1.Substring(slashIndex);
string transferredPart = trans < 1024 * 1024 ?
$"{Math.Round((double)(trans / 1024), 0)}KB" :
$"{Math.Round((double)(trans / (1024 * 1024)), 2)}MB";
$"{Math.Ceiling((decimal)trans / 1024)}KB" :
$"{Math.Ceiling((decimal)trans / (1024 * 1024))}MB";
ut.Value1 = $"{transferredPart}{sizePart}";
ut.Value3 = "上传中...";
if (progressReport.Percentage == 100)
{
ut.Value3 = "已完成";
//_sendViewModel.UpLoadItems.Remove(ut);
//_sendViewModel.CompleteItems.Add(ut);
}
else
{
ut.Value3 = "上传中...";
}
});
});
@ -636,9 +627,7 @@ namespace HeBianGu.App.Disk
.WithFileName(ut.Value5)
.WithProgress(progress);
await client.PutObjectAsync(putObjectArgs);
ut.Value3 = "已完成";
await client.PutObjectAsync(putObjectArgs);
}
catch (Exception ex)
{

View File

@ -0,0 +1,31 @@
using HeBianGu.Base.WpfBase;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hopetry.ViewModel.Send
{
internal class CompleteItems : TestViewModel
{
#region - 属性 -
private ObservableCollection<TreeNodeBase<TestViewModel>> _items = new ObservableCollection<TreeNodeBase<TestViewModel>>();
/// <summary> 说明 </summary>
public ObservableCollection<TreeNodeBase<TestViewModel>> Items
{
get { return _items; }
set
{
_items = value;
RaisePropertyChanged("Items");
}
}
#endregion
#region - 命令 -
#endregion
}
}

View File

@ -46,6 +46,18 @@ namespace HeBianGu.App.Disk
}
}
private ObservableCollection<UpLoadItems> _completeItems = new ObservableCollection<UpLoadItems>();
/// <summary> 说明 </summary>
public ObservableCollection<UpLoadItems> CompleteItems
{
get { return _completeItems; }
set
{
_completeItems = value;
RaisePropertyChanged("CompleteItems");
}
}
private double _progress;
public double Progress