コード例 #1
0
        public ActionResult CreateDemoData()
        {
            using (var ctx = new TicketDeskContext(null))
            {
                DemoDataManager.SetupDemoData(ctx);
            }
            DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext);

            ViewBag.DemoDataCreated = true;
            return(View("Demo"));
        }
コード例 #2
0
 public ActionResult CreateDemoData()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DemoDataManager.SetupDemoData(ctx);
     }
     DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext, User.Identity.GetUserId());
     DemoPushNotificationDataManager.SetupDemoPushNotificationData(PushNotificationContext);
     ViewBag.DemoDataCreated = true;
     return(View("Demo"));
 }
コード例 #3
0
        public ActionResult CreateDemoData()
        {
            using (var ctx = new TdDomainContext(null))
            {
                DemoDataManager.SetupDemoData(ctx);
            }
            DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext, User.Identity.GetUserId());
            DemoPushNotificationDataManager.SetupDemoPushNotificationData(PushNotificationContext);
            ViewBag.DemoDataCreated = true;
            Task.Delay(500).ContinueWith(t => System.Web.HttpRuntime.UnloadAppDomain()).ConfigureAwait(false);

            return(View("Demo"));
        }
コード例 #4
0
        public static void RegisterDatabase()
        {
            var setupEnabled    = ConfigurationManager.AppSettings["ticketdesk:SetupEnabled"];
            var firstRunEnabled = !string.IsNullOrEmpty(setupEnabled) &&
                                  setupEnabled.Equals("true", StringComparison.InvariantCultureIgnoreCase);


            if (firstRunEnabled && !IsDatabaseReady)
            {
                //add a global filter to send requests to the database managment first run functions
                GlobalFilters.Filters.Add(new DbSetupFilter());
            }
            else
            {
                //run any pending migrations automatically to bring the DB up to date
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TdDomainContext, Configuration>(true));
                using (var ctx = new TdDomainContext(null))
                {
                    try
                    {
                        ctx.Database.Initialize(!ctx.Database.CompatibleWithModel(true));
                    }
                    catch (Exception)//no metadata in DB, force run initializer anyway
                    {
                        ctx.Database.Initialize(true);
                    }
                    if (IsFirstRunDemoRefreshEnabled())
                    {
                        DemoDataManager.SetupDemoData(ctx);

                        //TODO: duplicated in FirstRunSetup controller, should refactor extension method or something... just not sure what the most appropriate place is
                        HostingEnvironment.QueueBackgroundWorkItem(async(ct) =>
                        {
                            using (var dctx = new TdDomainContext(null))
                            {
                                await TdSearchContext.Current.IndexManager.RunIndexMaintenanceAsync();
                                var searchItems = dctx.Tickets.Include("TicketEvents").ToSeachIndexItems();
                                await TdSearchContext.Current.IndexManager.AddItemsToIndexAsync(searchItems);
                            }
                        });
                    }
                }
            }
        }
コード例 #5
0
        public static void RegisterDatabase()
        {
            var setupEnabled    = ConfigurationManager.AppSettings["ticketdesk:SetupEnabled"];
            var firstRunEnabled = !string.IsNullOrEmpty(setupEnabled) &&
                                  setupEnabled.Equals("true", StringComparison.InvariantCultureIgnoreCase);


            if (firstRunEnabled && !IsDatabaseReady)
            {
                //add a global filter to send requests to the database managment first run functions
                GlobalFilters.Filters.Add(new DbSetupFilter());
            }
            else
            {
                var demoRefresh         = ConfigurationManager.AppSettings["ticketdesk:ResetDemoDataOnStartup"];
                var firstRunDemoRefresh = !string.IsNullOrEmpty(demoRefresh) &&
                                          demoRefresh.Equals("true", StringComparison.InvariantCultureIgnoreCase) &&
                                          IsDatabaseReady;//only do this if database was ready on startup, otherwise migrator will take care of it

                //run any pending migrations automatically to bring the DB up to date
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TicketDeskContext, Configuration>(true));
                using (var ctx = new TicketDeskContext(null))
                {
                    try
                    {
                        ctx.Database.Initialize(!ctx.Database.CompatibleWithModel(true));
                    }
                    catch (Exception)//no metadata in DB, force run initializer anyway
                    {
                        ctx.Database.Initialize(true);
                    }
                    if (firstRunDemoRefresh)
                    {
                        DemoDataManager.SetupDemoData(ctx);
                    }
                }
            }
        }