net开源商城,nopcommerce计划任务分析

2019-10-08 20:08 来源:未知

nopcommerce官网

本文转自:

对比了一下nopcommerce和orchard的计划任务,orchard的复杂的不是一点点,如果想拆下来自己用难度很大,搜索拆了orchard的lucene处理模块,邮件队列拆的discuznt和nopcommerce的结合,计划任务就拆nopcommerce的了,discuznt计划任务设计的没nopcommerce的好。

Here is very simple code to create widget in nopcommerce
First you can download nopcommerce version 3.70 in here  Seconds you should read bellow link Third download project sample widget for nopcommerce  here http://badpaybad.info/upload/nopcommerce/Nop.Plugin.BadPayBad.HelloWorld.zip Then extract and copy to folder plugins.  then add it to solution similar to image bellow
the output path for project will use in controller to return view (the file .cshtml) image for output path when build
public class HelloWorlWidgetNopPlugin : BasePlugin, IWidgetPlugin [big image] 图片 1 
As you can see in project sample. it very sample .cshml file . I just show the text hello world
The file HelloWorlWidgetNopPlugin.cs contain the defind of where is the action and controller for admin mode (the admin view) and frontend (the visitor view)
- Admin mode: the defind interface for admin can access to do some config defind by bellow

1.nopcommerce的tasks结构如下:

nopCommerce is a open source e-commerce solution that is ASP.NET 4 based with a MS SQL 2005 (or higher) backend database.

?

图片 2

 

1
2
3
4
5
6
7
8
9
10
11
public void GetConfigurationRoute(out string actionName, out string controllerName,
           out RouteValueDictionary routeValues)
       {
           actionName = "Configure";
           controllerName = "BadPayBadHelloWorld";
           routeValues = new RouteValueDictionary()
           {
               { "Namespaces", "Nop.Plugin.BadPayBad.HelloWorld.Controllers" },
               { "area", null }
           };
       }

IScheduleTaskService.cs 接口,这个主要是获取数据库里的任务信息,ScheduleTaskService.cs去实现它就可以了,当然需要在容器里注入一下。

nopcommerce中文网

- The front end mode: mean we show something for user visit the page

ITask 这个接口比较特别但是很重要,所有的任务处理类都要实现里面唯一的Execute方法。执行计划任务时就需要通过反射来执行这个实现。

  

namespace Nop.Services.Tasks
{
    /// <summary>
    /// Interface that should be implemented by each task
    /// </summary>
    public partial interface ITask
    {
        /// <summary>
        /// Execute task
        /// </summary>
        void Execute();
    }
}

 

?

核心类之一:Task.cs,这个主要是处理任务的执行过程及执行过程类的结果处理。

1
2
3
4
5
6
7
8
9
10
11
12
public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName,
            out RouteValueDictionary routeValues)
        {
            actionName = "FrontEndView";
            controllerName = "BadPayBadHelloWorld";
            routeValues = new RouteValueDictionary
            {
                {"Namespaces", "Nop.Plugin.BadPayBad.HelloWorld.Controllers"},
                {"area", null},
                {"widgetZone", widgetZone}
            };
        }
private ITask CreateTask()
        {
            ITask task = null;
            if (this.Enabled)
            {
                var type2 = System.Type.GetType(this._type);
                if (type2 != null)
                {
                    task = Activator.CreateInstance(type2) as ITask;
                }
                //this._enabled = task != null;
            }
            return task;
        }
TAG标签:
版权声明:本文由金沙澳门官网4166发布于文物考古,转载请注明出处:net开源商城,nopcommerce计划任务分析