ASP.NET定时发送邮件&windows server
2015-07-21 09:02
597 查看
System.Timers.Timer timer;
void Application_Start(object sender, EventArgs e)
{
long ltime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["lTick"]);
timer = new System.Timers.Timer();
timer.Interval = ltime;
timer.Enabled = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.AutoReset = false;
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
timer.Stop();
timer.Enabled = false;
SendMail(); 具体的任务操作在这里写
timer.Enabled = true;
timer.Start();
}
void Application_End(object sender, EventArgs e)
{
timer.Dispose();
}
http://www.cnblogs.com/JamesLi2015/archive/2008/10/23/1318196.html
创建windows server安装脚本
在项目中添加2个文件如下(必须是ANSI或者UTF-8无BOM格式):
1)安装脚本Install.bat
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe WindowsServiceTest.exe Net Start ServiceTest sc config ServiceTest start= auto
2)卸载脚本Uninstall.bat
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u WindowsServiceTest.exe
3)安装脚本说明
第二行为启动服务。
第三行为设置服务为自动运行。
这2行视服务形式自行选择。
4)脚本调试
如果需要查看脚本运行状况,在脚本最后一行加入pause
void Application_Start(object sender, EventArgs e)
{
long ltime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["lTick"]);
timer = new System.Timers.Timer();
timer.Interval = ltime;
timer.Enabled = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.AutoReset = false;
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
timer.Stop();
timer.Enabled = false;
SendMail(); 具体的任务操作在这里写
timer.Enabled = true;
timer.Start();
}
void Application_End(object sender, EventArgs e)
{
timer.Dispose();
}
http://www.cnblogs.com/JamesLi2015/archive/2008/10/23/1318196.html
创建windows server安装脚本
在项目中添加2个文件如下(必须是ANSI或者UTF-8无BOM格式):
1)安装脚本Install.bat
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe WindowsServiceTest.exe Net Start ServiceTest sc config ServiceTest start= auto
2)卸载脚本Uninstall.bat
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u WindowsServiceTest.exe
3)安装脚本说明
第二行为启动服务。
第三行为设置服务为自动运行。
这2行视服务形式自行选择。
4)脚本调试
如果需要查看脚本运行状况,在脚本最后一行加入pause
相关文章推荐
- ASP.NET通过自定义函数实现对字符串的大小写切换功能
- JS实现jasperreport交叉报表输出页面居中效果
- 【读书笔记】【03】【2015.07.20-】Dreamweaver cs6 +ASP
- 利用基于@AspectJ的AOP实现权限控制
- 【西祠日志】【04】还不错,今天asp基本功能完成了(2015.07.20周一)(第二周)
- 在ASP.NET MVC中使用Castle Windsor
- ASP.NET 对类进行XML序列化和反序列化
- ASP.NET Web API如何将注释自动生成帮助文档
- 【asp】透彻掌握ASP分页技术
- 架构设计(ASP.NET MVC+Knockout+Web API+SignalR)
- JAVA使用aspose.word 实现html转换word
- asp.net常用控件之一,GridView
- asp.net mvc 页面缓存
- ASP.NET MVC 过滤器开发与使用
- [转]ASP.Net MVC开发基础学习笔记(3):Razor视图引擎、控制器与路由机制学习
- 【asp10】asp中的rs.open与conn.execute的区别
- ASP.NET MVC 中出现的 方法 中的 this 关键字 用法 (this HtmlHelper helper)
- asp.net使用百度的webuploader批量上传图片
- ASP.NET web.config中<customErrors>节点说明
- ASP.NET发布WebService