Esempio n. 1
0
        /// <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;
        }
 protected override void ApplicationStarted(
     UmbracoApplicationBase umbracoApplication,
     ApplicationContext applicationContext)
 {
     base.ApplicationStarted(umbracoApplication,applicationContext);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Esempio n. 3
0
        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));
                }
            }

        }
Esempio n. 4
0
        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);
            }
        }
        /// <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;
        }
		public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
		{
			if (InternalHelpers.MvcRenderMode)
			{
				ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByPageIdQuery, CatalogContentFinder>();
			}
		}
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
            ApplicationContext applicationContext)
        {
            AddPluginSectionToDevelopersDashboard();

            ContentService.Published += ContentService_Published;
        }
Esempio n. 8
0
        /// <summary>
        /// Once the app has booted, then bind to the events
        /// </summary>
        /// <param name="umbracoApplication"></param>
        /// <param name="applicationContext"></param>
        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //do not continue if the app context or database is not ready
            if (!applicationContext.IsConfigured || !applicationContext.DatabaseContext.IsDatabaseConfigured)
                return;

            //TODO: Remove this in 6.1!!! It will not be needed because we've changed the Examine Events entirely since UmbracoExamine is
            // in the core. This is only temporary to get this task completed for 6.0:
            // http://issues.umbraco.org/issue/U4-1530
            MediaService.Saved += MediaService_Saved;
            MediaService.Deleted += MediaService_Deleted;
            MediaService.Moved += MediaService_Moved;
            MediaService.Trashed += MediaService_Trashed;

            ContentService.Saved += ContentService_Saved;
            ContentService.Deleted += ContentService_Deleted;
            ContentService.Moved += ContentService_Moved;
            ContentService.Trashed += ContentService_Trashed;

            //bind to examine events
            var contentIndexer = ExamineManager.Instance.IndexProviderCollection["InternalIndexer"] as UmbracoContentIndexer;
            if (contentIndexer != null)
            {
                contentIndexer.DocumentWriting += indexer_DocumentWriting;
            }
            var memberIndexer = ExamineManager.Instance.IndexProviderCollection["InternalMemberIndexer"] as UmbracoMemberIndexer;
            if (memberIndexer != null)
            {
                memberIndexer.DocumentWriting += indexer_DocumentWriting;
            }
        }
 /// <summary>
 /// Executes before resolution is frozen so that you are able to modify any plugin resolvers
 /// </summary>
 /// <param name="umbracoApplication"></param>
 /// <param name="applicationContext"></param>
 public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     if (USiteBuilderConfiguration.EnableDefaultControllerType)
     {
         DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(TemplateBaseController));
     }
 }
 /// <summary>
 /// Wire up events.
 /// </summary>
 /// <param name="umbracoApplication"></param>
 /// <param name="applicationContext"></param>
 public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     if (applicationContext.IsConfigured && applicationContext.DatabaseContext.IsDatabaseConfigured)
     {
         ContentService.Saved += this.ContentService_Saved;
     }
 }
        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);
        }
Esempio n. 12
0
 /// <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="webSecurity"></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,
     WebSecurity webSecurity)
 {
     return EnsureContext(httpContext, applicationContext, webSecurity, false);
 }
        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //Events
            ContentService.Created += Content_New;
            ContentService.Saving += ContentService_Saving;
            ContentService.Saved += ContentService_Saved;
            ContentService.Published += Content_Published;
            ContentService.UnPublished += Content_Unpublished;
            ContentService.Moved += Content_Moved;
            ContentService.Trashed += Content_Trashed;
            ContentService.Deleted += Content_Deleted;
            MediaService.Saved += Media_Saved;

            //By registering this here we can make sure that if route hijacking doesn't find a controller it will use this controller.
            //That way each page will always be routed through one of our controllers.
            DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(DefaultController));

            //Remove the media picker property converters from the Umbraco Core Property Value Converters package.
            //These will be replaced by custom converters.
            PropertyValueConvertersResolver.Current.RemoveType<MediaPickerPropertyConverter>();
            PropertyValueConvertersResolver.Current.RemoveType<MultipleMediaPickerPropertyConverter>();

            //Add a web api handler. Here we can change the values from each web api call.
            GlobalConfiguration.Configuration.MessageHandlers.Add(new WebApiHandler());

            //With the url providers we can change node urls.
            UrlProviderResolver.Current.InsertTypeBefore<DefaultUrlProvider, HomeUrlProvider>();
        }
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            base.ApplicationStarted(umbracoApplication, applicationContext);

            InvoiceService.StatusChanging += InvoiceService_StatusChanging;
            InvoiceService.StatusChanged += InvoiceService_StatusChanged;
        }
        /// <summary>
        /// The Umbraco Application Starting event.
        /// </summary>
        /// <param name="umbracoApplication">
        /// The umbraco application.
        /// </param>
        /// <param name="applicationContext">
        /// The application context.
        /// </param>
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            base.ApplicationStarted(umbracoApplication, applicationContext);

            LogHelper.Info<UmbracoApplicationEventHandler>("Initializing Customer related events");

            MemberService.Saving += this.MemberServiceOnSaving;

            SalePreparationBase.Finalizing += SalePreparationBaseOnFinalizing;

            InvoiceService.Deleted += InvoiceServiceOnDeleted;
            OrderService.Deleted += OrderServiceOnDeleted;

            // Store settings
            StoreSettingService.Saved += StoreSettingServiceOnSaved;

            // Clear the tax method if set
            TaxMethodService.Saved += TaxMethodServiceOnSaved;

            // Auditing
            PaymentGatewayMethodBase.VoidAttempted += PaymentGatewayMethodBaseOnVoidAttempted;

            ShipmentService.StatusChanged += ShipmentServiceOnStatusChanged;

            if (_merchelloIsStarted) this.VerifyMerchelloVersion();
        }
 public void OnApplicationStarted(
 UmbracoApplicationBase umbracoApplication,
 ApplicationContext applicationContext)
 {
     ProjectContext.Instance.Init(RouteTable.Routes);
     // Analytics.Initialize(ConfigurationManager.AppSettings["SegmentKey"]);
 }
 protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     RouteTable.Routes.MapRoute(
         "DomainManager",
         "App_Plugins/AgeBase.DomainManager/{action}/{id}",
         new {controller = "DomainManager", action = "Resource", id = UrlParameter.Optional});
 }
Esempio n. 18
0
        public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
        {
            //FROM IMacro TO EntityBasic
            config.CreateMap<IMacro, EntityBasic>()
                  .ForMember(entityBasic => entityBasic.Icon, expression => expression.UseValue("icon-settings-alt"))
                  .ForMember(dto => dto.ParentId, expression => expression.UseValue(-1))
                  .ForMember(dto => dto.Path, expression => expression.ResolveUsing(macro => "-1," + macro.Id));

            config.CreateMap<IMacro, IEnumerable<MacroParameter>>()
                    .ConvertUsing(macro => macro.Properties.Select(Mapper.Map<MacroParameter>).ToList());

            config.CreateMap<IMacroProperty, MacroParameter>()
                  .AfterMap((property, parameter) =>
                      {
                          //map the view and the config

                          var paramEditor = ParameterEditorResolver.Current.GetByAlias(property.EditorAlias);
                          if (paramEditor == null)
                          {
                              //we'll just map this to a text box
                              paramEditor = ParameterEditorResolver.Current.GetByAlias(Constants.PropertyEditors.TextboxAlias);
                              LogHelper.Warn<MacroModelMapper>("Could not resolve a parameter editor with alias " + property.EditorAlias + ", a textbox will be rendered in it's place");
                          }

                          parameter.View = paramEditor.ValueEditor.View;
                          //set the config
                          parameter.Configuration = paramEditor.Configuration;
                          
                      });

        }
        /// <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);
        }
        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) { }
        }
 /// <summary>
 /// Application started.
 /// </summary>
 protected override void ApplicationStarted(
     UmbracoApplicationBase umbracoApplication,
     ApplicationContext applicationContext)
 {
     HandleInstallAndUpgrade(applicationContext);
     ServerVariablesParser.Parsing += AddServerVariables;
 }
Esempio n. 22
0
        /// <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;
        }
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.Published += ContentService_Published;

            // Map routes for all Box urls in each site
            if (UmbracoContext.Current != null)
            {
                var allBoxes = UmbracoContext.Current.ContentCache.GetAtRoot().DescendantsOrSelf("Box");
                if (allBoxes.Any())
                {
                    foreach (var box in allBoxes)
                    {
                        var langIso = box.GetCulture().ThreeLetterISOLanguageName;
                        RouteTable.Routes.MapUmbracoRoute(
                        langIso + "MarketToBox",
                        box.UrlName + "/{slug}",
                        new
                        {
                            controller = "Fruits",
                            action = "Fruit",
                            slug = UrlParameter.Optional
                        },
                        new FruitsRouteHandler(MarketLibraryNodeId));
                    }
                }
            }
        }
Esempio n. 24
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var builder = new ContainerBuilder();

            //register umbracocontext as a factory
            builder.Register(c => UmbracoContext.Current).AsSelf();

            //add all the controllers from the assembly
            builder.RegisterControllers(System.Reflection.Assembly.GetExecutingAssembly());

            //getting null pointer exception in the backend of umbraco if I don't load this one
            builder.RegisterApiControllers(typeof(Umbraco.Web.Trees.ApplicationTreeController).Assembly);

            //add custom class to the container as transient instance
            builder.RegisterType<FriendService>().As<IFriendService>();

            //se if we can just pass the instances to the builder, works and not needed cause of the umbracocontext, but gives us more control
            builder.RegisterInstance(UmbracoContext.Current.Application.Services.ContentService);
            builder.RegisterInstance(UmbracoContext.Current.Application.Services.MemberService);
            builder.RegisterInstance(UmbracoContext.Current.Application.Services.RelationService);
            builder.RegisterInstance(UmbracoContext.Current.Application.Services.MediaService);
            builder.RegisterInstance(UmbracoContext.Current.Application.DatabaseContext.Database).As<Umbraco.Core.Persistence.Database>();

            //register the myhelper class should be a interface etc.
            builder.RegisterType<MyHelper>().As<IMyHelper>();

            var container = builder.Build();

            //setup the webapi dependency resolver to use autofac
            System.Web.Mvc.DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            base.ApplicationStarted(umbracoApplication, applicationContext);
        }
 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     if (CriteriaConfigHelpers.IsCriteriaInUse(NumberOfVisitsPersonalisationGroupCriteria.CriteriaAlias))
     {
         UmbracoApplicationBase.ApplicationInit += ApplicationInit;
     }
 }
Esempio n. 26
0
        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;
        }
        public void OnApplicationStarted(UmbracoApplicationBase httpApplication, ApplicationContext applicationContext)
        {
            this.httpApplication = httpApplication;
            this.applicationContext = applicationContext;

            umbraco.content.AfterRefreshContent += new umbraco.content.RefreshContentEventHandler(content_AfterRefreshContent);
        }
        public void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext)
        {
            var itemDocumentTypes = ConfigurationManager.AppSettings["AutoDocuments:ItemDocumentTypes"];
            var dateDocumentType = ConfigurationManager.AppSettings["AutoDocuments:DateDocumentType"];
            var itemDatePropertyAlias = ConfigurationManager.AppSettings["AutoDocuments:ItemDatePropertyAlias"];

            List<string> itemDocTypes = null;
            bool createDayDocuments = false;

            if (!string.IsNullOrEmpty(itemDocumentTypes))
                itemDocTypes = itemDocumentTypes.Split(',').ToList();

            string createDayDocumentsSetting = ConfigurationManager.AppSettings["AutoDocuments:CreateDayDocuments"];

            if (!string.IsNullOrEmpty(createDayDocumentsSetting))
                bool.TryParse(createDayDocumentsSetting, out createDayDocuments);

            if (itemDocTypes == null || itemDocTypes.Count == 0 || string.IsNullOrEmpty(dateDocumentType) || string.IsNullOrEmpty(itemDatePropertyAlias))
            {
                Log.Add(LogTypes.Debug, 0, string.Format("Auto Documents configuration invalid, ItemDocumentTypes:{0} DateDocumentType:{1} ItemDatePropertyAlias:{2}", itemDocumentTypes, dateDocumentType, itemDatePropertyAlias));
                return;
            }

            _autoDocuments = new AutoDocuments(itemDocTypes, itemDatePropertyAlias, dateDocumentType, createDayDocuments);

            Document.New += DocumentNew;
            Document.BeforePublish += DocumentBeforePublish;
        }
Esempio n. 29
0
 public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     DocumentTypeStrategyFactory.Current.SetStrategy(null);
     DocumentTypeStrategyFactory.Current.Execute();
     // something.Execute();
     // uCodeIt.Strategies.DoctypeStrategyFactory.Current.Execute();
 }
 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     global::Umbraco.Web.UI.JavaScript.ServerVariablesParser.Parsing += (sender, dictionary) =>
     {
         dictionary["paramsEditorResourceUrl"] = "/umbraco/api/params/";
     };
 }
Esempio n. 31
0
 public void OnApplicationStarted(UmbracoApplicationBase httpApplication, Umbraco.Core.ApplicationContext applicationContext)
 {
     if (Umbraco.Core.Configuration.UmbracoVersion.Current.Major >= 7 &&
         Umbraco.Core.Configuration.UmbracoVersion.Current.Minor >= 1)
     {
         DoOnStart();
     }
     else
     {
         LogHelper.Info <uSync>("########### this version of usync if for Umbraco 7.1 and above ##########");
     }
 }
Esempio n. 32
0
        public void OnApplicationStarted(
            UmbracoApplicationBase httpApplication, Umbraco.Core.ApplicationContext applicationContext)
        {
            var builder = new ContainerBuilder();

            // register all controllers found in this assembly
            builder.RegisterControllers(typeof(Roznamah).Assembly);
            builder.RegisterApiControllers(typeof(Roznamah).Assembly);

            // register Umbraco MVC + web API controllers used by the admin site
            builder.RegisterControllers(typeof(Roznamah).Assembly);
            builder.RegisterApiControllers(typeof(Roznamah).Assembly);

            // add custom class to the container as Transient instance
            //builder.RegisterType<ServiceContext>();
            //builder.RegisterType<IEntitiesService>();
            builder.RegisterType <EntitiesService>();


            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
        }
Esempio n. 33
0
 public void OnApplicationStarting(UmbracoApplicationBase httpApplication, Umbraco.Core.ApplicationContext applicationContext)
 {
     // don't think i do it here.
 }
Esempio n. 34
0
        public override void ConfigureMappings(AutoMapper.IConfiguration config, Umbraco.Core.ApplicationContext applicationContext)
        {
            //FROM SearchResult TO MemberListItem - used when searching for members.
            config.CreateMap <SearchResult, MemberListItem>()
            //.ForMember(member => member.Id, expression => expression.MapFrom(result => result.Id))
            .ForMember(member => member.Key, expression => expression.Ignore())

            .ForMember(member => member.LoginName,
                       expression => expression.MapFrom(result => result.Fields["loginName"]))

            .ForMember(member => member.Name,
                       expression => expression.MapFrom(result => result.Fields["nodeName"]))

            .ForMember(member => member.ContentType,
                       expression => expression.MapFrom(result => ApplicationContext.Current.Services.MemberTypeService.Get(result.Fields["nodeTypeAlias"])))

            .ForMember(member => member.Email,
                       expression => expression.MapFrom(result =>
                                                        result.Fields.ContainsKey("email") ? result.Fields["email"] : string.Empty))

            .ForMember(member => member.IsApproved, expression => expression.Ignore())

            .ForMember(member => member.IsLockedOut, expression => expression.Ignore())

            .ForMember(member => member.Icon, expression => expression.Ignore())
            .ForMember(member => member.Properties, expression => expression.Ignore())

            .AfterMap((searchResult, member) =>
            {
                if (searchResult.Fields.ContainsKey("__key") && searchResult.Fields["__key"] != null)
                {
                    Guid key;
                    if (Guid.TryParse(searchResult.Fields["__key"], out key))
                    {
                        member.Key = key;
                    }
                }

                bool val = true;
                // We assume not approved for this property.
                member.IsApproved = false;
                // We assume not locked out for this property.
                member.IsLockedOut = false;

                if (!searchResult.Fields.ContainsKey(Constants.Conventions.Member.IsApproved) ||
                    !searchResult.Fields.ContainsKey(Constants.Conventions.Member.IsLockedOut))
                {
                    // We need to get a member back from the database as these values aren't indexed reliably for some reason.
                    var m = ApplicationContext.Current.Services.MemberService.GetByKey((Guid)member.Key);
                    if (m != null)
                    {
                        member.IsApproved  = m.IsApproved;
                        member.IsLockedOut = m.IsLockedOut;
                    }
                }
                else
                {
                    if (searchResult.Fields[Constants.Conventions.Member.IsApproved] == "1")
                    {
                        member.IsApproved = true;
                    }
                    else if (bool.TryParse(searchResult.Fields[Constants.Conventions.Member.IsApproved], out val))
                    {
                        member.IsApproved = val;
                    }

                    if (searchResult.Fields[Constants.Conventions.Member.IsLockedOut] == "1")
                    {
                        member.IsLockedOut = true;
                    }
                    else if (bool.TryParse(searchResult.Fields[Constants.Conventions.Member.IsLockedOut], out val))
                    {
                        member.IsLockedOut = val;
                    }
                }

                // Get any other properties available from the fields.
                foreach (var field in searchResult.Fields)
                {
                    if (!field.Key.StartsWith("_") && !field.Key.StartsWith("umbraco") && !field.Key.EndsWith("_searchable") &&
                        field.Key != "id" && field.Key != "key" &&
                        field.Key != "updateDate" && field.Key != "writerName" &&
                        field.Key != "loginName" && field.Key != "email" &&
                        field.Key != Constants.Conventions.Member.IsApproved &&
                        field.Key != Constants.Conventions.Member.IsLockedOut &&
                        field.Key != "nodeName" && field.Key != "nodeTypeAlias")
                    {
                        member.Properties.Add(field.Key, field.Value);
                    }
                }
            });

            config.CreateMap <ISearchResults, IEnumerable <MemberListItem> >()
            .ConvertUsing(results => results.Select(Mapper.Map <MemberListItem>));

            //FROM MemberListItem to MemberExportModel.
            config.CreateMap <MemberListItem, MemberExportModel>()
            .ForMember(member => member.MemberType,
                       expression => expression.MapFrom(item => item.ContentType.Name))
            .ForMember(member => member.Properties, expression => expression.Ignore())
            .AfterMap((listItem, member) =>
            {
                // Get any other properties available from the fields.
                foreach (var p in listItem.Properties)
                {
                    member.Properties.Add(p.Key, p.Value);
                }

                // Resolve groups into a comma-delimited string.
                var roles = ApplicationContext.Current.Services.MemberService.GetAllRoles(member.Id);
                if (roles != null)
                {
                    member.Groups = roles.Aggregate("", (a, b) => (a == "" ? a : a + ",") + b);
                }
            });

            config.CreateMap <IEnumerable <MemberListItem>, IEnumerable <MemberExportModel> >()
            .ConvertUsing(results => results.Select(Mapper.Map <MemberExportModel>));

            //FROM SearchResult to MemberExportModel.
            config.CreateMap <SearchResult, MemberExportModel>()
            .ConvertUsing(result => Mapper.Map <MemberExportModel>(Mapper.Map <MemberListItem>(result)));

            config.CreateMap <IEnumerable <MemberListItem>, IEnumerable <MemberExportModel> >()
            .ConvertUsing(items => items.Select(Mapper.Map <MemberExportModel>));
        }
Esempio n. 35
0
 public void OnApplicationInitialized(UmbracoApplicationBase httpApplication, Umbraco.Core.ApplicationContext applicationContext)
 {
 }
Esempio n. 36
0
 public void OnApplicationStarting(UmbracoApplicationBase httpApplication, Umbraco.Core.ApplicationContext applicationContext)
 {
 }
Esempio n. 37
0
 public void OnApplicationInitialized(UmbracoApplicationBase httpApplication, Umbraco.Core.ApplicationContext applicationContext)
 {
     // don't think i do it here.
 }