Пример #1
0
 private static void SubscribeToEvents()
 {
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IUserPermissionDefinition>(OnUserPermissionChanged, true);
     DataEventSystemFacade.SubscribeToDataAfterAdd <IUserPermissionDefinition>(OnUserPermissionChanged, true);
     DataEventSystemFacade.SubscribeToDataDeleted <IUserPermissionDefinition>(OnUserPermissionChanged, true);
     DataEventSystemFacade.SubscribeToStoreChanged <IUserPermissionDefinition>(OnUserPermissionStoreChanged, true);
 }
Пример #2
0
 static DataBasedUserGroupPermissionDefinitionProvider()
 {
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IUserGroupPermissionDefinition>(OnUserGroupPermissionChanged, true);
     DataEventSystemFacade.SubscribeToDataAfterAdd <IUserGroupPermissionDefinition>(OnUserGroupPermissionChanged, true);
     DataEventSystemFacade.SubscribeToDataDeleted <IUserGroupPermissionDefinition>(OnUserGroupPermissionChanged, true);
     DataEventSystemFacade.SubscribeToStoreChanged <IUserGroupPermissionDefinition>(OnUserGroupPermissionStoreChanged, true);
 }
Пример #3
0
        private void SubscribeToEvents(IEnumerable <CacheDependentEntry> dependentEntities)
        {
            foreach (var dependentEntry in dependentEntities)
            {
                if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Add))
                {
                    DataEventSystemFacade.SubscribeToDataAfterAdd(dependentEntry.EntityType, ResetCache, true);
                }

                if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Update))
                {
                    DataEventSystemFacade.SubscribeToDataAfterUpdate(dependentEntry.EntityType, ResetCache, true);
                }

                if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Deleted))
                {
                    DataEventSystemFacade.SubscribeToDataDeleted(dependentEntry.EntityType, ResetCache, true);
                }

                if (dependentEntry.Operations > 0)
                {
                    DataEventSystemFacade.SubscribeToStoreChanged(dependentEntry.EntityType, ResetCacheOnUnhandledChange, true);
                }
            }
        }
 static UserSettingsImpl()
 {
     DataEventSystemFacade.SubscribeToDataAfterAdd <IUserSettings>(OnUserSettingsChanged, true);
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IUserSettings>(OnUserSettingsChanged, true);
     DataEventSystemFacade.SubscribeToDataDeleted <IUserSettings>(OnUserSettingsChanged, true);
     DataEventSystemFacade.SubscribeToStoreChanged <IUserSettings>(OnUserStoreChanged, true);
 }
Пример #5
0
        public TransformCache()
        {
            DataEventSystemFacade.SubscribeToDataAfterAdd <IMediaFile>(OnDataChanged, true);
//			DataEventSystemFacade.SubscribeToDataAfterMove<IMediaFile>(OnDataChanged);
            DataEventSystemFacade.SubscribeToDataBeforeUpdate <IMediaFile>(OnDataChanged, true);
            DataEventSystemFacade.SubscribeToDataDeleted <IMediaFile>(OnDataChanged, true);
        }
Пример #6
0
        public QueryCache(string name, Expression <Func <TDataType, TPropertyType> > propertyGetter, int size)
        {
            _innerCache     = new Cache <string, ExtendedNullable <TDataType> >(name, size);
            _propertyGetter = propertyGetter;

            DataEventSystemFacade.SubscribeToDataAfterAdd <TDataType>(OnDataChanged, true);
            DataEventSystemFacade.SubscribeToDataAfterUpdate <TDataType>(OnDataChanged, true);
            DataEventSystemFacade.SubscribeToDataDeleted <TDataType>(OnDataChanged, true);

            _typeIsLocalizable = DataLocalizationFacade.IsLocalized(typeof(TDataType));
        }
Пример #7
0
        public static void OnInitialized()
        {
            DataEventSystemFacade.SubscribeToDataBeforeUpdate <Entries>(BlogFacade.SetTitleUrl, true);
            DataEventSystemFacade.SubscribeToDataBeforeAdd <Entries>(BlogFacade.SetTitleUrl, true);

            DataEventSystemFacade.SubscribeToDataAfterAdd <Entries>(BlogFacade.ClearRssFeedCache, true);
            DataEventSystemFacade.SubscribeToDataAfterUpdate <Entries>(BlogFacade.ClearRssFeedCache, true);
            DataEventSystemFacade.SubscribeToDataDeleted <Entries>(BlogFacade.ClearRssFeedCache, true);

            DataUrls.RegisterGlobalDataUrlMapper <Entries>(new BlogEntryDataUrlMapper());
            UrlToEntityTokenFacade.Register(new BlogUrlToEntityTokenMapper());
        }
        public DataHookMapper(EntityToken parentEntityToken)
        {
            if (parentEntityToken == null)
            {
                throw new ArgumentNullException("parentEntityToken");
            }

            DataEventSystemFacade.SubscribeToDataAfterAdd <T>(OnDataAddedOrDeleted, false);
            DataEventSystemFacade.SubscribeToDataDeleted <T>(OnDataAddedOrDeleted, false);
            DataEventSystemFacade.SubscribeToStoreChanged <T>(OnStoreChanged, false);

            this.ParentEntityToken = parentEntityToken;
        }
        public void Start()
        {
            DataEventSystemFacade.SubscribeToDataAfterAdd(_interfaceType,
                                                          (sender, args) => CatchAll(() => GetActionContainer().Add(() => Data_OnAfterAdd(sender, args))),
                                                          true);

            DataEventSystemFacade.SubscribeToDataAfterUpdate(_interfaceType,
                                                             (sender, args) => CatchAll(() => GetActionContainer().Add(() => Data_OnAfterUpdate(sender, args))),
                                                             true);

            DataEventSystemFacade.SubscribeToDataDeleted(_interfaceType,
                                                         (sender, args) => CatchAll(() => GetActionContainer().Add(() => Data_OnDeleted(sender, args))),
                                                         true);
        }
Пример #10
0
        private static void SubscribeToDataEvents()
        {
            DataEvents <IPage> .OnAfterAdd += SitemapUpdateAfterPageChanged;
            DataEvents <IPage> .OnDeleted  += SitemapUpdateAfterPageChanged;

            foreach (var typeFullName in _dataTypesToIncludeFromConfig)
            {
                var type = Type.GetType(typeFullName);
                if (type == null)
                {
                    continue;
                }

                DataEventSystemFacade.SubscribeToDataAfterAdd(type, SitemapUpdateAfterPageChanged, true);
                DataEventSystemFacade.SubscribeToDataDeleted(type, SitemapUpdateAfterPageChanged, true);
            }
        }
Пример #11
0
            private ChangeEventsSingleton()
            {
                DataEventSystemFacade.SubscribeToStoreChanged <IMethodBasedFunctionInfo>(OnDataChanged, true);
                DataEventSystemFacade.SubscribeToDataDeleted <IInlineFunction>(OnDataChanged, true);
                DataEventSystemFacade.SubscribeToStoreChanged <IInlineFunction>(OnStoreChanged, true);

                string folderToWatch = PathUtil.Resolve(GlobalSettingsFacade.InlineCSharpFunctionDirectory);

                DirectoryUtils.EnsureDirectoryExists(folderToWatch);

                _codeDirectoryFileSystemWatcher = new C1FileSystemWatcher(folderToWatch)
                {
                    NotifyFilter          = NotifyFilters.LastWrite,
                    EnableRaisingEvents   = true,
                    IncludeSubdirectories = true
                };

                _codeDirectoryFileSystemWatcher.Changed += OnFileWatcherEvent;
            }
Пример #12
0
        public void Initialize()
        {
            using (_resourceLocker.Locker)
            {
                if (!GlobalInitializerFacade.IsReinitializingTheSystem)
                {
                    DataEventSystemFacade.SubscribeToDataAfterAdd <IDataItemTreeAttachmentPoint>(OnUpdateTreeAttachmentPoints, true);
                    DataEventSystemFacade.SubscribeToDataDeleted <IDataItemTreeAttachmentPoint>(OnUpdateTreeAttachmentPoints, true);
                    DataEventSystemFacade.SubscribeToStoreChanged <IDataItemTreeAttachmentPoint>(OnTreeAttachmentPointsStoreChange, true);

                    GeneratedTypesFacade.SubscribeToUpdateTypeEvent(OnDataTypeChanged);

                    var treeAuxiliaryAncestorProvider = new C1Console.Trees.TreeAuxiliaryAncestorProvider();
                    AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreeSimpleElementEntityToken>(treeAuxiliaryAncestorProvider, true);
                    AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreeFunctionElementGeneratorEntityToken>(treeAuxiliaryAncestorProvider, true);
                    AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreeDataFieldGroupingElementEntityToken>(treeAuxiliaryAncestorProvider, true);
                    AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <DataEntityToken>(treeAuxiliaryAncestorProvider, true);
                    AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreePerspectiveEntityToken>(treeAuxiliaryAncestorProvider, true);

                    _resourceLocker.Resources.PersistentAttachmentPoints = new Dictionary <string, List <IAttachmentPoint> >();

                    LoadAllTrees();
                    InitializeTreeAttachmentPoints();
                    TreeSharedRootsFacade.Clear();

                    var fileWatcher = new C1FileSystemWatcher(TreeDefinitionsFolder, "*.xml");
                    fileWatcher.Created            += OnReloadTrees;
                    fileWatcher.Deleted            += OnReloadTrees;
                    fileWatcher.Changed            += OnReloadTrees;
                    fileWatcher.Renamed            += OnReloadTrees;
                    fileWatcher.EnableRaisingEvents = true;

                    _resourceLocker.Resources.FileSystemWatcher = fileWatcher;


                    _resourceLocker.Resources.RootEntityToken = ElementFacade.GetRootsWithNoSecurity().First().ElementHandle.EntityToken;
                }
            }
        }
        public static void Initialize()
        {
            ServiceBusListener.Register(new CommonEventMessageProcessor()
            {
                EventName = "ProductUpdatedEvent",
                Action    = SitemapGeneratorScheduler.RegenerateSitemapJob
            });
            ServiceBusListener.Start();

            DataEvents <IPage> .OnAfterAdd += new DataEventHandler(SitemapUpdateAfterPageChanged);
            DataEvents <IPage> .OnDeleted  += new DataEventHandler(SitemapUpdateAfterPageChanged);

            foreach (var typeFullName in _dataTypesToIncludeFromConfig)
            {
                var type = Type.GetType(typeFullName);
                if (type == null)
                {
                    continue;
                }

                DataEventSystemFacade.SubscribeToDataAfterAdd(type, SitemapUpdateAfterPageChanged, true);
                DataEventSystemFacade.SubscribeToDataDeleted(type, SitemapUpdateAfterPageChanged, true);
            }
        }
Пример #14
0
        private void InitializeTreeAttachmentPoints()
        {
            lock (_reloadAttachmentPointsSyncRoot)
            {
                ClearAttachmentPoints <DynamicDataItemAttachmentPoint>();

                IEnumerable <IDataItemTreeAttachmentPoint> attachmentPoints = DataFacade.GetData <IDataItemTreeAttachmentPoint>().Evaluate();

                foreach (IDataItemTreeAttachmentPoint attachmentPoint in attachmentPoints)
                {
                    Tree tree = GetTree(attachmentPoint.TreeId);
                    if (tree == null)
                    {
                        string treePath = Path.Combine(TreeDefinitionsFolder, attachmentPoint.TreeId);
                        if (!C1File.Exists(treePath)) // This ensures that invalid, but existing trees does not remove these attachment points
                        {
                            if (DataFacade.WillDeleteSucceed(attachmentPoint))
                            {
                                Log.LogWarning("TreeFacade", "A data item attachment points is referring a non existing tree '{0}' and is deleted", attachmentPoint.TreeId);

                                // Preventing events so this method won't call itself recursively
                                DataFacade.Delete(attachmentPoint, true, CascadeDeleteType.Allow);
                            }
                        }

                        continue;
                    }

                    Type   interfaceType = TypeManager.GetType(attachmentPoint.InterfaceType);
                    object keyValue      = ValueTypeConverter.Convert(attachmentPoint.KeyValue, interfaceType.GetKeyProperties()[0].PropertyType);

                    var position = (ElementAttachingProviderPosition)Enum.Parse(typeof(ElementAttachingProviderPosition), attachmentPoint.Position);

                    var dataItemTreeAttachmentPoint = new DynamicDataItemAttachmentPoint
                    {
                        InterfaceType = interfaceType,
                        KeyValue      = keyValue,
                        Position      = position
                    };

                    // Log.LogVerbose("TreeFacade", string.Format("Tree with id '{0}' is dynamically attached to the data type '{1}' with key value of '{2}'", attachmentPoint.TreeId, interfaceType, keyValue));

                    tree.AttachmentPoints.Add(dataItemTreeAttachmentPoint);

                    DataEventSystemFacade.SubscribeToDataDeleted(interfaceType, OnDataItemDeleted, false);
                }


                using (_resourceLocker.ReadLocker)
                {
                    foreach (var kvp in _resourceLocker.Resources.PersistentAttachmentPoints)
                    {
                        Tree tree = GetTree(kvp.Key);
                        if (tree == null)
                        {
                            continue;
                        }

                        tree.AttachmentPoints.AddRange(kvp.Value);
                    }
                }
            }
        }
Пример #15
0
 static Tree()
 {
     DataEventSystemFacade.SubscribeToDataDeleted <IPageStructure>(OnPageStructureDeleted, true);
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IMediaFileFolder>(OnMediaFolderChanged, true);
 }
Пример #16
0
 public FavoriteFunctionsProvider()
 {
     DataEventSystemFacade.SubscribeToDataAfterAdd <IFavoriteFunction>(OnDataChanged, false);
     DataEventSystemFacade.SubscribeToDataDeleted <IFavoriteFunction>(OnDataChanged, false);
 }
Пример #17
0
 /// <exclude />
 static TemplateInfo()
 {
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IXmlPageTemplate>(PageTemplate_Changed, true);
     DataEventSystemFacade.SubscribeToDataDeleted <IXmlPageTemplate>(PageTemplate_Changed, true);
     DataEventSystemFacade.SubscribeToStoreChanged <IXmlPageTemplate>(PageTemplate_StoreChanged, true);
 }