orchardcms - how can i inject IContentManager in Timer callback (Orchard CMS) -
public models.manageduserspart getmanagedusers(int managedusersid) { return _cachemanager.get(managedusersid, ctx => { monitormanagedusersignal(ctx, managedusersid); timer = new timer(t => doupdate(_contentmanager,managedusersid), "c", timespan.fromminutes(2), timespan.frommilliseconds(-1)); var managedusers = _contentmanager.get<manageduserspart>(managedusersid); return managedusers; }); }
and doupdate function:
public void doupdate(icontentmanager contentmanager,int managedusersid) { var transation = _iworkcontext.createworkcontextscope().resolve<itransactionmanager>(); transation.requirenew(); var manager = getmanager(); var modifiemanageruser = manager.get<manageduserspart>(managedusersid); var modi = getmanagedusers(managedusersid); modifiemanageruser.invitedcount = modi.invitedcount; }
and ,this getmanager function:
public icontentmanager getmanager() { if (timermanager == null) { timermanager = _iworkcontext.createworkcontextscope().resolve<icontentmanager>(); } return timermanager; }
the question "modifiemanageruser.invitedcount = modi.invitedcount" code not persist update database,anyone can help?
Comments
Post a Comment