Esempio n. 1
0
        /// <summary>
        /// implementation to remove session detail from the cache memory
        /// </summary>
        private static void RemoveObsoleteSessionDestination()
        {
            // Loop over pairs with foreach of cache memory.
            foreach (KeyValuePair <string, List <object> > pair in cacheDestinations)
            {
                bool sessionInvalidFlg = false;

                List <object> sapSessionValue = pair.Value;

                if (sapSessionValue == null || sapSessionValue.Count < 2 || sapSessionValue[1] == null) //invalid value;
                {
                    sessionInvalidFlg = true;

                    //logging  abnormal case
                    if (logger.IsInfoEnabled())
                    {
                        MessageData messageData = new MessageData("scci00004", Properties.Resources.scci00004, pair.Key);
                        logger.Info(messageData);
                    }
                }
                else
                {
                    RfcDestination sapRfcDestination = (RfcDestination)sapSessionValue[1]; // get RfcDestination from cache session in 1
                    if (sapRfcDestination == null || sapRfcDestination.IsShutDown)
                    {
                        sessionInvalidFlg = true;
                    }
                }

                if (sessionInvalidFlg)       //if session value is not invalid, remove from cache.
                {
                    lock (cacheDestinations) //lock only while removing.
                    {
                        cacheDestinations.Remove(pair.Key);
                    }

                    if (logger.IsInfoEnabled())
                    {
                        //logging the remove sessiondetail of the usersession
                        MessageData messageData = new MessageData("scci00003", Properties.Resources.scci00003, pair.Key);
                        logger.Info(messageData);
                    }
                }
            }
        }