private void LoadFormForSite() { var cmsSite = SiteFactory.Get(_siteId); _siteName = cmsSite.Name; PageHeader.Text = _siteName; SetStandardFieldLabels(); // Standard fields SiteName.PropertyValue = new StringProperty(cmsSite.Name); // Advanced fields ChildSortDirection.SelectedValue = ((int)cmsSite.ChildSortDirection).ToString(); ChildSortOrder.SelectedValue = ((int)cmsSite.ChildSortOrder).ToString(); var propertyDefinitions = CmsSite.PropertyDefinitions; AddTabs(propertyDefinitions); foreach (var propertyDefinition in propertyDefinitions) { var propertyName = propertyDefinition.Name; var propertyData = cmsSite.Property[propertyName]; AddControl(propertyName, propertyData, propertyDefinition.PropertyTypeId, propertyDefinition.Header, propertyDefinition.Parameters, propertyDefinition.Required, propertyDefinition.TabGroup); } }
private void RedirectIfSite() { if (_pageTypeId == 0 && SiteFactory.IsSite(_pageId)) { Response.Redirect(string.Format("EditSite.aspx?id={0}", _pageId)); } }
internal PageCollection GetRootChildren() { Predicate <PageIndexItem> match = IsPublished.And(t => t.ParentId == Guid.Empty); var site = SiteFactory.CurrentSite <CmsSite>(); return(GetPagesByCriteriaSorted(match, site.ChildSortOrder, site.ChildSortDirection)); }
public SiteViewModel() { var siteFactory = new SiteFactory(); sites = siteFactory.GetSites().ToList(); ParameterCommand = new ParameterCommand(this); MenuVisability = true; BrowserVisability = false; }
public void SaveAndPublish() { var languageId = Language.CurrentLanguageId; using (var context = new DataContext()) { var siteEntity = context.Sites.SingleOrDefault(x => x.SiteId == SiteId); if (siteEntity == null) { siteEntity = new SiteEntity { SiteId = SiteId }; context.Add(siteEntity); context.SaveChanges(); } siteEntity.Author = HttpContext.Current.User.Identity.Name; siteEntity.ChildSortDirection = ChildSortDirection; siteEntity.ChildSortOrder = ChildSortOrder; siteEntity.Name = Name; siteEntity.UpdateDate = DateTime.Now.ToUniversalTime(); context.SaveChanges(); // --------------- var propertiesForSite = context.SiteProperties.Where(x => x.SiteId == SiteId && x.LanguageId == languageId).ToList(); foreach (var propertyItem in Property) { var propertyEntity = propertiesForSite.Find(c => c.PropertyId == propertyItem.PropertyId); if (propertyEntity == null) { propertyEntity = new SitePropertyEntity { LanguageId = languageId, SiteId = SiteId, PropertyId = propertyItem.PropertyId }; context.Add(propertyEntity); propertiesForSite.Add(propertyEntity); } propertyEntity.SiteData = GetSerializedPropertyValue(propertyItem); } context.SaveChanges(); } SiteFactory.UpdateSite(this); CacheManager.RemoveRelated(SiteId); SiteFactory.RaiseSitePublished(SiteId, languageId); }
internal PageCollection GetRootChildren(int pageTypeId, PublishState pageState) { Predicate <PageIndexItem> match = t => t.ParentId == Guid.Empty && t.PageTypeId == pageTypeId; match = AddPredicateForPageState(pageState, match); var site = SiteFactory.CurrentSite <CmsSite>(); return(GetPagesByCriteriaSorted(match, site.ChildSortOrder, site.ChildSortDirection)); }
public void Should_set_id_in_site_deleted_event() { var site = SiteFactory.CreateNew(); site.Delete(); var @event = site.Events.OfType <SiteDeleted>().SingleOrDefault(); Assert.AreEqual(site.Id, @event.AggregateRootId); }
public void Should_save_new_site() { var newSite = SiteFactory.Site(Guid.NewGuid(), "Name 3"); _sut.Create(newSite); var actual = _sut.GetById(newSite.Id); Assert.NotNull(actual); }
private object SaveData() { var cmsSite = SiteFactory.Get(_siteId); var editableSite = cmsSite.MakeEditable(); SavePropertiesForPage(editableSite); _siteName = editableSite.Name; return(editableSite); }
public void Should_set_name_in_site_deleted_event() { var site = SiteFactory.CreateNew(); site.Delete(); var @event = site.Events.OfType <SiteDeleted>().SingleOrDefault(); Assert.AreEqual(site.Name, @event.Name); }
public void Should_update_site() { var newSiteName = "New Title 1"; var siteToUpdate = SiteFactory.Site(_siteId1, newSiteName); _sut.Update(siteToUpdate); var updatedSite = _sut.GetById(_siteId1); Assert.AreEqual(newSiteName, updatedSite.Title); }
private static void RunInitializingSteps() { var startupSequence = GetStartupSequence(); ExecutePreStartupSequence(startupSequence); KeepDatabaseUpToDate(); AutoMapperConfiguration.Configure(); PageType.LoadPageTypes(); SiteFactory.LoadSites(); PageFactory.IndexSite(); ExecutePostStartupSequence(startupSequence); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); var dbContext = new WeapsyDbContext(optionsBuilder.Options); _siteId1 = Guid.NewGuid(); _siteId2 = Guid.NewGuid(); dbContext.Set <SiteDbEntity>().AddRange( new SiteDbEntity { Id = _siteId1, Name = "Name 1", Title = "Title 1", Url = "Url 1", Status = SiteStatus.Active }, new SiteDbEntity { Id = _siteId2, Name = "Name 2", Title = "Title 2", Url = "Url 2", Status = SiteStatus.Active }, new SiteDbEntity { Status = SiteStatus.Deleted } ); dbContext.SaveChanges(); var mapperMock = new Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <SiteDbEntity>(It.IsAny <Site>())).Returns(new SiteDbEntity()); mapperMock.Setup(x => x.Map <Site>(It.IsAny <SiteDbEntity>())).Returns(new Site()); mapperMock.Setup(x => x.Map <IList <Site> >(It.IsAny <IList <SiteDbEntity> >())).Returns(new List <Site> { SiteFactory.Site(_siteId1, "Name"), SiteFactory.Site(_siteId2, "Name") }); _sut = new SiteRepository(dbContext, mapperMock.Object); }
public void Should_save_new_site() { var newSite = SiteFactory.CreateNew(Guid.NewGuid(), "Name 3"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newSite); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var language = repository.GetById(newSite.Id); Assert.NotNull(language); } }
public void Should_return_true_if_page_is_set_as_home_page() { var siteId = Guid.NewGuid(); var pageId = Guid.NewGuid(); var site = SiteFactory.CreateNew(); site.Update(pageId); var repositoryMock = new Mock <ISiteRepository>(); repositoryMock.Setup(x => x.GetById(siteId)).Returns(site); var sut = new SiteRules(repositoryMock.Object); var actual = sut.IsPageSetAsHomePage(siteId, pageId); Assert.AreEqual(true, actual); }
private void GetChildren(HttpContext context) { context.Response.ContentType = "application/json"; var items = new List <dynamic>(); var id = context.Request.Form["id"]; if (id == "#") { var siteId = Guid.Empty; var site = SiteFactory.Get(siteId); var jQueryTreeItem = new JQueryTreeItem { text = site.Name, children = true, id = siteId.ToString(), parent = "#", icon = "jstree-rooticon" }; items.Add(jQueryTreeItem); context.Response.Write(Serialization.JsonSerialization.SerializeJson(items, new JSONParameters { UseExtensions = false, SerializeNullValues = false })); context.Response.End(); } var pageId = new Guid(id); var children = PageFactory.GetChildrenForPage(pageId, PublishState.All); foreach (var childId in children.PageIds) { var page = PageFactory.GetPage(childId); var icon = page.Status == PageInstanceStatus.Published ? "" : "jstree-newpage"; var text = page.Status == PageInstanceStatus.Published ? page.PageName : "<i>" + page.PageName + "</i>"; items.Add(new JQueryTreeItem { text = text, children = page.HasChildren, id = childId.ToString(), icon = icon, a_attr = new JQueryTreeLink { href = page.PageUrl.ToString() } }); } context.Response.Write(Serialization.JsonSerialization.SerializeJson(items, new JSONParameters { UseExtensions = false, SerializeNullValues = false })); }
public void Should_update_site() { const string newSiteName = "New Title 1"; var siteToUpdate = SiteFactory.CreateNew(_siteId1, newSiteName); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Update(siteToUpdate); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var updatedSite = repository.GetById(_siteId1); Assert.AreEqual(newSiteName, updatedSite.Name); } }
public void Should_save_new_site() { var newSite = SiteFactory.Site(Guid.NewGuid(), "Name 3"); var newSiteDbEntity = new SiteDbEntity { Id = newSite.Id, Name = newSite.Name }; var mapperMock = new Mock <IMapper>(); mapperMock.Setup(x => x.Map <SiteDbEntity>(newSite)).Returns(newSiteDbEntity); mapperMock.Setup(x => x.Map <Site>(newSiteDbEntity)).Returns(newSite); _sut = new SiteRepository(_dbContext, mapperMock.Object); _sut.Create(newSite); var actual = _sut.GetById(newSite.Id); Assert.NotNull(actual); }
public Models.GlobalHeader GetGlobalHeader(RenderingContext renderingContext, Item contextItem) { var model = new Models.GlobalHeader(GetDatasource(renderingContext, contextItem, Global_Header_Constants.TemplateId)); // the GetDatasource returned no Sitecore item or it returned an item of the wrong template if (model.SitecoreItem == null || !model.SitecoreItem.IsOrInherits(Global_Header_Constants.TemplateId)) { var site = SiteFactory.GetSite(); if (site != null) { model.SitecoreItem = site.GetDefaultGlobalHeader(); } } if (model.SitecoreItem != null) { model.NavigationLinks = model.SitecoreItem.Children.Where(i => i.IsOrInherits(_Navigation_Link_Constants.TemplateId)); } return(model); }
/// <summary> /// Resets all parameters. Used on first time page load or when user wants to clear everything /// </summary> private void resetParameters() { //Clear all Text Fields clearTextFields(); //Local Time format txtParamDTEnd.Text = DateTime.Now.AddMinutes(-1).ToString("yyyy-MM-dd HH:mm:ss"); //Rebuild the dictionaries clearDictionaries(); buildDictionaries(); //Clear the ListView and rebuild it. ListView_Alarms.DataSource = ""; ListView_Alarms.DataBind(); List <String> siteList = new List <string>(); foreach (SiteStructure site in SiteFactory.getSiteList()) { if (!siteList.Contains(site.siteName)) { siteList.Add(site.siteName); } } //Add the filters foreach (KeyValuePair <string, string> filter in SiteFactory.getFilters()) { siteList.Add(filter.Key); } siteList.Sort(); //Rebind the siteList to the dropdown list SiteDropDownList.DataSource = siteList; //Set the txtParamLogList textfield to the first item in the siteList txtParamLogList.Text = siteList[0]; SiteDropDownList.DataBind(); }
private List <Item> GetResults(string q, string databaseName) { if (q.IsNotNullAndNotWhiteSpace()) { using (var searcher = ContentSearchManager.GetIndex(string.Format("sitecore_{0}_index", databaseName)).CreateSearchContext()) { var site = SiteFactory.GetSite(); return(searcher .GetQueryable <SearchResultItem>() .Where(i => i.Paths.Contains(site.SitecoreItem.ID) && i.Content == q) .ToList() .Select(i => i.GetItem()) .ToList()); } } else { return(new List <Item>()); } }
/// <summary> /// This function updates the time of the DataTable after queried from Oracle and update the time to PT and the Station to h /// human readable format /// </summary> /// <param name="myDT"></param> /// <returns>A modified DataTable with changes to Time and changes to Station </returns> private DataTable postTableQueryEdits(DataTable myDT) { DataTable newTable = myDT.Clone(); string TIME_COL = "Time"; string STATION_COL = "Station"; string DOMAIN_COL = "Domain"; string ALARM_LIST_COL = "AlarmList"; //Make a copy of the station id column int stationIndex = newTable.Columns.IndexOf(STATION_COL); newTable.Columns.Remove(STATION_COL); DataColumn newStationCol = newTable.Columns.Add(STATION_COL); newStationCol.SetOrdinal(stationIndex); //Make a copy of the time column int timeIndex = newTable.Columns.IndexOf(TIME_COL); newTable.Columns.Remove(TIME_COL); DataColumn newTimeCol = newTable.Columns.Add(TIME_COL); newTimeCol.SetOrdinal(timeIndex); Random random = new Random(); foreach (DataRow row in myDT.Rows) { DataRow newRow = newTable.Rows.Add(); //The station number should be changed so that the STATION should be a human readable value and not just a number. //The time should be in Local time and not UTC // If it is anything else, just ignore it newRow.BeginEdit(); foreach (DataColumn col in newTable.Columns) { //If Time. This should be in local pacific time if (col == newTimeCol) { Object temp = fmtDateTime(epochToDateTime(row[col.ColumnName]).ToLocalTime()); newRow.SetField(col, temp); } //If Station. This should be in a machine name format else if (col == newStationCol) { //Get the Site prefix from the Domain Column. Note that not all alarm will have a Domain or a nature string sitePrefix = row[DOMAIN_COL].ToString(); //Get the site ID from the STATION Column int siteID = Convert.ToInt16(row[STATION_COL]); //Get the Alarm List column from the Alarm Column. This is only used for matching the Front Ends. string alarmListName = row[ALARM_LIST_COL].ToString(); string temp = ""; temp = SiteFactory.getComputerName(siteID); newRow.SetField(col, temp); } else { newRow.SetField(col, row[col.ColumnName]); } } newRow.AcceptChanges(); } //Drop the alarms list column (as Victor doesn't want it newTable.Columns.Remove(ALARM_LIST_COL); return(newTable); }
public StartPageViewModel(StartPage currentPage) { CurrentPage = currentPage; CurrentSite = SiteFactory.CurrentSite <DemoSite>(); }
protected void Page_Load(object sender, EventArgs e) { var pageTypes = PageType.PageTypes; if (pageTypes == null) { return; } bool allowAll; Type[] allowedTypes; Guid pageId; Guid.TryParse(Request.QueryString["pageId"], out pageId); if (SiteFactory.IsSite(pageId)) { allowedTypes = CmsSite.AllowedTypes; allowAll = allowedTypes == null; if (allowedTypes != null && allowedTypes.Length == 0) { PageTypeList.Text = "No pages can be created under the selected page."; return; } } else { var parent = PageFactory.GetPage(pageId); var parentPageType = pageTypes.Find(p => p.PageTypeId == parent.PageTypeId); allowedTypes = parentPageType.AllowedTypes; allowAll = parentPageType.AllowedTypes == null; if (allowedTypes != null && allowedTypes.Length == 0) { PageTypeList.Text = "No pages can be created under the selected page."; return; } } var stringBuilder = new StringBuilder(); var count = 0; foreach (var pageType in pageTypes.OrderBy(x => x.DisplayName)) { if (!allowAll && !allowedTypes.Contains(pageType.Type)) { continue; } if (count > 0 && count % 2 == 0) { stringBuilder.Append("</div><div class=\"row\">"); } var previewImage = string.IsNullOrEmpty(pageType.PreviewImage) ? "assets/images/defaultpagetype.png" : pageType.PreviewImage; stringBuilder.Append("<div class=\"col-xs-6\"><a href=\"javascript:selectPageType('" + pageType.PageTypeId + "')\" class=\"no-decoration\"><div class=\"media pick-box\"><div class=\"pull-left\"><img class=\"media-object\" src=\"" + previewImage + "\"></div><div class=\"media-body\"><h2 class=\"media-heading\">" + pageType.DisplayName + "</h2>" + pageType.PageTypeDescription + "</div></div></a></div>"); count++; } PageTypeList.Text = stringBuilder.ToString(); }
public NewsListPageViewModel(NewsListPage currentPage) { CurrentPage = currentPage; CurrentSite = SiteFactory.CurrentSite <DemoSite>(); }
public ContactPageViewModel(ContactPage currentPage) { CurrentPage = currentPage; CurrentSite = SiteFactory.CurrentSite <DemoSite>(); FormData = new ContactPageFormData(); }
public BaseSite(ISettings settings) { Settings = settings; BaseDriver = new BaseDriver(Settings); SiteFactory.InitElements(this, BaseDriver); }
public BaseSite() { BaseDriver = new BaseDriver(); Settings = BaseDriver.Settings; SiteFactory.InitElements(this, BaseDriver); }
public BaseSite(BaseDriver baseDriver) { BaseDriver = baseDriver; SiteFactory.InitElements(this, BaseDriver); }
public ProductListPageViewModel(ProductListPage currentPage) { CurrentPage = currentPage; CurrentSite = SiteFactory.CurrentSite <DemoSite>(); }