315 Star 741 Fork 365

车江毅 / TaskManager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

##分支说明##

该分支是基于BSF的基础上开发的分支。
修改内容
1)sdk以插件的形式扩展自BSF。
2)项目命名空间从Dyd.BaseService.TaskManager修改为TaskManager
3) 打包安装包,可以直接被第三方安装使用。
4)旧版本XXF.dll,则使用master分支

直接使用**“任务调度平台安装”**下的安装包直接安装试用。
5)【新】增加redis内部即时通知功能,优化web与节点之间的通信。
6)【新】增加共享配置功能,所有任务都可以共享使用这些配置。
7)【新】节点监控任务未运行出错,导致持续报错bug。

##无法编译的问题## git下载源码后部分开发人员无法编译的问题(挺诡异的问题),可以按照以下两种方式尝试解决:
1)改成.net 4.5 framework 再试试。
2)直接下载BSF源码进行编译
3) 给所有项目安装2.0版本的system.Net.Http包(右键解决方案→Nuget可以给所有项目安装这个包)。 原因:BSF引用的是system.Net.Http 2.0,但win8以后windows默认的NETFramework是4.5,包含的是system.Net.Http 4.0版本

.net 简单任务调度平台

用于.net dll,exe的任务的挂载,任务的隔离,调度执行,访问权限控制,监控,管理,日志,错误预警,性能分析等。

  1. 平台基于quartz.net进行任务调度功能开发,采用C#代码编写, 支持corn表达式和第三方自定义的corn表达式扩展。

  2. 架构以插件形式开发,具有良好的功能扩展性,稳定性,简单性,便于第三方开发人员进一步进行功能扩展。

  3. 支持多节点集群,便于集群服务器的资源有效分配,任务的相互隔离。

  4. 支持邮件形式的错误预警,便于运维及时处理任务异常等。

-- 车江毅 2015-06-17

Dyd.BaseService.TaskManager源码部署须知:

  • 1、删除各个项目中Newtonsoft.Json.dll的引用
  • 2、检查各项目中XXF.dll的引用,确保引用了“引用”文件夹中的XXF.dll
  • 3、执行,建模脚本.txt中的sql server脚本语句
  • 4、【Dyd.BaseService.TaskManager.Web】 任务管理后台,部署此站点,修改web.config数据库的字符串连接
  • 5、修改登录代码和用户权限(看源码),不用源码内部通过crm登录
  • 6、【Dyd.BaseService.TaskManager.MonitorTasks】 监控任务,此任务需要重新生成,打包此此文件(原有的打包文件可以直接删除)
  • 7、【Dyd.BaseService.TaskManager.WinService】 进行服务安装,修改安装包的实际路径
  • 8、管理后台,可以正常访问后,请参照 “任务调度平台安装->任务调度平台部署流程(示例).xls”,来新建任务,调通任务可以正常进行,则为成功
*(感谢俞忠亮同学整理)*
## 开源相关群: .net 开源基础服务 851340557 ## (大家都有本职工作,也许不能及时响应和跟踪解决问题,请谅解。)

参考文档

####(相关文档,请参考master分支,但master分支相对来说是比较旧的版本分支)####

  • 文档\任务调度(TaskManage)实现分析.xp.docx 徐品提供
  • 文档\任务调度部署-易懂版.docx 北京-谢江提供

任务demo示例

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Dyd.BaseService.TaskManager.Demo
{
    /// <summary>
    /// 任务调度平台 任务插件的写法demo及说明
    /// </summary>
    public class DemoTask : XXF.BaseService.TaskManager.BaseDllTask
    {
        /// <summary>
        /// 任务调度平台根据发布的任务时间配置,定时回调运行方法
        /// 开发人员的任务插件必须要重载并该方法
        /// </summary>
        public override void Run()
        {
            /* 
             * this.OpenOperator 用于任务调度平台提供给第三方使用的所有api接口封装
             */
 
            /*获取当前任务dll安装目录*/
            this.OpenOperator.GetTaskInstallDirectory();
 
            /*打印一条日志到任务调度平台,因为日志会存到平台数据库,所以日志要精简,对任务出错时有分析价值【注意:不要频繁打印无用的,非必要的,对分析无价值的日志信息】*/
            this.OpenOperator.Log("这里打印一条日志到任务调度平台");
 
            /*打印一条错误到任务调度平台,因为日志会存到平台数据库,所以日志要精简,对任务出错时有分析价值【注意:不要频繁打印无用的,非必要的,对分析无价值的日志信息】
             *后续任务会有增加优先级区分,根据任务的优先级,错误的出现频率等,错误日志会定期推送到开发者邮箱和短信*/
            this.OpenOperator.Error("这里打印一条错误日志到任务调度平台", new Exception("错误msg信息"));
 
            /*从数据库获取任务的临时数据,临时数据以jason的形式保存在数据库里面,便于任务上下文的恢复和信息传递【注意:不应用于"频繁的"存储"大量的"临时数据,会操作网络耗时和数据库性能差】*/
            var databasetempinfo = this.OpenOperator.GetDataBaseTempData<DemoTaskDatabaseTempInfo>();
            if (databasetempinfo == null)//若任务第一次运行,可能没有临时数据。当然也可以在发布任务的时候配置临时数据也可。
            {
                databasetempinfo = new DemoTaskDatabaseTempInfo();
                databasetempinfo.LastLogID = 0;
            }
 
            /*将任务的临时数据持久化到数据库中,临时数据以json的形式保存在数据库里面,便于任务上下文的恢复和信息传递【注意:不应用于"频繁的"存储"大量的"临时数据,会操作网络耗时和数据库性能差】
              若临时数据用于下一次使用,必须要执行此方法,否则下次无法获取【注意:执行此方法,当前临时数据有可能被重置为null,便于内存资源释放】*/
            this.OpenOperator.SaveDataBaseTempData(databasetempinfo);
 
            /*从本地安装目录中获取任务的临时数据,临时数据以jason的形式保存在本地,便于任务上下文的恢复和信息传递【注意:本地临时数据一般用于保存"大量的"临时数据】*/
            var localtempinfo = this.OpenOperator.GetLocalTempData<DemoTaskLocalTempInfo>();
            if (localtempinfo == null)//若任务第一次运行,可能没有临时数据。当然也可以在发布任务的时候上传临时数据json至安装压缩包中也可。
            {
                localtempinfo = new DemoTaskLocalTempInfo();
                localtempinfo.file = new byte[0];
            }
 
            /*将任务的临时数据持久化到本地安装目录中,临时数据以json的形式保存在本地安装目录里面,便于任务上下文的恢复和信息传递【注意:本地临时数据一般用于保存"大量的"临时数据】
              若临时数据用于下一次使用,必须要执行此方法,否则下次可能无法获取【注意:执行此方法,当前临时数据有可能被重置为null,便于内存资源释放】*/
            this.OpenOperator.SaveLocalTempData(localtempinfo);
 
            {
                string msg = "执行业务中...."+ this.AppConfig["sendmailhost"];
                Debug.WriteLine(msg);
                System.IO.File.AppendAllText(this.OpenOperator.GetTaskInstallDirectory()+"业务.txt", msg);
            }
        }
        /// <summary>
        /// 开发人员自测运行入口
        /// 需要将项目配置为->控制台应用程序,写好Program类和Main入口函数
        /// </summary>
        public override void TestRun()
        {
            /*测试环境下任务的配置信息需要手工填写,正式环境下需要配置在任务配置中心里面*/
            this.AppConfig = new XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo();
            this.AppConfig.Add("sendmailhost", "smtp.163.com");
            this.AppConfig.Add("sendmailname", "fengyeguigui@163.com");
            this.AppConfig.Add("password", "******");
 
            base.TestRun();
        }
    }
 
    /// <summary>
    /// 任务调度平台之临时数据信息,用于任务上下文的信息传递。
    /// 将会以json形式保存在任务调度平台数据库中,便于下一次回调运行时恢复并使用。【注意:不应用于"频繁的"存储"大量的"临时数据,会操作网络耗时和数据库性能差】
    /// </summary>
    public class DemoTaskDatabaseTempInfo
    {
        public int LastLogID { get; set; }
    }
 
    /// <summary>
    /// 任务调度平台之临时数据信息,用于任务上下文的信息传递。
    /// 将会以json形式保存在任务调度平台本地安装文件夹中,便于下一次回调运行时恢复并使用。【注意:本地临时数据一般用于保存"大量的"临时数据】
    /// </summary>
    public class DemoTaskLocalTempInfo
    {
        public byte[] file { get; set; }
    }
}

web后端部分截图及安装

未来构想:

    1. 任务故障转移: 检测到任务持续故障n次或者故障频率,判定进行异地节点/节点集群内的任务启动,可支持n次故障恢复。
  • 2)任务负载均衡: 多个任务并行执行,用于高资源负载任务的多节点运行。
  • 3)任务拆分: 一个父级任务可以创建多个子任务,并对任务进行管理,调度,故障恢复,预警等。
  • 4)任务流程化及管理。

##.net 开源第三方开发学习路线 ##

  • 路线1:下载开源源码->学习开源项目->成功部署项目(根据开源文档或者QQ群项目管理员协助)->成为QQ群相关项目管理员->了解并解决日常开源项目问题->总结并整理开源项目文档并分享给大家或推广->成为git项目的开发者和参与者
  • 路线2:下载开源源码->学习开源项目->成功部署项目(根据开源文档或者QQ群项目管理员协助)->在实际使用中发现bug并提交bug给项目相关管理员
  • 路线3:下载开源源码->学习开源项目->成功部署项目(根据开源文档或者QQ群项目管理员协助)->自行建立开源项目分支->提交分支新功能给项目官方开发人员->官方开发人员根据项目情况合并新功能并发布新版本

关于.net 开源生态圈的构想

.net 生态闭环:官方开源项目->第三方参与学习->第三方改进并提交新功能或bug->官方合并新功能或bug->官方发布新版本
为什么开源? .net 开源生态本身弱,而强大是你与我不断学习,点滴分享,相互协助,共同营造良好的.net生态环境。
开源理念: 开源是一种态度,分享是一种精神,学习仍需坚持,进步仍需努力,.net生态圈因你我更加美好。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

.net 简单任务调度平台,用于.net dll,exe的任务的挂载,任务的隔离,调度执行,访问权限控制,监控,管理,日志,错误预警,性能分析等。 平台基于quartz.net进行任务调度功能开发,采用C#代码编写, 支持corn表达式和第三方自定义的corn表达式扩展。 架构以插件形式开发,具有良好的功能扩展性,稳定性,简单性,便于第三方开发人员进一步进行功能扩展。 支持多节点集群,便于集群服务器的资源有效分配,任务的相互隔离。 支持邮件形式的错误预警,便于运维及时处理任务异常等。 (项目允许用于第三方公司进行二次开发且在公司内部使用,但禁止以盈利为目的进行商业行为) 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/chejiangyi/Dyd.BaseService.TaskManager.git
git@gitee.com:chejiangyi/Dyd.BaseService.TaskManager.git
chejiangyi
Dyd.BaseService.TaskManager
TaskManager
BSF_TaskManager20160929

搜索帮助