protected override IEnumerable<ActionBase> CollectActions(SenseNet.ContentRepository.Content context, string backUrl) { var actList = new List<ActionBase>(); if (context == null) return actList; actList.AddRange(base.CollectActions(context, backUrl)); var appApprove = ApplicationStorage.Instance.GetApplication("Approve", context, PortalContext.Current.DeviceName); var appEdit = ApplicationStorage.Instance.GetApplication("Edit", context, PortalContext.Current.DeviceName); var appDelete = ApplicationStorage.Instance.GetApplication("Delete", context, PortalContext.Current.DeviceName); var action = appApprove.CreateAction(context, backUrl, null); action.Text = "Approve"; actList.Add(action); action = appEdit.CreateAction(context, backUrl, null); action.Text = "Edit"; actList.Add(action); action = appDelete.CreateAction(context, backUrl, null); action.Text = "Delete"; actList.Add(action); return actList; }
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(); }
private void AddControl(ControlCollection container, SenseNet.ContentRepository.Field field) { var control = GenericFieldControl.CreateDefaultFieldControl(field); control.ID = String.Concat("Generic", _id++); var fv = GenericFieldControl.GetFieldVisibility(ViewMode, field); if (fv == FieldVisibility.Advanced && AdvancedPanel != null) { AdvancedPanel.Controls.Add(control); } else { container.Add(control); } }
//=================================================================================== Events protected override void OnMoving(object sender, SenseNet.ContentRepository.Storage.Events.CancellableNodeOperationEventArgs e) { // AD Sync check var ADProvider = DirectoryProvider.Current; if (ADProvider != null) { var targetNodePath = RepositoryPath.Combine(e.TargetNode.Path, this.Name); var allowMove = ADProvider.AllowMoveADObject(this, targetNodePath); if (!allowMove) { e.CancelMessage = "Moving of synced nodes is only allowed within AD server bounds!"; e.Cancel = true; } } base.OnMoving(sender, e); }
public SenseNet.Services.IdentityManagement.LookupIdentityResult LookupIdentityEx(SenseNet.Services.IdentityManagement.LookupIdentityParameters parameters) { throw new NotImplementedException(); }
protected override void OnCreated(object sender, SenseNet.ContentRepository.Storage.Events.NodeEventArgs e) { var image = sender as Image; if (image == null) return; // thumbnail has been loaded -> reference it in parent's imagefield (if such exists) if (image.Name.ToLower().StartsWith("thumbnail")) { var parent = image.Parent; var content = Content.Create(parent); // first available imagefield is used var imageField = content.Fields.Where(d => d.Value is ImageField).Select(d => d.Value as ImageField).FirstOrDefault(); if (imageField != null) { // initialize field (field inner data is not yet initialized from node properties!) imageField.GetData(); // set reference var result = imageField.SetThumbnailReference(image); if (result) content.Save(); } } base.OnCreated(sender, e); }
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 querystring = string.Format("+InTree:'{0}' +Type:'ForumEntry' +CreationDate:<'{1}' .COUNTONLY", this.ParentPath, this.CreationDate.ToString("yyyy-MM-dd HH:mm:ss.fff")); var q = ContentQuery.Query(querystring, new QuerySettings { Top = int.MaxValue }); this.SerialNo = q.Count; } catch { Trace.Write("Lucene query failed on node " + this.Path); } } }
protected void ContentHandler_Modified(object sender, SenseNet.ContentRepository.Storage.Events.NodeEventArgs e) { if (_data.ImgRef != null) { _data.ImgRef.Delete(true); _data.ImgRef = null; } }
protected void ContentHandler_Created(object sender, SenseNet.ContentRepository.Storage.Events.NodeEventArgs e) { // reload content with image field, as it may have changed (_copying member) var node = Node.LoadNode(this.Content.Id); CreateImageReference(node); // set reference to content var content = ContentRepository.Content.Create(node); content[this.Field.Name] = _data; content.Save(); }
public static void SetAttachment(SenseNet.ContentRepository.File file, FileAttachment fileAttachment) { using (var stream = new MemoryStream()) { fileAttachment.Load(stream); stream.Seek(0, SeekOrigin.Begin); var binaryData = new BinaryData(); binaryData.SetStream(stream); file.Binary = binaryData; file.Save(); } }
protected override void OnDeleted(object sender, SenseNet.ContentRepository.Storage.Events.NodeEventArgs e) { if (HttpContext.Current != null) DeleteCacheFolder(); }
protected override void OnModifying(object sender, SenseNet.ContentRepository.Storage.Events.CancellableNodeEventArgs e) { if (HttpContext.Current != null) ReCreateCacheFolder(); }
internal static IEnumerable<Fieldable> GetFields(IndexDocumentInfo info, SenseNet.ContentRepository.Storage.Data.IndexDocumentData docData) { Debug.WriteLine("%> adding custom fields for " + docData.Path); return Instance.GetFieldsPrivate(info, docData); }
public override SenseNet.Search.QueryResult GetChildren(string text, SenseNet.Search.QuerySettings settings, bool getAllChildren) { return new SenseNet.Search.QueryResult(_children); }
public string Compile(Query query, int top, int skip, SortField[] orders, out SenseNet.ContentRepository.Storage.Search.NodeQueryParameter[] parameters) { throw new NotImplementedException("Partially implemented."); if(skip > 0) throw new NotImplementedException("Paging is not implemented (skip > 0)."); var whereCompiler = new SqlWhereVisitor(); whereCompiler.Visit(query); var sb = new StringBuilder(); sb.Append("SELECT"); if(top > 0) sb.Append(" TOP ").Append(top); sb.AppendLine(" NodeId FROM Nodes"); sb.Append("WHERE "); sb.AppendLine(whereCompiler.ToString()); if (orders.Count() > 0) { sb.Append("ORDER BY "); sb.AppendLine(String.Join(", ", orders.Select(o => o.GetField() + (o.GetReverse() ? " DESC" : String.Empty)).ToArray())); } parameters = whereCompiler.Parameters; return sb.ToString(); }