Jelajahi Sumber

修改文件名别名

zhuyiyi 1 Minggu lalu
induk
melakukan
bee13e9027
2 mengubah file dengan 33 tambahan dan 1 penghapusan
  1. 25 0
      supplierBuildFile.aspx.cs
  2. 8 1
      supplierDownload.aspx.cs

+ 25 - 0
supplierBuildFile.aspx.cs

@@ -252,6 +252,8 @@ public partial class supplierBuildFile : System.Web.UI.Page
         name = string.Join("-", list);
         return name;
     }
+
+    
     private string formatMemo(object memo)
     {
         string m = memo.ToString();
@@ -559,6 +561,23 @@ public partial class supplierBuildFile : System.Web.UI.Page
         //CeErpTradeCell.ExecuteNonQuery(sql.ToString());
     }
 
+    static Dictionary<string, string> replaceRules = new Dictionary<string, string>
+        {
+            { "皙贝", "白卡" },
+            { "睿狐", "莱尼" },
+            { "岚蝶", "安格" },
+            { "琮纹", "刚古" },
+            { "珠光", "珠光" },
+            { "溪雪", "珠光" },
+            { "雅柔", "雅柔" },
+            { "萱姿", "雅柔" },
+            { "草香", "草香" },
+            { "芳怡", "草香" },
+            { "金绒", "牛皮" },
+            { "素芸", "棉卡" },
+            { "玉蕊", "蛋壳" }
+        };
+
     /// <summary>
     /// 压缩大文件夹(分块处理)
     /// </summary>
@@ -590,6 +609,8 @@ public partial class supplierBuildFile : System.Web.UI.Page
         // 使用 EnumerateFiles 减少内存使用
         var files = Directory.EnumerateFiles(sourceFolder, "*.*", SearchOption.AllDirectories);
 
+
+
         using (var fileStream = new FileStream(zipFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192))
         using (var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Create, true))
         {
@@ -602,6 +623,10 @@ public partial class supplierBuildFile : System.Web.UI.Page
                     {
                         fileName = dealMemoName(fileName);
                     }
+                    foreach (var rule in replaceRules)
+                    {
+                        fileName = fileName.Replace(rule.Key, rule.Value);
+                    }
                     // 获取相对路径
                     string relativePath = GetRelativePath(sourceFolder, file);
 

+ 8 - 1
supplierDownload.aspx.cs

@@ -389,6 +389,10 @@ public partial class supplierDownload : System.Web.UI.Page
                 {
                     try
                     {
+                        foreach (var rule in replaceRules)
+                        {
+                            rnameList[i] = rnameList[i].Replace(rule.Key, rule.Value);
+                        }
                         file.Add(files[i], rnameList[i]);
                         addFiles.Add(files[i]);
                         addCtid.Add(ctidLst[i]);
@@ -432,7 +436,10 @@ public partial class supplierDownload : System.Web.UI.Page
     {
         string filePath = file;
         string dfile = Path.GetFileName(file);
-
+        foreach (var rule in replaceRules)
+        {
+            fname = fname.Replace(rule.Key, rule.Value);
+        }
         FileStream fs = new FileStream(filePath, FileMode.Open);
         byte[] bytes = new byte[(int)fs.Length];
         fs.Read(bytes, 0, bytes.Length);