Esempio n. 1
0
        static void Main(string[] args)
        {
           
            config = new Config();
            timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");
            path = System.Environment.CurrentDirectory + "\\TmpExcel\\";
            if (!Directory.Exists(path))
            { Directory.CreateDirectory(path); }
            connStr = config.GetConnectionString("DBServer");
            try
            {

                SendMail("GetFAINotApproval");
                SendMail("GetFAINotToUnitWeight");
                DeleteOldFile(path);
            
            }
            catch (Exception e)
            {

                logger.Error(System.Reflection.MethodBase.GetCurrentMethod(), e);
            }
         
        }
Esempio n. 2
0
 static void DeleteOldFile(string path)
 {
     try
     {
         int keepCount = 0;
         Config config = new Config();
         string t = config.GetValue("keepExcelAmount");
         int.TryParse(t, out keepCount);
         //keepExcelAmount
         DirectoryInfo d = new DirectoryInfo(path);
         List<FileInfo> lstFi = d.GetFiles().ToList();
         int delTotal = lstFi.Count - keepCount;
         if (delTotal <= 0 || keepCount==0)
         { return; }
         var tmp = lstFi.OrderBy(x => x.CreationTime).Take(delTotal);
         foreach (FileInfo f in tmp)
         {
            f.Delete();
         }
     }
     catch
     { 
         return;
     }
    
 
 }