protected override void OnStop() { StringBuilder log = new StringBuilder(); log.AppendLine("\n当前时间:" + DateTime.Now.ToString() + " 服务关闭...\n"); LogFileOperator.writeLog(log.ToString()); }
/** * 入口程序 * */ public static void work(object sender, ElapsedEventArgs args) { //检查日志 LogFileOperator.check(); //执行文件删除 string log = Cleaner.cleanUpExcessFiles(GlobleParams.getConfigList(), GlobleParams.getDeletePercent()); //写日志 LogFileOperator.writeLog(log); }
private static void printGlobleParams() { StringBuilder log = new StringBuilder(); log.AppendLine("当前时间:" + DateTime.Now.ToString() + " 服务启动...\n"); log.AppendLine("执行频率:" + GlobleParams.getFrequency() / 60000 + "分钟"); log.AppendLine("删除比例:" + GlobleParams.getDeletePercent() + "%"); log.AppendLine("共读取到:" + GlobleParams.getConfigList().Count() + "个需要检查的路径\n"); LogFileOperator.writeLog(log.ToString()); }