Ive installed it, checked its enabled, and reduced the time to 60 seconds. I have also added logging.
Nothing happens, never gets used.
plugin code as follows:
Plugin class
public class MereSyncPlugin : BasePlugin, IMiscPlugin
{
private MereSyncObjectContext _context;
private IScheduleTaskService _schedualTaskService;
public MereSyncPlugin(MereSyncObjectContext context, IScheduleTaskService schedualTaskService)
{
_context = context;
_schedualTaskService = schedualTaskService;
}
public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
{
actionName = "";
controllerName = "";
routeValues = new RouteValueDictionary()
{
{ "Namespaces", "Nop.plugin.Misc.MereSync.Controllers" },
{ "area", null }
};
}
public override void Install()
{
//TODO: add more
_schedualTaskService.InsertTask(new Nop.Core.Domain.Tasks.ScheduleTask()
{
Enabled = true,
Name = "Product Sync",
Seconds = 3600,
StopOnError = false,
Type = "Nop.Plugin.Misc.MereSync.ProductSyncTask, Nop.Plugin.Misc.MereSync"
});
//_context.Install();
base.Install();
}
public override void Uninstall()
{
Nop.Core.Domain.Tasks.ScheduleTask task = _schedualTaskService.GetTaskByType("Nop.Plugin.Misc.MereSync.ProductSyncTask, Nop.Plugin.Misc.MereSync");
if (task != null)
_schedualTaskService.DeleteTask(task);
//_context.Uninstall();
base.Uninstall();
}
}
Object context class (although not set up at this point so commented out some parts)
public class MereSyncObjectContext : DbContext, IDbContext
{
public bool ProxyCreationEnabled
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public bool AutoDetectChangesEnabled
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public MereSyncObjectContext(string nameOrConnectionString) : base(nameOrConnectionString)
{
}
/*protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//TODO: insert ALL model MAPPINGS!!!!
//modelBuilder.Configurations.Add(new insertnewmap());
base.OnModelCreating(modelBuilder);
}*/
public string CreateDatabaseInstallationScript()
{
return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
}
public void Install()
{
Database.SetInitializer<MereSyncObjectContext>(null);
Database.ExecuteSqlCommand(CreateDatabaseInstallationScript());
SaveChanges();
}
public void Uninstall()
{
//this.DropPluginTable("MereSys_TableName");
}
IDbSet<TEntity> IDbContext.Set<TEntity>()
{
return base.Set<TEntity>();
}
public IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new()
{
throw new NotImplementedException();
}
public IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters)
{
throw new NotImplementedException();
}
public int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = default(int?), params object[] parameters)
{
throw new NotImplementedException();
}
public void Detach(object entity)
{
throw new NotImplementedException();
}
}
Task class
public class ProductSyncTask : ITask
{
private readonly ILogger _logger;
public ProductSyncTask(ILogger logger)
{
this._logger = logger;
}
public async void Execute()
{
//TODO: Call My method, USE BEST PRACTICE, IoC DI
//throw new NotImplementedException();
_logger.InsertLog(Nop.Core.Domain.Logging.LogLevel.Information, "Start", "Product sync has started");
ProductSyncService test = new ProductSyncService();
await test.GetProductsAsync();
}
}
The rest fo the code isnt relevant as its just a service class etc. When i go to Nops logging, admin area > system > log nothing shows up. when i check to see if my task is enabled its true, but hasnt run. My plugin appears to be installed too.
What am i missing here?
Thanks!
UPDATE
A public action method 'null' was not found on controller 'Nop.Admin.Controllers.PluginController'.
System.Web.HttpException (0x80004005): A public action method 'null' was not found on controller 'Nop.Admin.Controllers.PluginController'. at System.Web.Mvc.Controller.HandleUnknownAction(String actionName) at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)