Global.asax,我可以在生产服务器中更新它吗?

发布于 2024-09-16 12:35:46 字数 1508 浏览 11 评论 0原文

我的生产服务器中有一个 asp.net 网站,现在运行良好。现在我使用quartz.net 来执行计划任务,并在我的开发系统中对其进行了测试。我想将其移至生产服务器。

我的 global.asax 目前在生产服务器中:

void Application_Start(object sender, EventArgs e)
{
    Application["Hits"] = 0;
    Application["Sessions"] = 0;
    Application["TerminatedSessions"] = 0;
    ConfigureLogging();
}

我将把它更改为

void Application_Start(object sender, EventArgs e)
{
    ISchedulerFactory schedFact = new StdSchedulerFactory();
    // get a scheduler
    IScheduler sched = schedFact.GetScheduler();
    sched.Start();
    // construct job info
    JobDetail jobDetail = new JobDetail("mysSendMailJob", typeof(ScheduledMail));
    // fire every day at 06:00
    Trigger trigger = TriggerUtils.MakeDailyTrigger(06, 00);
    SimpleTrigger trigger2 = new SimpleTrigger("myTrigger",
                            null,
                            DateTime.UtcNow,
                            null,
                            SimpleTrigger.RepeatIndefinitely,
                            TimeSpan.FromSeconds(60));
    // start on the next even hour
    trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);  
    trigger.Name = "mySendMailTrigger";
    // schedule the job for execution
    sched.ScheduleJob(jobDetail, trigger2);
    // Code that runs on application startup
    Application["Hits"] = 0;
    Application["Sessions"] = 0;
    Application["TerminatedSessions"] = 0;
    ConfigureLogging();    
}

这些更改会更新还是会发生什么?

I have an asp.net website in my production server which running fine now. Now I am using quartz.net for scheduled tasks and in my development system I have tested it. I want to move it to production server.

My global.asax at present in production server:

void Application_Start(object sender, EventArgs e)
{
    Application["Hits"] = 0;
    Application["Sessions"] = 0;
    Application["TerminatedSessions"] = 0;
    ConfigureLogging();
}

and I am going to change it to

void Application_Start(object sender, EventArgs e)
{
    ISchedulerFactory schedFact = new StdSchedulerFactory();
    // get a scheduler
    IScheduler sched = schedFact.GetScheduler();
    sched.Start();
    // construct job info
    JobDetail jobDetail = new JobDetail("mysSendMailJob", typeof(ScheduledMail));
    // fire every day at 06:00
    Trigger trigger = TriggerUtils.MakeDailyTrigger(06, 00);
    SimpleTrigger trigger2 = new SimpleTrigger("myTrigger",
                            null,
                            DateTime.UtcNow,
                            null,
                            SimpleTrigger.RepeatIndefinitely,
                            TimeSpan.FromSeconds(60));
    // start on the next even hour
    trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);  
    trigger.Name = "mySendMailTrigger";
    // schedule the job for execution
    sched.ScheduleJob(jobDetail, trigger2);
    // Code that runs on application startup
    Application["Hits"] = 0;
    Application["Sessions"] = 0;
    Application["TerminatedSessions"] = 0;
    ConfigureLogging();    
}

Will these changes be updated or what will happen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江心雾 2024-09-23 12:35:46

如果它没有预编译,那么您可以在服务器上拥有不同的文件。

如果它是预编译的,则无法在服务器上更改它。
要解决此问题,您可以使用编译符号来具有不同的 application_start 方法或具有定义要调用哪个方法的设置。

如果您使用 .Net 4,您可以拥有一个调试和发布 web.config 文件,您可以在其中设置某种条件,并在应用程序启动时检查它。

If it is not precompiled then you can have a different file on the server.

If it is precompiled you can't change it on the server.
To fix this you an use compilation symbols to have different application_start methods or have setting that defines which method to call.

If you are using .Net 4 you can have a debug and release web.config file you you could set some sort of condition in there and check for it when the app spins up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文