public async void RunWork(object source, System.Timers.ElapsedEventArgs e) { try { //检查配置文件 string routinepath = @"F:\Prepare\SOFTWARE_PUB\Autorivet_team_manage\settings\PartDBRoutine"; //检查配置文件 var PartRoutine = jsonMethod.ReadFromFile(routinepath); var lastrocord = PartRoutine.Last(); var lastDate = DateTime.Parse(lastrocord.date); var span = DateTime.Now.Date - lastDate; //If the span is so long, then update the database if (span.Days > 7) { //Get the update path var up = GoumangToolKit.localMethod.GetConfigValue("UPDATE_PATH", "PartDBCfg.py"); var col = GoumangToolKit.localMethod.GetConfigValue("PART_MONGO_COLNAME", "PartDBCfg.py"); PartDB pd = new PartDB(col); foreach (dynamic pp in up) { await pd.UpdatePartDB((string)pp); } var ftpup = GoumangToolKit.localMethod.GetConfigValue("FTP_UPDATE_PATH", "PartDBCfg.py"); var ftpcol = GoumangToolKit.localMethod.GetConfigValue("FTP_PART_MONGO_COLNAME", "PartDBCfg.py"); var ftppd = new PartDB(ftpcol); foreach (dynamic pp in ftpup) { await ftppd.UpdateFTPPartDB((string)pp); } //Clean backup files var cleanpath = GoumangToolKit.localMethod.GetConfigValue("InfoPath"); BackupOperation.CleanBackup(cleanpath); } PartRoutine.Add(new historyJsonModel() { writer = "System", date = DateTime.Now.ToShortDateString(), operation = "Done" }); PartRoutine.WriteToFile(routinepath); } catch { //Do nothing } }
public static int CleanBackup() { return(BackupOperation.CleanBackup(Program.InfoPath)); }