Custom Timed Events

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Custom Timed Events

Post by jguengerich » Thu Jul 11, 2013 8:16 am

I would like to set up a timed event, so I followed the instructions here: http://wiki.ablecommerce.com/index.php/ ... med_Events.

I set up a variable:

Code: Select all

private System.Threading.Timer _timer2;
I initialized it in Application_Start:

Code: Select all

    _timer2 = new System.Threading.Timer(new System.Threading.TimerCallback(TimedEvent), null, 60000, 60000);
I modified the TimedEvent code to work in Gold (I think), so it looks like the following:

Code: Select all

private void TimedEvent(Object stateInfo)
{
    // THIS IS RUNNING ON ITS OWN THREAD, OUTSIDE OF HTTPCONTEXT
    // (HTTPCONTEXT.CONTEXT IS NULL)
    // YOU MUST INITIALIZE THE TOKEN FOR THE STORE, CHANGE THE ID IF IT IS OTHER THAN 1
    Store store = StoreDataSource.Load(1);
    // INITIALIZE THE TOKEN FOR THIS STORE
    // Token.Instance.InitStoreContext(store);
    AbleContext.Current.Store = store;
    // *********
    // PUT YOUR CODE BELOW THIS COMMENT
    // *********
    Logger.Info("Timed task is running...");
    // *********
    // PUT YOUR CODE ABOVE THIS COMMENT
    // *********
    // RESET THE TOKEN INSTANCE AFTER THE EVENT RUNS
    // Token.ResetInstance();
    AbleContext.Current.Store = null;
}
I do not get any entries in the app.log file, so I have the following questions:
1. Did I modify the code correctly for Gold?
2. What else do I need to do to get this to work?
Jay

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Custom Timed Events

Post by jguengerich » Mon Jul 15, 2013 11:52 am

Actually the code I posted works. However, Logger.Info() doesn't add entries to the app.log file. Use Logger.Error() to create an entry in the app.log file.
Jay

User avatar
ForumsAdmin
AbleCommerce Moderator
AbleCommerce Moderator
Posts: 399
Joined: Wed Mar 13, 2013 7:19 am

Re: Custom Timed Events

Post by ForumsAdmin » Mon Jul 15, 2013 5:53 pm

Check App_Data/log4net.config for setting up the logging level. The default level is "WARN". You can set it to "DEBUG" or "INFO".

Post Reply