public Task Execute(IJobExecutionContext context) { return(Task.Factory.StartNew(() => { LogNetHelper.Info("<<<<<<<<<<执行获取数据服务>>>>>>>>>>"); Repository <HouseInfo> .Delete(n => n.ID > 0);//先清空数据表数据 })); }
public Logger GetLogger(string name) { return((level, func, exception, parameters) => { if (level >= LogLevel.Info && func != null) { LogNetHelper.Info("[" + DateTime.Now.ToLongTimeString() + "] [" + level + "] " + func() + "parameters:" + parameters); } return true; }); }
static void Main(string[] args) { HostFactory.Run(x => //1 { x.Service <LianjiaData>(s => //2 { s.ConstructUsing(name => new LianjiaData()); //3 s.WhenStarted(tc => tc.Start()); //4 s.WhenStopped(tc => tc.Stop()); //5 }); x.RunAsLocalSystem(); //6 x.SetDescription("定时获取链家网在郑州地区的二手房价格"); //7 x.SetDisplayName("Houseanalyse"); //8 x.SetServiceName("Houseanalyse"); //9 }); LogNetHelper.Info("Service Start"); }