Click here to Skip to main content
14,879,366 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello!!!

i am using Microsoft Enterprise Library for the caching application block, i have an application that is suppose to load clients into the caching with an absolute expiration time defined in minutes.

the idea is that when an item expires, the ICacheItemRefreshAction is suppose to run the refresh method and send an sms message via WCF.

but the event doesn't fire on absolute time expiration or it works once and another time it dosent work. the code seems to be OK what am i doing wrong?

this is the code
int ReminderTime; int cacheExparationTime; string CellPhone;

    ObjCacheManager = CacheFactory.GetCacheManager("parkingCache");

    m_CacheInterval = TimerCache.CacheInterval;

    dt = DL.DataLayer.LoadToCache(SP_LOAD_CACHE, m_CacheInterval.ToString()).Tables[0];//UniParkDAL.DalManager.GetDataTable(SP_LOAD_CACHE, sqlParams);

    if (dt != null && dt.Rows.Count > 0)
    {
        foreach (DataRow dr in dt.Rows)
        {
            ReminderTime = Convert.ToInt32(dr["ReminderTime"]);
            CellPhone = CleanPhoneNumber(dr["Mobile"].ToString(), "972");
            TimeSpan DateDiff = DateTime.Parse(dr["IntervalEnd"].ToString()).Subtract(DateTime.Now);
            string Minutes = DateDiff.Minutes.ToString();

            if (ReminderTime > 0)
            {
                cacheExparationTime = ReminderTime;
                ReminderTime = Convert.ToInt32(Minutes) - ReminderTime;
                m_message = string.Format("your parking will end in {0} minutes", ReminderTime.ToString());

                m_AbsoulteTime = new AbsoluteTime(TimeSpan.FromMinutes(cacheExparationTime));
                ObjCacheManager.Add(CellPhone, m_message, CacheItemPriority.Normal, new CallService(), m_AbsoulteTime);
            }
        }
    }
Posted
Updated 5-Jun-11 4:33am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900