Esempio n. 1
0
        public static GenericContent GetSystemContext(Node child)
        {
            SystemFolder ancestor = null;

            while ((child != null) && ((ancestor = child as SystemFolder) == null))
            {
                child = child.Parent;
            }

            return((ancestor != null) ? ancestor.Parent as GenericContent : null);
        }
Esempio n. 2
0
 private Node GetAppCacheRoot()
 {
     var node = Node.LoadNode(PersistentAppCacheFolderPath);
     if (node != null)
         return node;
     var folder = new SystemFolder(Repository.SystemFolder);
     folder.Name = PersistentAppCacheFolderName;
     //folder.AddReference("ContentTypes", ContentType.GetByName("ApplicationCacheFile"));
     folder.Save();
     return folder;
 }
Esempio n. 3
0
 public static SystemFolder GetPortletFolder()
 {
     var parent = Node.LoadNode(PortletsFolderPath);
     if (parent == null)
     {
         // new portletsDir
         parent = new SystemFolder(Node.LoadNode("/Root"));
         parent.Name = "Portlets";
         parent.Save();
     }
     return parent as SystemFolder;
 }
Esempio n. 4
0
        private Node GetAppCacheRoot()
        {
            var node = Node.LoadNode(PersistentAppCacheFolderPath);

            if (node != null)
            {
                return(node);
            }
            var folder = new SystemFolder(Repository.SystemFolder);

            folder.Name = PersistentAppCacheFolderName;
            folder.Save();
            return(folder);
        }
Esempio n. 5
0
        public Folder GetWorkflowContainer()
        {
            var path      = RepositoryPath.Combine(this.Path, WorkflowContainerName);
            var container = (Folder)Node.LoadNode(path);

            if (container != null)
            {
                return(container);
            }
            container      = new SystemFolder(this);
            container.Name = WorkflowContainerName;
            using (new SenseNet.ContentRepository.Storage.Security.SystemAccount())
                container.Save();
            return(container);
        }
Esempio n. 6
0
        private Node GetAppCacheRoot()
        {
            var node = Node.LoadNode(PersistentAppCacheFolderPath);

            if (node != null)
            {
                return(node);
            }
            var folder = new SystemFolder(Repository.SystemFolder);

            folder.Name = PersistentAppCacheFolderName;
            //folder.AddReference("ContentTypes", ContentType.GetByName("ApplicationCacheFile"));
            folder.Save();
            return(folder);
        }
Esempio n. 7
0
        private static Node GetMailProcessorWorkflowContainer(Node contextNode)
        {
            var parent = Node.LoadNode(RepositoryPath.Combine(contextNode.Path, "Workflows/MailProcess"));

            if (parent == null)
            {
                var workflows = Node.LoadNode(RepositoryPath.Combine(contextNode.Path, "Workflows"));
                if (workflows == null)
                {
                    using (new SystemAccount())
                    {
                        workflows = new SystemFolder(contextNode)
                        {
                            Name = "Workflows"
                        };

                        try
                        {
                            workflows.Save();
                        }
                        catch (Exception ex)
                        {
                            SnLog.WriteException(ex, categories: ExchangeHelper.ExchangeLogCategory);
                            return(null);
                        }
                    }
                }
                using (new SystemAccount())
                {
                    parent = new Folder(workflows)
                    {
                        Name = "MailProcess"
                    };

                    try
                    {
                        parent.Save();
                    }
                    catch (Exception ex)
                    {
                        SnLog.WriteException(ex, categories: ExchangeHelper.ExchangeLogCategory);
                        return(null);
                    }
                }
            }
            return(parent);
        }
        public ActionResult CopyAppLocal(string nodepath, string apppath, string back)
        {
            AssertPermission();

            nodepath = HttpUtility.UrlDecode(nodepath);
            apppath = HttpUtility.UrlDecode(apppath);
            back = HttpUtility.UrlDecode(back);

            var targetAppPath = RepositoryPath.Combine(nodepath, "(apps)");
            var targetThisPath = RepositoryPath.Combine(targetAppPath, "This");

            //we don't use the system account here, the user must have create rights here
            if (!Node.Exists(targetAppPath))
            {
                var apps = new SystemFolder(Node.LoadNode(nodepath)) {Name = "(apps)"};
                apps.Save();
            }
            if (!Node.Exists(targetThisPath))
            {
                var thisFolder = new Folder(Node.LoadNode(targetAppPath)) { Name = "This" };
                thisFolder.Save();
            }

            try
            {
                Node.Copy(apppath, targetThisPath);
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
            }

            return this.Redirect(back);
        }
 private static Node GetParent(Node contextNode)
 {
     var parent = Node.LoadNode(RepositoryPath.Combine(contextNode.Path, "Workflows/MailProcess"));
     if (parent == null)
     {
         var workflows = Node.LoadNode(RepositoryPath.Combine(contextNode.Path, "Workflows"));
         if (workflows == null)
         {
             using (new SystemAccount())
             {
                 workflows = new SystemFolder(contextNode);
                 workflows.Name = "Workflows";
                 try
                 {
                     workflows.Save();
                 }
                 catch (Exception ex)
                 {
                     Logger.WriteException(ex, ExchangeHelper.ExchangeLogCategory);
                     return null;
                 }
             }
         }
         using (new SystemAccount())
         {
             parent = new SenseNet.ContentRepository.Folder(workflows);
             parent.Name = "MailProcess";
             try
             {
                 parent.Save();
             }
             catch (Exception ex)
             {
                 Logger.WriteException(ex, ExchangeHelper.ExchangeLogCategory);
                 return null;
             }
         }
     }
     return parent;
 }
Esempio n. 10
0
        private static Node SetWatermark(Node contextNode, string watermark)
        {
            var parent = Node.LoadNode(RepositoryPath.Combine(contextNode.Path, ExchangeHelper.PUSHNOTIFICATIONMAILCONTAINER));
            if (parent == null)
            {
                using (new SystemAccount())
                {
                    parent = new SystemFolder(contextNode);
                    parent.Name = ExchangeHelper.PUSHNOTIFICATIONMAILCONTAINER;
                    try
                    {
                        parent["Description"] = watermark;
                        parent.Save();
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteException(ex, ExchangeHelper.ExchangeLogCategory);
                        return null;
                    }
                }
            }
            else
            {
                // persist watermark on existing content
                using (new SystemAccount())
                {
                    var retryCount = 3;
                    while (retryCount > 0)
                    {
                        try
                        {
                            var gc = parent as GenericContent;
                            gc["Description"] = watermark;
                            gc.Save(SavingMode.KeepVersion);
                            break;
                        }
                        catch (NodeIsOutOfDateException)
                        {
                            retryCount--;
                            parent = Node.LoadNode(RepositoryPath.Combine(contextNode.Path, ExchangeHelper.PUSHNOTIFICATIONMAILCONTAINER));
                        }
                    }
                }
            }

            return parent;
        }