/// <summary>
        /// Close the session.
        /// </summary>
        public static void CloseSession()
        {
            if (string.IsNullOrEmpty(AppContext.Current.SessionID))
               {
               return;
               }

               using (SessionRenewProxy sessionRenewProxy = new SessionRenewProxy())
               {
               ISessionRenewService wrappedProxy = InstanceBuilder.Wrap<ISessionRenewService>(sessionRenewProxy);
               wrappedProxy.CloseSession(new Guid(AppContext.Current.SessionID));
               }
        }
        public static SessionStatus RefreshSession(bool refreshImmediately)
        {
            SessionStatus status;
               //try
               {
               if (!refreshImmediately
                   && ((DateTime.Now - LatestRefreshTime) < _refreshInterval))
               {
                   return SessionStatus.Active;
               }

               if (string.IsNullOrEmpty(AppContext.Current.SessionID))
               {
                   throw new SessionRenewException(Messages.Framework.FWE002.Format(), SessionStatus.UnKnown);
               }

               AppContext.SetToCallContext(AppContext.Current.ToDictionary());
               if (!refreshImmediately)
               {
                   LatestRefreshTime = DateTime.Now;
               }

               using (SessionRenewProxy sessionRenewProxy = new SessionRenewProxy())
               {
                   ISessionRenewService wrappedProxy = InstanceBuilder.Wrap<ISessionRenewService>(sessionRenewProxy);
                   status = wrappedProxy.RefreshSession(AppContext.Current.SessionID);
                   return status;
               }
               }
               //finally
               //{
               //    //ExceptionManager.IsActive = (status==SessionStatus.Active);
               //}
        }