public static string GetRunningWorkflowsText(Node relatedContent) { if (!StorageContext.Search.IsOuterEngineEnabled) { return(string.Empty); } var cl = ContentList.GetContentListForNode(relatedContent); if (cl == null) { return(string.Empty); } var query = string.Format("+InTree:\"{0}\" +TypeIs:Workflow +WorkflowStatus:1 +RelatedContent:{1} .AUTOFILTERS:OFF .LIFESPAN:OFF", cl.Path + "/Workflows", relatedContent.Id); var result = ContentQuery.Query(query); var sb = new StringBuilder(); foreach (var wfInstance in result.Nodes) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(wfInstance.DisplayName); } return(sb.ToString()); }
public static string GetRunningWorkflowsText(Node relatedContent) { if (!SearchManager.ContentQueryIsAllowed) { return(string.Empty); } var cl = ContentList.GetContentListForNode(relatedContent); if (cl == null) { return(string.Empty); } var result = ContentQuery.Query("+InTree:@0 +TypeIs:Workflow +WorkflowStatus:1 +RelatedContent:@1 .AUTOFILTERS:OFF .LIFESPAN:OFF", null, cl.Path + "/Workflows", relatedContent.Id); var sb = new StringBuilder(); foreach (var wfInstance in result.Nodes) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(wfInstance.DisplayName); } return(sb.ToString()); }
public static string GetColumnTitle(string fieldFullName, Node contextNode) { ContentList cl = null; if (contextNode != null) { cl = ContentList.GetContentListForNode(contextNode) ?? ContentList.GetContentListByParentWalk(contextNode); } return(GetColumnTitle(fieldFullName, cl != null ? cl.Path : string.Empty)); }
private Node GetContextNode() { if (PortalContext.Current == null) { return(null); } var contextNode = PortalContext.Current.ContextNode; if (UsePortletContext) { var portletcontext = ContextBoundPortlet.GetContextNodeForControl(this); if (portletcontext != null) { contextNode = portletcontext; } else { // workaround: we can't reach the obsolete singlecontent // portlet here, unless we use reflection... try { var scp = TypeResolver.GetType("SenseNet.Portal.Portlets.SingleContentPortlet"); if (scp != null) { var mm = scp.GetMethod("GetContextNodeForControl"); if (mm != null) { var singleNode = mm.Invoke(null, new[] { this }) as Node; if (singleNode != null) { contextNode = singleNode; } } } } catch (Exception ex) { // error loading single content portlet SnLog.WriteException(ex); } } } var selector = this.Selector == null ? string.Empty : this.Selector.ToLower(); switch (selector) { case "currentuser": contextNode = User.Current as Node; break; case "currentpage": contextNode = PortalContext.Current.Page; break; case "currentsite": contextNode = Portal.Site.GetSiteByNode(contextNode); break; case "currentlist": contextNode = ContentList.GetContentListForNode(contextNode); break; case "currentworkspace": contextNode = PortalContext.Current.ContextWorkspace; break; case "parentworkspace": { var portalContext = PortalContext.Current; Workspace ws = null; using (new SystemAccount()) ws = portalContext.ContextWorkspace != null?Workspace.GetWorkspaceForNode(portalContext.ContextWorkspace.Parent) : null; if (ws != null && !ws.Security.HasPermission(PermissionType.See)) { ws = null; } contextNode = ws; break; } case "currentapplicationcontext": var app = PortalContext.Current.GetApplicationContext(); if (app != null) { contextNode = app; } else if (!ReplaceNullWithContext) { contextNode = null; } break; case "currenturlcontent": var urlNodePath = HttpContext.Current.Request.Params[PortalContext.ContextNodeParamName]; contextNode = !string.IsNullOrEmpty(urlNodePath) ? Node.LoadNode(urlNodePath) : null; break; } if (!string.IsNullOrEmpty(ReferenceFieldName) && contextNode != null) { // need to create the content here for its fields var content = Content.Create(contextNode); if (content.Fields.ContainsKey(ReferenceFieldName)) { var refValue = content[ReferenceFieldName]; var list = refValue as IEnumerable <Node>; var single = refValue as Node; if (list != null) { contextNode = list.FirstOrDefault(); } else if (single != null) { contextNode = single; } else { contextNode = null; } } else { throw new InvalidOperationException(string.Format("Content of type {0} does not have a field named {1}", contextNode.NodeType.Name, ReferenceFieldName)); } } return(contextNode); }