Exemple #1
0
        public static Stream GetInventioPageStream(string path)
        {
            Stream ret = null;

            InventioPage page = PageWorker.SelectByPath(path, PageWorker.RepositoryWebConfig);

            if (page != null)
            {
                InventioLayout layout = LayoutWorker.SelectById(page.IdLayout, LayoutWorker.RepositoryWebConfig);
                if (layout != null)
                {
                    string raw    = System.Text.Encoding.UTF8.GetString(layout.Body);
                    string parsed = string.Empty;

                    // BEGIN RazorEngine Template // TODO igual hay que meterlo en global asax
                    var config = new RazorEngine.Configuration.TemplateServiceConfiguration
                    {
                        //BaseTemplateType = typeof(InventioTemplateBase<>)
                        BaseTemplateType = typeof(InventioTemplateBase <>),
                        Resolver         = new InventioTemplateResolver()
                    };

                    using (var service = new TemplateService(config))
                    {
                        RazorEngine.Razor.SetTemplateService(service);
                        parsed = Razor.Parse(raw);
                    }
                    // END RazorEngine

                    ret = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parsed), false);
                }
            }

            return(ret);
        }
Exemple #2
0
        public static bool IsInventioPage(string path)
        {
            bool ret = false;

            if (!string.IsNullOrWhiteSpace(path))
            {
                InventioPage selected = PageWorker.SelectByPath(path, PageWorker.RepositoryWebConfig);
                ret = selected != null;
            }

            return(ret);
        }
Exemple #3
0
 public static void RemovePage(string path)
 {
     if (!string.IsNullOrWhiteSpace(path))
     {
         InventioNavigationNode nav = NavigationWorker.SelectByPath(path, NavigationWorker.RepositoryWebConfig);
         if (nav != null)
         {
             NavigationWorker.Remove(nav.Id, NavigationWorker.RepositoryWebConfig);
         }                                                                                           // eliminamos navigation
         InventioPage page = PageWorker.SelectByPath(path, PageWorker.RepositoryWebConfig);
         if (page != null)
         {
             PageWorker.Remove(page.Id, PageWorker.RepositoryWebConfig);
         }                                                                                 // eliminamos página
     }
 }
Exemple #4
0
        public static void AddPage(string Path, string title, int IdLayout, Nullable <int> ParentId)
        {
            bool ok = !string.IsNullOrWhiteSpace(Path) && !string.IsNullOrWhiteSpace(title);

            if (ok)
            {
                // añadimos página
                InventioPage NewPage = new InventioPage();
                NewPage.Path     = Path + "/" + Tc.Inventio.Framework.Web.UrlHelper.Slug(title);
                NewPage.Title    = title;
                NewPage.IdLayout = IdLayout;
                PageWorker.Add(NewPage, PageWorker.RepositoryWebConfig);

                // añadimos entrada en navigation
                InventioNavigationNode NewNode = new InventioNavigationNode();
                NewNode.NodeType = InventioNavigationNodeType.Page;
                NewNode.ParentId = ParentId;
                NewNode.Url      = NewPage.Path;
                NewNode.Title    = title;
                NavigationWorker.Add(NewNode, NavigationWorker.RepositoryWebConfig);
            }
        }