• c#计划任务


    做一个类似计划任务的模块,在配置文件里写要执行的时间,让程序定时执行。

    1.建立配置文件App.config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <!--设定每月执行计划任务的日期,先设定每月的16号,17号,25号执行-->
        <add key ="DateNum" value ="16,17,25"/>
      </appSettings>
    </configuration>

    2. 建立PlanWork.cs文件

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Configuration;
    using System.Timers;

    namespace PlanWork
    {
        public class PlanWork
        {
            static void Main(string[] args)
            {
                Myplan mp = new Myplan();


                //*************************************************
                //设定间隔时间是15天,测试的时候设定时间为1000纳秒
                //Timer t = new Timer(15 * 24 * 60 * 60000);
                Timer t = new Timer(1000);
                //*************************************************


                //绑定定时触发的函数
                t.Elapsed += new ElapsedEventHandler(mp.RunMyplan);
                t.Start();
                Console.ReadLine();
            }

        }
        public class Myplan
        {
            public void RunMyplan(Object source, ElapsedEventArgs e)
            {
                //读取配置文件设定的日期时间
                string SetDate = ConfigurationManager.AppSettings["DateNum"].ToString();

                //获取现在的系统时间
                DateTime nowTime = System.DateTime.Now;
                string d = nowTime.Day.ToString(); //取日期

                //比较是否符合设定的时间,SetDate中是否有d的存在 
                int i = SetDate.IndexOf(d);
                if (i >= 0)
                {
                    //计划任务要执行程序
                    Console.Write("\nToday is " + d + " day!");
                }

            }

        }
    }

    这样一个计划任务的小程序就ok了。

    Asp.net:

    http://book.chinaz.com/others/web/web/aspnet/index.htm

    Data Access Application Block for .NET

    http://www.microsoft.com/china/MSDN/library/EnterpriseDevelopment/BuildDistApp/Vsdnbdadaab_rm.mspx?mfr=true

     开源资料大全

    Programming C#中文版:第4版

    ASP.NET 2.0揭秘(卷2):http://book.csdn.net/bookfiles/488/

    最优化ASP.NET (面向对象):http://book.csdn.net/bookfiles/90/index.html

    精通基于ASP.NET 2.0的Web 2.0应用(如RSS、Blog、Tags、Web service、BBS、XML、AJAX、WIKI) :

                                                 http://book.csdn.net/bookfiles/425/index.html

    Expert C# 2005 Business Objects中文版 :http://book.csdn.net/bookfiles/397/

    Beginning C# Objects从概念到代码 :http://book.csdn.net/bookfiles/26/index.html

    C#和.NET实战:平台、语言与框架 :http://book.csdn.net/bookfiles/588/index.html

    框架设计(第2版):CLR Via C# :http://book.csdn.net/bookfiles/154/index.html

    C#高级编程(第4版) :http://book.csdn.net/bookfiles/140/

    Effective C#中文版:改善C#程序的50种方法 :http://book.csdn.net/bookfiles/295/

    ASP.NET 2.0服务器控件与组件开发高级编程 :http://book.csdn.net/bookfiles/337/index.html

     道不远人:深入解析ASP.NET 2.0控件开发 :http://book.csdn.net/bookfiles/533/


  • 相关阅读:
    《大道至简》读后感
    论校园跑腿软件的体验
    php学习
    小资料:管理学中的几种分析方法
    SQL Server 连接失败(转自http://7880.com/Info/Article116a9e40.html)
    无法打开项目文件:Visual Studio .net
    ASP.NET设计网络硬盘之下载或在线查看 (转)
    upload file to sql
    转自thinhunan 应用WEB标准进行网站设计--《网站重构》读书笔记
    关于轻量级权限控制的实现(转自登峰之道)
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/2224735.html
Copyright © 2020-2023  润新知