Bläddra i källkod

vscode插件接口

lichunlei 4 månader sedan
förälder
incheckning
ef5303220c

+ 157 - 0
Controllers/Feign/VsCodeController.cs

@@ -0,0 +1,157 @@
+using Attribute;
+using Base;
+using Common;
+using Dto;
+using Enums;
+using Extensions;
+using Filters;
+using Infrastructure;
+using Infrastructure.Model;
+using Mapster;
+using Microsoft.AspNetCore.Mvc;
+using Middleware;
+using Model;
+using Model.Base;
+using Services;
+using Util;
+using Vo;
+
+namespace Controllers.Feign
+{
+    public class VsCodeController : BaseController
+    {
+        private readonly IVersionsService versionsService;
+        private readonly IVersionForProjectService versionForProjectService;
+        private readonly IMakeFilesService makeFilesService;
+
+        public VsCodeController(IVersionsService versionsService, IVersionForProjectService versionForProjectService, IMakeFilesService makeFilesService)
+        {
+            this.versionsService = versionsService;
+            this.versionForProjectService = versionForProjectService;
+            this.makeFilesService = makeFilesService;
+        }
+
+        /// <summary>
+        /// vscode项目版本列表
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        [HttpGet("/api/vscode/versions")]
+        public IActionResult versions([FromQuery] VersionDto para)
+        {
+            TokenModel tokenModel = JwtUtil.GetLoginUser(HttpContext);
+            if(tokenModel == null)
+            {
+                return ToResponse(ResultCode.BAD_REQUEST, "用户未登录");
+            }
+            List<VersionVo> list = new List<VersionVo>();
+            VersionForProject ver = versionForProjectService.GetFirst(m => m.databaseId == para.serverId) ?? new VersionForProject();
+            var versions = versionsService.GetList(m => m.serverId == para.serverId && m.groupId == tokenModel.userId);
+            foreach(var version in versions)
+            {
+                VersionVo item = new VersionVo();
+                item.versionId = version.versionId;
+                item.batchNo = version.versionNo;
+                if(version.versionNo.StartsWith("java")) item.verNo = ver.javaVersion;
+                if(version.versionNo.StartsWith("net")) item.verNo = ver.netVersion;
+                if(version.versionNo.StartsWith("vue")) item.verNo = ver.frontendVersion;
+                if(version.versionNo.StartsWith("py")) item.verNo = ver.pythonVersion;
+                item.createTime = version.createTime == null ? "" : version.createTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
+                list.Add(item);
+            }
+            return SUCCESS(list);
+        }
+
+        /// <summary>
+        /// vscode项目文件列表
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        [HttpGet("/api/vscode/files")]
+        public IActionResult files([FromQuery] FileDto para)
+        {
+            TokenModel tokenModel = JwtUtil.GetLoginUser(HttpContext);
+            if(tokenModel == null)
+            {
+                return ToResponse(ResultCode.BAD_REQUEST, "用户未登录");
+            }
+            Versions version = versionsService.GetFirst(m => m.versionId == para.versionId) ?? new Versions();
+            VersionForProject ver = versionForProjectService.GetFirst(m => m.databaseId == version.serverId) ?? new VersionForProject();
+            int verNo = 1;
+            if(version.versionNo.StartsWith("java")) verNo = ver.javaVersion;
+            if(version.versionNo.StartsWith("net")) verNo = ver.netVersion;
+            if(version.versionNo.StartsWith("vue")) verNo = ver.frontendVersion;
+            if(version.versionNo.StartsWith("py")) verNo = ver.pythonVersion;
+            List<FileVo> list = GetFileList(para.versionId, verNo, 0);
+            return SUCCESS(list);
+        }
+        public List<FileVo> GetFileList(int versionId, int verNo, int parentFileId = 0)
+        {
+            List<FileVo> list = new List<FileVo>();
+            var files = makeFilesService.GetList(m => m.versionId == versionId && m.parentFileId == parentFileId);
+            foreach(var file in files)
+            {
+                FileVo item = new FileVo();
+                item.fileId = file.fileId;
+                item.versionId = file.versionId;
+                item.fileVersionNo = file.fileVersionNo;
+                item.verNo = verNo;
+                item.fileName = file.fileName.TrimEnd('/');
+                item.createTime = file.createTime == null ? "" : file.createTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
+                item.downloadPath = !string.IsNullOrEmpty(file.downloadPath) ? OssHelper.Instance.SourceHost + file.downloadPath : null;
+                item.localPath = file.fileType == "path" ? null : file.localPath;
+                List<FileVo> Children = GetFileList(versionId, verNo, file.fileId);
+                if(Children.Count > 0)
+                {
+                    item.children = Children;
+                }
+                bool op = true;
+                if(string.IsNullOrEmpty(file.localPath) && Children.Count <= 0)
+                {
+                    op = false;
+                }
+                if(op) list.Add(item);
+            }
+            return list;
+        }
+
+        /// <summary>
+        /// vscode项目所有文件列表(包含无效文件)
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        [HttpGet("/api/vscode/filesForAll")]
+        public IActionResult filesForAll([FromQuery] FileDto para)
+        {
+            TokenModel tokenModel = JwtUtil.GetLoginUser(HttpContext);
+            if(tokenModel == null)
+            {
+                return ToResponse(ResultCode.BAD_REQUEST, "用户未登录");
+            }
+            List<FileVo> list = GetFileList(para.versionId, 0);
+            return SUCCESS(list);
+        }
+
+        /// <summary>
+        /// vscode项目文件内容
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        [HttpPost("/api/vscode/getFile")]
+        public IActionResult getFile([FromBody] GetFileDto para)
+        {
+            TokenModel tokenModel = JwtUtil.GetLoginUser(HttpContext);
+            if(tokenModel == null)
+            {
+                return ToResponse(ResultCode.BAD_REQUEST, "用户未登录");
+            }
+            var item = makeFilesService.GetFirst(m => m.fileId == para.fileId) ?? new MakeFiles();
+            // CheckCode.Transfer(para.fileContent, item.DownloadPath, item.FileType); //检查代码增量
+            GetFileVo data = new GetFileVo();
+            data.fileId = item.fileId;
+            data.downloadPath = OssHelper.Instance.SourceHost + item.downloadPath.TrimStart('/');
+            data.localPath = item.localPath;
+            return SUCCESS(data);
+        }
+    }
+}

+ 4 - 0
Extensions/AppServiceExtensions.cs

@@ -32,6 +32,10 @@ namespace Infrastructure
             services.AddTransient<IMakeTemplateGategoryService, MakeTemplateGategoryService>();
             services.AddTransient<IMakeTemplateService, MakeTemplateService>();
             services.AddTransient<IMakeDataService, MakeDataService>();
+            services.AddTransient<IMakeFilesService, MakeFilesService>();
+            services.AddTransient<IFilesForAllService, FilesForAllService>();
+            services.AddTransient<IVersionsService, VersionsService>();
+            services.AddTransient<IVersionForProjectService, VersionForProjectService>();
         }
 
         private static void Register(IServiceCollection services, string item)

+ 1 - 1
Model/Base/OptionsSetting.cs

@@ -21,7 +21,7 @@ namespace Infrastructure.Model
         public bool InitDb { get; set; }
         public MailOptions MailOptions { get; set; }
         public Upload Upload { get; set; }
-        public ALIYUN_OSS ALIYUN_OSS { get; set; }
+        public OssConfigs OssConfigs { get; set; }
         public JwtSettings JwtSettings { get; set; }
         public CodeGen CodeGen { get; set; }
         public List<DbConfigs> DbConfigs { get; set; }

+ 78 - 0
Model/Database/FilesForAll.cs

@@ -0,0 +1,78 @@
+using Mapster;
+
+
+namespace Model
+{
+    /// <summary>
+    /// 项目 files_for_all
+    /// </summary>
+    [SugarTable("files_for_all", "项目")]
+    [Tenant("0")]
+    public class FilesForAll
+    {
+        /// <summary>
+        ///  文件ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", IsPrimaryKey = true, IsIdentity = true, ColumnName = "file_id")]
+        public int fileId { get; set; }
+
+
+        /// <summary>
+        ///  项目ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "project_id")]
+        public int projectId { get; set; }
+
+
+        /// <summary>
+        ///  文件名
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 200, ColumnName = "file_name")]
+        public string? fileName { get; set; }
+
+
+        /// <summary>
+        ///  下载路径
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 200, ColumnName = "download_path")]
+        public string? downloadPath { get; set; }
+
+
+        /// <summary>
+        /// 本地路径
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 200, ColumnName = "local_path")]
+        public string? localPath { get; set; }
+
+
+        /// <summary>
+        ///  创建时间
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "create_time")]
+        public DateTime? createTime { get; set; }
+
+
+        /// <summary>
+        ///  文件类型
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 20, ColumnName = "file_type")]
+        public string? fileType { get; set; }
+
+
+        /// <summary>
+        ///  父文件ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "parent_file_id")]
+        public int parentFileId { get; set; }
+
+
+        /// <summary>
+        ///  版本号
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "version_no")]
+        public int versionNo { get; set; }
+
+
+
+    }
+}

+ 92 - 0
Model/Database/MakeFiles.cs

@@ -0,0 +1,92 @@
+using Mapster;
+
+
+namespace Model
+{
+    /// <summary>
+    /// 项目 make_files
+    /// </summary>
+    [SugarTable("make_files", "项目")]
+    [Tenant("0")]
+    public class MakeFiles
+    {
+        /// <summary>
+        ///  文件ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", IsPrimaryKey = true, IsIdentity = true, ColumnName = "file_id")]
+        public int fileId { get; set; }
+
+
+        /// <summary>
+        ///  版本ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "version_id")]
+        public int versionId { get; set; }
+
+
+        /// <summary>
+        ///  项目ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "project_id")]
+        public int projectId { get; set; }
+
+
+        /// <summary>
+        ///  文件名
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 200, ColumnName = "file_name")]
+        public string? fileName { get; set; }
+
+
+        /// <summary>
+        ///  下载路径
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 200, ColumnName = "download_path")]
+        public string? downloadPath { get; set; }
+
+
+        /// <summary>
+        /// 本地路径
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 200, ColumnName = "local_path")]
+        public string? localPath { get; set; }
+
+
+        /// <summary>
+        ///  创建时间
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "create_time")]
+        public DateTime? createTime { get; set; }
+
+
+        /// <summary>
+        ///  文件类型
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 20, ColumnName = "file_type")]
+        public string? fileType { get; set; }
+
+
+        /// <summary>
+        ///  父文件ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "parent_file_id")]
+        public int parentFileId { get; set; }
+
+
+        /// <summary>
+        ///  文件版本号
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "file_version_no")]
+        public int fileVersionNo { get; set; }
+
+
+        /// <summary>
+        ///  语言
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", Length = 20, ColumnName = "language")]
+        public string? language { get; set; }
+
+
+
+    }
+}

+ 50 - 0
Model/Database/VersionForProject.cs

@@ -0,0 +1,50 @@
+using Mapster;
+
+
+namespace Model
+{
+    /// <summary>
+    /// 项目 version_for_project
+    /// </summary>
+    [SugarTable("version_for_project", "项目")]
+    [Tenant("0")]
+    public class VersionForProject
+    {
+        /// <summary>
+        /// 数据库ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", IsPrimaryKey = true, ColumnName = "database_id")]
+        public int databaseId { get; set; }
+
+
+        /// <summary>
+        /// Java版本
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "java_version")]
+        public int javaVersion { get; set; }
+
+
+        /// <summary>
+        /// .NET版本
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "net_version")]
+        public int netVersion { get; set; }
+
+
+        /// <summary>
+        /// 前端版本
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "frontend_version")]
+        public int frontendVersion { get; set; }
+
+
+        /// <summary>
+        /// Python版本
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "python_version")]
+        public int pythonVersion { get; set; }
+
+
+
+    }
+}

+ 57 - 0
Model/Database/Versions.cs

@@ -0,0 +1,57 @@
+using Mapster;
+
+
+namespace Model
+{
+    /// <summary>
+    /// 生成项目版本 versions
+    /// </summary>
+    [SugarTable("versions", "生成项目版本")]
+    [Tenant("0")]
+    public class Versions
+    {
+        /// <summary>
+        /// 版本ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", IsPrimaryKey = true, IsIdentity = true, ColumnName = "version_id")]
+        public int versionId { get; set; }
+
+
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        [SugarColumn(ColumnDescription = "版本号", Length = 50, ColumnName = "version_no")]
+        public string? versionNo { get; set; }
+
+
+        /// <summary>
+        /// 项目ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "project_id")]
+        public int projectId { get; set; }
+
+
+        /// <summary>
+        /// 服务器ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "server_id")]
+        public int serverId { get; set; }
+
+
+        /// <summary>
+        ///  创建时间
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "create_time")]
+        public DateTime? createTime { get; set; }
+
+
+        /// <summary>
+        ///  组ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "", ColumnName = "group_id")]
+        public int groupId { get; set; }
+
+
+
+    }
+}

+ 27 - 0
Model/Dto/FileDto.cs

@@ -0,0 +1,27 @@
+using System;
+namespace Dto
+{
+    public class FileDto
+    {
+        //项目Id
+        public int projectId { get; set; }
+
+        //版本Id
+        public int versionId { get; set; }
+    }
+
+    public class GetFileDto
+    {
+        //文件Id
+        public int fileId { get; set; }
+
+        //文件内容
+        public string fileContent { get; set; }
+    }
+
+    public class InitServerDto
+    {
+        //服务Id
+        public int serverId { get; set; }
+    }
+}

+ 9 - 0
Model/Dto/VersionDto.cs

@@ -0,0 +1,9 @@
+using System;
+namespace Dto
+{
+    public class VersionDto
+    {
+        //项目Id
+        public int serverId { get; set; }
+    }
+}

+ 18 - 0
Model/Vo/Admin/VersionVo.cs

@@ -0,0 +1,18 @@
+using System;
+namespace Vo
+{
+    public class VersionVo
+    {
+        //版本Id
+        public int versionId { get; set; }
+
+        //批次号
+        public string batchNo { get; set; }
+
+        //创建时间
+        public string createTime { get; set; }
+
+        //版本号
+        public int verNo { get; set; }
+    }
+}

+ 46 - 0
Model/Vo/FileVo.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+namespace Vo
+{
+    public class FileVo
+    {
+        //文件Id
+        public int fileId { get; set; }
+
+        //版本Id
+        public int versionId { get; set; }
+
+        //文件名
+        public string fileName { get; set; }
+
+        //创建时间
+        public string createTime { get; set; }
+
+        //下载路径
+        public string downloadPath { get; set; }
+
+        //本地文件存放路径
+        public string localPath { get; set; }
+
+        //版本Id
+        public int fileVersionNo { get; set; }
+
+        //总版本号
+        public int verNo { get; set; }
+
+        //子集
+        public List<FileVo> children { get; set; }
+    }
+
+    public class GetFileVo
+    {
+        //文件Id
+        public int fileId { get; set; }
+
+        //下载路径
+        public string downloadPath { get; set; }
+
+        //本地文件存放路径
+        public string localPath { get; set; }
+    }
+}

+ 19 - 0
Services/FilesForAllService.cs

@@ -0,0 +1,19 @@
+using Attribute;
+using Model;
+using Model.Base;
+using Repository;
+using Service;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    /// <summary>
+    /// 项目Service业务层处理
+    /// </summary>
+    [AppService(ServiceType = typeof(IFilesForAllService), ServiceLifetime = LifeTime.Transient)]
+    public class FilesForAllService : BaseService<FilesForAll>, IFilesForAllService
+    {
+
+    }
+}

+ 12 - 0
Services/IService/IFilesForAllService.cs

@@ -0,0 +1,12 @@
+using Model;
+using Model.Base;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    public interface IFilesForAllService : IBaseService<FilesForAll>
+    {
+
+    }
+}

+ 12 - 0
Services/IService/IMakeFilesService.cs

@@ -0,0 +1,12 @@
+using Model;
+using Model.Base;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    public interface IMakeFilesService : IBaseService<MakeFiles>
+    {
+
+    }
+}

+ 12 - 0
Services/IService/IVersionForProjectService.cs

@@ -0,0 +1,12 @@
+using Model;
+using Model.Base;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    public interface IVersionForProjectService : IBaseService<VersionForProject>
+    {
+
+    }
+}

+ 12 - 0
Services/IService/IVersionsService.cs

@@ -0,0 +1,12 @@
+using Model;
+using Model.Base;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    public interface IVersionsService : IBaseService<Versions>
+    {
+
+    }
+}

+ 19 - 0
Services/MakeFilesService.cs

@@ -0,0 +1,19 @@
+using Attribute;
+using Model;
+using Model.Base;
+using Repository;
+using Service;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    /// <summary>
+    /// 项目Service业务层处理
+    /// </summary>
+    [AppService(ServiceType = typeof(IMakeFilesService), ServiceLifetime = LifeTime.Transient)]
+    public class MakeFilesService : BaseService<MakeFiles>, IMakeFilesService
+    {
+
+    }
+}

+ 19 - 0
Services/VersionForProjectService.cs

@@ -0,0 +1,19 @@
+using Attribute;
+using Model;
+using Model.Base;
+using Repository;
+using Service;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    /// <summary>
+    /// 项目Service业务层处理
+    /// </summary>
+    [AppService(ServiceType = typeof(IVersionForProjectService), ServiceLifetime = LifeTime.Transient)]
+    public class VersionForProjectService : BaseService<VersionForProject>, IVersionForProjectService
+    {
+
+    }
+}

+ 19 - 0
Services/VersionsService.cs

@@ -0,0 +1,19 @@
+using Attribute;
+using Model;
+using Model.Base;
+using Repository;
+using Service;
+using Microsoft.AspNetCore.Mvc;
+
+
+namespace Services
+{
+    /// <summary>
+    /// 生成项目版本Service业务层处理
+    /// </summary>
+    [AppService(ServiceType = typeof(IVersionsService), ServiceLifetime = LifeTime.Transient)]
+    public class VersionsService : BaseService<Versions>, IVersionsService
+    {
+
+    }
+}

+ 3 - 0
Task/MakeHelper.cs

@@ -7,6 +7,7 @@ using LitJson;
 using Microsoft.CodeAnalysis.CSharp.Scripting;
 using Model;
 using Services;
+using Util;
 
 namespace Tasks
 {
@@ -61,6 +62,8 @@ namespace Tasks
                 path = Util.Maker.replaceKeyToValue(jsonObj["data"], path);
                 fileName = Util.Maker.replaceKeyToValue(jsonObj["data"], fileName);
                 Function.WritePage(path, fileName, resultString);
+                string startPath = Function.getPath(path + fileName);
+                OssHelper.Instance.Upload(startPath);
                 //生成数据入库
                 JsonData data = JsonMapper.ToObject(attach);
                 int dataId = 0;

+ 100 - 0
Util/OssHelper.cs

@@ -0,0 +1,100 @@
+using System;
+using System.Threading;
+using System.Linq;
+using System.IO;
+using Aliyun.OSS;
+using Aliyun.OSS.Common;
+using System.Text.RegularExpressions;
+using Common;
+using Infrastructure;
+using Infrastructure.Model;
+
+namespace Util
+{
+    public class OssHelper
+    {
+        public string key = ""; //阿里云AccessKey ID
+        public string secret = "";  //阿里云Access Key Secret
+        public string PathName = "Omega";
+        public string endpoint = "";  //endpoint
+        public string bucketName = "";
+        public string SourceHost = "";
+        public bool OssStatus = false;
+        public readonly static OssHelper Instance = new OssHelper();
+        private OssHelper()
+        {
+            var options = App.OptionsSetting;
+            OssConfigs ossConfigs = options.OssConfigs;
+            key = ossConfigs.Key;
+            secret = ossConfigs.Secret;
+            endpoint = ossConfigs.Endpoint;
+            bucketName = ossConfigs.BucketName;
+            SourceHost = "https://" + ossConfigs.BucketName + "." + ossConfigs.Endpoint + "/";
+        }
+
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        /// <returns></returns>
+        public void Upload(string dataFilePath)
+        {
+            var client = new OssClient(OssHelper.Instance.endpoint, OssHelper.Instance.key, OssHelper.Instance.secret);
+            if(dataFilePath.Substring(dataFilePath.LastIndexOf("/")).Contains("."))
+            {
+                string localFile = dataFilePath.Substring(dataFilePath.IndexOf("Code/")).Replace("\\", "/");
+                ScanQueue(localFile, dataFilePath, client);
+            }
+            else
+            {
+                System.IO.FileSystemInfo info = new System.IO.DirectoryInfo(dataFilePath);
+                scan(info, client);
+            }
+        }
+        private void scan(System.IO.FileSystemInfo info, OssClient client)
+        {
+            if (!info.Exists) return;
+            System.IO.DirectoryInfo dir = info as System.IO.DirectoryInfo;
+            //不是目录
+            if (dir == null) return;
+            System.IO.FileSystemInfo[] files = dir.GetFileSystemInfos();
+            for (int i = 0; i < files.Length; i++)
+            {
+                System.IO.FileInfo file = files[i] as System.IO.FileInfo;
+                //是文件
+                if (file != null)
+                {
+                    string localFile = file.FullName.Substring(file.FullName.IndexOf("Code/")).Replace("\\", "/");
+                    ScanQueue(localFile, file.FullName, client);
+                }
+                else scan(files[i], client);
+            }
+        }
+
+        //上传        
+        public void ScanQueue(string data, string FileFullName, OssClient client)
+        {
+            // 上传文件。
+            string localFile = Function.getPath(data);
+            string filePath = data.TrimStart('/');
+            var result = client.PutObject(bucketName, filePath, localFile, new ObjectMetadata()
+            {
+                ExpirationTime = DateTime.Parse("2050-12-31 23:59:59")
+            });
+            if (!string.IsNullOrEmpty(result.ETag))
+            {
+                if (result.ETag.Length == 32)
+                {
+                    if (File.Exists(localFile))
+                    {
+                        File.Delete(localFile);
+                    }
+                }
+            }
+
+            if (File.Exists(FileFullName))
+            {
+                File.Delete(FileFullName);
+            }
+        }
+    }
+}