Пример #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);
        }
Пример #2
0
        public static List <InventioLayout> SelectAllLayouts()
        {
            List <InventioLayout> ret = null;

            ret = LayoutWorker.SelectAll(LayoutWorker.RepositoryWebConfig);

            return(ret);
        }
Пример #3
0
        public static Nullable <int> AddLayout(InventioLayout layout)
        {
            Nullable <int> ret = null;

            if (layout != null)
            {
                InventioLayout hit = LayoutWorker.SelectByTitle(layout.Title, LayoutWorker.RepositoryWebConfig);
                if (hit == null)
                {
                    ret = LayoutWorker.Add(layout, LayoutWorker.RepositoryWebConfig);
                }
                else
                {
                    layout.Id = hit.Id;
                    LayoutWorker.Update(layout, LayoutWorker.RepositoryWebConfig);
                    ret = layout.Id;
                }
            }

            return(ret);
        }