コード例 #1
0
ファイル: MsSqlPlatform.cs プロジェクト: pianomanx/sensenet
        public override void OnAfterRepositoryStart(RepositoryInstance repository)
        {
            var state = DistributedIndexingActivityQueue.GetCurrentState();

            DistributedIndexingActivityQueue._setCurrentExecutionState(IndexingActivityStatus.Startup);
            base.OnAfterRepositoryStart(repository);
        }
コード例 #2
0
        protected virtual void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            using (var op = SnTrace.Repository.StartOperation("Application_Start. Process: {0}, AppDomain: {1}, ",
                                                              System.Diagnostics.Process.GetCurrentProcess().Id, AppDomain.CurrentDomain.Id))
            {
                var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
                var firstRun          = File.Exists(runOnceMarkerPath);
                var startConfig       = new RepositoryStartSettings {
                    StartLuceneManager = !firstRun, IsWebContext = true
                };

                RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

                Repository.Start(startConfig);

                RepositoryVersionInfo.CheckComponentVersions();

                StorageContext.L2Cache = new L2CacheImpl();

                RegisterRoutes(RouteTable.Routes, application);
                RepositoryPathProvider.Register();

                op.Successful = true;
            }
        }
コード例 #3
0
ファイル: Global.cs プロジェクト: pchaozhong/FlexNet
        /* ============================================================================================================ static handlers */
        protected static void ApplicationStartHandler(object sender, EventArgs e, HttpApplication application)
        {
            var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
            var firstRun          = File.Exists(runOnceMarkerPath);
            var startConfig       = new SenseNet.ContentRepository.RepositoryStartSettings {
                StartLuceneManager = !firstRun
            };

            RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

            Repository.Start(startConfig);

            //-- <L2Cache>
            StorageContext.L2Cache = new L2CacheImpl();
            //-- </L2Cache>

            RegisterRoutes(RouteTable.Routes);
            RepositoryPathProvider.Register();

            //Database.SetInitializer(new InDocContextInitializer());

            //using (var context = DependencyResolver.Current.GetService<InDocContext>())
            //{
            //    context.Database.Initialize(false);
            //}

            //preload
            WarmUp.Preload();
        }
コード例 #4
0
        protected virtual void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            var op = DetailedLogger.CreateOperation();   // category: general

            DetailedLogger.Log(op, "Application_Start"); // category: general

            var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
            var firstRun          = File.Exists(runOnceMarkerPath);
            var startConfig       = new ContentRepository.RepositoryStartSettings {
                StartLuceneManager = !firstRun
            };

            RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

            Repository.Start(startConfig);

            //-- <L2Cache>
            StorageContext.L2Cache = new L2CacheImpl();
            //-- </L2Cache>

            GlobalConfiguration.Configure(WebApiConfiguration.Register);
            RegisterRoutes(RouteTable.Routes, application);
            RepositoryPathProvider.Register();

            //preload
            WarmUp.Preload();

            op.Finish(); // category: general
        }
コード例 #5
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            var portalContextAcc = new PrivateType(typeof(PortalContext));

            portalContextAcc.SetStaticField("_sites", new Dictionary <string, Site>());

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            Cache.Reset();
            ContentTypeManager.Reset();

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
コード例 #6
0
 public Controller(IXSocketClient client, string controller)
 {
     this.Subscriptions = new RepositoryInstance<string, ISubscription>();
     this.Listeners = new RepositoryInstance<string, IListener>();
     this.AddDefaultSubscriptions();
     this.ClientInfo = new ClientInfo{PersistentId = client.PersistentId, Controller = controller};
     this.XSocketClient = client;
 }
コード例 #7
0
        /// <summary>
        /// Sets the items database and feeds.db database files to non-deployed paths
        /// </summary>
        public void UnitTestMode()
        {
            var feedDatabaseConnection = string.Format("Data Source={0}/Feeds.db;Version=3;", "/Volumes/Public/Monotouch/ReallySimple/ReallySimple.UI");
            var userDatabaseFilePath   = string.Format("{0}/User.db", "/tmp");

            string itemsDbFilePath        = string.Format("{0}/{1}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Settings.Current.ItemsDatabaseFilename);
            var    userDatabaseConnection = string.Format("Data Source={0};Version=3;", itemsDbFilePath);

            RepositoryInstance.WipeUserDatabase();
        }
コード例 #8
0
 public Controller(IXSocketClient client, string controller)
 {
     this.queuedFrames  = new List <byte>();
     this.Subscriptions = new RepositoryInstance <string, ISubscription>();
     this.Listeners     = new RepositoryInstance <string, IListener>();
     this.AddDefaultSubscriptions();
     this.ClientInfo = new ClientInfo {
         PersistentId = client.PersistentId, Controller = controller
     };
     this.XSocketClient = client;
 }
コード例 #9
0
        private async Task IntegrationTestAsync(bool isolated, Func <Task> callback, Func <SystemFolder, Task> callbackWithSandbox)
        {
            var platformName   = Platform.GetType().Name;
            var needToStartNew = isolated || _repositoryInstance == null || platformName != _lastPlatformName;

            if (needToStartNew)
            {
                Logger.Log("  (cleanup repository)");
                _repositoryInstance?.Dispose();
                _repositoryInstance = null;
                _lastPlatformName   = null;

                var builder = Platform.CreateRepositoryBuilder();

                Logger.Log("  start new repository");
                _repositoryInstance = Repository.Start(builder);
                _lastPlatformName   = platformName;

                //PrepareRepository();
            }

            SystemFolder sandbox = null;

            try
            {
                using (new SystemAccount())
                {
                    if (callback != null)
                    {
                        await callback();
                    }
                    else
                    {
                        await callbackWithSandbox(sandbox = CreateSandbox());
                    }
                }
            }
            finally
            {
                if (sandbox != null)
                {
                    using (new SystemAccount())
                        sandbox.ForceDelete();
                }

                if (isolated)
                {
                    Logger.Log("  cleanup repository");
                    _repositoryInstance?.Dispose();
                    _repositoryInstance = null;
                    _lastPlatformName   = null;
                }
            }
        }
コード例 #10
0
        private void IntegrationTest <T>(bool isolated, Action callback, Action <T> callbackWithSandbox) where T : GenericContent
        {
            var platformName   = Platform.GetType().Name;
            var needToStartNew = isolated || _repositoryInstance == null || platformName != _lastPlatformName;

            if (needToStartNew)
            {
                Logger.Log("  (cleanup repository)");
                _repositoryInstance?.Dispose();
                _repositoryInstance = null;
                _lastPlatformName   = null;

                var builder = Platform.CreateRepositoryBuilder();

                Logger.Log("  start new repository");
                _repositoryInstance = Repository.Start(builder);
                _lastPlatformName   = platformName;

                //PrepareRepository();
            }

            T sandbox = null;

            try
            {
                using (new SystemAccount())
                    if (callback != null)
                    {
                        callback();
                    }
                    else
                    {
                        callbackWithSandbox(sandbox = CreateSandbox <T>());
                    }
            }
            finally
            {
                if (sandbox != null)
                {
                    using (new SystemAccount())
                        sandbox.ForceDelete();
                }

                if (isolated)
                {
                    Logger.Log("  cleanup repository");
                    _repositoryInstance?.Dispose();
                    _repositoryInstance = null;
                    _lastPlatformName   = null;
                }
            }
        }
コード例 #11
0
ファイル: TestBase.cs プロジェクト: sreekanthedayar/sensenet
        public void InitializeTest()
        {
            // workaround for having a half-started repository
            if (RepositoryInstance.Started())
            {
                RepositoryInstance.Shutdown();
            }

            // the original collector default value is a class that is not available in this context
            Providers.PropertyCollectorClassName = typeof(EventPropertyCollector).FullName;

            SnTrace.Test.Enabled = true;
            SnTrace.Test.Write("START test: {0}", TestContext.TestName);
        }
コード例 #12
0
        public void ClearCache(bool deleteImages)
        {
            ImageDownloader.Current.TryStop();
            RepositoryInstance.WipeUserDatabase();
            ItemCache.Current.Clear();

            LastUpdate       = DateTime.Now.AddDays(-1);
            LastControllerId = "";
            LastItemId       = "";

            if (deleteImages)
            {
                ClearImageCache();
            }
        }
コード例 #13
0
ファイル: ODataTestBase.cs プロジェクト: kuber123/sensenet
        private async Task ODataTestAsync(IUser user, Action <RepositoryBuilder> initialize, Func <Task> callback, bool reused)
        {
            Cache.Reset();

            if (!reused || _repository == null)
            {
                _repository?.Dispose();
                _repository = null;

                var repoBuilder = CreateRepositoryBuilder();
                if (initialize != null)
                {
                    initialize(repoBuilder);
                }

                Indexing.IsOuterSearchEngineEnabled = true;
                _repository = Repository.Start(repoBuilder);
            }

            if (user == null)
            {
                using (new SystemAccount())
                    await callback().ConfigureAwait(false);
            }
            else
            {
                IUser backup = null;
                try
                {
                    backup       = User.Current;
                    User.Current = user;
                    await callback().ConfigureAwait(false);
                }
                finally
                {
                    User.Current = backup;
                }
            }

            if (!reused)
            {
                _repository?.Dispose();
                _repository = null;
            }
        }
コード例 #14
0
ファイル: TestBase.cs プロジェクト: kuber123/sensenet
        public void InitializeTest()
        {
            // workaround for having a half-started repository
            if (RepositoryInstance.Started())
            {
                RepositoryInstance.Shutdown();
            }

            SnTrace.Test.Enabled = true;

            if (_testMethodOperation != null)
            {
                SnTrace.Test.Write("The operation was forced to close.");
                _testMethodOperation.Successful = false;
                _testMethodOperation.Dispose();
            }
            _testMethodOperation = SnTrace.Test.StartOperation("TESTMETHOD: " + TestContext.TestName);
        }
コード例 #15
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
コード例 #16
0
ファイル: SenseNetGlobal.cs プロジェクト: vlslavik/SenseNet
        protected virtual void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
            var firstRun          = File.Exists(runOnceMarkerPath);
            var startConfig       = new SenseNet.ContentRepository.RepositoryStartSettings {
                StartLuceneManager = !firstRun
            };

            RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

            Repository.Start(startConfig);

            //-- <L2Cache>
            StorageContext.L2Cache = new L2CacheImpl();
            //-- </L2Cache>

            RegisterRoutes(RouteTable.Routes, application);
            RepositoryPathProvider.Register();

            //preload
            WarmUp.Preload();
        }
コード例 #17
0
 public static void CleanupClass()
 {
     Logger.Log("  ((cleanup repository))");
     _repositoryInstance?.Dispose();
     _repositoryInstance = null;
 }
コード例 #18
0
 public virtual void OnAfterRepositoryStart(RepositoryInstance repository)
 {
 }