Example #1
0
 private void initJob()
 {
     try
     {
         if (scheduler == null && job == null)
         {
             scheduler           = Quartz.Impl.StdSchedulerFactory.GetDefaultScheduler();
             JobWorker.jobHolder = this;
             job = JobBuilder.Create <JobWorker>().WithIdentity("connectJob", "jobs").Build();
             string   time    = ConfigWorker.GetConfigValue("timeTask");
             ITrigger trigger = TriggerBuilder.Create().WithIdentity("connectTrigger", "triggers").StartAt(DateTimeOffset.Now.AddSeconds(1))
                                .WithSimpleSchedule(x => x.WithIntervalInSeconds(60 * int.Parse(time)).RepeatForever()).Build();
             //ITrigger trigger = TriggerBuilder.Create().WithIdentity("connectTrigger", "triggers").StartAt(DateTimeOffset.Now.AddSeconds(1))
             //    .WithCronSchedule(time).Build();
             scheduler.ScheduleJob(job, trigger);//把作业,触发器加入调度器。
             jobKey = job.Key;
             //scheduler.DeleteJob
         }
         scheduler.Start();
     }
     catch (Exception ex)
     {
         FileWorker.LogHelper.WriteLog("定时任务异常:" + ex.Message);
     }
 }
Example #2
0
 static FileWorker()
 {
     txtFilePath = ConfigWorker.GetConfigValue("logPath");
     if (!System.IO.Directory.Exists(txtFilePath))
     {
         System.IO.Directory.CreateDirectory(txtFilePath);//不存在就创建目录
     }
 }
Example #3
0
 static FtpHelper()
 {
     try
     {
         string ftpServer = ConfigWorker.GetConfigValue("ftpServer");
         int    ftpPort   = int.Parse(ConfigWorker.GetConfigValue("ftpPort"));
         string ftpUser   = ConfigWorker.GetConfigValue("ftpUser");
         string ftpPwd    = ConfigWorker.GetConfigValue("ftpPwd");
         client = new FtpClient(ftpServer, ftpPort, ftpUser, ftpPwd);
     }
     catch (Exception ex)
     {
         FileWorker.LogHelper.WriteLog("实例化FTP客户端失败:" + ex.Message);
         //MessageBox.Show("实例化FTP客户端失败:" + ex.Message);
     }
 }