コード例 #1
0
 public void SetSessionModel(Session aSession, IPageModel aModel)
 {
     lock (iLock)
     {
         iSessionModels[aSession] = aModel;
     }
 }
コード例 #2
0
ファイル: Pager.cs プロジェクト: sandeep18051989/SMS
 public Pager(IPageModel model, ViewContext context)
 {
     this.model                 = model;
     this.viewContext           = context;
     this.urlBuilder            = CreateDefaultUrl;
     this.booleanParameterNames = new List <string>();
 }
コード例 #3
0
 internal Page(PrintJob job, Guid id, IPageModel pageModel)
 {
     _job         = job;
     _id          = id;
     _templateUri = pageModel.TemplateUrl;
     _variables   = pageModel.Variables;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <b>PagesController</b> class.
 /// </summary>
 /// <param name="structureInfo">The structure info.</param>
 /// <param name="currentPage">The current page.</param>
 /// <param name="session">The session.</param>
 /// <param name="content">The content.</param>
 public PagesController(IStructureInfo structureInfo, IPageModel currentPage, IDocumentSession session, IContent content)
 {
     _structureInfo = structureInfo;
     _currentPage = currentPage;
     _session = session;
     _content = content;
 }
コード例 #5
0
 public MasterPageViewModel(MenuPage menu, IPageModel detailModel)
 {
     Title  = "Home Page";
     _menu  = menu;
     Master = _menu;
     Detail = new NavigationPage(detailModel.ViewModel.ContentPage);
 }
コード例 #6
0
        private void AddSections(string pageName, IPageModel page)
        {
            var sections = this.GetSectionsForPage(pageName);

            foreach (var section in sections)
            {
                page.Sections.Add(section.Name, section);
            }
        }
コード例 #7
0
        public IPathData ResolvePath(string virtualUrl)
        {
            // Set the default action to index
            _pathData.Action = ContentRoute.DefaultAction;
            // Set the default controller to content
            _pathData.Controller = ContentRoute.DefaultControllerName;
            // Get an up to date document session from structuremap
            _session = ObjectFactory.GetInstance <IDocumentSession>();
            // The requested url is for the start page with no action
            if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/"))
            {
                _pageModel = _session.Query <IPageModel>()
                             .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                             .SingleOrDefault(x => x.Parent == null);
                _pathData.CurrentPageModel = _pageModel;

                return(_pathData);
            }
            // Remove the trailing slash
            virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl);
            // The normal beahaviour should be to load the page based on the url
            _pageModel = _session.Query <IPageModel, Document_ByUrl>()
                         .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                         .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
            // Try to load the page without the last segment of the url and set the last segment as action))
            if (_pageModel == null && virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal) > 0)
            {
                var index  = virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal);
                var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' });
                virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' });
                _pageModel = _session.Query <IPageModel, Document_ByUrl>()
                             .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                             .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
                _pathData.Action = action;
            }

            // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl)
            if (_pageModel == null)
            {
                _pageModel = _session.Query <IPageModel>().SingleOrDefault(x => x.Parent == null);
                var controllerName = _controllerMapper.GetControllerName(typeof(ContentController));
                var action         = virtualUrl.TrimStart(new[] { '/' });
                if (!_controllerMapper.ControllerHasAction(controllerName, action))
                {
                    return(null);
                }
                _pathData.Action = action;
            }

            if (_pageModel == null)
            {
                return(null);
            }

            _pathData.CurrentPageModel = _pageModel;
            return(_pathData);
        }
コード例 #8
0
ファイル: PathResolver.cs プロジェクト: pullpush/NAd
        /// <summary>
        /// Resolves the path.
        /// </summary>
        /// <param name="virtualUrl">The virtual URL.</param>
        /// <returns></returns>
        public IPathData ResolvePath(string virtualUrl) {

            // Set the default action to index
            _pathData.Action = PageRoute.DefaultAction;

            // Get an up to date page repository
            //_pageService = _container.Resolve<IPageServiceFacade>();

            
            // The requested url is for the start page with no action
            if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/") || virtualUrl.StartsWith("classifieds"))
            {
                //_pageModel = _pageService.SingleOrDefault<IPageModel>(x => x.Parent == null);
                //_pageModel = _pageService.GetPageByUrl(null);
                //This is a site home page
                _pageModel = null; // new Home();

            } else {
                // Remove the trailing slash
                virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl);
                // The normal beahaviour should be to load the page based on the url
                //_pageModel = _pageService.GetPageByUrl<IPageModel>(virtualUrl);
                _pageModel = _pageService.GetPageByUrl(virtualUrl);
                // Try to load the page without the last segment of the url and set the last segment as action))
                if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) {
                    var index = virtualUrl.LastIndexOf("/");
                    var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' });
                    virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' });
                    //_pageModel = _pageService.GetPageByUrl<IPageModel>(virtualUrl);
                    _pageModel = _pageService.GetPageByUrl(virtualUrl);
                    _pathData.Action = action;
                }
                // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl)
                if (_pageModel == null) {
                    //_pageModel = _pageService.SingleOrDefault<IPageModel>(x => x.Parent == null);
                    _pageModel = _pageService.GetPageByUrl(null);
                    var pageModelAttribute = _pageModel.GetType().GetAttribute<PageModelAttribute>();
                    _controllerName = _controllerMapper.GetControllerName(pageModelAttribute.ControllerType);
                    var action = virtualUrl.TrimStart(new[] { '/' });
                    if (!_controllerMapper.ControllerHasAction(_controllerName, action)) {
                        return null;
                    }
                    _pathData.Action = action;
                }
            }
            

            if (_pageModel == null) {
                return null;
            }

            var controllerType = _pageModel.GetType().GetAttribute<PageModelAttribute>().ControllerType;
            _pathData.Controller = _controllerMapper.GetControllerName(controllerType);
            _pathData.CurrentPageModel = _pageModel;
            return _pathData;
        }
コード例 #9
0
ファイル: PageHandler.cs プロジェクト: rene1997/PrekenwebApp
        public PageHandler(Main main)
        {
            this._main = main;
            this._menu = new MenuPage();
            _menu.ListView.ItemSelected += OnItemSelected;
            this._detailPage             = new HomePageModel();
            _detailPage.SetMain(_main);

            _mainPage         = new MasterPageViewModel(_menu, _detailPage);
            main.App.MainPage = _mainPage;
        }
コード例 #10
0
 public PageModel(IPageModel model)
     : base()
 {
     if (model != null)
     {
         this.PageIndex = model.PageIndex;
         this.PageSize = model.PageSize;
         this.ResultCount = model.ResultCount;
         this.SortBy = model.SortBy;
         this.SortDesc = model.SortDesc;
     }
 }
コード例 #11
0
 public PageModel(IPageModel model)
     : base()
 {
     if (model != null)
     {
         this.PageIndex   = model.PageIndex;
         this.PageSize    = model.PageSize;
         this.ResultCount = model.ResultCount;
         this.SortBy      = model.SortBy;
         this.SortDesc    = model.SortDesc;
     }
 }
コード例 #12
0
        public IPathData ResolvePath(string virtualUrl)
        {
            // Set the default action to index
            _pathData.Action = ContentRoute.DefaultAction;
            // Set the default controller to content
            _pathData.Controller = ContentRoute.DefaultControllerName;
            // Get an up to date document session from structuremap
            _session = ObjectFactory.GetInstance<IDocumentSession>();
            // The requested url is for the start page with no action
            if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl,"/")) {
                _pageModel = _session.Query<IPageModel>()
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .SingleOrDefault(x => x.Parent == null);
                _pathData.CurrentPageModel = _pageModel;

                return _pathData;
            }
            // Remove the trailing slash
            virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl);
            // The normal beahaviour should be to load the page based on the url
            _pageModel = _session.Query<IPageModel, Document_ByUrl>()
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
            // Try to load the page without the last segment of the url and set the last segment as action))
            if (_pageModel == null && virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal) > 0) {
                var index = virtualUrl.LastIndexOf("/", System.StringComparison.Ordinal);
                var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] {'/'});
                virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' });
                _pageModel = _session.Query<IPageModel, Document_ByUrl>()
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
                _pathData.Action = action;
            }

            // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl)
            if(_pageModel == null) {
                _pageModel = _session.Query<IPageModel>().SingleOrDefault(x => x.Parent == null);
                var controllerName = _controllerMapper.GetControllerName(typeof(ContentController));
                var action = virtualUrl.TrimStart(new[] {'/'});
                if(!_controllerMapper.ControllerHasAction(controllerName,action)) {
                    return null;
                }
                _pathData.Action = action;
            }

            if (_pageModel == null) {
                return null;
            }

            _pathData.CurrentPageModel = _pageModel;
            return _pathData;
        }
コード例 #13
0
ファイル: PageHandler.cs プロジェクト: rene1997/PrekenwebApp
        void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as MenuItem;

            if (item != null)
            {
                IPageModel model = (IPageModel)Activator.CreateInstance(item.TargetType);
                model.SetMain(_main);
                _mainPage.SetDetailPage(model);
                //change page and hide menu
                _menu.ListView.SelectedItem = null;
            }
        }
コード例 #14
0
        private PageInstance CreatePageInstance(Entry aEntry, Session aSession)
        {
            IPageModel pageModel = null;

            if (!string.IsNullOrEmpty(aEntry.PageDefinition.Model))
            {
                Type pageModelType = Type.GetType(aEntry.PageDefinition.Model, true);
                pageModel = Activator.CreateInstance(pageModelType, aSession) as IPageModel;
                Assert.Check(pageModel != null);
            }

            return(new PageInstance(aEntry.Page, pageModel));
        }
コード例 #15
0
        public void CloseModel()
        {
            if (DataModel is null)
            {
                return;
            }
            DataModel = null;

            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                _window.Close();
            });
        }
コード例 #16
0
        protected override void OnActivated(Session aSession)
        {
            // get the page model for this session
            IPageModel model = GetSessionModel(aSession);

            // enable analytics and send page view event if tracking
            aSession.Tracker.SetTracking(aSession.Tracking);
            aSession.Tracker.TrackPageView(Id);

            // update any ui widgets that reflect tracking state
            aSession.Send("DataCollectionEnabled", aSession.Tracking);

            // render widgets
            foreach (PageDefinitions.Widget widget in iPageDefinition.Widgets)
            {
                // get the value of the data from the page model
                Assert.Check(model != null);
                System.Reflection.PropertyInfo prop = model.GetType().GetProperty(widget.DataId);
                string data = prop.GetValue(model, null) as string;

                // create the json object
                OpenHome.Xapp.JsonObject json = new OpenHome.Xapp.JsonObject();

                // add the basic required properties
                json.Add("Id", new OpenHome.Xapp.JsonValueString(widget.Id));
                json.Add("DataId", new OpenHome.Xapp.JsonValueString(widget.DataId));
                json.Add("Value", new OpenHome.Xapp.JsonValueString(data));

                // add the optional allowed values
                if (widget.AllowedValues != null || widget.AllowedValuesSource != null)
                {
                    // get the list of string allowed values from either the widget XML or an IPageModel property
                    string[] allowedValuesStr = (widget.AllowedValues != null)
                                              ? widget.AllowedValues
                                              : model.GetType().GetProperty(widget.AllowedValuesSource).GetValue(model, null) as string[];

                    // create the json array of allowed values
                    OpenHome.Xapp.JsonArray <OpenHome.Xapp.JsonValueString> allowedValues = new OpenHome.Xapp.JsonArray <OpenHome.Xapp.JsonValueString>();

                    foreach (string value in allowedValuesStr)
                    {
                        allowedValues.Add(new OpenHome.Xapp.JsonValueString(value));
                    }

                    json.Add("AllowedValues", allowedValues);
                }

                // render the widget
                aSession.Send(widget.XappEvent, json);
            }
        }
コード例 #17
0
ファイル: ModelRepository.cs プロジェクト: TVolden/FlatoutCMS
        public Maybe <IPageModel> GetModel(string uri)
        {
            IPageModel model = null;

            dataFileFetcher.Find(uri).Apply(page =>
            {
                var parser    = parserFactory.CreateParser(page);
                var baseModel = parser.Parse <PageModel>();
                var modelType = typeFetcher.GetModelType(baseModel.View);
                model         = parser.Parse(modelType);
            });

            return(model == null ? new Maybe <IPageModel>() : new Maybe <IPageModel>(model));
        }
コード例 #18
0
        /// <summary>
        /// Resolves the virtual path.
        /// </summary>
        /// <param name="pageModel">The page model.</param>
        /// <param name="routeValueDictionary">The route value dictionary.</param>
        /// <returns></returns>
        public virtual string ResolveVirtualPath(IPageModel pageModel, RouteValueDictionary routeValueDictionary)
        {
            if (pageModel == null) {
                return null;
            }
            var url = pageModel.Metadata.Url ?? string.Empty;

            if (routeValueDictionary.ContainsKey(UIRoute.ActionKey)) {
                _action = routeValueDictionary[UIRoute.ActionKey] as string;
                if (_action != null && !_action.Equals(UIRoute.DefaultAction)) {
                    return string.Format("{0}/{1}/", url, _action);
                }
            }
            return string.Format("{0}", VirtualPathUtility.AppendTrailingSlash(url));
        }
コード例 #19
0
 private List <WebContentResultsModel> GetResults(IPageModel model)
 {
     return(Service
            .FindAll()
            .OrderBy(x => x.WebContentId)
            .Skip(model.PageIndex * model.PageSize)
            .Take(model.PageSize)
            .Select(x => new WebContentResultsModel()
     {
         PageIndex = model.PageIndex,
         PageSize = model.PageSize,
         ResultCount = model.ResultCount,
         WebContentId = x.WebContentId,
         Name = x.Name
     }).ToList());
 }
コード例 #20
0
        /// <summary>
        /// Resolves the virtual path.
        /// </summary>
        /// <param name="pageModel">The page model.</param>
        /// <param name="routeValueDictionary">The route value dictionary.</param>
        /// <returns></returns>
        public virtual string ResolveVirtualPath(IPageModel pageModel, RouteValueDictionary routeValueDictionary)
        {
            if(pageModel == null) {
                throw new BrickPileException("A link cannot be created to a non existing page");
            }

            var url = pageModel.Parent == null ? string.Empty : pageModel.Metadata.Url;

            if (routeValueDictionary.ContainsKey(PageRoute.ActionKey)) {
                _action = routeValueDictionary[PageRoute.ActionKey] as string;
                if (!string.IsNullOrEmpty(_action) && !_action.Equals(PageRoute.DefaultAction)) {
                    return string.Format("{0}/{1}", url, _action);
                }
            }

            return string.Format("{0}", url);
        }
コード例 #21
0
        public IPathData ResolvePath(string virtualUrl)
        {
            // Set the default action to index
            _pathData.Action = ContentRoute.DefaultAction;
            // Set the default controller to content
            _pathData.Controller = ContentRoute.DefaultControllerName;
            // Get an up to date page repository
            _repository = _container.GetInstance<IPageRepository>();
            // The requested url is for the start page with no action
            if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl,"/")) {
                _pageModel = _repository.SingleOrDefault<IPageModel>(x => x.Parent == null);
                _pathData.CurrentPageModel = _pageModel;

                return _pathData;
            }
            // Remove the trailing slash
            virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl);
            // The normal beahaviour should be to load the page based on the url
            _pageModel = _repository.GetPageByUrl<IPageModel>(virtualUrl);
            // Try to load the page without the last segment of the url and set the last segment as action))
            if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) {
                var index = virtualUrl.LastIndexOf("/");
                var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] {'/'});
                virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' });
                _pageModel = _repository.GetPageByUrl<IPageModel>(virtualUrl);
                _pathData.Action = action;
            }

            // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl)
            if(_pageModel == null) {
                _pageModel = _repository.SingleOrDefault<IPageModel>(x => x.Parent == null);
                var controllerName = _controllerMapper.GetControllerName(typeof(ContentController));
                var action = virtualUrl.TrimStart(new[] {'/'});
                if(!_controllerMapper.ControllerHasAction(controllerName,action)) {
                    return null;
                }
                _pathData.Action = action;
            }

            if (_pageModel == null) {
                return null;
            }

            _pathData.CurrentPageModel = _pageModel;
            return _pathData;
        }
コード例 #22
0
        /// <summary>
        /// Resolves the virtual path.
        /// </summary>
        /// <param name="pageModel">The page model.</param>
        /// <param name="routeValueDictionary">The route value dictionary.</param>
        /// <returns></returns>
        public virtual string ResolveVirtualPath(IPageModel pageModel, RouteValueDictionary routeValueDictionary)
        {
            if (pageModel == null)
            {
                return(null);
            }
            var url = pageModel.Metadata.Url ?? string.Empty;

            if (routeValueDictionary.ContainsKey(UIRoute.ActionKey))
            {
                _action = routeValueDictionary[UIRoute.ActionKey] as string;
                if (_action != null && !_action.Equals(UIRoute.DefaultAction))
                {
                    return(string.Format("{0}/{1}/", url, _action));
                }
            }
            return(string.Format("{0}", VirtualPathUtility.AppendTrailingSlash(url)));
        }
コード例 #23
0
        void Frame_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var        tabFrame = Frame;
            IPageModel page     = PageActive;

            if (tabFrame.SelectedIndex < 0 || page == null)
            {
                return;
            }

            if (oldPageActive != null && page != oldPageActive)
            {
                //oldPageActive.Deactivate();
                //oldPageActive = null;
            }

            //page.Activate();
            oldPageActive = page;
        }
コード例 #24
0
 private List <ListBookModel> GetResults(IPageModel model)
 {
     return(Service
            .FindAll()
            .OrderBy(x => x.BookingId)
            .Skip(model.PageIndex * model.PageSize)
            .Take(model.PageSize)
            .Select(x => new ListBookModel()
     {
         PageIndex = model.PageIndex,
         PageSize = model.PageSize,
         ResultCount = model.ResultCount,
         BookingId = x.BookingId,
         CreatedOn = x.CreatedOn,
         Email = x.Email,
         Name = x.Name,
         Telephone = x.Telephone
     }).ToList());
 }
コード例 #25
0
        public void CloseRelatedModels(IPageModel model)
        {
            var views = SecondaryViews.ToArray();

            foreach (var view in views)
            {
                var m = view.DataModel;

                if (m is null)
                {
                    continue;
                }
                if (m.Root != m.Root)
                {
                    continue;
                }

                view.CloseModel();
            }
        }
コード例 #26
0
        /// <summary>
        /// Responsible for providing the Edit view with data from the current page
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit()
        {
            IPageModel parent = _model.Parent != null?_session.Load <IPageModel>(_model.Parent.Id) : null;

            var viewModel = new EditViewModel
            {
                RootModel    = _session.Query <IPageModel>().SingleOrDefault(model => model.Parent == null),
                CurrentModel = _model,
                ParentModel  = parent,
                IlligalSlugs = parent != null?Newtonsoft.Json.JsonConvert.SerializeObject(_session.Load <IPageModel>(parent.Children).Select(x => x.Metadata.Slug)) : null
            };

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Edit", viewModel));
            }

            ViewBag.Class = "edit";
            return(View(viewModel));
        }
コード例 #27
0
ファイル: HtmlHelperExtension.cs プロジェクト: yeshusuper/Flh
 public static IHtmlString Pager(this HtmlHelper helper, IPageModel model,
     int showCount = 10,
     bool isShowHomeAndLast = true,
     bool isShowPrevAndNext = true,
     bool isHomeAndLastInside = true,
     bool isShowInput = true,
     bool isUseDefaultSubmitScript = true,
     bool isWithQueryString = true,
     bool isUrlEncode = false,
     string interval = "<span class=\"{0}\">...</span>",
     string itemTemplate = "<a href=\"{1}\" class=\"{2}\">{0}</a>",
     string indexTemplate = "<b class=\"{1}\">{0}</b>",
     string parentTemplate = null,
     string inputTemplate = "<input class=\"{1}\" value=\"{0}\" />",
     string submitTemplate = "<input type=\"button\" class=\"{0}\" id=\"{1}\" value=\"确定\" />",
     string homeString = null,
     string lastString = null,
     string prevString = "上一页",
     string nextString = "下一页")
 {
     return new Pager(helper,
         model,
         showCount: showCount,
         isShowHomeAndLast: isShowHomeAndLast,
         isShowPrevAndNext: isShowPrevAndNext,
         isHomeAndLastInside: isHomeAndLastInside,
         isShowInput: isShowInput,
         isUseDefaultSubmitScript: isUseDefaultSubmitScript,
         isWithQueryString: isWithQueryString,
         isUrlEncode: isUrlEncode,
         interval: interval,
         itemTemplate: itemTemplate,
         indexTemplate: indexTemplate,
         parentTemplate: parentTemplate,
         inputTemplate: inputTemplate,
         submitTemplate: submitTemplate,
         homeString: homeString,
         lastString: lastString,
         prevString: prevString,
         nextString: nextString);
 }
コード例 #28
0
ファイル: HtmlHelperExtension.cs プロジェクト: pathrough/Flh
 public static IHtmlString Pager(this HtmlHelper helper, IPageModel model,
                                 int showCount                 = 10,
                                 bool isShowHomeAndLast        = true,
                                 bool isShowPrevAndNext        = true,
                                 bool isHomeAndLastInside      = true,
                                 bool isShowInput              = true,
                                 bool isUseDefaultSubmitScript = true,
                                 bool isWithQueryString        = true,
                                 bool isUrlEncode              = false,
                                 string interval               = "<span class=\"{0}\">...</span>",
                                 string itemTemplate           = "<a href=\"{1}\" class=\"{2}\">{0}</a>",
                                 string indexTemplate          = "<b class=\"{1}\">{0}</b>",
                                 string parentTemplate         = null,
                                 string inputTemplate          = "<input class=\"{1}\" value=\"{0}\" />",
                                 string submitTemplate         = "<input type=\"button\" class=\"{0}\" id=\"{1}\" value=\"确定\" />",
                                 string homeString             = null,
                                 string lastString             = null,
                                 string prevString             = "上一页",
                                 string nextString             = "下一页")
 {
     return(new Pager(helper,
                      model,
                      showCount: showCount,
                      isShowHomeAndLast: isShowHomeAndLast,
                      isShowPrevAndNext: isShowPrevAndNext,
                      isHomeAndLastInside: isHomeAndLastInside,
                      isShowInput: isShowInput,
                      isUseDefaultSubmitScript: isUseDefaultSubmitScript,
                      isWithQueryString: isWithQueryString,
                      isUrlEncode: isUrlEncode,
                      interval: interval,
                      itemTemplate: itemTemplate,
                      indexTemplate: indexTemplate,
                      parentTemplate: parentTemplate,
                      inputTemplate: inputTemplate,
                      submitTemplate: submitTemplate,
                      homeString: homeString,
                      lastString: lastString,
                      prevString: prevString,
                      nextString: nextString));
 }
コード例 #29
0
        //
        #region RemoveModelPage  ==============================================
        public void RemoveModelPage(IPageModel model)
        {
            var item = navigationView.MenuItems
                       .OfType <WinUI.NavigationViewItem>()
                       .FirstOrDefault(menuItem => (menuItem.Tag == model));

            if (item is null)
            {
                return;
            }
            navigationView.MenuItems.Remove(item);

            var home = navigationView.MenuItems
                       .OfType <WinUI.NavigationViewItem>()
                       .FirstOrDefault(menuItem => (menuItem.Name == "Home"));

            if (!(home is null))
            {
                home.IsSelected = true;
                NavigationService.Navigate(typeof(MainPage));
            }
        }
コード例 #30
0
        //
        #region InsertModelPage  ==============================================
        public void InsertModelPage(IPageModel model)
        {
            if (model is null)
            {
                return;
            }

            Root.SetLocalizer(Helpers.ResourceExtensions.CoreLocalizer());

            var item = navigationView.MenuItems
                       .OfType <WinUI.NavigationViewItem>()
                       .FirstOrDefault(menuItem => (menuItem.Name == "Home"));

            if (item is null)
            {
                return;
            }

            var index   = navigationView.MenuItems.IndexOf(item) + 2;
            var navItem = new WinUI.NavigationViewItem
            {
                Content = model.TitleName,
                Icon    = new SymbolIcon(Symbol.AllApps),
                Tag     = model
            };

            ToolTipService.SetToolTip(navItem, model.TitleSummary);

            navItem.Loaded += NavItem_Loaded;
            navigationView.MenuItems.Insert(index, navItem);

            //navigationView.SelectedItem = navItem;
            //Selected = navItem;

            NavigationService.Navigate(typeof(ModelPage), model);
        }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <b>PagesController</b> class.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="session">The session.</param>
 public PagesController(IPageModel model, IDocumentSession session)
 {
     _model   = model;
     _session = session;
 }
コード例 #32
0
 public AdminValuesController(IUserModel userModel, ITokenModel token, IPageModel page)
 {
     _page  = page;
     _user  = userModel;
     _token = token;
 }
コード例 #33
0
ファイル: PageList.cs プロジェクト: dasheddot/BrickPile
 private static void RenderLi(StringBuilder sb, string format, IPageModel item, Func<IPageModel, MvcHtmlString> itemContent)
 {
     sb.AppendFormat(format, itemContent(item));
 }
コード例 #34
0
ファイル: HtmlExtensions.cs プロジェクト: sandeep18051989/SMS
 public static Pager Pager(this HtmlHelper helper, IPageModel pager)
 {
     return(new Pager(pager, helper.ViewContext));
 }
コード例 #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PageModelEventArgs"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 public PageModelEventArgs(IPageModel model)
 {
     this.Model = model;
 }
コード例 #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DashboardViewModel"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 public DashboardViewModel(IPageModel model)
 {
     CurrentModel = model;
 }
コード例 #37
0
ファイル: MenuHelper.cs プロジェクト: dasheddot/BrickPile
 /// <summary>
 /// Responsible for creating a navigation based on an unordered list
 /// </summary>
 /// <param name="html">HtmlHelper</param>
 /// <param name="id">Id of the unordered list</param>
 /// <param name="currentModel">The current page in the current request</param>
 /// <param name="hierarchy">The hierarchy.</param>
 /// <param name="itemContent">Default content for links</param>
 /// <returns></returns>
 public static string Menu(this HtmlHelper html, string id, IPageModel currentModel, IEnumerable<IPageModel> hierarchy, Func<IPageModel, MvcHtmlString> itemContent)
 {
     return Menu(html, id, currentModel, hierarchy, itemContent, itemContent);
 }
コード例 #38
0
ファイル: MenuHelper.cs プロジェクト: dasheddot/BrickPile
        /// <summary>
        /// Responsible for creating a main navigation based on an unordered list
        /// </summary>
        /// <param name="html">HtmlHelper</param>
        /// <param name="id">The id of the unordered list</param>
        /// <param name="currentModel">The current model.</param>
        /// <param name="hierarchy">The hierarchy.</param>
        /// <param name="itemContent">Default content for links</param>
        /// <param name="selectedItemContent">Content for selected links</param>
        /// <returns></returns>
        public static string Menu(this HtmlHelper html, string id, IPageModel currentModel, IEnumerable<IPageModel> hierarchy, Func<IPageModel, MvcHtmlString> itemContent, Func<IPageModel, MvcHtmlString> selectedItemContent)
        {
            if (hierarchy== null) {
                return String.Empty;
            }

            var hierarchyNodes = hierarchy.AsHierarchy();
            // only render the top level items

            var items = hierarchyNodes.Where(x => x.Depth == 1);

            var sb = new StringBuilder();
            if(string.IsNullOrEmpty(id)) {
                sb.AppendLine("<ul>");
            }
            else {
                sb.AppendFormat("<ul id=\"{0}\">", id);
            }

            foreach (var item in items)
            {
                RenderLi(sb, "<li>{0}</li>", item.Entity, item.Entity.Equals(currentModel) ? selectedItemContent : itemContent);
            }

            sb.AppendLine("</ul>");
            return sb.ToString();
        }
コード例 #39
0
ファイル: Extensions.cs プロジェクト: sriv/BrickPile
 /// <summary>
 /// Actions the specified URL helper.
 /// </summary>
 /// <param name="urlHelper">The URL helper.</param>
 /// <param name="actionName">Name of the action.</param>
 /// <param name="model">The model.</param>
 /// <returns></returns>
 public static string Action(this UrlHelper urlHelper, string actionName, IPageModel model)
 {
     return(urlHelper.Action(actionName, new { model }));
 }
コード例 #40
0
 public PageInstance(Page aPage, IPageModel aModel)
 {
     iPage  = aPage;
     iModel = aModel;
 }
コード例 #41
0
ファイル: Print.cs プロジェクト: m-berkani/ClearCanvas
			internal Page(PrintJob job, Guid id, IPageModel pageModel)
			{
				_job = job;
				_id = id;
				_templateUri = pageModel.TemplateUrl;
				_variables = pageModel.Variables;
			}
コード例 #42
0
ファイル: Print.cs プロジェクト: m-berkani/ClearCanvas
		/// <summary>
		/// Creates and executes a single-page print job.
		/// </summary>
		/// <param name="pageModel"></param>
		/// <returns></returns>
		public static Result Run(IPageModel pageModel)
		{
			return Run(new[] {pageModel});
		}
コード例 #43
0
 /// <summary>
 /// Creates and executes a single-page print job.
 /// </summary>
 /// <param name="pageModel"></param>
 /// <returns></returns>
 public static Result Run(IPageModel pageModel)
 {
     return(Run(new[] { pageModel }));
 }
コード例 #44
0
        protected override void OnReceive(Session aSession, string aName, string aValue)
        {
            switch (aName)
            {
            case "PreviousPage":
                aSession.Navigator.PreviousPage(aSession);
                return;

            case "ReturnToPage":
                aSession.Navigator.PreviousPage(aSession, aValue);
                return;

            case "LinkClicked":
                System.Diagnostics.Process.Start(aValue);
                return;

            case "DataCollectionEnabled":
                aSession.Tracking = bool.Parse(aValue);
                return;
            }

            if (aName.StartsWith("setData"))
            {
                // get the page model for this session
                IPageModel model = GetSessionModel(aSession);
                Assert.Check(model != null);

                // get the data id to set
                string dataId = aName.Substring(7);

                System.Reflection.PropertyInfo prop = model.GetType().GetProperty(dataId);
                prop.SetValue(model, aValue, null);
            }

            if (aName.StartsWith("action"))
            {
                // get the page model for this session
                IPageModel model = GetSessionModel(aSession);

                // get the action id to process
                string actionId = aName.Substring(6);

                // process all actions with the given id
                foreach (PageDefinitions.Action action in iPageDefinition.Actions)
                {
                    if (action.Id == actionId)
                    {
                        // process <Action type="navigate"> actions
                        PageDefinitions.ActionNavigate actionNav = action as PageDefinitions.ActionNavigate;
                        if (actionNav != null)
                        {
                            if (actionNav.Source != null)
                            {
                                Assert.Check(model != null);

                                // get next page name from data model
                                System.Reflection.PropertyInfo prop = model.GetType().GetProperty(actionNav.Source);
                                string pageId = prop.GetValue(model, null) as string;
                                aSession.Navigator.NextPage(aSession, pageId);
                            }
                            else
                            {
                                // jump to specified page id
                                aSession.Navigator.NextPage(aSession, actionNav.PageId);
                            }
                        }

                        // process <Action type="data"> actions
                        PageDefinitions.ActionData actionData = action as PageDefinitions.ActionData;
                        if (actionData != null)
                        {
                            Assert.Check(model != null);

                            System.Reflection.PropertyInfo prop = model.GetType().GetProperty(actionData.DataId);
                            prop.SetValue(model, (actionData.DataValue != null) ? actionData.DataValue : aValue, null);
                        }

                        // process <Action type="method"> actions
                        PageDefinitions.ActionMethod actionMethod = action as PageDefinitions.ActionMethod;
                        if (actionMethod != null)
                        {
                            Assert.Check(model != null);

                            System.Reflection.MethodInfo method = model.GetType().GetMethod(actionMethod.MethodId);
                            method.Invoke(model, null);
                        }
                    }
                }
            }
        }
コード例 #45
0
ファイル: PagesController.cs プロジェクト: sriv/BrickPile
 /// <summary>
 /// Initializes a new instance of the <b>PagesController</b> class.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="session">The session.</param>
 public PagesController(IPageModel model, IDocumentSession session)
 {
     _model = model;
     _session = session;
 }
コード例 #46
0
 public PageNotExpectedException(IPageModel model, string expectedUrl)
         : base(ToMessage(model, expectedUrl))
 {
 }
コード例 #47
0
 private static string ToMessage(IPageModel model, string expectedUrl)
 {
     return string.Format("Expected URL was {0} but page was created with URL {1}", expectedUrl, model.Url);
 }
コード例 #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PageModelEventArgs"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 public PageModelEventArgs(IPageModel model)
 {
     this.Model = model;
 }
コード例 #49
0
 public GuestBookController(IPageRepository pageRepository, IStructureInfo structureInfo,IPageModel currentPage) {
     _currentPage = currentPage as GuestBook;
     _pageRepository = pageRepository;
     _structureInfo = structureInfo;
 }
コード例 #50
0
ファイル: PathResolver.cs プロジェクト: sriv/BrickPile
        /// <summary>
        /// Resolves the path.
        /// </summary>
        /// <param name="routeData">The route data.</param>
        /// <param name="virtualUrl">The virtual URL.</param>
        /// <returns></returns>
        public IPathData ResolvePath(RouteData routeData, string virtualUrl)
        {
            // Set the default action to index
            _pathData.Action = UIRoute.DefaultAction;
            // Get an up to date document session from structuremap
            _session = _container.GetInstance<IDocumentSession>();

            // The requested url is for the start page with no action
            if (string.IsNullOrEmpty(virtualUrl) || string.Equals(virtualUrl, "/")) {
                _pageModel = _session.Query<IPageModel>()
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .SingleOrDefault(x => x.Parent == null);
            } else {
                // Remove the trailing slash
                virtualUrl = VirtualPathUtility.RemoveTrailingSlash(virtualUrl).TrimStart(new[] { '/' });
                // The normal beahaviour should be to load the page based on the url
                _pageModel = _session.Query<IPageModel, PageByUrl>()
                    .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                    .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
                // Try to load the page without the last segment of the url and set the last segment as action))
                if (_pageModel == null && virtualUrl.LastIndexOf("/") > 0) {
                    var index = virtualUrl.LastIndexOf("/");
                    var action = virtualUrl.Substring(index, virtualUrl.Length - index).Trim(new[] { '/' });
                    virtualUrl = virtualUrl.Substring(0, index).TrimStart(new[] { '/' });
                    _pageModel = _session.Query<IPageModel, PageByUrl>()
                        .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                        .FirstOrDefault(x => x.Metadata.Url == virtualUrl);
                    _pathData.Action = action;
                }
                // If the page model still is empty, let's try to resolve if the start page has an action named (virtualUrl)
                if (_pageModel == null) {
                    _pageModel = _session.Query<IPageModel>().SingleOrDefault(x => x.Parent == null);
                    if(_pageModel == null) {
                        return null;
                    }
                    var pageTypeAttribute = _pageModel.GetType().GetAttribute<PageTypeAttribute>();
                    object area;
                    _controllerName = _controllerMapper.GetControllerName(routeData.Values.TryGetValue("area", out area) ? typeof(PagesController) : pageTypeAttribute.ControllerType);
                    var action = virtualUrl.TrimStart(new[] { '/' });
                    if (!_controllerMapper.ControllerHasAction(_controllerName, action)) {
                        return null;
                    }
                    _pathData.Action = action;
                }
            }

            if (_pageModel == null) {
                return null;
            }

            var controllerType = _pageModel.GetType().GetAttribute<PageTypeAttribute>().ControllerType;
            _pathData.Controller = controllerType != null ? _controllerMapper.GetControllerName(controllerType) : string.Format("{0}Controller", _pageModel.GetType().Name);
            _pathData.CurrentPage = _pageModel;
            _pathData.NavigationContext = _session.GetPublishedPages(_pageModel.Id);
            return _pathData;
        }
コード例 #51
0
 /// <summary>
 /// Initializes a new instance of the <b>PagesController</b> class.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="repository">The repository.</param>
 /// <param name="session">The session.</param>
 public ContentController(IPageModel model, IRepository<IPageModel> repository, IDocumentSession session)
 {
     _model = model;
     _repository = repository;
     _session = session;
 }