123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.ServiceProcess;
- using System.Text;
- using EMISOnline.WinService.Common;
- namespace EMISOnline.WinService
- {
- partial class FfmpegService : ServiceBase
- {
- System.Timers.Timer ftpTimer; //计时器
- System.Timers.Timer m3u8Timer; //计时器
- public FfmpegService()
- {
- InitializeComponent();
- }
- protected override void OnStart(string[] args)
- {
- Log.Info("配置信息","==>");
- Log.Info("FtpPath", Config.FtpPath);
- Log.Info("FtpFileType", Config.FtpFileType);
- Log.Info("ServUFile", Config.ServUFile);
- Log.Info("M3u8Server", Config.M3u8Server);
- Log.Info("FTPServer", Config.FTPServer);
- Log.Info("DataServer", Config.DataServer);
- // TODO: 在此处添加代码以启动服务。
- ftpTimer = new System.Timers.Timer();
- ftpTimer.Interval = 0.2 * 60 * 1000; //设置计时器事件间隔执行时间
- ftpTimer.Elapsed += new System.Timers.ElapsedEventHandler(ftpTimer_Elapsed);
- ftpTimer.Enabled = true;
- m3u8Timer = new System.Timers.Timer();
- m3u8Timer.Interval = 1 * 60 * 1000; //设置计时器事件间隔执行时间
- m3u8Timer.Elapsed += new System.Timers.ElapsedEventHandler(m3u8Timer_Elapsed);
- m3u8Timer.Enabled = true;
- }
- protected override void OnStop()
- {
- // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
- }
- private bool ftpTimerRuning = false;
- private void ftpTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- //每次检查文件维持单线程检查,多余的次数触发直接跳过
- if (!ftpTimerRuning)
- {
- ftpTimerRuning = true;
- try
- {
- new FtpTimer().CheckFiles();
- }
- catch (Exception ex)
- {
- Log.Error(this.GetType().ToString(), ex.Message + ex.ToString());
- }
- ftpTimerRuning = false;
- }
- }
- private bool m3u8TimerRuning = false;
- private void m3u8Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- //每次转换维持单线程,多余的次数触发直接跳过
- if (!m3u8TimerRuning)
- {
- m3u8TimerRuning = true;
- try
- {
- new M3u8Timer().doingM3u8();
- }
- catch (Exception ex)
- {
- Log.Error(this.GetType().ToString(), ex.Message + ex.ToString());
- }
- m3u8TimerRuning = false;
- }
- }
- }
- }
|