From 5703aa1072175f4390006f73e43a4236e81ad678 Mon Sep 17 00:00:00 2001 From: zs <zhousong@weben-smart.com> Date: 周五, 16 5月 2025 12:00:39 +0800 Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo --- Weben_CMS专用代码生成器/Code/MainForm.cs | 12 ++ PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Services/ICallMaterialOrderAppService.cs | 21 ++++ PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Domain/CallMaterialOrder/ICallMaterialOrderRepository.cs | 20 +++ Weben_CMS专用代码生成器/Code/MainForm.Designer.cs | 18 +++ Weben_CMS专用代码生成器/Code/Utility/FileHelper.cs | 71 ++++++++++++++ PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs | 56 ++++++++++ Weben_CMS专用代码生成器/Code/GenerateCode_WeiBen_CMS.csproj | 1 PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/CallMaterialOrderAppService.cs | 60 ++++++++--- PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs | 8 9 files changed, 241 insertions(+), 26 deletions(-) diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Services/ICallMaterialOrderAppService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Services/ICallMaterialOrderAppService.cs index 706f0ba..c1be461 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Services/ICallMaterialOrderAppService.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Services/ICallMaterialOrderAppService.cs @@ -1,5 +1,7 @@ using CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.CallMaterialOrder; using CMS.Plugin.PipeLineLems.Domain.CallMaterialOrder; +using System.Linq.Expressions; +using Volo.Abp; using Volo.Abp.Application.Services; namespace CMS.Plugin.PipeLineLems.Application.Contracts.Services; @@ -49,4 +51,23 @@ /// <param name="input"></param> /// <returns></returns> Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetCallMaterialOrderInput input); + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍙枡鍗曡〃鍒楄〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default); + + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍗曚釜鍙枡鍗曡〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="isMultipleThrowException">鏄惁鏌ヨ鍑哄鏉″氨鎶ラ敊</param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + /// <exception cref="UserFriendlyException"></exception> + Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool is鈥婱ultipleThrowException = false, CancellationToken cancellationToken = default); } diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/CallMaterialOrderAppService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/CallMaterialOrderAppService.cs index 0ca282e..440d4f5 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/CallMaterialOrderAppService.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/CallMaterialOrderAppService.cs @@ -18,16 +18,16 @@ /// </summary> public class CallMaterialOrderAppService : CMSPluginAppService, ICallMaterialOrderAppService { - private readonly ICallMaterialOrderRepository callMaterialOrderRepository; + private readonly ICallMaterialOrderRepository _callMaterialOrderRepository; private readonly SharedService _sharedService; private readonly IServiceProvider _serviceProvider; /// <summary> /// Initializes a new instance of the <see cref="CallMaterialOrderAppService"/> class. /// </summary> /// <param name="CallMaterialOrderRepository">The task job repository.</param> - public CallMaterialOrderAppService(ICallMaterialOrderRepository _CallMaterialOrderRepository, SharedService sharedService, IServiceProvider serviceProvider) + public CallMaterialOrderAppService(ICallMaterialOrderRepository callMaterialOrderRepository, SharedService sharedService, IServiceProvider serviceProvider) { - callMaterialOrderRepository = _CallMaterialOrderRepository; + _callMaterialOrderRepository = callMaterialOrderRepository; _sharedService = sharedService; _serviceProvider = serviceProvider; } @@ -39,7 +39,7 @@ /// <returns></returns> public virtual async Task<CallMaterialOrderDto> GetAsync(Guid id) { - return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(await callMaterialOrderRepository.GetAsync(id)); + return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(await _callMaterialOrderRepository.GetAsync(id)); } public virtual async Task CallMaterialByDataIdentifier(Guid id) @@ -49,7 +49,7 @@ public virtual async Task<CallMaterialOrder> FindByWmsTaskNoAsync(string wmsTaskNo) { - return await callMaterialOrderRepository.FindByWmsTaskNoAsync(wmsTaskNo); + return await _callMaterialOrderRepository.FindByWmsTaskNoAsync(wmsTaskNo); } /// <summary> @@ -73,8 +73,8 @@ #endregion - var count = await callMaterialOrderRepository.GetCountAsync(whereConditions); - var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); + var count = await _callMaterialOrderRepository.GetCountAsync(whereConditions); + var list = await _callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); return new PagedResultDto<CallMaterialOrderDto>(count, ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(list)); } @@ -112,20 +112,20 @@ { await CheckCreateOrUpdateDtoAsync(input); - var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier); + var exist = await _callMaterialOrderRepository.NameExistAsync(input.DataIdentifier); if (exist) { throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]); } - var maxSort = await callMaterialOrderRepository.GetMaxSortAsync(); + var maxSort = await _callMaterialOrderRepository.GetMaxSortAsync(); var sort = input.Sort ?? maxSort; var insertObj = ObjectMapper.Map<CallMaterialOrderCreateDto, CallMaterialOrder>(input); insertObj.Sort = sort; input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None); - await callMaterialOrderRepository.InsertAsync(insertObj); + await _callMaterialOrderRepository.InsertAsync(insertObj); //if (input.Sort.HasValue && insertObj.Sort != maxSort) //{ @@ -146,8 +146,8 @@ { await CheckCreateOrUpdateDtoAsync(input); - var updateObj = await callMaterialOrderRepository.GetAsync(id); - var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier, updateObj.Id); + var updateObj = await _callMaterialOrderRepository.GetAsync(id); + var exist = await _callMaterialOrderRepository.NameExistAsync(input.DataIdentifier, updateObj.Id); if (exist) { throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]); @@ -165,7 +165,7 @@ updateObj.Remark = input.Remark; - await callMaterialOrderRepository.UpdateAsync(updateObj); + await _callMaterialOrderRepository.UpdateAsync(updateObj); return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(updateObj); } @@ -217,7 +217,7 @@ /// <returns></returns> public virtual Task DeleteAsync(Guid id) { - return callMaterialOrderRepository.DeleteAsync(id); + return _callMaterialOrderRepository.DeleteAsync(id); } /// <summary> @@ -241,7 +241,7 @@ /// <returns></returns> public virtual async Task AdjustSortAsync(Guid id, int sort) { - var list = await callMaterialOrderRepository.GetListAsync(null, nameof(CallMaterialOrder.Sort)); + var list = await _callMaterialOrderRepository.GetListAsync(null, nameof(CallMaterialOrder.Sort)); if (list != null && list.Any()) { var initSort = 1; @@ -268,7 +268,7 @@ } } - await callMaterialOrderRepository.UpdateManyAsync(list); + await _callMaterialOrderRepository.UpdateManyAsync(list); } /// <summary> @@ -313,7 +313,7 @@ throw new UserFriendlyException(errorMsg); } - var oldCallMaterialOrder = await callMaterialOrderRepository.FindByNameAsync(impItem.DataIdentifier); + var oldCallMaterialOrder = await _callMaterialOrderRepository.FindByNameAsync(impItem.DataIdentifier); if (oldCallMaterialOrder != null) { var callMaterialOrderUpdateDto = new CallMaterialOrderUpdateDto @@ -400,7 +400,7 @@ #endregion - var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); + var list = await _callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); var result = ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(list); var sheets = new Dictionary<string, object> @@ -426,4 +426,28 @@ return Task.CompletedTask; } + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍙枡鍗曡〃鍒楄〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public async Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default) + { + return await _callMaterialOrderRepository.GetListByFilterAsync(whereConditions); + } + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍗曚釜鍙枡鍗曡〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="isMultipleThrowException">鏄惁鏌ヨ鍑哄鏉″氨鎶ラ敊</param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + /// <exception cref="UserFriendlyException"></exception> + public async Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool is鈥婱ultipleThrowException = false, CancellationToken cancellationToken = default) + { + return await _callMaterialOrderRepository.GetSingleByFilterAsync(whereConditions, is鈥婱ultipleThrowException); + } } diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Domain/CallMaterialOrder/ICallMaterialOrderRepository.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Domain/CallMaterialOrder/ICallMaterialOrderRepository.cs index 5fa6208..4cc38c4 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Domain/CallMaterialOrder/ICallMaterialOrderRepository.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Domain/CallMaterialOrder/ICallMaterialOrderRepository.cs @@ -54,5 +54,23 @@ /// <param name="whereConditions"></param> /// <param name="cancellationToken"></param> /// <returns></returns> - Task<long> GetCountAsync(FunReturnResultModel<Expression<Func<CallMaterialOrder, bool>>> whereConditions, CancellationToken cancellationToken = default); + Task<long> GetCountAsync(FunReturnResultModel<Expression<Func<CallMaterialOrder, bool>>> whereConditions, CancellationToken cancellationToken = default); + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍙枡鍗曡〃鍒楄〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default); + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍗曚釜鍙枡鍗曡〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="isMultipleThrowException">鏄惁鏌ヨ鍑哄鏉″氨鎶ラ敊</param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + /// <exception cref="UserFriendlyException"></exception> + Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool is鈥婱ultipleThrowException = false, CancellationToken cancellationToken = default); } diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs index 0a78686..da7e88a 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs @@ -3,7 +3,8 @@ using CmsQueryExtensions.Extension; using Microsoft.EntityFrameworkCore; using System.Linq.Dynamic.Core; -using System.Linq.Expressions; +using System.Linq.Expressions; +using Volo.Abp; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; @@ -118,5 +119,56 @@ { return (await GetQueryableAsync()) .Where(x => !x.IsDeleted).IncludeDetails(); - } + } + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍙枡鍗曡〃鍒楄〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public async Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .IncludeDetails() + .WhereIf(whereConditions != null, whereConditions) + .Where(x => !x.IsDeleted) + .OrderByDescending(x => x.CreationTime) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + /// <summary> + /// 鏍规嵁鏉′欢鑾峰彇鍗曚釜鍙枡鍗曡〃 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="isMultipleThrowException">鏄惁鏌ヨ鍑哄鏉″氨鎶ラ敊</param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + /// <exception cref="UserFriendlyException"></exception> + public async Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool is鈥婱ultipleThrowException = false, CancellationToken cancellationToken = default) + { + if (is鈥婱ultipleThrowException) + { + var entitys = await (await GetDbSetAsync()) + .IncludeDetails() + .WhereIf(whereConditions != null, whereConditions) + .Where(x => !x.IsDeleted) + .OrderByDescending(x => x.CreationTime) + .ToListAsync(GetCancellationToken(cancellationToken)); + if (entitys?.Count > 1) + { + throw new UserFriendlyException("鏌ヨ鍒板鏉¤褰�"); + } + return entitys?.FirstOrDefault(); + } + else + { + return await (await GetDbSetAsync()) + .IncludeDetails() + .WhereIf(whereConditions != null, whereConditions) + .Where(x => !x.IsDeleted) + .OrderByDescending(x => x.CreationTime) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + } } diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs index d3e1b4e..81e821c 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs @@ -377,8 +377,7 @@ pipeSpecCode3 = new_workPlanList[i].PipeSpecCode; } } - //鑾峰彇 鎵规 - await callMaterialOrderAppService.wh + Dictionary<string, object?> keyValuePairs = new Dictionary<string, object?> { { "鎵撶爜宸ヤ欢1",code1}, @@ -391,7 +390,7 @@ { "鎵撶爜绠℃鍚嶇О", new_workPlanList.First().PipeSectionName }, { "鎵撶爜鍘熸枡绠″瀷鍙�", new_workPlanList.First().MaterialMode }, { "鎵撶爜鍘熸枡鏍囪瘑", new_workPlanList.First().DataIdentifier }, - { "鎵撶爜鍘熸枡绠℃壒娆�", new_workPlanList.First() }, + { "鎵撶爜鍘熸枡绠℃壒娆�", callMaterialOrder.MaterialBatch },//鎵规 }; _variableService.WriteValueAsync(keyValuePairs); @@ -662,7 +661,8 @@ { "鍒囧壊绠℃缂栫爜", new_workPlanList.First().PipeSpecCode }, { "鍒囧壊绠℃鍚嶇О", new_workPlanList.First().PipeSectionName }, { "鍒囧壊鍘熸枡绠″瀷鍙�", new_workPlanList.First().MaterialMode }, - { "鍒囧壊鍘熸枡鏍囪瘑", new_workPlanList.First().DataIdentifier } + { "鍒囧壊鍘熸枡鏍囪瘑", new_workPlanList.First().DataIdentifier }, + { "鍒囧壊鍘熸枡绠℃壒娆�", callMaterialOrder.MaterialBatch },//鎵规 }; _variableService.WriteValueAsync(keyValuePairs); diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" index f57c03d..695e495 100644 --- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" @@ -273,6 +273,7 @@ <DependentUpon>MainForm.cs</DependentUpon> </Compile> <Compile Include="Utility\StructStrHelper.cs" /> + <Compile Include="Utility\FileHelper.cs" /> <Compile Include="Utility\TextHelper.cs" /> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" index d0ab2c9..442d677 100644 --- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" @@ -79,13 +79,14 @@ this.tb_FilePath = new System.Windows.Forms.TextBox(); this.btn_SelectFile = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); + this.ck_IsDeletefile = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // btnPath // - this.btnPath.Location = new System.Drawing.Point(453, 723); + this.btnPath.Location = new System.Drawing.Point(425, 720); this.btnPath.Name = "btnPath"; this.btnPath.Size = new System.Drawing.Size(97, 23); this.btnPath.TabIndex = 1; @@ -564,11 +565,25 @@ this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click_1); // + // ck_IsDeletefile + // + this.ck_IsDeletefile.AutoSize = true; + this.ck_IsDeletefile.Checked = true; + this.ck_IsDeletefile.CheckState = System.Windows.Forms.CheckState.Checked; + this.ck_IsDeletefile.Location = new System.Drawing.Point(561, 724); + this.ck_IsDeletefile.Name = "ck_IsDeletefile"; + this.ck_IsDeletefile.Size = new System.Drawing.Size(192, 16); + this.ck_IsDeletefile.TabIndex = 50; + this.ck_IsDeletefile.Text = "鐢熸垚鍓嶆槸鍚﹀厛娓呯悊鏂囦欢澶圭殑鏂囦欢"; + this.ck_IsDeletefile.UseVisualStyleBackColor = true; + this.ck_IsDeletefile.CheckedChanged += new System.EventHandler(this.ck_IsDeletefile_CheckedChanged); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1402, 831); + this.Controls.Add(this.ck_IsDeletefile); this.Controls.Add(this.button1); this.Controls.Add(this.btn_SelectFile); this.Controls.Add(this.tb_FilePath); @@ -645,6 +660,7 @@ private System.Windows.Forms.Button btn_SelectFile; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox ck_IsDeletefile; } } diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" index 5867a50..de76ad1 100644 --- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" @@ -283,6 +283,13 @@ //CreateModelFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); //CreateModelParamFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); genCodeRootPath = tbPath.Text + @"\" + tb_WCF_NameSpacePath.Text.Trim(); + + //鏄惁瑕佷簨鍏堟竻鐞嗘枃浠跺す + if (this.ck_IsDeletefile.Checked) + { + FileHelper.ClearFolder(genCodeRootPath); // 閫掑綊鍒犻櫎 + } + //var webFolerPath = (tb_WCF_NameSpacePath.Text.Trim() + "_Web").ToLower(); var webFolerPath = _tb_VueRootFolerName; #region 瀹炰綋绫� @@ -825,5 +832,10 @@ { this.tb_FilePath.Text = ""; } + + private void ck_IsDeletefile_CheckedChanged(object sender, EventArgs e) + { + + } } } diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/FileHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/FileHelper.cs" new file mode 100644 index 0000000..dbab47a --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/FileHelper.cs" @@ -0,0 +1,71 @@ +锘� +using GenerateCode_GEBrilliantFactory; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory +{ + public class FileHelper + { + + public static void DeleteAllContentsInFolder(string folderPath) + { + try + { + if (Directory.Exists(folderPath)) + { + // 鍒犻櫎鎵�鏈夋枃浠跺拰瀛愭枃浠跺す锛堝寘鎷瓙鏂囦欢澶逛腑鐨勬枃浠讹級 + foreach (string file in Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories)) + { + File.Delete(file); + Console.WriteLine($"宸插垹闄ゆ枃浠�: {file}"); + } + + // 鍒犻櫎鎵�鏈夊瓙鏂囦欢澶癸紙姝ゆ椂鏂囦欢澶瑰凡绌猴紝鍙互瀹夊叏鍒犻櫎锛� + foreach (string dir in Directory.GetDirectories(folderPath, "*", SearchOption.AllDirectories)) + { + Directory.Delete(dir); // 涓嶉渶瑕侀�掑綊锛屽洜涓烘枃浠跺凡琚垹闄� + Console.WriteLine($"宸插垹闄ゆ枃浠跺す: {dir}"); + } + + Console.WriteLine($"鎴愬姛娓呯┖鏂囦欢澶� '{folderPath}' 涓嬬殑鎵�鏈夊唴瀹广��"); + } + else + { + Console.WriteLine($"鏂囦欢澶逛笉瀛樺湪: {folderPath}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"鍒犻櫎鏂囦欢/鏂囦欢澶规椂鍑洪敊: {ex.Message}"); + } + } + + + public static void ClearFolder(string folderPath) + { + try + { + if (Directory.Exists(folderPath)) + { + // 鍒犻櫎鎵�鏈夋枃浠跺拰瀛愭枃浠跺す锛堝寘鎷瓙鏂囦欢澶逛腑鐨勬枃浠讹級 + Directory.Delete(folderPath, true); // true 琛ㄧず閫掑綊鍒犻櫎 + Directory.CreateDirectory(folderPath); // 閲嶆柊鍒涘缓绌烘枃浠跺す + Console.WriteLine($"宸叉竻绌哄苟閲嶅缓鏂囦欢澶� '{folderPath}'銆�"); + } + else + { + Console.WriteLine($"鏂囦欢澶逛笉瀛樺湪: {folderPath}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"娓呯┖鏂囦欢澶规椂鍑洪敊: {ex.Message}"); + } + } + } +} -- Gitblit v1.9.3