Example #1
0
 protected override void OnModifying(object sender, SenseNet.ContentRepository.Storage.Events.CancellableNodeEventArgs e)
 {
     if (HttpContext.Current != null)
     {
         ReCreateCacheFolder();
     }
 }
Example #2
0
        protected override void OnCreating(object sender, SenseNet.ContentRepository.Storage.Events.CancellableNodeEventArgs e)
        {
            base.OnCreating(sender, e);

            if (!StorageContext.Search.IsOuterEngineEnabled)
            {
                return;
            }

            var searchPath = e.SourceNode.Parent.GetType().Name == "Voting"
                                 ? e.SourceNode.ParentPath
                                 : e.SourceNode.Parent.ParentPath;

            // Count Voting Items
            var votingItemCount = ContentQuery.Query(SafeQueries.InTreeAndTypeIsCountOnly,
                                                     new QuerySettings {
                EnableAutofilters = FilterStatus.Disabled
            },
                                                     searchPath, typeof(VotingItem).Name).Count;

            // Get children (VotingItems) count
            String tempName;

            if (votingItemCount < 10 && votingItemCount != 9)
            {
                tempName = "VotingItem_0" + (votingItemCount + 1);
            }
            else
            {
                tempName = "VotingItem_" + (votingItemCount + 1);
            }

            // If node already exits
            while (Node.Exists(RepositoryPath.Combine(e.SourceNode.Parent.Path, tempName)))
            {
                votingItemCount++;
                if (votingItemCount < 10)
                {
                    tempName = "VotingItem_0" + (votingItemCount + 1);
                }
                else
                {
                    tempName = "VotingItem_" + (votingItemCount + 1);
                }
            }

            e.SourceNode["DisplayName"] = tempName;
            e.SourceNode["Name"]        = tempName.ToLower();
        }
Example #3
0
        protected override void OnCreating(object sender, SenseNet.ContentRepository.Storage.Events.CancellableNodeEventArgs e)
        {
            base.OnCreating(sender, e);

            if (!StorageContext.Search.IsOuterEngineEnabled)
            {
                return;
            }

            var searchPath = e.SourceNode.Parent.GetType().Name == "Voting"
                                 ? e.SourceNode.ParentPath
                                 : e.SourceNode.Parent.ParentPath;

            // Count Voting Items
            var votingItemCount = ContentQuery.Query(string.Format("+Type:votingitem +InTree:\"{0}\" .AUTOFILTERS:OFF .COUNTONLY", searchPath)).Count;

            // Get children (VotingItems) count
            String tempName;

            if (votingItemCount < 10 && votingItemCount != 9)
            {
                tempName = "VotingItem_0" + (votingItemCount + 1);
            }
            else
            {
                tempName = "VotingItem_" + (votingItemCount + 1);
            }

            // If node already exits
            while (Node.Exists(RepositoryPath.Combine(e.SourceNode.Parent.Path, tempName)))
            {
                votingItemCount++;
                if (votingItemCount < 10)
                {
                    tempName = "VotingItem_0" + (votingItemCount + 1);
                }
                else
                {
                    tempName = "VotingItem_" + (votingItemCount + 1);
                }
            }

            e.SourceNode["DisplayName"] = tempName;
            e.SourceNode["Name"]        = tempName.ToLower();
        }
Example #4
0
        protected override void OnCreating(object sender, SenseNet.ContentRepository.Storage.Events.CancellableNodeEventArgs e)
        {
            base.OnCreating(sender, e);

            this.PostedBy = this.CreatedBy;
            if (StorageContext.Search.IsOuterEngineEnabled && StorageContext.Search.SearchEngine != InternalSearchEngine.Instance)
            {
                try
                {
                    var q = ContentQuery.Query("+InTree:@0 +Type:'ForumEntry' +CreationDate:<@1 .COUNTONLY",
                                               null, this.ParentPath, this.CreationDate.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    this.SerialNo = q.Count;
                }
                catch
                {
                    Trace.Write("Lucene query failed on node " + this.Path);
                }
            }
        }