Exemplo n.º 1
0
        /// <summary>
        /// Creates the hangfire database.
        /// Forces it to be created by adding a dummy table.
        /// </summary>
        /// <param name="context"></param>
        public void CreateHangfireDB(HangfireContext context)
        {
            Dummy lo_dummy = new Dummy { DummyId = 0 };

            context.Dummy.Add(lo_dummy);
            context.SaveChanges();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes hangfire.
        /// </summary>
        /// <param name="ao_app"></param>
        /// <param name="as_constring"></param>
        public void Init(IAppBuilder ao_app, string as_constring)
        {
            using (HangfireContext context = new HangfireContext())
            {
                if (context.Dummy.Count() <= 0)
                {
                    CreateHangfireDB(context);
                }
            }
            GlobalConfiguration.Configuration
            .UseSqlServerStorage("Hangfire");

            ao_app.UseHangfireDashboard();
            ao_app.UseHangfireServer();
        }