首先介绍一下什么是定时器作业,说的再多,也不如一张图说的清楚


这两张图应该把我想说的已经表达清楚了,下一步介绍一下如何自定义Timer Job
第一步:创建一个类(CustomTimerJob.cs)
第二步:引用 using Microsoft.SharePoint.Administration;并继承SPJobDefinition
第三步:构造 三个函数
        public CustomTimerJob()
            : base()
        {
        }
        public CustomTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)
            : base(jobName, service, server, targetType)
        {
        }
        public CustomTimerJob(string jobName, SPWebApplication webApplication)
            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = "Custom Timer Job";  //在上面的图处上可以看到这个名字
        }
第四步:override Execute 处理自己的业务
     public override void Execute(Guid targetInstanceId)
        {
            SPWebApplication webApplication = this.Parent as SPWebApplication;
            SPContentDatabase contentDb = webApplication.ContentDatabases[targetInstanceId];
            // get a reference to the "Tasks" list in the RootWeb of the first site collection in the content database
            SPList taskList = contentDb.Sites[0].RootWeb.Lists["Product"];
            // create a new task, set the Title to the current day/time, and update the item
            SPListItem newTask = taskList.Items.Add();
            newTask["Title"] = DateTime.Now.ToString();
            newTask.Update();
        }
在上一篇 自定义 Features 里面,当激活功能时,到管理中心可以看到自己的定义的 Timer Job
public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
            if (site != null)
            {
                foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
                {
                    if (job.Name == CUSTOM_TIMER_JOB)
                    {
                        job.Delete();
                    }
                }
            }
            //开始Job
            CustomTimerJob customTimerJob = new CustomTimerJob(CUSTOM_TIMER_JOB, site.WebApplication);
            SPMinuteSchedule schedule = new SPMinuteSchedule();
            schedule.BeginSecond = 0;
            schedule.EndSecond = 59;
            schedule.Interval = 5;
            customTimerJob.Schedule = schedule;
            customTimerJob.Update();
        }
之后部署,到网站网站集里停止再激活,之后去管理中心,就可以看到自己定义的Job了

更多精彩请关注

转载于:https://www.cnblogs.com/Fengger/archive/2012/06/02/2532047.html

SharePoint Timer Job相关推荐

  1. sharepoint timer job 读取config文件内容

    需要写一个自定义的sharepoint timer job, 目的是要定时到Site Collection Images这个List里检查图片的过期日期,如果即将过期的话,需要发送email到相关的人 ...

  2. 步步为营 SharePoint 开发学习笔记系列 七、SharePoint Timer Job 开发

    概要 项目需求要求我们每天晚上同步员工的一些信息到sharepoint 的user List ,我们决定定制开发sharepoint timer Job,Sharepoint timer Job是sh ...

  3. 创建SharePoint 2010 Timer Job

    好久没有写博客了.最近在使用SharePoint 2010中Timer Job的功能,有了一点心得,分享一下. 我个人认为SharePoint Timer Job和Windows Service或者是 ...

  4. 管理SharePoint中的账号的密码

    在SharePoint环境中更换密码 下图展示了在一个拥有两个WFE服务器的SharePoint服务器场中更换SharePoint场管理员密码的一个过程. 密码的更改并不要求重启系统. Windows ...

  5. Windows SharePoint Services 3.0编码开发工具和技巧(Part 1 of 2)

    转:http://blog.csdn.net/mattwin/article/details/2074984 WSSv3 Technical Articles_Windows SharePoint S ...

  6. Moss/Sharepoint 备份或还原时出错的处理(持续更新)

    Moss/Sharepoint  备份或还原时出现了两个错误,现在我把他记录下来 当用sharepoint 2010 管理中心备份一个网站的时候出现了这样一个错误 目录 D:\\backu\ 不存在, ...

  7. 登陆SharePoint站点出现service unavailable----Http错误503

    今天在登陆SharePoint站点时,遇到服务不可用,Http error 503.建议如下操作: 1. 在IIS中检查站点属性.在"起始页",检查应用程序池. 2. 发现Shar ...

  8. 在SharePoint环境中更换密码

    下图展示了在一个拥有两个WFE服务器的SharePoint服务器场中更换SharePoint场管理员密码的一个过程. 密码的更改并不要求重启系统. Windows的服务和IIS可以使用密码更换之前的, ...

  9. SharePoint 2013 Farm 安装指南——Least Privilege

    写过很多关于SharePoint 2013 安装,这是第四篇.可能你会觉得为什么如此简单的安装至于花那么多精力去折腾吗.我的答案是肯定的.知识的积累不是一蹴而就的,而是循序渐进的去学习,每一个阶段都有 ...

最新文章

  1. Python 键盘鼠标监听
  2. 今天聊聊分布式锁 No.86
  3. 关于二叉树的链表表示的一个问题
  4. windows 安装 spark 及 pycharm 调试 TopN 实例
  5. win7 storm搭建
  6. python3 redis操作 错误 cannot import name 'StrictRedis' from 'redis'
  7. JS 转换数字为大写
  8. python中实现定时器Timer
  9. Grid game CodeForces - 1104C 放格子|思维|找规律
  10. PTA最大子列和问题
  11. 12月中国区块链经理人指数:环比出现大幅下跌 企业融资不理想
  12. c/c++教程 - 2.4.2.1~2 对象的初始化和清理,构造函数和析构函数,构造函数的分类和调用(有参构造,无参构造,普通构造,拷贝构造,括号法,显示法,隐式转换法,匿名对象)
  13. 评论关于中国工厂代工的Andr​​oid 4.0迷你PC的智能电视棒Mk802 CF卡
  14. 百度AI之百度图像识别java版本使用
  15. 手把手教你搭建用户标签体系
  16. 【人在运维囧途_14】打扫干净屋子再请客
  17. 360金融:“巨头”式的快与稳
  18. 阐述商务礼仪的重要性
  19. 操作系统实验四 进程同步与互斥
  20. python自动读取短信_自动化测试-自动获取手机短信验证码

热门文章

  1. 数据库:分享六个 MySQL 死锁案例,能让你理解死锁的原因!
  2. 计算机基础:存储系统知识笔记(二)
  3. 收集MySQL常用函数,值得收藏!
  4. 电脑小白来一起学习计算机基础知识!
  5. h5 手风琴效果_小程序-实现折叠面板-手风琴效果
  6. mysql 5.7.23要钱吗_最新mysql 5.7.23安装配置图文教程
  7. STM32 PWM输出实验
  8. lottie 动画_使用After Effects和Lottie制作网络动画而不会损失质量
  9. webpack 配置详解
  10. 【九章算法免费讲座第一期】转专业找CS工作的“打狗棒法”