本文整理汇总了C#中Umbraco.Core.ApplicationContext类的典型用法代码示例。如果您正苦于以下问题:C# ApplicationContext类的具体用法?C# ApplicationContext怎么用?C# ApplicationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationContext类属于Umbraco.Core命名空间,在下文中一共展示了ApplicationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationStarted
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
InvoiceService.StatusChanging += InvoiceService_StatusChanging;
InvoiceService.StatusChanged += InvoiceService_StatusChanged;
}
示例2: OnApplicationInitialized
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
DocumentTypeStrategyFactory.Current.SetStrategy(null);
DocumentTypeStrategyFactory.Current.Execute();
// something.Execute();
// uCodeIt.Strategies.DoctypeStrategyFactory.Current.Execute();
}
示例3: ApplicationStarted
/// <summary>
/// See https://our.umbraco.org/documentation/Reference/Events/ for event handling documentation.
/// </summary>
/// <param name="umbracoApplication"></param>
/// <param name="applicationContext"></param>
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
queueConnection = new SqlConnection(applicationContext.DatabaseContext.ConnectionString);
/*
ContentService
MediaService
ContentTypeService
MemberService
FileService
LocalizationService
DataTypeService
*/
var contentQueue = new ContentQueue(queueConnection);
ContentService.Saved += contentQueue.ContentService_Saved;
var mediaQueue = new MediaQueue(queueConnection);
MediaService.Saved += mediaQueue.MediaService_Saved;
MediaService.Deleted += mediaQueue.MediaService_Deleted;
var memberQueue = new MemberQueue(queueConnection);
MemberService.Created += memberQueue.MemberService_Created;
base.ApplicationStarted(umbracoApplication, applicationContext);
}
示例4: ApplicationStarted
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
LogHelper.Info<ExamineEvents>("Initializing Merchello ProductIndex binding events");
// Merchello registered providers
var registeredProviders =
ExamineManager.Instance.IndexProviderCollection.OfType<BaseMerchelloIndexer>()
.Count(x => x.EnableDefaultEventHandler);
if(registeredProviders == 0)
return;
ProductService.Created += ProductServiceCreated;
ProductService.Saved += ProductServiceSaved;
ProductService.Deleted += ProductServiceDeleted;
ProductVariantService.Created += ProductVariantServiceCreated;
ProductVariantService.Saved += ProductVariantServiceSaved;
ProductVariantService.Deleted += ProductVariantServiceDeleted;
InvoiceService.Saved += InvoiceServiceSaved;
InvoiceService.Deleted += InvoiceServiceDeleted;
OrderService.Saved += OrderServiceSaved;
OrderService.Deleted += OrderServiceDeleted;
}
示例5: EnsureContext
/// <summary>
/// This is a helper method which is called to ensure that the singleton context is created and the nice url and routing
/// context is created and assigned.
/// </summary>
/// <param name="httpContext"></param>
/// <param name="applicationContext"></param>
/// <param name="replaceContext">
/// if set to true will replace the current singleton with a new one, this is generally only ever used because
/// during application startup the base url domain will not be available so after app startup we'll replace the current
/// context with a new one in which we can access the httpcontext.Request object.
/// </param>
/// <returns>
/// The Singleton context object
/// </returns>
/// <remarks>
/// This is created in order to standardize the creation of the singleton. Normally it is created during a request
/// in the UmbracoModule, however this module does not execute during application startup so we need to ensure it
/// during the startup process as well.
/// See: http://issues.umbraco.org/issue/U4-1890, http://issues.umbraco.org/issue/U4-1717
/// </remarks>
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext, bool? preview)
{
if (UmbracoContext.Current != null)
{
if (!replaceContext)
return UmbracoContext.Current;
UmbracoContext.Current._replacing = true;
}
var umbracoContext = new UmbracoContext(
httpContext,
applicationContext,
PublishedCachesResolver.Current.Caches,
preview);
// create the nice urls provider
// there's one per request because there are some behavior parameters that can be changed
var urlProvider = new UrlProvider(
umbracoContext,
UrlProviderResolver.Current.Providers);
// create the RoutingContext, and assign
var routingContext = new RoutingContext(
umbracoContext,
ContentFinderResolver.Current.Finders,
ContentLastChanceFinderResolver.Current.Finder,
urlProvider);
//assign the routing context back
umbracoContext.RoutingContext = routingContext;
//assign the singleton
UmbracoContext.Current = umbracoContext;
return UmbracoContext.Current;
}
示例6: OnApplicationStarting
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var treeService = ApplicationContext.Current.Services.ApplicationTreeService;
// Hide default Umbraco Forms folder, we use our own to display folders
var umbFormTree = treeService.GetByAlias("form");
if (umbFormTree != null && umbFormTree.Initialize)
{
umbFormTree.Initialize = false;
treeService.SaveTree(umbFormTree);
}
// Add our own tree if it's not there yet
var pplxFormTree = treeService.GetByAlias("perplexForms");
if (pplxFormTree == null)
{
treeService.MakeNew(true, 1, "forms", "perplexForms", "Forms", "icon-folder", "icon-folder-open", "PerplexUmbraco.Forms.Controllers.PerplexFormTreeController, Perplex.Umbraco.Forms");
}
FormStorage.Created += FormStorage_Created;
FormStorage.Deleted += FormStorage_Deleted;
// Create perplexUmbracoUser for storage of Forms start nodes
// if it does not exist already. There seem to be some issues with SqlServer CE,
// it does not support some statements in this query.
// Those will be fixed later, for now we continue
try { Sql.ExecuteSql(PerplexUmbraco.Forms.Code.Constants.SQL_CREATE_PERPLEX_USER_TABLE_IF_NOT_EXISTS); }
catch (Exception) { }
}
示例7: OnApplicationStarted
public void OnApplicationStarted(UmbracoApplicationBase httpApplication, ApplicationContext applicationContext)
{
this.httpApplication = httpApplication;
this.applicationContext = applicationContext;
umbraco.content.AfterRefreshContent += new umbraco.content.RefreshContentEventHandler(content_AfterRefreshContent);
}
示例8: EnsureContext
/// <summary>
/// This is a helper method which is called to ensure that the singleton context is created and the nice url and routing
/// context is created and assigned.
/// </summary>
/// <param name="httpContext"></param>
/// <param name="applicationContext"></param>
/// <param name="replaceContext">
/// if set to true will replace the current singleton with a new one, this is generally only ever used because
/// during application startup the base url domain will not be available so after app startup we'll replace the current
/// context with a new one in which we can access the httpcontext.Request object.
/// </param>
/// <returns>
/// The Singleton context object
/// </returns>
/// <remarks>
/// This is created in order to standardize the creation of the singleton. Normally it is created during a request
/// in the UmbracoModule, however this module does not execute during application startup so we need to ensure it
/// during the startup process as well.
/// See: http://issues.umbraco.org/issue/U4-1890
/// </remarks>
internal static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext)
{
if (UmbracoContext.Current != null)
{
if (!replaceContext)
return UmbracoContext.Current;
UmbracoContext.Current._replacing = true;
}
var umbracoContext = new UmbracoContext(httpContext, applicationContext, RoutesCacheResolver.Current.RoutesCache);
// create the nice urls provider
var niceUrls = new NiceUrlProvider(PublishedContentStoreResolver.Current.PublishedContentStore, umbracoContext);
// create the RoutingContext, and assign
var routingContext = new RoutingContext(
umbracoContext,
DocumentLookupsResolver.Current.DocumentLookups,
LastChanceLookupResolver.Current.LastChanceLookup,
PublishedContentStoreResolver.Current.PublishedContentStore,
niceUrls);
//assign the routing context back
umbracoContext.RoutingContext = routingContext;
//assign the singleton
UmbracoContext.Current = umbracoContext;
return UmbracoContext.Current;
}
示例9: ApplicationStarted
protected override void ApplicationStarted(
UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication,applicationContext);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
示例10: OnApplicationStarted
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
// Map the Custom routes
DialogueRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache);
//list to the init event of the application base, this allows us to bind to the actual HttpApplication events
UmbracoApplicationBase.ApplicationInit += UmbracoApplicationBase_ApplicationInit;
MemberService.Saved += MemberServiceSaved;
MemberService.Deleting += MemberServiceOnDeleting;
ContentService.Trashing +=ContentService_Trashing;
PageCacheRefresher.CacheUpdated += PageCacheRefresher_CacheUpdated;
// Sync the badges
// Do the badge processing
var unitOfWorkManager = new UnitOfWorkManager(ContextPerRequest.Db);
using (var unitOfWork = unitOfWorkManager.NewUnitOfWork())
{
try
{
ServiceFactory.BadgeService.SyncBadges();
unitOfWork.Commit();
}
catch (Exception ex)
{
AppHelpers.LogError(string.Format("Error processing badge classes: {0}", ex.Message));
}
}
}
示例11: ExecuteMigrations
private static void ExecuteMigrations(ApplicationContext applicationContext, Dictionary<string, IMigration> migrations)
{
var db = applicationContext.DatabaseContext.Database;
var databaseMigrations = db.Query<DbMigration>("SELECT * FROM Lucrasoft_Migrations")
.Select(x => x.MigrationName)
.ToList();
foreach (var migration in migrations)
{
if (databaseMigrations.Contains(migration.Key, CaseInsensitiveStringComparer.Instance))
{
LogHelper.Debug<Migrator>(string.Format("Lucrasoft uMigrations (version {0}) - Skipping migration '{1}' because it has already been executed", Version, migration.Key));
continue;
}
try
{
LogHelper.Info<Migrator>(string.Format("Lucrasoft uMigrations (version {0}) - Running migration with key '{1}'", Version, migration.Key));
migration.Value.MigrationAction.Invoke(applicationContext);
}
catch (Exception ex)
{
LogHelper.Error<Migrator>(string.Format("Lucrasoft uMigrations (version {0}) - Migration '{1}' failed: {2}", Version, migration.Key, ex.Message), ex);
throw;
}
db.Insert(new DbMigration
{
MigrationDateTime = DateTime.Now,
MigrationName = migration.Key
});
databaseMigrations.Add(migration.Key);
}
}
示例12: UseUmbracoCookieAuthenticationForRestApi
/// <summary>
/// Used to enable back office cookie authentication for the REST API calls
/// </summary>
/// <param name="app"></param>
/// <param name="appContext"></param>
/// <returns></returns>
public static IAppBuilder UseUmbracoCookieAuthenticationForRestApi(this IAppBuilder app, ApplicationContext appContext)
{
//Don't proceed if the app is not ready
if (appContext.IsUpgrading == false && appContext.IsConfigured == false) return app;
var authOptions = new UmbracoBackOfficeCookieAuthOptions(
UmbracoConfig.For.UmbracoSettings().Security,
GlobalSettings.TimeOutInMinutes,
GlobalSettings.UseSSL)
{
Provider = new BackOfficeCookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user
// logs in. This is a security feature which is used when you
// change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator
.OnValidateIdentity<BackOfficeUserManager, BackOfficeIdentityUser, int>(
TimeSpan.FromMinutes(30),
(manager, user) => user.GenerateUserIdentityAsync(manager),
identity => identity.GetUserId<int>()),
}
};
//This is what will ensure that the rest api calls are auth'd
authOptions.CookieManager = new RestApiCookieManager();
app.UseCookieAuthentication(authOptions);
return app;
}
示例13: OnApplicationStarting
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
if (InternalHelpers.MvcRenderMode)
{
ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByPageIdQuery, CatalogContentFinder>();
}
}
示例14: ApplicationStarted
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
AddPluginSectionToDevelopersDashboard();
ContentService.Published += ContentService_Published;
}
示例15: Initialize
public override void Initialize()
{
InitializeFirstRunFlags();
var path = TestHelper.CurrentAssemblyDirectory;
AppDomain.CurrentDomain.SetData("DataDirectory", path);
var dbFactory = new DefaultDatabaseFactory(
GetDbConnectionString(),
GetDbProviderName());
_appContext = new ApplicationContext(
//assign the db context
new DatabaseContext(dbFactory),
//assign the service context
new ServiceContext(new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy()),
//disable cache
false)
{
IsReady = true
};
base.Initialize();
DatabaseContext.Initialize(dbFactory.ProviderName, dbFactory.ConnectionString);
CreateSqlCeDatabase();
InitializeDatabase();
//ensure the configuration matches the current version for tests
SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
}