添加文件

This commit is contained in:
曾艳 2024-06-13 14:35:16 +08:00
parent 7af2bd1119
commit 9ec3334f37
16 changed files with 936 additions and 7 deletions

View File

@ -0,0 +1,141 @@
/**
* v_model_version.cs
*
* N/A
* v_model_version
*
* Ver
*
* V0.01 2024/6/13 13:55:19 N/A
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*
*  
*               
*
*/
using System;
namespace Competition.Mysql.Model
{
/// <summary>
/// v_model_version:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class v_model_version
{
public v_model_version()
{}
#region Model
private string _modelid;
private string _monitor_id;
private string _modelname;
private string _versionnumber;
private string _maplongitude;
private string _maplatitude;
private string _trainingsize;
private string _modelresources;
private DateTime _updatetime;
private string _remark1;
private string _remark2;
private string _remark3;
/// <summary>
///
/// </summary>
public string ModelId
{
set{ _modelid=value;}
get{return _modelid;}
}
/// <summary>
///
/// </summary>
public string MONITOR_ID
{
set{ _monitor_id=value;}
get{return _monitor_id;}
}
/// <summary>
///
/// </summary>
public string ModelName
{
set{ _modelname=value;}
get{return _modelname;}
}
/// <summary>
///
/// </summary>
public string VersionNumber
{
set{ _versionnumber=value;}
get{return _versionnumber;}
}
/// <summary>
///
/// </summary>
public string MapLongitude
{
set{ _maplongitude=value;}
get{return _maplongitude;}
}
/// <summary>
///
/// </summary>
public string MapLatitude
{
set{ _maplatitude=value;}
get{return _maplatitude;}
}
/// <summary>
///
/// </summary>
public string TrainingSize
{
set{ _trainingsize=value;}
get{return _trainingsize;}
}
/// <summary>
///
/// </summary>
public string ModelResources
{
set{ _modelresources=value;}
get{return _modelresources;}
}
/// <summary>
///
/// </summary>
public DateTime UpdateTime
{
set{ _updatetime=value;}
get{return _updatetime;}
}
/// <summary>
///
/// </summary>
public string Remark1
{
set{ _remark1=value;}
get{return _remark1;}
}
/// <summary>
///
/// </summary>
public string Remark2
{
set{ _remark2=value;}
get{return _remark2;}
}
/// <summary>
///
/// </summary>
public string Remark3
{
set{ _remark3=value;}
get{return _remark3;}
}
#endregion Model
}
}

View File

@ -0,0 +1,105 @@
/**
* v_starter_version.cs
*
* N/A
* v_starter_version
*
* Ver
*
* V0.01 2024/6/13 13:55:19 N/A
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*
*  
*               
*
*/
using System;
namespace Competition.Mysql.Model
{
/// <summary>
/// v_starter_version:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class v_starter_version
{
public v_starter_version()
{}
#region Model
private string _starterid;
private string _softwarename;
private string _versionnumber;
private string _launcherresources;
private string _updateresources;
private string _remark1;
private string _remark2;
private string _remark3;
/// <summary>
///
/// </summary>
public string StarterId
{
set{ _starterid=value;}
get{return _starterid;}
}
/// <summary>
///
/// </summary>
public string SoftwareName
{
set{ _softwarename=value;}
get{return _softwarename;}
}
/// <summary>
///
/// </summary>
public string VersionNumber
{
set{ _versionnumber=value;}
get{return _versionnumber;}
}
/// <summary>
///
/// </summary>
public string LauncherResources
{
set{ _launcherresources=value;}
get{return _launcherresources;}
}
/// <summary>
///
/// </summary>
public string UpdateResources
{
set{ _updateresources=value;}
get{return _updateresources;}
}
/// <summary>
///
/// </summary>
public string Remark1
{
set{ _remark1=value;}
get{return _remark1;}
}
/// <summary>
///
/// </summary>
public string Remark2
{
set{ _remark2=value;}
get{return _remark2;}
}
/// <summary>
///
/// </summary>
public string Remark3
{
set{ _remark3=value;}
get{return _remark3;}
}
#endregion Model
}
}

View File

@ -28,7 +28,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
<Folder Include="Other\" />
</ItemGroup>

View File

@ -0,0 +1,141 @@
/**
* v_model_version.cs
*
* N/A
* v_model_version
*
* Ver
*
* V0.01 2024/6/13 13:55:19 N/A
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*
*  
*               
*
*/
using System;
namespace Competition.Mysql.Model
{
/// <summary>
/// v_model_version:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class v_model_version
{
public v_model_version()
{}
#region Model
private string _modelid;
private string _monitor_id;
private string _modelname;
private string _versionnumber;
private string _maplongitude;
private string _maplatitude;
private string _trainingsize;
private string _modelresources;
private DateTime _updatetime;
private string _remark1;
private string _remark2;
private string _remark3;
/// <summary>
///
/// </summary>
public string ModelId
{
set{ _modelid=value;}
get{return _modelid;}
}
/// <summary>
///
/// </summary>
public string MONITOR_ID
{
set{ _monitor_id=value;}
get{return _monitor_id;}
}
/// <summary>
///
/// </summary>
public string ModelName
{
set{ _modelname=value;}
get{return _modelname;}
}
/// <summary>
///
/// </summary>
public string VersionNumber
{
set{ _versionnumber=value;}
get{return _versionnumber;}
}
/// <summary>
///
/// </summary>
public string MapLongitude
{
set{ _maplongitude=value;}
get{return _maplongitude;}
}
/// <summary>
///
/// </summary>
public string MapLatitude
{
set{ _maplatitude=value;}
get{return _maplatitude;}
}
/// <summary>
///
/// </summary>
public string TrainingSize
{
set{ _trainingsize=value;}
get{return _trainingsize;}
}
/// <summary>
///
/// </summary>
public string ModelResources
{
set{ _modelresources=value;}
get{return _modelresources;}
}
/// <summary>
///
/// </summary>
public DateTime UpdateTime
{
set{ _updatetime=value;}
get{return _updatetime;}
}
/// <summary>
///
/// </summary>
public string Remark1
{
set{ _remark1=value;}
get{return _remark1;}
}
/// <summary>
///
/// </summary>
public string Remark2
{
set{ _remark2=value;}
get{return _remark2;}
}
/// <summary>
///
/// </summary>
public string Remark3
{
set{ _remark3=value;}
get{return _remark3;}
}
#endregion Model
}
}

View File

@ -0,0 +1,105 @@
/**
* v_starter_version.cs
*
* N/A
* v_starter_version
*
* Ver
*
* V0.01 2024/6/13 13:55:19 N/A
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*
*  
*               
*
*/
using System;
namespace Competition.Mysql.Model
{
/// <summary>
/// v_starter_version:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class v_starter_version
{
public v_starter_version()
{}
#region Model
private string _starterid;
private string _softwarename;
private string _versionnumber;
private string _launcherresources;
private string _updateresources;
private string _remark1;
private string _remark2;
private string _remark3;
/// <summary>
///
/// </summary>
public string StarterId
{
set{ _starterid=value;}
get{return _starterid;}
}
/// <summary>
///
/// </summary>
public string SoftwareName
{
set{ _softwarename=value;}
get{return _softwarename;}
}
/// <summary>
///
/// </summary>
public string VersionNumber
{
set{ _versionnumber=value;}
get{return _versionnumber;}
}
/// <summary>
///
/// </summary>
public string LauncherResources
{
set{ _launcherresources=value;}
get{return _launcherresources;}
}
/// <summary>
///
/// </summary>
public string UpdateResources
{
set{ _updateresources=value;}
get{return _updateresources;}
}
/// <summary>
///
/// </summary>
public string Remark1
{
set{ _remark1=value;}
get{return _remark1;}
}
/// <summary>
///
/// </summary>
public string Remark2
{
set{ _remark2=value;}
get{return _remark2;}
}
/// <summary>
///
/// </summary>
public string Remark3
{
set{ _remark3=value;}
get{return _remark3;}
}
#endregion Model
}
}

View File

@ -0,0 +1,141 @@
/**
* v_model_version.cs
*
* N/A
* v_model_version
*
* Ver
*
* V0.01 2024/6/13 13:55:19 N/A
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*
*  
*               
*
*/
using System;
namespace Competition.Mysql.Model
{
/// <summary>
/// v_model_version:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class v_model_version
{
public v_model_version()
{}
#region Model
private string _modelid;
private string _monitor_id;
private string _modelname;
private string _versionnumber;
private string _maplongitude;
private string _maplatitude;
private string _trainingsize;
private string _modelresources;
private DateTime _updatetime;
private string _remark1;
private string _remark2;
private string _remark3;
/// <summary>
///
/// </summary>
public string ModelId
{
set{ _modelid=value;}
get{return _modelid;}
}
/// <summary>
///
/// </summary>
public string MONITOR_ID
{
set{ _monitor_id=value;}
get{return _monitor_id;}
}
/// <summary>
///
/// </summary>
public string ModelName
{
set{ _modelname=value;}
get{return _modelname;}
}
/// <summary>
///
/// </summary>
public string VersionNumber
{
set{ _versionnumber=value;}
get{return _versionnumber;}
}
/// <summary>
///
/// </summary>
public string MapLongitude
{
set{ _maplongitude=value;}
get{return _maplongitude;}
}
/// <summary>
///
/// </summary>
public string MapLatitude
{
set{ _maplatitude=value;}
get{return _maplatitude;}
}
/// <summary>
///
/// </summary>
public string TrainingSize
{
set{ _trainingsize=value;}
get{return _trainingsize;}
}
/// <summary>
///
/// </summary>
public string ModelResources
{
set{ _modelresources=value;}
get{return _modelresources;}
}
/// <summary>
///
/// </summary>
public DateTime UpdateTime
{
set{ _updatetime=value;}
get{return _updatetime;}
}
/// <summary>
///
/// </summary>
public string Remark1
{
set{ _remark1=value;}
get{return _remark1;}
}
/// <summary>
///
/// </summary>
public string Remark2
{
set{ _remark2=value;}
get{return _remark2;}
}
/// <summary>
///
/// </summary>
public string Remark3
{
set{ _remark3=value;}
get{return _remark3;}
}
#endregion Model
}
}

View File

@ -0,0 +1,105 @@
/**
* v_starter_version.cs
*
* N/A
* v_starter_version
*
* Ver
*
* V0.01 2024/6/13 13:55:19 N/A
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*
*  
*               
*
*/
using System;
namespace Competition.Mysql.Model
{
/// <summary>
/// v_starter_version:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class v_starter_version
{
public v_starter_version()
{}
#region Model
private string _starterid;
private string _softwarename;
private string _versionnumber;
private string _launcherresources;
private string _updateresources;
private string _remark1;
private string _remark2;
private string _remark3;
/// <summary>
///
/// </summary>
public string StarterId
{
set{ _starterid=value;}
get{return _starterid;}
}
/// <summary>
///
/// </summary>
public string SoftwareName
{
set{ _softwarename=value;}
get{return _softwarename;}
}
/// <summary>
///
/// </summary>
public string VersionNumber
{
set{ _versionnumber=value;}
get{return _versionnumber;}
}
/// <summary>
///
/// </summary>
public string LauncherResources
{
set{ _launcherresources=value;}
get{return _launcherresources;}
}
/// <summary>
///
/// </summary>
public string UpdateResources
{
set{ _updateresources=value;}
get{return _updateresources;}
}
/// <summary>
///
/// </summary>
public string Remark1
{
set{ _remark1=value;}
get{return _remark1;}
}
/// <summary>
///
/// </summary>
public string Remark2
{
set{ _remark2=value;}
get{return _remark2;}
}
/// <summary>
///
/// </summary>
public string Remark3
{
set{ _remark3=value;}
get{return _remark3;}
}
#endregion Model
}
}

View File

@ -7,6 +7,13 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\Json\**" />
<Content Remove="wwwroot\Json\**" />
<EmbeddedResource Remove="wwwroot\Json\**" />
<None Remove="wwwroot\Json\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Controllers\demo\p3k2d4gz.r22~" />
</ItemGroup>
@ -46,10 +53,6 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\Json\" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\Upload\1.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -83,4 +86,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
</Project>

View File

@ -2,8 +2,8 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>CompetitionAPI</ActiveDebugProfile>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
<NameOfLastUsedPublishProfile>F:\项目\禄口机场农电竞赛\web\LKJCpowerSupplyOfficeSimulationSystem\CompetitionAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CompetitionAPI.Controllers.version
{
[Route("api/[controller]")]
[ApiController]
public class EditModelController : ControllerBase
{
}
}

View File

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CompetitionAPI.Controllers.version
{
[Route("api/[controller]")]
[ApiController]
public class EditStarterController : ControllerBase
{
}
}

View File

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CompetitionAPI.Controllers.version
{
[Route("api/[controller]")]
[ApiController]
public class GetModelListController : ControllerBase
{
}
}

View File

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CompetitionAPI.Controllers.version
{
[Route("api/[controller]")]
[ApiController]
public class GetStarterListController : ControllerBase
{
}
}

View File

@ -0,0 +1,129 @@
using Competition.Common.Util;
using CompetitionAPI.api;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Polly;
namespace CompetitionAPI.Controllers.version
{
[Route("api/[controller]")]
[ApiController]
public class UploadController : Controller
{
private readonly IWebHostEnvironment _webHostEnvironment;
public IConfiguration Configuration { get; }
public UploadController(IWebHostEnvironment webHostEnvironment, IConfiguration configuration)
{
_webHostEnvironment = webHostEnvironment;
Configuration = configuration;
}
/// <summary>
/// 分片上传文件接口
/// </summary>
/// <param name="file">请求参数</param>
/// <returns></returns>
[Authorize]
[HttpPost]
public async Task<JsonResult> RuleUploadFile([FromQuery] SliceFileInfo file)
{
try
{
string path = System.IO.Path.Combine(_webHostEnvironment.WebRootPath, "Upload", file.FolderName);
var files = Request.Form.Files;
var buffer = new byte[file.Size];
var fileName = file.Name.Replace("(", "").Replace(")", "").Replace("", "").Replace("", "");
path = path + "//" + fileName + "//";
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
string filepath = path + "//" + file.Name.Replace("(", "").Replace(")", "").Replace("", "").Replace("", "") + "^" + file.Number;
using (var stream = new FileStream(filepath, FileMode.Append))
{
await files[0].CopyToAsync(stream);
}
var filesList = Directory.GetFiles(Path.GetDirectoryName(path));
//当顺序号等于分片总数量 合并文件
if ((file.Number + 1) == file.Count || filesList.Length == file.Count)
{
await MergeFile(file);
return Json(Tool.GetJsonWithCode(APICode.Success, "/Upload/" + file.FolderName + "/" + file.Name.Replace("(", "").Replace(")", "").Replace("", "").Replace("", "") + "/" + fileName.Split("~")[0].ToString()));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Success, "成功"));
}
}
catch (Exception ex)
{
return Json(Tool.GetJsonWithCode(APICode.Fail, ex.Message));
}
}
/// <summary>
/// 合并文件
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
private async Task MergeFile(SliceFileInfo file)
{
string path = System.IO.Path.Combine(_webHostEnvironment.WebRootPath, "Upload", file.FolderName);
var fileName = file.Name.Replace("(", "").Replace(")", "").Replace("", "").Replace("", "");
path = path + "//" + fileName + "//";
string baseFileName = path + fileName.Split("~")[0].ToString();
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
var filesList = Directory.GetFiles(Path.GetDirectoryName(path));
if (filesList.Length != file.Count)
{
return;
}
List<FileSort> lstFile = new List<FileSort>();
foreach (var item in filesList)
{
lstFile.Add(new FileSort()
{
Name = item,
NumBer = Convert.ToInt32(item.Substring(item.IndexOf('^') + 1))
});
}
lstFile = lstFile.OrderBy(x => x.NumBer).ToList();
using (var fileStream = new FileStream(baseFileName, FileMode.Create))
{
//foreach (var fileSort in filesList)
//{
// using (FileStream fileChunk = new FileStream(fileSort, FileMode.Open))
// {
// await fileChunk.CopyToAsync(fileStream);
// }
//}
await Policy.Handle<IOException>()
.RetryForeverAsync()
.ExecuteAsync(async () =>
{
foreach (var fileSort in lstFile)
{
using (FileStream fileChunk = new FileStream(fileSort.Name, FileMode.Open))
{
await fileChunk.CopyToAsync(fileStream);
}
}
});
}
//删除分片文件
foreach (var dirfile in filesList)
{
System.IO.File.Delete(dirfile);
}
}
}
}

View File

@ -0,0 +1,6 @@
namespace CompetitionAPI.api.version
{
public class EditModelRequest
{
}
}

View File

@ -0,0 +1,6 @@
namespace CompetitionAPI.api.version
{
public class EditStarterRequest
{
}
}