Browse Source

删除过期日志

chenxy 6 years ago
parent
commit
1c82b9b9f5

+ 40 - 20
DK.Basics/Library/OutputLog.cs

@@ -119,7 +119,7 @@ namespace Dongke.IBOSS.PRD.Basics.Library
                 if (!File.Exists(logFile))
                 {
                     // 旧文件删除
-                    //DeleteLogFile(logFilePath);
+                    DeleteLogFile(logFilePath);
                 }
 
                 // 把错误消息写入日志文件
@@ -173,35 +173,55 @@ namespace Dongke.IBOSS.PRD.Basics.Library
             try
             {
                 // 日志文件夹里面的所有的日志文件的取得
-                DirectoryInfo diDirectoryInfo = new DirectoryInfo(logFilePath);
-                FileInfo[] fiFileInfo = diDirectoryInfo.GetFiles();
+                //DirectoryInfo diDirectoryInfo = new DirectoryInfo(logFilePath);
+                //FileInfo[] fiFileInfo = diDirectoryInfo.GetFiles();
 
-                // 旧文件删除
-                string strLogFile = string.Empty;
-                foreach (FileInfo fileInfo in fiFileInfo)
-                {
-                    strLogFile = fileInfo.Name.Remove(fileInfo.Name.LastIndexOf('.'));
+                //// 旧文件删除
+                //string strLogFile = string.Empty;
+                //foreach (FileInfo fileInfo in fiFileInfo)
+                //{
+                //    strLogFile = fileInfo.Name.Remove(fileInfo.Name.LastIndexOf('.'));
 
-                    DateTime? datDateTime;
-                    bool bolCheckValid = Utility.IsValidDate(strLogFile, out datDateTime);
-                    if (!bolCheckValid)
-                    {
-                        // 无效的文件删除
-                        File.Delete(fileInfo.FullName);
-                    }
-                    else
+                //    DateTime? datDateTime;
+                //    bool bolCheckValid = Utility.IsValidDate(strLogFile, out datDateTime);
+                //    if (!bolCheckValid)
+                //    {
+                //        // 无效的文件删除
+                //        File.Delete(fileInfo.FullName);
+                //    }
+                //    else
+                //    {
+                //        // 旧文件的删除
+                //        if (datDateTime < DateTime.Now.AddDays(DELETE_FILE_PERIOD))
+                //        {
+                //            File.Delete(fileInfo.FullName);
+                //        }
+                //    }
+                //}
+
+                string[] files = System.IO.Directory.GetFiles(logFilePath, "*.log");
+                if (files != null && files.Length > 0)
+                {
+                    DateTime deathDate = DateTime.Now.Date.AddDays(-60);
+                    foreach (string file in files)
                     {
-                        // 旧文件的删除
-                        if (datDateTime < DateTime.Now.AddDays(DELETE_FILE_PERIOD))
+                        try
+                        {
+                            //if (File.GetCreationTime(file) < deathDate)
+                            if (File.GetLastWriteTime(file) < deathDate)
+                            {
+                                File.Delete(file);
+                            }
+                        }
+                        catch
                         {
-                            File.Delete(fileInfo.FullName);
                         }
                     }
                 }
             }
             catch (Exception ex)
             {
-                throw ex;
+                //throw ex;
             }
         }
 

+ 4 - 0
DK.Service/BarcodePrintService/BarcodePrintLogic.cs

@@ -498,6 +498,10 @@ namespace Dongke.IBOSS.PRD.Service.BarcodePrintService
         }
 
         // 服务码打印、补打 (打印时重新生成onlycode,补打时onlycode不能为空)
+        //FUN_CMN_GetOnlyCodeBySeq(:new.accountid
+        //                                          ,:new.GroutingDailyDetailID
+        //                                          ,:new.createuserid)
+
 
         // 
     }

+ 1 - 1
WCF.Service/WCF.Services/PDAModuleService.cs

@@ -7751,7 +7751,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
 		}
 
 		/// <summary>
-		/// 打印条码样式
+		/// 打印条码样式(补打)
 		/// </summary>
 		/// <param name="accountCode"></param>
 		/// <param name="userCode"></param>