Open source task management platform TaskManagerV2.0 introduction and upgrade instructions

Open source task management platform TaskManagerV2.0 introduction and upgrade instructions

  Previous open source task management platform TaskManager introduced after the release, that someone contact me see if I can do a background management interface, easy management system for all tasks. Due to time and technical issues in version 1.0, a new function was added to dynamically modify tasks by reading configuration files in 3 minutes, but overall it is still not intuitive and the operation is not convenient. I just came into contact with Owin recently, and I can run my own host program to run the Web site. You can run the background Web without IIS. Here is the result of clicking the console program to run . Recently, I used this technology in my free time to realize the background management program, which is the version of TaskManagerV2.0 that this article will talk about. If you don't know the TaskManagerV1.0 version, you can take a look first. The final interface is as follows, you can also open this address http://tm.myscloud.cn to browse online. Still before the old rules article will provide the program and source code download address at the end.

Read the table of contents

back to the top

V2.0 upgrade instructions

  There are four biggest changes in 2.0 compared to the previous version

     1. Background management program

      The most obvious difference provides the background management program. When the user starts TaskManager, he can enter the background management system through the browser to easily configure and manage all tasks, and conveniently view the task's recent running time and next running time. Of course, the site address of the background management program can also be configured by the user, which will be explained later.

     2. Diversified host programs

     V1.0 is implemented based on Window service, V2.0 can be reloaded using console program, Windows service or traditional Web program.

  3. Task storage method

All tasks of the system are stored in the database, and version 1.0 is no longer stored in the xml configuration file.

4. Automatically start as system administrator

      Before the program starts, it will first judge whether it is currently running in administrator mode, if not, it will restart to run in administrator mode

      The most important change, the Web management site does not require users to deploy in iis, it will automatically start when the console program or service is started

back to the top

Cron expression

    Cron expressions are used to specify the frequency of task execution. I have written an article on the Quartz Cron expression online generator. You can use it directly.

back to the top

Implementation principle of open source TaskManagerV2.0

    TaskManager is an open source task management system based on Quartz.NET and Nancy. It can be carried by Window service or console program. The web background is implemented using Nancy Host. The next article will introduce this technology.

    Project structure introduction:

  The background management site is completely independent of window services and console programs, and is loosely coupled. Let's see how these two hosting services start the background site.

  window service

  protected override void OnStart(string[] args)
        {
            DebuggableAttribute att = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttribute<DebuggableAttribute>();
            if (att.IsJITTrackingEnabled)
            {
               //Debug mode stops the thread for 10s, which is convenient for attaching to the process for debugging
                Thread.Sleep(10000);
            }
           //Read configuration information
            ConfigInit.InitConfig();
            QuartzHelper.InitScheduler();
            QuartzHelper.StartScheduler();

           //Keep the web service running  
            ThreadPool.QueueUserWorkItem((o) =>
            {
               //Start the site
                Startup.Start(SysConfig.WebPort);
            });
        }

   When the window service starts, the startup interface provided by the Web program is called.

   Console program  

 static void Main(string[] args)
        {
            AdminRun.Run();
            ConfigInit.InitConfig();
            QuartzHelper.InitScheduler();
            QuartzHelper.StartScheduler();
            try
            {
               //Start the site
                using (NancyHost host = Startup.Start(SysConfig.WebPort))
                {
                   //Call the system default browser   
                    Process.Start("http://127.0.0.1:9000");
                    Console.WriteLine("System monitoring site address: {0}", "http://127.0.0.1:9000");
                    Console.WriteLine("The program has been started, press any key to exit");
                    Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }

back to the top

Use introduction

  For the first use, you need to create a new database, execute the SQL merge script under the publishing program, and modify the database connection in the config configuration file.

Use Windows service as a carrier

  Then we only need to know how to install the Windows service to be able to use the platform. Considering that many people don't know how to install and uninstall Windows services, I provide a small tool I wrote before to install and uninstall Windows services . The source code is also placed in the TaskManager.

  1. Run the Windows installation and uninstallation tool

  2. Select TaskManger.exe-"Install -" Run

 After running successfully, you can find "Timed Task Management Service" in System Management-"Services"

After the operation is successful, the Logs folder will be generated. At present, the system will record the execution log by task, which is convenient for users to view the execution of each task.

 3. Open http://local IP:9000 in the browser to enter the background

 Use the console program as the carrier

  Click to run Ywdsoft.Test.exe

 Introduction to the use of background management programs

  1. Customize the site port

  Modify the Config.config file, the default port is 9000

 2. How to fill in the cron expression in the editing interface

       Here is also considered for everyone, you can use the online Cron generator to generate, the address is http://tool.myscloud.cn , or you can use the Cron provided in the source code to deploy your own site.

 3. Others can be explored by yourself

back to the top

summary

      This concludes the content of this article, and now it’s time to release the source code. Stay tuned for the next article!

  GitHub address: Due to the unstable SVN address, many netizens cannot download it, so they decided to host the code on GitHub    https://github.com/CrazyJson/TaskManager

      Download link of experience tool: Task Management Framework V2.0

Reference: https://cloud.tencent.com/developer/article/1014520 Open source task management platform TaskManagerV2.0 introduction and upgrade instructions-Cloud + Community-Tencent Cloud