public DataServices(DbContext ctx) { DataContext = ctx as BizConnectEntities; Layouts = new LayoutService(DataContext); InvoiceData = new InvoiceDataService(DataContext); Client = new ClientService(DataContext); Invoice = new InvoiceService(DataContext); }
public void OnActionExecuted(ActionExecutedContext filterContext) { ZoneWidgetCollection zones = new ZoneWidgetCollection(); //Page string pageId = filterContext.RequestContext.HttpContext.Request.QueryString["ID"]; PageService pageService = new PageService(); PageEntity page = pageService.Get(pageId); if (page != null) { LayoutService layoutService = new LayoutService(); var layout = layoutService.Get(page.LayoutId); layout.Page = page; WidgetService widgetService = new WidgetService(); IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where<WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID)); Action<WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver; WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { WidgetCollection partCollection = new WidgetCollection(); partCollection.Add(part); zones.Add(part.Widget.ZoneID, partCollection); } } }; widgets.Each(processWidget); IEnumerable<WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where<WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId)); Layoutwidgets.Each(processWidget); layout.ZoneWidgets = zones; ViewResult viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
/// <summary> /// Binds the group members grid. /// </summary> protected void BindLayoutsGrid() { pnlLayouts.Visible = false; int siteId = PageParameter("siteId").AsInteger(); if (siteId == 0) { // quit if the siteId can't be determined return; } var rockContext = new RockContext(); var site = SiteCache.Read(siteId, rockContext); if (site == null) { return; } hfSiteId.SetValue(siteId); pnlLayouts.Visible = true; // Add any missing layouts LayoutService.RegisterLayouts(Request.MapPath("~"), site); LayoutService layoutService = new LayoutService(new RockContext()); var qry = layoutService.Queryable().Where(a => a.SiteId.Equals(siteId)); SortProperty sortProperty = gLayouts.SortProperty; if (sortProperty != null) { gLayouts.DataSource = qry.Sort(sortProperty).ToList(); } else { gLayouts.DataSource = qry.OrderBy(l => l.Name).ToList(); } gLayouts.DataBind(); }
/// <summary> /// Binds the filter. /// </summary> private void BindFilter() { int siteId = PageParameter("siteId").AsInteger(); if (siteId == 0) { // quit if the siteId can't be determined return; } LayoutService.RegisterLayouts(Request.MapPath("~"), SiteCache.Get(siteId)); LayoutService layoutService = new LayoutService(new RockContext()); var layouts = layoutService.Queryable().Where(a => a.SiteId.Equals(siteId)).ToList(); ddlLayoutFilter.DataSource = layouts; ddlLayoutFilter.DataBind(); ddlLayoutFilter.Items.Insert(0, Rock.Constants.All.ListItem); ddlLayoutFilter.Visible = layouts.Any(); ddlLayoutFilter.SetValue(gPagesFilter.GetUserPreference("Layout")); }
public ActionResult NavLast() { LayoutModel layoutModel; layoutService = new LayoutService(); layoutModel = layoutService.NavLast(); if (layoutModel != null) { layoutModel._FormMode = FormModeEnum.Edit; } if (layoutModel == null) { //layoutModel = layoutService.GetNewModel(); throw new Exception("[VALIDATION]-Data not exists"); } return(PartialView(VIEW_FORM_PARTIAL, layoutModel)); }
/// <summary> /// Handles the Click event of the btnCancel control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnCancel_Click(object sender, EventArgs e) { if (hfLayoutId.Value.Equals("0")) { // Cancelling on Add Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["siteId"] = hfSiteId.Value; NavigateToParentPage(qryString); } else { // Cancelling on Edit LayoutService layoutService = new LayoutService(); Layout layout = layoutService.Get(int.Parse(hfLayoutId.Value)); Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["siteId"] = layout.SiteId.ToString(); NavigateToParentPage(qryString); } }
public void PrepareEZLayout_OneLayer_ManyKeys() { // Arrange ILayoutService layoutService = new LayoutService(); ErgodoxLayout ergodoxLayout = InitializeDataTree(); var keys = ergodoxLayout.Revision.Layers.First().Keys; keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_A" }); keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_0" }); keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_TRANSPARENT" }); EZLayout ezLayoutResult; // Act ezLayoutResult = layoutService.PrepareEZLayout(ergodoxLayout); // Assert Assert.Single(ezLayoutResult.EZLayers); Assert.Equal(3, ezLayoutResult.EZLayers.First().EZKeys.Count); var keyResults = ezLayoutResult.EZLayers.First().EZKeys; Assert.Equal("A", keyResults[0].Label.Content); Assert.Equal(KeyCategory.Letters, keyResults[0].KeyCategory); Assert.Equal("0", keyResults[1].Label.Content); Assert.Equal(KeyCategory.Digit, keyResults[1].KeyCategory); Assert.Equal("", keyResults[2].Label.Content); Assert.Equal(KeyCategory.Other, keyResults[2].KeyCategory); }
public App() { InitializeComponent(); //tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "LogFile.txt"); //File.AppendAllText(App.tempFile, "Add log to File"); //Debug.WriteLine("File Name====" + App.tempFile); FlowListView.Init(); LayoutService.Init(); XF.Material.Forms.Material.Init(this); NavigationPage navPage = new NavigationPage { BarBackgroundColor = Color.White, BarTextColor = Color.Black, }; if (Settings.LoggedInUser != null) { IsFirstTime = true; MainPage = new NavigationPage(new LandingPage()) { BarTextColor = Color.Black, BarBackgroundColor = Color.White }; } else { MainPage = new NavigationPage(new LoginPage()) { BarTextColor = Color.Black, BarBackgroundColor = Color.White }; } }
public MainWindow() { InitializeComponent(); SaveCommandBinding.Command = SaveCommand; SaveMenuItem.Command = SaveCommand; SaveLayoutCommandBinding.Command = SaveLayoutCommand; SaveLayoutMenuItem.Command = SaveLayoutCommand; ReloadLayoutCommandBinding.Command = ReloadLayoutCommand; ReloadLayoutMenuItem.Command = ReloadLayoutCommand; _layoutService = new LayoutService(); CheckMenuItems(); var anchorable = new LayoutAnchorable { Content = new ConnectionOverview(DisplayConnection), Title = Properties.Resources.Connections, ContentId = "ConnectionsId", IsActive = true, IsSelected = true, CanFloat = true, CanAutoHide = true, CanClose = false, CanHide = false }; anchorable.AddToLayout(DockingManager, AnchorableShowStrategy.Left); anchorable.DockAsDocument(); OpenConnectionWithAutoOpen(); }
public App() { InitializeComponent(); //tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "LogFile.txt"); //File.AppendAllText(App.tempFile, "Add log to File"); //Debug.WriteLine("File Name====" + App.tempFile); FlowListView.Init(); LayoutService.Init(); XF.Material.Forms.Material.Init(this); // MainPage = new MainPage(); //App.Current.Properties["REFRESHTOKEN"] =token; NavigationPage navPage = new NavigationPage { BarBackgroundColor = Color.White, BarTextColor = Color.Black }; //MainPage = new NavigationPage(new MainPage()) //{ // BarTextColor = Color.White, // BarBackgroundColor= Color.FromHex("#002343") //}; MainPage = new NavigationPage(new LoginPage()) { BarTextColor = Color.Black, BarBackgroundColor = Color.White }; bindingContext = (BaseViewModel)this.BindingContext; App.Current.Resources["MsgCount"] = "0"; //MainPage = new NavigationPage(new LoginPage()); }
protected override void OnStart() { Settings.DeviceToken = CrossPushNotification.Current.Token; CrossPushNotification.Current.OnTokenRefresh += (s, p) => { if (Device.RuntimePlatform == Device.iOS) { System.Diagnostics.Debug.WriteLine($"TOKEN REC: {Settings.DeviceToken}"); Console.WriteLine("Token ref : " + Settings.DeviceToken); } else { Settings.DeviceToken = p.Token; System.Diagnostics.Debug.WriteLine($"TOKEN REC: {Settings.DeviceToken}"); Console.WriteLine("Token ref : " + Settings.DeviceToken); } }; System.Diagnostics.Debug.WriteLine($"TOKEN: {CrossPushNotification.Current.Token}"); Console.WriteLine("Token " + CrossPushNotification.Current.Token); CrossPushNotification.Current.OnNotificationReceived += (s, p) => { try { System.Diagnostics.Debug.WriteLine("Received"); Settings.MessageCount++; LayoutService.Init(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }; CrossPushNotification.Current.OnNotificationOpened += (s, p) => { System.Diagnostics.Debug.WriteLine("Opened"); foreach (var data in p.Data) { System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}"); } }; CrossPushNotification.Current.OnNotificationAction += (s, p) => { System.Diagnostics.Debug.WriteLine("Action"); if (!string.IsNullOrEmpty(p.Identifier)) { System.Diagnostics.Debug.WriteLine($"ActionId: {p.Identifier}"); foreach (var data in p.Data) { System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}"); } } }; CrossPushNotification.Current.OnNotificationDeleted += (s, p) => { System.Diagnostics.Debug.WriteLine("Dismissed"); }; }
/// <summary> /// Shows the detail. /// </summary> /// <param name="layoutId">The layout identifier.</param> /// <param name="siteId">The group id.</param> public void ShowDetail(int layoutId, int?siteId) { Layout layout = null; if (!layoutId.Equals(0)) { layout = new LayoutService(new RockContext()).Get(layoutId); } if (layout == null && siteId.HasValue) { var site = SiteCache.Read(siteId.Value); if (site != null) { layout = new Layout { Id = 0 }; layout.SiteId = siteId.Value; } } if (layout == null) { pnlDetails.Visible = false; return; } hfSiteId.Value = layout.SiteId.ToString(); hfLayoutId.Value = layout.Id.ToString(); bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized(Authorization.EDIT)) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Rock.Model.Layout.FriendlyTypeName); } if (layout.IsSystem) { nbEditModeMessage.Text = EditModeMessage.System(Rock.Model.Layout.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; //btnDelete.Visible = false; ShowReadonlyDetails(layout); } else { btnEdit.Visible = true; //btnDelete.Visible = !layout.IsSystem; if (layout.Id > 0) { ShowReadonlyDetails(layout); } else { ShowEditDetails(layout); } } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { Site site; if (Page.IsValid) { var rockContext = new RockContext(); SiteService siteService = new SiteService(rockContext); SiteDomainService siteDomainService = new SiteDomainService(rockContext); bool newSite = false; int siteId = hfSiteId.Value.AsInteger(); if (siteId == 0) { newSite = true; site = new Rock.Model.Site(); siteService.Add(site); } else { site = siteService.Get(siteId); } site.Name = tbSiteName.Text; site.Description = tbDescription.Text; site.Theme = ddlTheme.Text; site.DefaultPageId = ppDefaultPage.PageId; site.DefaultPageRouteId = ppDefaultPage.PageRouteId; site.LoginPageId = ppLoginPage.PageId; site.LoginPageRouteId = ppLoginPage.PageRouteId; site.ChangePasswordPageId = ppChangePasswordPage.PageId; site.ChangePasswordPageRouteId = ppChangePasswordPage.PageRouteId; site.CommunicationPageId = ppCommunicationPage.PageId; site.CommunicationPageRouteId = ppCommunicationPage.PageRouteId; site.RegistrationPageId = ppRegistrationPage.PageId; site.RegistrationPageRouteId = ppRegistrationPage.PageRouteId; site.PageNotFoundPageId = ppPageNotFoundPage.PageId; site.PageNotFoundPageRouteId = ppPageNotFoundPage.PageRouteId; site.ErrorPage = tbErrorPage.Text; site.GoogleAnalyticsCode = tbGoogleAnalytics.Text; site.RequiresEncryption = cbRequireEncryption.Checked; site.EnableMobileRedirect = cbEnableMobileRedirect.Checked; site.MobilePageId = ppMobilePage.PageId; site.ExternalUrl = tbExternalURL.Text; site.AllowedFrameDomains = tbAllowedFrameDomains.Text; site.RedirectTablets = cbRedirectTablets.Checked; site.EnablePageViews = cbEnablePageViews.Checked; site.PageViewRetentionPeriodDays = nbPageViewRetentionPeriodDays.Text.AsIntegerOrNull(); site.AllowIndexing = cbAllowIndexing.Checked; site.PageHeaderContent = cePageHeaderContent.Text; var currentDomains = tbSiteDomains.Text.SplitDelimitedValues().ToList <string>(); site.SiteDomains = site.SiteDomains ?? new List <SiteDomain>(); // Remove any deleted domains foreach (var domain in site.SiteDomains.Where(w => !currentDomains.Contains(w.Domain)).ToList()) { site.SiteDomains.Remove(domain); siteDomainService.Delete(domain); } foreach (string domain in currentDomains) { SiteDomain sd = site.SiteDomains.Where(d => d.Domain == domain).FirstOrDefault(); if (sd == null) { sd = new SiteDomain(); sd.Domain = domain; sd.Guid = Guid.NewGuid(); site.SiteDomains.Add(sd); } } if (!site.DefaultPageId.HasValue && !newSite) { ppDefaultPage.ShowErrorMessage("Default Page is required."); return; } if (!site.IsValid) { // Controls will render the error messages return; } rockContext.WrapTransaction(() => { rockContext.SaveChanges(); if (newSite) { Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, rockContext, Authorization.EDIT); Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, rockContext, Authorization.ADMINISTRATE); Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, rockContext, Authorization.APPROVE); } }); SiteCache.Flush(site.Id); // Create the default page is this is a new site if (!site.DefaultPageId.HasValue && newSite) { var siteCache = SiteCache.Read(site.Id); // Create the layouts for the site, and find the first one LayoutService.RegisterLayouts(Request.MapPath("~"), siteCache); var layoutService = new LayoutService(rockContext); var layouts = layoutService.GetBySiteId(siteCache.Id); Layout layout = layouts.FirstOrDefault(l => l.FileName.Equals("FullWidth", StringComparison.OrdinalIgnoreCase)); if (layout == null) { layout = layouts.FirstOrDefault(); } if (layout != null) { var pageService = new PageService(rockContext); var page = new Page(); page.LayoutId = layout.Id; page.PageTitle = siteCache.Name + " Home Page"; page.InternalName = page.PageTitle; page.BrowserTitle = page.PageTitle; page.EnableViewState = true; page.IncludeAdminFooter = true; page.MenuDisplayChildPages = true; var lastPage = pageService.GetByParentPageId(null).OrderByDescending(b => b.Order).FirstOrDefault(); page.Order = lastPage != null ? lastPage.Order + 1 : 0; pageService.Add(page); rockContext.SaveChanges(); site = siteService.Get(siteCache.Id); site.DefaultPageId = page.Id; rockContext.SaveChanges(); SiteCache.Flush(site.Id); } } var qryParams = new Dictionary <string, string>(); qryParams["siteId"] = site.Id.ToString(); NavigateToPage(RockPage.Guid, qryParams); } }
public MainViewModel(NavigationService navService, LayoutService layService) { navigationService = navService; layoutService = layService; }
public void PrepareEZLayout_TwoLayer_ManyKeys() { // Arrange ILayoutService layoutService = new LayoutService(); ErgodoxLayout ergodoxLayout = InitializeDataTree(); var layer0Keys = ergodoxLayout.Revision.Layers.First().Keys; layer0Keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_A" }); layer0Keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_0" }); layer0Keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_TRANSPARENT" }); ergodoxLayout.Revision .Layers.Add(new ErgodoxLayer { Color = "color", Title = "Layer 2", Position = 1, Keys = new List <ErgodoxKey>() }); var layer1Keys = ergodoxLayout.Revision.Layers[1].Keys; layer1Keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_F1" }); layer1Keys.Add(new ErgodoxKey() { GlowColor = "", Code = "KC_SPACE" }); // Act var ezLayoutResult = layoutService.PrepareEZLayout(ergodoxLayout); // Assert Assert.Equal(2, ezLayoutResult.EZLayers.Count); Assert.Equal(3, ezLayoutResult.EZLayers[0].EZKeys.Count); Assert.Equal(2, ezLayoutResult.EZLayers[1].EZKeys.Count); var layer0KeyResults = ezLayoutResult.EZLayers[0].EZKeys; Assert.Equal("A", layer0KeyResults[0].Label.Content); Assert.Equal(KeyCategory.Letters, layer0KeyResults[0].KeyCategory); Assert.Equal("0", layer0KeyResults[1].Label.Content); Assert.Equal(KeyCategory.Digit, layer0KeyResults[1].KeyCategory); Assert.Equal("", layer0KeyResults[2].Label.Content); Assert.Equal(KeyCategory.Other, layer0KeyResults[2].KeyCategory); var layer1KeyResults = ezLayoutResult.EZLayers[1].EZKeys; Assert.Equal("F1", layer1KeyResults[0].Label.Content); Assert.Equal(KeyCategory.Fn, layer1KeyResults[0].KeyCategory); Assert.Equal("\u23b5", layer1KeyResults[1].Label.Content); Assert.Equal(KeyCategory.Spacing, layer1KeyResults[1].KeyCategory); }
private ServiceBase getService(string className) { ServiceBase service = null; if (className.Equals("com.liferay.portal.model.User")) { service = new UserService(_session); } else if (className.Equals("com.liferay.portal.model.Address")) { service = new AddressService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetCategory")) { service = new AssetCategoryService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetEntry")) { service = new AssetEntryService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetTag")) { service = new AssetTagService(_session); } else if (className.Equals("com.liferay.portlet.asset.model.AssetVocabulary")) { service = new AssetVocabularyService(_session); } else if (className.Equals("com.liferay.portlet.blogs.model.BlogsEntry")) { service = new BlogsEntryService(_session); } else if (className.Equals("com.liferay.portlet.bookmarks.model.BookmarksEntry")) { service = new BookmarksEntryService(_session); } else if (className.Equals("com.liferay.portlet.bookmarks.model.BookmarksFolder")) { service = new BookmarksFolderService(_session); } else if (className.Equals("com.liferay.portal.model.Company")) { service = new CompanyService(_session); } else if (className.Equals("com.liferay.portal.model.Contact")) { service = new ContactService(_session); } else if (className.Equals("com.liferay.portal.model.Country")) { service = new CountryService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatalists.model.DDLRecord")) { service = new DDLRecordService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatalists.model.DDLRecordSet")) { service = new DDLRecordSetService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatamapping.model.DDMStructure")) { service = new DDMStructureService(_session); } else if (className.Equals("com.liferay.portlet.dynamicdatamapping.model.DDMTemplate")) { service = new DDMTemplateService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFileEntry")) { service = new DLFileEntryService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFileEntryType")) { service = new DLFileEntryTypeService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFileVersion")) { service = new DLFileVersionService(_session); } else if (className.Equals("com.liferay.portlet.documentlibrary.model.DLFolder")) { service = new DLFolderService(_session); } else if (className.Equals("com.liferay.portal.model.EmailAddress")) { service = new EmailAddressService(_session); } else if (className.Equals("com.liferay.portlet.expando.model.ExpandoColumn")) { service = new ExpandoColumnService(_session); } else if (className.Equals("com.liferay.portlet.expando.model.ExpandoValue")) { service = new ExpandoValueService(_session); } else if (className.Equals("com.liferay.portal.model.Group")) { service = new GroupService(_session); } else if (className.Equals("com.liferay.portal.model.Image")) { service = new ImageService(_session); } else if (className.Equals("com.liferay.portlet.journal.model.JournalArticle")) { service = new JournalArticleService(_session); } else if (className.Equals("com.liferay.portlet.journal.model.JournalFeed")) { service = new JournalFeedService(_session); } else if (className.Equals("com.liferay.portlet.journal.model.JournalFolder")) { service = new JournalFolderService(_session); } else if (className.Equals("com.liferay.portal.model.Layout")) { service = new LayoutService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutBranch")) { service = new LayoutBranchService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutPrototype")) { service = new LayoutPrototypeService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutRevision")) { service = new LayoutRevisionService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutSet")) { service = new LayoutSetService(_session); } else if (className.Equals("com.liferay.portal.model.LayoutSetPrototype")) { service = new LayoutSetPrototypeService(_session); } else if (className.Equals("com.liferay.portal.model.ListType")) { service = new ListTypeService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBBan")) { service = new MBBanService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBCategory")) { service = new MBCategoryService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBMessage")) { service = new MBMessageService(_session); } else if (className.Equals("com.liferay.portlet.messageboards.model.MBThread")) { service = new MBThreadService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRAction")) { service = new MDRActionService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRRule")) { service = new MDRRuleService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRRuleGroup")) { service = new MDRRuleGroupService(_session); } else if (className.Equals("com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance")) { service = new MDRRuleGroupInstanceService(_session); } else if (className.Equals("com.liferay.portal.model.MembershipRequest")) { service = new MembershipRequestService(_session); } else if (className.Equals("com.liferay.portal.model.Organization")) { service = new OrganizationService(_session); } else if (className.Equals("com.liferay.portal.model.OrgLabor")) { service = new OrgLaborService(_session); } else if (className.Equals("com.liferay.portal.model.PasswordPolicy")) { service = new PasswordPolicyService(_session); } else if (className.Equals("Permission")) { service = new PermissionService(_session); } else if (className.Equals("com.liferay.portal.model.Phone")) { service = new PhoneService(_session); } else if (className.Equals("Portal")) { service = new PortalService(_session); } else if (className.Equals("com.liferay.portal.model.Portlet")) { service = new PortletService(_session); } else if (className.Equals("com.liferay.portal.model.PortletPreferences")) { service = new PortletPreferencesService(_session); } else if (className.Equals("com.liferay.portal.model.Repository")) { service = new RepositoryService(_session); } else if (className.Equals("com.liferay.portal.model.ResourcePermission")) { service = new ResourcePermissionService(_session); } else if (className.Equals("com.liferay.portal.model.Role")) { service = new RoleService(_session); } else if (className.Equals("com.liferay.portal.model.Team")) { service = new TeamService(_session); } else if (className.Equals("com.liferay.portal.model.UserGroup")) { service = new UserGroupService(_session); } else if (className.Equals("com.liferay.portal.model.UserGroupGroupRole")) { service = new UserGroupGroupRoleService(_session); } else if (className.Equals("com.liferay.portal.model.UserGroupRole")) { service = new UserGroupRoleService(_session); } else if (className.Equals("com.liferay.portlet.wiki.model.WikiNode")) { service = new WikiNodeService(_session); } else if (className.Equals("com.liferay.portlet.wiki.model.WikiPage")) { service = new WikiPageService(_session); } return(service); }
/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> /// <param name="siteId">The group id.</param> public void ShowDetail(string itemKey, int itemKeyValue, int?siteId) { if (!itemKey.Equals("layoutId")) { return; } Layout layout = null; if (!itemKeyValue.Equals(0)) { layout = new LayoutService(new RockContext()).Get(itemKeyValue); } else { // only create a new one if parent was specified if (siteId.HasValue) { layout = new Layout { Id = 0 }; layout.SiteId = siteId.Value; } } if (layout == null) { return; } hfSiteId.Value = layout.SiteId.ToString(); hfLayoutId.Value = layout.Id.ToString(); bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized(Authorization.EDIT)) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Rock.Model.Layout.FriendlyTypeName); } if (layout.IsSystem) { nbEditModeMessage.Text = EditModeMessage.System(Rock.Model.Layout.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; //btnDelete.Visible = false; ShowReadonlyDetails(layout); } else { btnEdit.Visible = true; //btnDelete.Visible = !layout.IsSystem; if (layout.Id > 0) { ShowReadonlyDetails(layout); } else { ShowEditDetails(layout); } } }
protected void ConfirmNo() { LayoutService.ConfirmDialog(false); }
public IResource GetResource(ResourceTypeEnum type) { IResource resource = null; if (_resourcesMap.TryGetValue(type, out resource) == true) { return(resource); } switch (type) { case ResourceTypeEnum.QuizzCurrentUserRating: resource = new QuizzCurrentUserRatingService(_controller); break; case ResourceTypeEnum.QuizzUserRating: resource = new QuizzUserRatingService(_controller); break; case ResourceTypeEnum.AssignmentGroup: resource = new AssignmentGroupService(_controller); break; case ResourceTypeEnum.Assignment: resource = new AssignmentService(_controller); break; case ResourceTypeEnum.TestSnapshot: resource = new TestSnapshotService(_controller); break; case ResourceTypeEnum.QuizzCategories: resource = new QuizzCategoryService(_controller); break; case ResourceTypeEnum.QuizzerInfo: resource = new QuizzerInfoService(_controller); break; case ResourceTypeEnum.BadgeList: resource = new BadgeService(_controller); break; case ResourceTypeEnum.QuizzmateRequest: resource = new QuizzmateRequestService(_controller); break; case ResourceTypeEnum.QuizzlingRequest: resource = new QuizzlingRequestService(_controller); break; case ResourceTypeEnum.RelationshipNotification: resource = new RelationshipNotificationService(_controller); break; case ResourceTypeEnum.Quizzmates: resource = new QuizzmatesService(_controller); break; case ResourceTypeEnum.QuizzmateMsgThread: resource = new QuizzmateMsgThreadService(_controller); break; case ResourceTypeEnum.QuizzmateMsgThreadMember: resource = new QuizzmateMsgThreadMemberService(_controller); break; case ResourceTypeEnum.QuizzmateMsg: resource = new QuizzmateMsgService(_controller); break; case ResourceTypeEnum.QuizzConnectMsgThread: resource = new QuizzConnectMsgThreadService(_controller); break; case ResourceTypeEnum.QuizzClass: resource = new QuizzClassService(_controller); break; case ResourceTypeEnum.QuizzClassAnnouncement: resource = new QuizzClassAnnouncementService(_controller); break; case ResourceTypeEnum.QuizzClassComment: resource = new QuizzClassCommentService(_controller); break; case ResourceTypeEnum.QuizzClassLesson: resource = new QuizzClassLessonService(_controller); break; case ResourceTypeEnum.QuizzClassLessonMessage: resource = new QuizzClassLessonMessageService(_controller); break; case ResourceTypeEnum.QuizzClassLessonComment: resource = new QuizzClassLessonCommentService(_controller); break; case ResourceTypeEnum.QuizzClassJoinRequest: resource = new QuizzClassJoinService(_controller); break; case ResourceTypeEnum.QuizzClassMember: resource = new QuizzClassMemberService(_controller); break; case ResourceTypeEnum.QuizzClassInviteRequest: resource = new QuizzClassInviteService(_controller); break; case ResourceTypeEnum.QuizzClassMemberInvite: resource = new QuizzClassMemberInviteService(_controller); break; case ResourceTypeEnum.QuizzClassLessonQuizz: resource = new QuizzClassLessonQuizzService(_controller); break; case ResourceTypeEnum.QuizzClassQuizz: resource = new QuizzClassQuizzService(_controller); break; case ResourceTypeEnum.Layout: resource = new LayoutService(_controller); break; case ResourceTypeEnum.QuizzComment: resource = new QuizzCommentService(_controller); break; case ResourceTypeEnum.QuizzQuickNote: resource = new QuickNoteService(_controller); break; case ResourceTypeEnum.FlashCards: resource = new TextFlashCardService(_controller); break; case ResourceTypeEnum.ReviewerFromQuestions: resource = new ReviewerFromQuestionsService(_controller); break; case ResourceTypeEnum.TestLog: resource = new TestLogService(_controller); break; default: break; } if (resource != null) { _resourcesMap.Add(type, resource); } return(resource); }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { var applicationId = PageParameter(PageParameterKey.SiteId).AsInteger(); var rockContext = new RockContext(); var siteService = new SiteService(rockContext); var site = siteService.Get(applicationId); var additionalSettings = new AppleTvApplicationSettings(); var isNewSite = false; // Site is new so create one if (site == null) { site = new Site(); siteService.Add(site); isNewSite = true; } else { additionalSettings = JsonConvert.DeserializeObject <AppleTvApplicationSettings>(site.AdditionalSettings); } site.Name = tbApplicationName.Text; site.Description = tbDescription.Text; site.IsActive = cbIsActive.Checked; site.SiteType = SiteType.Tv; additionalSettings.ApplicationScript = ceApplicationJavaScript.Text; additionalSettings.ApplicationStyles = ceApplicationStyles.Text; additionalSettings.TvApplicationType = TvApplicationType.AppleTv; // Login page site.LoginPageId = ppLoginPage.PageId; site.LoginPageRouteId = ppLoginPage.PageRouteId; // Create/Modify API Key additionalSettings.ApiKeyId = SaveApiKey(additionalSettings.ApiKeyId, txtApiKey.Text, string.Format("tv_application_{0}", site.Id), rockContext); site.AdditionalSettings = additionalSettings.ToJson(); rockContext.SaveChanges(); // Create interaction channel for this site var interactionChannelService = new InteractionChannelService(rockContext); int channelMediumWebsiteValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.INTERACTIONCHANNELTYPE_WEBSITE.AsGuid()).Id; var interactionChannelForSite = interactionChannelService.Queryable() .Where(a => a.ChannelTypeMediumValueId == channelMediumWebsiteValueId && a.ChannelEntityId == site.Id).FirstOrDefault(); if (interactionChannelForSite == null) { interactionChannelForSite = new InteractionChannel(); interactionChannelForSite.ChannelTypeMediumValueId = channelMediumWebsiteValueId; interactionChannelForSite.ChannelEntityId = site.Id; interactionChannelService.Add(interactionChannelForSite); } interactionChannelForSite.Name = site.Name; interactionChannelForSite.RetentionDuration = nbPageViewRetentionPeriodDays.Text.AsIntegerOrNull(); interactionChannelForSite.ComponentEntityTypeId = EntityTypeCache.Get <Rock.Model.Page>().Id; rockContext.SaveChanges(); // If this is a new site then we also need to add a layout record and a 'default page' if (isNewSite) { var layoutService = new LayoutService(rockContext); var layout = new Layout { Name = "Homepage", FileName = "Homepage.xaml", Description = string.Empty, SiteId = site.Id }; layoutService.Add(layout); rockContext.SaveChanges(); var pageService = new PageService(rockContext); var page = new Rock.Model.Page { InternalName = "Start Screen", BrowserTitle = "Start Screen", PageTitle = "Start Screen", DisplayInNavWhen = DisplayInNavWhen.WhenAllowed, Description = string.Empty, LayoutId = layout.Id, Order = 0 }; pageService.Add(page); rockContext.SaveChanges(); site.DefaultPageId = page.Id; rockContext.SaveChanges(); } // If the save was successful, reload the page using the new record Id. var qryParams = new Dictionary <string, string>(); qryParams[PageParameterKey.SiteId] = site.Id.ToString(); NavigateToPage(RockPage.Guid, qryParams); }
public static void Load(XmlNode rootNode) { if (service == null) service = new LayoutService(() => rootNode); else throw new ApplicationException("LayoutManager is already initialized."); }
protected override void OnInitialized() { LayoutService.SetBaseTheme(Theme.DocsTheme()); }
/// <summary> /// Handles the Click event of the btnEdit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnEdit_Click(object sender, EventArgs e) { var layout = new LayoutService(new RockContext()).Get(int.Parse(hfLayoutId.Value)); ShowEditDetails(layout); }
/// <summary> /// Recursively saves Pages and associated Blocks, PageRoutes and PageContexts. /// </summary> /// <param name="rockContext">The rock context.</param> /// <param name="page">The current Page to save</param> /// <param name="newBlockTypes">List of BlockTypes not currently installed</param> /// <param name="parentPageId">Id of the current Page's parent</param> /// <param name="siteId">Id of the site the current Page is being imported into</param> private void SavePages(RockContext rockContext, Page page, IEnumerable <BlockType> newBlockTypes, int parentPageId, int siteId) { rockContext = rockContext ?? new RockContext(); // find layout var layoutService = new LayoutService(rockContext); Layout layout = new Layout(); if (page.Layout != null) { layout = layoutService.GetBySiteId(siteId).Where(l => l.Name == page.Layout.Name && l.FileName == page.Layout.FileName).FirstOrDefault(); if (layout == null) { layout = new Layout(); layout.FileName = page.Layout.FileName; layout.Name = page.Layout.Name; layout.SiteId = siteId; layoutService.Add(layout); rockContext.SaveChanges(); } } else { layout = layoutService.GetBySiteId(siteId).Where(l => l.Name.Contains("Full") || l.Name.Contains("Home")).First(); } int layoutId = layout.Id; // Force shallow copies on entities so save operations are more atomic and don't get hosed // by nested object references. var pg = page.Clone(deepCopy: false); var blockTypes = newBlockTypes.ToList(); pg.ParentPageId = parentPageId; pg.LayoutId = layoutId; var pageService = new PageService(rockContext); pageService.Add(pg); rockContext.SaveChanges(); var blockService = new BlockService(rockContext); foreach (var block in page.Blocks ?? new List <Block>()) { var blockType = blockTypes.FirstOrDefault(bt => block.BlockType.Path == bt.Path); var b = block.Clone(deepCopy: false); b.PageId = pg.Id; if (blockType != null) { b.BlockTypeId = blockType.Id; } blockService.Add(b); } rockContext.SaveChanges(); var pageRouteService = new PageRouteService(rockContext); foreach (var pageRoute in page.PageRoutes ?? new List <PageRoute>()) { var pr = pageRoute.Clone(deepCopy: false); pr.PageId = pg.Id; pageRouteService.Add(pr); } rockContext.SaveChanges(); var pageContextService = new PageContextService(rockContext); foreach (var pageContext in page.PageContexts ?? new List <PageContext>()) { var pc = pageContext.Clone(deepCopy: false); pc.PageId = pg.Id; pageContextService.Add(pc); } rockContext.SaveChanges(); foreach (var p in page.Pages ?? new List <Page>()) { SavePages(rockContext, p, blockTypes, pg.Id, siteId); } }
public AdditionalViewModel(NavigationService navService, LayoutService layService) { navigationService = navService; layoutService = layService; }
protected void ConfirmYes() { //Do not clear LayoutService.AdditionalLogon here, were in the middle of an await. LayoutService.ConfirmDialog(true); }
/// <summary> /// Binds the pages grid. /// </summary> protected void BindPagesGrid() { pnlPages.Visible = false; int siteId = PageParameter("siteId").AsInteger(); if (siteId == 0) { // quit if the siteId can't be determined return; } hfSiteId.SetValue(siteId); pnlPages.Visible = true; // Question: Is this RegisterLayouts necessary here? Since if it's a new layout // there would not be any pages on them (which is our concern here). // It seems like it should be the concern of some other part of the puzzle. LayoutService.RegisterLayouts(Request.MapPath("~"), SiteCache.Read(siteId)); //var layouts = layoutService.Queryable().Where( a => a.SiteId.Equals( siteId ) ).Select( a => a.Id ).ToList(); // Find all the pages that are related to this site... // 1) pages used by one of this site's layouts and // 2) the site's 'special' pages used directly by the site. var rockContext = new RockContext(); var siteService = new SiteService(rockContext); var pageService = new PageService(rockContext); var site = siteService.Get(siteId); if (site != null) { var sitePages = new List <int> { site.DefaultPageId ?? -1, site.LoginPageId ?? -1, site.RegistrationPageId ?? -1, site.PageNotFoundPageId ?? -1 }; var qry = pageService.Queryable("Layout") .Where(t => t.Layout.SiteId == siteId || sitePages.Contains(t.Id)); string layoutFilter = gPagesFilter.GetUserPreference("Layout"); if (!string.IsNullOrWhiteSpace(layoutFilter) && layoutFilter != Rock.Constants.All.Text) { qry = qry.Where(a => a.Layout.ToString() == layoutFilter); } SortProperty sortProperty = gPages.SortProperty; if (sortProperty != null) { qry = qry.Sort(sortProperty); } else { qry = qry .OrderBy(t => t.Layout.Name) .ThenBy(t => t.InternalName); } gPages.DataSource = qry.ToList(); gPages.DataBind(); } }
/// <summary> /// Handles the Click event of the btnDeleteConfirm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnDeleteConfirm_Click(object sender, EventArgs e) { bool canDelete = false; var rockContext = new RockContext(); SiteService siteService = new SiteService(rockContext); Site site = siteService.Get(hfSiteId.Value.AsInteger()); LayoutService layoutService = new LayoutService(rockContext); PageService pageService = new PageService(rockContext); PageViewService pageViewService = new PageViewService(rockContext); if (site != null) { var sitePages = new List <int> { site.DefaultPageId ?? -1, site.LoginPageId ?? -1, site.RegistrationPageId ?? -1, site.PageNotFoundPageId ?? -1 }; foreach (var pageView in pageViewService .Queryable() .Where(t => t.Page != null && t.Page.Layout != null && t.Page.Layout.SiteId == site.Id)) { pageView.Page = null; pageView.PageId = null; } var pageQry = pageService.Queryable("Layout") .Where(t => t.Layout.SiteId == site.Id || sitePages.Contains(t.Id)); pageService.DeleteRange(pageQry); var layoutQry = layoutService.Queryable() .Where(l => l.SiteId == site.Id); layoutService.DeleteRange(layoutQry); rockContext.SaveChanges(true); string errorMessage; canDelete = siteService.CanDelete(site, out errorMessage, includeSecondLvl: true); if (!canDelete) { mdDeleteWarning.Show(errorMessage, ModalAlertType.Alert); return; } siteService.Delete(site); rockContext.SaveChanges(); SiteCache.Flush(site.Id); } NavigateToParentPage(); }
public void OnActionExecuted(ActionExecutedContext filterContext) { var zones = new ZoneWidgetCollection(); var cache = new StaticCache(); //Page string path = filterContext.RequestContext.HttpContext.Request.Path; if (path.EndsWith("/") && path.Length > 1) { path = path.Substring(0, path.Length - 1); //filterContext.HttpContext.Response.Redirect(path); filterContext.Result = new RedirectResult(path); return; } bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase); var page = new PageService().GetByPath(path, publish); if (page != null) { var layoutService = new LayoutService(); LayoutEntity layout = layoutService.Get(page.LayoutId); layout.Page = page; Action<WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source => Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver ); WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { var partCollection = new WidgetCollection { part }; zones.Add(part.Widget.ZoneID, partCollection); } } }; var layoutWidgetsTask = Task.Factory.StartNew(layoutId => { var widgetServiceIn = new WidgetService(); IEnumerable<WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId)); layoutwidgets.Each(processWidget); }, page.LayoutId); var widgetService = new WidgetService(); IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID)); int middle = widgets.Count() / 2; var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget)); widgets.Take(middle).Each(processWidget); Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask }); layout.ZoneWidgets = zones; var viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { Site site; if (Page.IsValid) { using (new Rock.Data.UnitOfWorkScope()) { SiteService siteService = new SiteService(); SiteDomainService siteDomainService = new SiteDomainService(); bool newSite = false; int siteId = int.Parse(hfSiteId.Value); if (siteId == 0) { newSite = true; site = new Rock.Model.Site(); siteService.Add(site, CurrentPersonId); } else { site = siteService.Get(siteId); } site.Name = tbSiteName.Text; site.Description = tbDescription.Text; site.Theme = ddlTheme.Text; site.DefaultPageId = ppDefaultPage.PageId; site.DefaultPageRouteId = ppDefaultPage.PageRouteId; site.LoginPageId = ppLoginPage.PageId; site.LoginPageRouteId = ppLoginPage.PageRouteId; site.RegistrationPageId = ppRegistrationPage.PageId; site.RegistrationPageRouteId = ppRegistrationPage.PageRouteId; site.PageNotFoundPageId = ppPageNotFoundPage.PageId; site.PageNotFoundPageRouteId = ppPageNotFoundPage.PageRouteId; site.ErrorPage = tbErrorPage.Text; site.GoogleAnalyticsCode = tbGoogleAnalytics.Text; site.FacebookAppId = tbFacebookAppId.Text; site.FacebookAppSecret = tbFacebookAppSecret.Text; var currentDomains = tbSiteDomains.Text.SplitDelimitedValues().ToList <string>(); site.SiteDomains = site.SiteDomains ?? new List <SiteDomain>(); // Remove any deleted domains foreach (var domain in site.SiteDomains.Where(w => !currentDomains.Contains(w.Domain)).ToList()) { site.SiteDomains.Remove(domain); siteDomainService.Delete(domain, CurrentPersonId); } foreach (string domain in currentDomains) { SiteDomain sd = site.SiteDomains.Where(d => d.Domain == domain).FirstOrDefault(); if (sd == null) { sd = new SiteDomain(); sd.Domain = domain; sd.Guid = Guid.NewGuid(); site.SiteDomains.Add(sd); } } if (!site.DefaultPageId.HasValue && !newSite) { ppDefaultPage.ShowErrorMessage("Default Page is required."); return; } if (!site.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { siteService.Save(site, CurrentPersonId); if (newSite) { Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, CurrentPersonId); } }); SiteCache.Flush(site.Id); // Create the default page is this is a new site if (!site.DefaultPageId.HasValue && newSite) { var siteCache = SiteCache.Read(site.Id); // Create the layouts for the site, and find the first one var layoutService = new LayoutService(); layoutService.RegisterLayouts(Request.MapPath("~"), siteCache, CurrentPersonId); var layouts = layoutService.GetBySiteId(siteCache.Id); Layout layout = layouts.FirstOrDefault(l => l.FileName.Equals("FullWidth", StringComparison.OrdinalIgnoreCase)); if (layout == null) { layout = layouts.FirstOrDefault(); } if (layout != null) { var pageService = new PageService(); var page = new Page(); page.LayoutId = layout.Id; page.PageTitle = siteCache.Name + " Home Page"; page.InternalName = page.PageTitle; page.BrowserTitle = page.PageTitle; page.EnableViewState = true; page.IncludeAdminFooter = true; page.MenuDisplayChildPages = true; var lastPage = pageService.GetByParentPageId(null). OrderByDescending(b => b.Order).FirstOrDefault(); page.Order = lastPage != null ? lastPage.Order + 1 : 0; pageService.Add(page, CurrentPersonId); pageService.Save(page, CurrentPersonId); site = siteService.Get(siteCache.Id); site.DefaultPageId = page.Id; siteService.Save(site, CurrentPersonId); SiteCache.Flush(site.Id); } } } var qryParams = new Dictionary <string, string>(); qryParams["siteId"] = site.Id.ToString(); NavigateToPage(RockPage.Guid, qryParams); } }
public void OnActionExecuted(ActionExecutedContext filterContext) { var zones = new ZoneWidgetCollection(); var cache = new StaticCache(); //Page string path = filterContext.RequestContext.HttpContext.Request.Path; if (path.EndsWith("/") && path.Length > 1) { path = path.Substring(0, path.Length - 1); //filterContext.HttpContext.Response.Redirect(path); filterContext.Result = new RedirectResult(path); return; } bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase); var page = new PageService().GetByPath(path, publish); if (page != null) { var layoutService = new LayoutService(); LayoutEntity layout = layoutService.Get(page.LayoutId); layout.Page = page; Action <WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source => Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver ); WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { var partCollection = new WidgetCollection { part }; zones.Add(part.Widget.ZoneID, partCollection); } } }; var layoutWidgetsTask = Task.Factory.StartNew(layoutId => { var widgetServiceIn = new WidgetService(); IEnumerable <WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId)); layoutwidgets.Each(processWidget); }, page.LayoutId); var widgetService = new WidgetService(); IEnumerable <WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID)); int middle = widgets.Count() / 2; var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget)); widgets.Take(middle).Each(processWidget); Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask }); layout.ZoneWidgets = zones; var viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
public void Init() { service = new LayoutService(new FakeLayoutRepository()); }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { Site site; if (Page.IsValid) { var rockContext = new RockContext(); PageService pageService = new PageService(rockContext); SiteService siteService = new SiteService(rockContext); SiteDomainService siteDomainService = new SiteDomainService(rockContext); bool newSite = false; int siteId = hfSiteId.Value.AsInteger(); if (siteId == 0) { newSite = true; site = new Rock.Model.Site(); siteService.Add(site); } else { site = siteService.Get(siteId); } site.Name = tbSiteName.Text; site.Description = tbDescription.Text; site.Theme = ddlTheme.Text; site.DefaultPageId = ppDefaultPage.PageId; site.DefaultPageRouteId = ppDefaultPage.PageRouteId; site.LoginPageId = ppLoginPage.PageId; site.LoginPageRouteId = ppLoginPage.PageRouteId; site.ChangePasswordPageId = ppChangePasswordPage.PageId; site.ChangePasswordPageRouteId = ppChangePasswordPage.PageRouteId; site.CommunicationPageId = ppCommunicationPage.PageId; site.CommunicationPageRouteId = ppCommunicationPage.PageRouteId; site.RegistrationPageId = ppRegistrationPage.PageId; site.RegistrationPageRouteId = ppRegistrationPage.PageRouteId; site.PageNotFoundPageId = ppPageNotFoundPage.PageId; site.PageNotFoundPageRouteId = ppPageNotFoundPage.PageRouteId; site.ErrorPage = tbErrorPage.Text; site.GoogleAnalyticsCode = tbGoogleAnalytics.Text; site.RequiresEncryption = cbRequireEncryption.Checked; site.EnabledForShortening = cbEnableForShortening.Checked; site.EnableMobileRedirect = cbEnableMobileRedirect.Checked; site.MobilePageId = ppMobilePage.PageId; site.ExternalUrl = tbExternalURL.Text; site.AllowedFrameDomains = tbAllowedFrameDomains.Text; site.RedirectTablets = cbRedirectTablets.Checked; site.EnablePageViews = cbEnablePageViews.Checked; site.AllowIndexing = cbAllowIndexing.Checked; site.IsIndexEnabled = cbEnableIndexing.Checked; site.IndexStartingLocation = tbIndexStartingLocation.Text; site.PageHeaderContent = cePageHeaderContent.Text; int?existingIconId = null; if (site.FavIconBinaryFileId != imgSiteIcon.BinaryFileId) { existingIconId = site.FavIconBinaryFileId; site.FavIconBinaryFileId = imgSiteIcon.BinaryFileId; } int?existingLogoId = null; if (site.SiteLogoBinaryFileId != imgSiteLogo.BinaryFileId) { existingLogoId = site.SiteLogoBinaryFileId; site.SiteLogoBinaryFileId = imgSiteLogo.BinaryFileId; } var currentDomains = tbSiteDomains.Text.SplitDelimitedValues().ToList <string>(); site.SiteDomains = site.SiteDomains ?? new List <SiteDomain>(); // Remove any deleted domains foreach (var domain in site.SiteDomains.Where(w => !currentDomains.Contains(w.Domain)).ToList()) { site.SiteDomains.Remove(domain); siteDomainService.Delete(domain); } int order = 0; foreach (string domain in currentDomains) { SiteDomain sd = site.SiteDomains.Where(d => d.Domain == domain).FirstOrDefault(); if (sd == null) { sd = new SiteDomain(); sd.Domain = domain; sd.Guid = Guid.NewGuid(); site.SiteDomains.Add(sd); } sd.Order = order++; } if (!site.DefaultPageId.HasValue && !newSite) { ppDefaultPage.ShowErrorMessage("Default Page is required."); return; } if (!site.IsValid) { // Controls will render the error messages return; } rockContext.WrapTransaction(() => { rockContext.SaveChanges(); SaveAttributes(new Page().TypeId, "SiteId", site.Id.ToString(), PageAttributesState, rockContext); if (existingIconId.HasValue) { BinaryFileService binaryFileService = new BinaryFileService(rockContext); var binaryFile = binaryFileService.Get(existingIconId.Value); if (binaryFile != null) { // marked the old images as IsTemporary so they will get cleaned up later binaryFile.IsTemporary = true; rockContext.SaveChanges(); } } if (existingLogoId.HasValue) { BinaryFileService binaryFileService = new BinaryFileService(rockContext); var binaryFile = binaryFileService.Get(existingLogoId.Value); if (binaryFile != null) { // marked the old images as IsTemporary so they will get cleaned up later binaryFile.IsTemporary = true; rockContext.SaveChanges(); } } if (newSite) { Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, rockContext, Authorization.EDIT); Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, rockContext, Authorization.ADMINISTRATE); Rock.Security.Authorization.CopyAuthorization(RockPage.Layout.Site, site, rockContext, Authorization.APPROVE); } }); // add/update for the InteractionChannel for this site and set the RetentionPeriod var interactionChannelService = new InteractionChannelService(rockContext); int channelMediumWebsiteValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.INTERACTIONCHANNELTYPE_WEBSITE.AsGuid()).Id; var interactionChannelForSite = interactionChannelService.Queryable() .Where(a => a.ChannelTypeMediumValueId == channelMediumWebsiteValueId && a.ChannelEntityId == site.Id).FirstOrDefault(); if (interactionChannelForSite == null) { interactionChannelForSite = new InteractionChannel(); interactionChannelForSite.ChannelTypeMediumValueId = channelMediumWebsiteValueId; interactionChannelForSite.ChannelEntityId = site.Id; interactionChannelService.Add(interactionChannelForSite); } interactionChannelForSite.Name = site.Name; interactionChannelForSite.RetentionDuration = nbPageViewRetentionPeriodDays.Text.AsIntegerOrNull(); interactionChannelForSite.ComponentEntityTypeId = EntityTypeCache.Get <Rock.Model.Page>().Id; rockContext.SaveChanges(); // Create the default page is this is a new site if (!site.DefaultPageId.HasValue && newSite) { var siteCache = SiteCache.Get(site.Id); // Create the layouts for the site, and find the first one LayoutService.RegisterLayouts(Request.MapPath("~"), siteCache); var layoutService = new LayoutService(rockContext); var layouts = layoutService.GetBySiteId(siteCache.Id); Layout layout = layouts.FirstOrDefault(l => l.FileName.Equals("FullWidth", StringComparison.OrdinalIgnoreCase)); if (layout == null) { layout = layouts.FirstOrDefault(); } if (layout != null) { var page = new Page(); page.LayoutId = layout.Id; page.PageTitle = siteCache.Name + " Home Page"; page.InternalName = page.PageTitle; page.BrowserTitle = page.PageTitle; page.EnableViewState = true; page.IncludeAdminFooter = true; page.MenuDisplayChildPages = true; var lastPage = pageService.GetByParentPageId(null).OrderByDescending(b => b.Order).FirstOrDefault(); page.Order = lastPage != null ? lastPage.Order + 1 : 0; pageService.Add(page); rockContext.SaveChanges(); site = siteService.Get(siteCache.Id); site.DefaultPageId = page.Id; rockContext.SaveChanges(); } } var qryParams = new Dictionary <string, string>(); qryParams["siteId"] = site.Id.ToString(); NavigateToPage(RockPage.Guid, qryParams); } }
private void Initialize() { ArcGIS.Desktop.Core.Events.ProjectClosingEvent.Subscribe((args) => { CIMService = null;//just do it when the project closes return(Task.FromResult(0)); }); #region Layout //ArcGIS.Desktop.Layouts.Events.LayoutChangedEvent.Subscribe((args) => { // if (_cimService != null && // _cimService.ServiceType == CIMServiceType.LayoutElement) { // if (_cimService.URI == args.Layout.URI) { // CIMService = new LayoutService(args.Layout); // } // } //}); ArcGIS.Desktop.Layouts.Events.LayoutClosedEvent.Subscribe((args) => { if (_cimService != null && (_cimService.ServiceType == CIMServiceType.Layout || _cimService.ServiceType == CIMServiceType.LayoutElement)) { //assume we are showing the active layout or an element on it if (FrameworkApplication.Panes.Count == 0 || FrameworkApplication.Panes.OfType <ILayoutPane>().Count() == 0) { lock (this) { CIMService = null; } } } }); ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe((args) => { if (args.Type == LayoutViewEventType.Initialized) { if (LayoutView.Active != null) { lock (this) { CIMService = null; if (LayoutView.Active.Layout != null) { CIMService = new LayoutService(LayoutView.Active.Layout); } } } } }); //A layout or layout element has been selected in the TOC ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent.Subscribe((args) => { if (args.Elements == null || args.Elements.Count() == 0) { //The layout itself has been selected var layout = LayoutView.Active?.Layout; if (layout != null) { CIMService = new LayoutService(layout); } } else { //take the first element CIMService = new LayoutElementService(args.Elements.First()); } }); ArcGIS.Desktop.Layouts.Events.ElementsPlacementChangedEvent.Subscribe((args) => { SetLayoutElement(args.ElementNames); }); ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent.Subscribe((args) => { SetLayoutElement(args.ElementNames); }); ArcGIS.Desktop.Layouts.Events.PageChangedEvent.Subscribe((args) => { if (_cimService != null && _cimService.ServiceType == CIMServiceType.LayoutElement) { if (LayoutView.Active != null) { if (LayoutView.Active.Layout.URI == _cimService.URI) { CIMService = new LayoutService(LayoutView.Active.Layout); } } } }); #endregion #region Map //The map is deleted from the Project dockpane ArcGIS.Desktop.Mapping.Events.MapRemovedEvent.Subscribe((args) => { lock (this) { if (CIMService != null && CIMService.ServiceType == CIMServiceType.Map) { if (args.MapPath == CIMService.URI) { //this affects our map CIMService = null;//just do it when our map is removed } } } }); //The MapPane is closed ArcGIS.Desktop.Mapping.Events.MapClosedEvent.Subscribe((args) => { lock (this) { if (CIMService != null && CIMService.ServiceType == CIMServiceType.Map) { if (args.MapPane.MapView != null)//I think MapView is always valid here { if (args.MapPane.MapView.Map.URI == CIMService.URI) { //this affects our map CIMService = null;//just do it when our map is closed } } else if (FrameworkApplication.Panes.Count == 0 || FrameworkApplication.Panes.OfType <IMapPane>().Count() == 0) { CIMService = null;//There are no more maps } } } }); ArcGIS.Desktop.Mapping.Events.TOCSelectionChangedEvent.Subscribe((args) => { if (CIMViewerModule.IgnoreEvents) { return; } CIMViewerModule.IgnoreEvents = true; SetMapMember(args.MapView); CIMViewerModule.IgnoreEvents = false; }); ArcGIS.Desktop.Mapping.Events.ActiveMapViewChangedEvent.Subscribe((args) => { if (CIMViewerModule.IgnoreEvents) { return; } CIMViewerModule.IgnoreEvents = true; if (args.OutgoingView != null) { CIMService = null; } else if (args.IncomingView != null) { SetMapMember(args.IncomingView); } CIMViewerModule.IgnoreEvents = false; }); ArcGIS.Desktop.Mapping.Events.MapPropertyChangedEvent.Subscribe((args) => { if (CIMViewerModule.IgnoreEvents) { return; } CIMViewerModule.IgnoreEvents = true; if (_cimService != null && _cimService.ServiceType == CIMServiceType.Map) { //we have a map definition loaded foreach (var map in args.Maps) { if (map.URI == _cimService.URI) { //our map is one of the maps that changed //refresh it CIMService = new MapService(map); break; } } } CIMViewerModule.IgnoreEvents = false; }); ArcGIS.Desktop.Mapping.Events.MapMemberPropertiesChangedEvent.Subscribe((args) => { if (CIMViewerModule.IgnoreEvents) { return; } CIMViewerModule.IgnoreEvents = true; if (_cimService != null && _cimService.ServiceType == CIMServiceType.MapMember) { foreach (var mm in args.MapMembers) { if (mm.URI == _cimService.URI) { //refresh CIMService = new MapMemberService(mm); break; } } } CIMViewerModule.IgnoreEvents = false; }); ArcGIS.Desktop.Mapping.Events.LayersRemovedEvent.Subscribe((args) => { if (CIMViewerModule.IgnoreEvents) { return; } CIMViewerModule.IgnoreEvents = true; if (_cimService != null && _cimService.ServiceType == CIMServiceType.MapMember) { foreach (var layer in args.Layers) { if (layer.URI == _cimService.URI) { CIMService = null; } } } CIMViewerModule.IgnoreEvents = false; }); #endregion Map }