Пример #1
0
        public static MobiContext GetCurrent(HttpContext httpContext)
        {
            try
            {
                lock (httpContext.Request)
                {
                    MobiContext mobiContext = httpContext.Items[MobiHttpContextItemKey] as MobiContext;
                    if (mobiContext != null)
                    {
                        return(mobiContext as MobiContext);
                    }

                    mobiContext = new MobiContext(httpContext, ServiceCallbackApplication.GetRuntime(httpContext));
                    httpContext.Items[MobiHttpContextItemKey] = mobiContext;
                    return(mobiContext);
                }
            }
            catch (Exception e)
            {
                MobiContext mobiContext = httpContext.Items[MobiHttpContextItemKey] as MobiContext;
                if (mobiContext != null)
                {
                    return(mobiContext as MobiContext);
                }

                mobiContext = new MobiContext(httpContext, ServiceCallbackApplication.GetRuntime(httpContext));
                httpContext.Items[MobiHttpContextItemKey] = mobiContext;
                return(mobiContext);
            }
        }
Пример #2
0
        protected virtual void InitializeRuntime()
        {
            if (ServiceCallbackApplication.HasRuntime(this))
            {
                return;
            }

            lock (MobiHttpApplicationInitializeRuntimeLockObject)
            {
                //string name = HostingEnvironment.SiteName;
                if (ServiceCallbackApplication.HasRuntime(this))
                {
                    return;
                }

                // TODO: Load application differently
                this._baseApplication = new ApplicationBase(MobiChat.Data.Application.CreateManager().Load(3));
                //MobilePaywall.Data.Application application = appManager.Load(HostingEnvironment.SiteName);

                if (this._baseApplication == null)
                {
                    //Log.Fatal(new LogMessageBuilder(new LogErrorCode("paywall.web.core", "paywallhttpapplication", "initializeruntime"),
                    //  string.Format("Application {0} is not loaded.", HostingEnvironment.SiteName), application));

                    throw new InvalidOperationException(string.Format("No application with name '{0}' registered in database.", HostingEnvironment.SiteName));
                }

                IRuntime runtime = this._baseApplication.ApplicationData.InstantiateRuntime();
                if (!runtime.Initialize(HostingEnvironment.SiteName))
                {
                    return;
                }

                ServiceCallbackApplication.SetRuntime(this, runtime);
                Log.Info("ServiceCallbackApplication initialized!");
                this.InitializeApplication();
            }

            //Log.Info(new LogMessageBuilder(new LogErrorCode("paywall.web.core", "paywallhttpapplication", "initializeruntime"),
            //  "Initialization of PaywallHttpApplication(" + HostingEnvironment.SiteName + ") is complete"));

            return;
        }
Пример #3
0
 public static bool HasRuntime(HttpContext context)
 {
     return(ServiceCallbackApplication.HasRuntime(context.Application));
 }