}       //	get

        /// <summary>
        /// Get existing or create local session
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="createNew">create if not found</param>
        /// <param name="requestAddr">Request address</param>
        /// <returns>session</returns>
        public static MSession Get(Ctx ctx, Boolean createNew, String requestAddr)
        {
            int      AD_Session_ID = ctx.GetContextAsInt("#AD_Session_ID");
            MSession session       = null;

            if (AD_Session_ID > 0)
            {
                session = cache[AD_Session_ID];
            }

            if (session == null && AD_Session_ID > 0)
            {
                // check from DB
                session = new MSession(ctx, AD_Session_ID, null);
                if (session.Get_ID() != AD_Session_ID)
                {
                    session = null;
                }
                else
                {
                    cache.Add(AD_Session_ID, session);
                }
            }

            if (session != null && session.IsProcessed())
            {
                s_log.Log(Level.WARNING, "Session Processed=" + session);

                cache.Remove(AD_Session_ID);
                session = null;
            }


            if (session == null && createNew)
            {
                session = new MSession(ctx, null);      //	local session
                if (!string.IsNullOrEmpty(requestAddr))
                {
                    session.SetRequest_Addr(requestAddr);
                }
                session.Save();
                AD_Session_ID = session.GetAD_Session_ID();
                ctx.SetContext("#AD_Session_ID", AD_Session_ID.ToString());
                cache.Add(AD_Session_ID, session);
            }

            if (session == null)
            {
                s_log.Fine("No Session");
            }

            return(session);
        }
示例#2
0
        }       //	get

        /// <summary>
        /// Get existing or create local session
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="createNew">create if not found</param>
        /// <param name="requestAddr">Request address</param>
        /// <returns>session</returns>
        public static MSession Get(Ctx ctx, Boolean createNew, String requestAddr)
        {
            int      AD_Session_ID = ctx.GetContextAsInt("#AD_Session_ID");
            MSession session       = null;

            if (AD_Session_ID > 0)
            {
                session = cache[AD_Session_ID];
            }



            if (session == null && createNew)
            {
                session = new MSession(ctx, null);      //	local session
                session.SetRequest_Addr(requestAddr);
                session.Save();
                AD_Session_ID = session.GetAD_Session_ID();
                ctx.SetContext("#AD_Session_ID", AD_Session_ID.ToString());
                cache.Add(AD_Session_ID, session);
            }
            return(session);
        }