public void PrivilegedUserAddPhoto( string userName, string password, string imageFilePath, string imageTitle, string imageType) { var imageFullPath = Path.Combine(GetBaseDirectory(), imageFilePath); using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(userName, password); galleryPage.AddImageToGallery(imageTitle, imageType, imageFullPath); TakeScreenshot(galleryPage); var successMessage = galleryPage.GetSuccessMessage(); Assert.Equal("Image has been added successfully!", successMessage); var totalRecordsActual = galleryPage.GetTotalRecordsMessage(); Assert.Equal("Total Records: 1", totalRecordsActual); galleryPage.DeleteImageByTitle(imageTitle); successMessage = galleryPage.GetSuccessMessage(); Assert.Equal("Image has been deleted successfully!", successMessage); } }
private void RegisterStartupScript() { var uiTemplate = GalleryPage.UiTemplates.Get(UiTemplateType.MediaObject, GalleryPage.GetAlbum()); // Define 3 script tags. The first two hold the HTML and javascript jsRender templates. // The last contains start script that does 2 things: // 1. Compile the jsRender template and run the javascript generated in the template // 2. Generate the JavaScript from the template and add to the page string script = String.Format(CultureInfo.InvariantCulture, @" <script id='{0}' type='text/x-jsrender'> {1} </script> <script id='{2}' type='text/x-jsrender'> {3} </script> <script> (function ($) {{ $(document).ready(function () {{ $.templates({{{5}: $('#{0}').html() }}); (new Function($('#{2}').render(Gs.Vars['{4}'].gsData)))(); }}); }})(jQuery); </script> ", MediaHtmlTmplClientId, // 0 uiTemplate.HtmlTemplate, // 1 MediaScriptTmplClientId, // 2 uiTemplate.ScriptTemplate, // 3 GalleryPage.GspClientId, // 4 GalleryPage.MediaTmplName // 5 ); Page.ClientScript.RegisterStartupScript(GetType(), String.Concat(GalleryPage.ClientID, "_mViewTmplScript"), script, false); }
public void DeleteAlbums(int[] albumIds) { try { foreach (int albumId in albumIds) { try { IGalleryObject album = Factory.LoadAlbumInstance(albumId, false); if (GalleryPage.IsUserAuthorized(SecurityActions.DeleteAlbum, album.Id)) { album.Delete(); } } catch (GalleryServerPro.ErrorHandler.CustomExceptions.InvalidAlbumException) { } } HelperFunctions.PurgeCache(); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
private void ConfigureControlsFirstTime() { const int albumTitleMaxLength = DataConstants.AlbumTitleLength; txtTitle.MaxLength = albumTitleMaxLength; string albumTitleMaxLengthInfo = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.UC_Album_Header_Album_Title_Max_Length_Text, albumTitleMaxLength); lblMaxTitleLengthInfo.Text = albumTitleMaxLengthInfo; // Configure Calendar. string imagesBaseUrl = String.Concat(Utils.GalleryRoot, "/images/componentart/calendar/"); cdrBeginDate.ImagesBaseUrl = imagesBaseUrl; cdrEndDate.ImagesBaseUrl = imagesBaseUrl; // Configure ComboBox. cboOwner.DropHoverImageUrl = Utils.GetUrl("/images/componentart/combobox/ddn-hover.png"); cboOwner.DropImageUrl = Utils.GetUrl("/images/componentart/combobox/ddn.png"); if (GalleryPage.GetAlbum().Parent.IsPrivate) { lblPrivateAlbumIsInherited.Text = Resources.GalleryServerPro.UC_Album_Header_Edit_Album_Is_Private_Disabled_Text; } this.ConfigureAlbumOwnerControls(); }
/// <summary> /// Configures and attach the treeview page to this instance. /// </summary> /// <returns>Returns an instance of <see cref="albumtreeview" />.</returns> private Control ConfigureTreeViewControl() { const PageId page = PageId.albumtreeview; string src = GetUserControlPath(page); Control control = LoadControl(src); GalleryPage galleryControl = control as GalleryPage; if (galleryControl != null) { galleryControl.GalleryControl = this; galleryControl.PageId = page; } if (AlbumId > int.MinValue) { albumtreeview albumTreeviewcontrol = control as albumtreeview; if (albumTreeviewcontrol != null) { albumTreeviewcontrol.RootAlbumId = AlbumId; } } return(control); }
public string UpdateMediaObjectTitle(int mediaObjectId, string title) { try { IGalleryObject mo = Factory.LoadMediaObjectInstance(mediaObjectId); if (GalleryPage.IsUserAuthorized(SecurityActions.EditMediaObject, mo.Parent.Id)) { string previousTitle = mo.Title; mo.Title = Util.CleanHtmlTags(title); if (mo.Title != previousTitle) { GalleryObjectController.SaveGalleryObject(mo); } HelperFunctions.PurgeCache(); } return(mo.Title); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
// GET: Content public ActionResult Index(string permalink) { string section = ""; string qString = "/" + permalink; int firstSlash = 0; if (!string.IsNullOrEmpty(permalink)) { firstSlash = permalink.IndexOf('/'); } if (firstSlash > 0) { section = permalink.Substring(0, firstSlash); } else { section = permalink; } ContentPage contentPage = new ContentPage(qString); if (contentPage.PageID != Guid.Empty) { ViewData = contentPage.GetSections(); ViewBag.Meta = contentPage.MetaTags; ViewBag.City = new MLSListings().GetCitySelectList(""); switch (contentPage.PageTypeName) { case "Gallery Page": List <GalleryItemModel> gallery = new GalleryPage(contentPage.PageID).GetImages(); return(View("Gallery", gallery)); case "News Index": List <NewsModel> news = new NewsSet(contentPage.PageID).News(); return(View("NewsIndex", news)); case "Event Index": return(View("EventIndex", new EventSet().Events())); default: return(View()); } } else { if (!string.IsNullOrEmpty(contentPage.RedirectURL)) { return(RedirectPermanent(contentPage.RedirectURL)); } ViewBag.City = new Listing().GetCitySelectList(""); contentPage = new ContentPage("404"); Response.TrySkipIisCustomErrors = true; Server.ClearError(); Response.Status = "404 not found"; Response.StatusCode = 404; return(View()); } }
void actorCommand_Invoked(object sender, EventArgs e) { Library.Code.V3.CastCommand actor = (Library.Code.V3.CastCommand)sender; List <TitleFilter> filter = new List <TitleFilter>(); filter.Add(new TitleFilter(TitleFilterType.Person, actor.Description)); IEnumerable <Title> items = TitleCollectionManager.GetFilteredTitles(filter); GalleryPage page = new GalleryPage(items, actor.Description); }
void viewPlayCmd_Invoked(object sender, EventArgs e) { OMLApplication.Current.CatchMoreInfo(); if (this.Owner is GalleryPage && ((GalleryPage)this.Owner).SelectedItemCommand is MovieItem) { GalleryPage page = this.Owner as GalleryPage; MovieItem movie = page.SelectedItemCommand as MovieItem; movie.PlayAllDisks(); } }
public void UserRolesTest(string userName, string password, string role) { using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(userName, password); TakeScreenshot(galleryPage); string actualRole = GetRole(galleryPage); Assert.Equal(role, actualRole); } }
public void BasicUserLogoutTest() { using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(BasicUserName, BasicUserPassword); galleryPage.LogoutAndWait(); TakeScreenshot(galleryPage); Assert.Contains(LoginPageTitle, galleryPage.Title); } }
/// <summary> /// Handles the Load event of the Page 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 Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (GalleryPage.GetMediaObjectId() == int.MinValue) { Utils.Redirect(Utils.AddQueryStringParameter(Utils.GetCurrentPageUrl(), "msg=" + (int)MessageType.MediaObjectDoesNotExist)); } RegisterJavascript(); } }
public void IncorrectLoginAttemptTest() { using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(BasicUserName, IncorrectPassword); TakeScreenshot(galleryPage); var validationText = galleryPage.GetValidationErrorText(); Assert.Equal(InvalidLoginMessage, validationText); } }
public void PrivilegedUserLoginTest() { using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(PrivilegedUserName, PrivilegedUserPassword); TakeScreenshot(galleryPage); Assert.True( galleryPage.IsAddImageButtonAvailable(), "User is logged in with elevated permissions, so 'Add Image' button should be available."); } }
public MediaObjectWebEntity GetMediaObjectHtml(int mediaObjectId, DisplayObjectType displayType) { try { return(GalleryPage.GetMediaObjectHtml(Factory.LoadMediaObjectInstance(mediaObjectId), displayType, true)); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
public void BasicUserLoginTest() { using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(BasicUserName, BasicUserPassword); TakeScreenshot(galleryPage); Assert.False( galleryPage.IsAddImageButtonAvailable(), "User is logged in as free user, so 'Add Image' button should not be available."); } }
public void EmptyUsernamePasswordTest() { using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(string.Empty, string.Empty); TakeScreenshot(galleryPage); var validationText = galleryPage.GetValidationErrorText(); Assert.Contains(LoginRequiredMessage, validationText); Assert.Contains(PasswordRequiredessage, validationText); } }
private static void AddtionalInfo(StringBuilder sb, GalleryPage gp) { if (gp.ViewModel is null) { return; } var pv = gp.Descendants <Pivot>("pv").FirstOrDefault(); if (pv != null) { sb.AppendLine($"Pivot: SelectedIndex={pv.SelectedIndex}"); } AddtionalInfo(sb, gp.ViewModel); }
private static void AddtionalInfo(StringBuilder sb, GalleryPage gp) { if (gp.VM == null) { return; } var pv = gp.Descendants <Windows.UI.Xaml.Controls.Pivot>("pv").FirstOrDefault(); if (pv != null) { sb.AppendLine($"Pivot: SelectedIndex={pv.SelectedIndex}"); } AddtionalInfo(sb, gp.VM); }
protected override void OnPostExecute(Bitmap bitmap) { if (bitmap != null) { MemoryStream stream = new MemoryStream(); bitmap.Compress(Bitmap.CompressFormat.Jpeg, 50, stream); byte[] bitmapData = stream.ToArray(); GalleryPage.Galleryimages(bitmapData); bitmap.Recycle(); GC.Collect(); } }
/// <summary> /// Configures and attach the album thumbnail page to this instance. /// </summary> /// <returns>Returns an instance of <see cref="media" />.</returns> private Control ConfigureAlbumThumbnailControl() { const PageId page = PageId.album; string src = GetUserControlPath(page); Control control = LoadControl(src); GalleryPage galleryControl = control as GalleryPage; if (galleryControl != null) { galleryControl.GalleryControl = this; galleryControl.PageId = page; } return(control); }
public void GetUsersTotalPhotosCountTest() { var totalPhotosCount = BasicUserTotalPhotos; using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(BasicUserName, BasicUserPassword); TakeScreenshot(galleryPage); var totalRecordMessage = galleryPage.GetTotalRecordsMessage(); int photosCountNumericPart; totalRecordMessage = totalRecordMessage.Substring(1 + totalRecordMessage.LastIndexOf(':')); Assert.True(int.TryParse(totalRecordMessage, out photosCountNumericPart)); var totalPhotosActualCount = Convert.ToInt32(photosCountNumericPart); Assert.Equal(totalPhotosCount, totalPhotosActualCount); } }
/// <summary> /// Configures and attach the media object page to this instance. /// </summary> /// <returns>Returns an instance of <see cref="Control" />.</returns> private Control ConfigureMediaObjectControl() { const PageId page = PageId.mediaobject; string src = GetUserControlPath(page); Control control = LoadControl(src); GalleryPage galleryControl = control as GalleryPage; if (galleryControl != null) { galleryControl.GalleryControl = this; galleryControl.PageId = page; } return(control); }
public void DeleteMediaObject(int mediaObjectId) { try { IGalleryObject mo = Factory.LoadMediaObjectInstance(mediaObjectId); if (GalleryPage.IsUserAuthorized(SecurityActions.DeleteMediaObject, mo.Parent.Id)) { mo.Delete(); HelperFunctions.PurgeCache(); } } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
private void Button_Clicked(object sender, EventArgs e) { var photo = ((Button)sender).BindingContext as WrappedCell <Photo>; bool shouldHighlight = GalleryPage.OnCellTapped(this); if (!photo.IsSelected && originalColor == null) { originalColor = View.BackgroundColor; } photo.IsSelected = shouldHighlight; compareButton.Text = (shouldHighlight) ? buttonHighlightText : buttonDefaultText; View.BackgroundColor = (photo.IsSelected) ? highlightColor : originalColor; }
/// <summary> /// Verify the user control we created is the right one, correcting it if necessary. When our initial guess proves correct, this function /// returns the same instance that is passed in. If required, replace the <paramref name="galleryControl" /> parameter with the correct one, /// and return its base <see cref="Control" /> class. /// </summary> /// <param name="galleryControl">The gallery control to validate.</param> /// <param name="page">The requested page as determined by an analysis of the query string.</param> /// <returns>Returns a <see cref="Control" /> that is correct for the current configuration. May be the same control that is passed in.</returns> /// <remarks>We initially determined which page to load by looking at the query string, but the developer may have overridden this by setting /// various properties on this control. For example, she may have specified a media object on the <see cref="Gallery.MediaObjectId" /> property, /// or she may have also specified a <see cref="Gallery.AlbumId" /> combined with <see cref="Gallery.ViewMode" /> = Single or SingleRandom, in /// which case we need to display a particular media object rather than album thumbnails. If this situation is detected, replace the /// <paramref name="galleryControl" /> parameter with the correct one, and return its base <see cref="Control" /> class. If you are wondering /// why we didn't just determine the right page the first time, that is because we can't invoke <see cref="GalleryPage.GetMediaObjectId" /> until /// after <see cref="GalleryController.InitializeGspApplication" /> fires, which won't happen until after a user control has been loaded. So we make our best guess /// by looking at the query string and correcting it here if necessary. Our initial guess should be right more than 99% of the time.</remarks> private Control ValidateRequestedPage(GalleryPage galleryControl, PageId page) { Control control = galleryControl; if ((page == PageId.album) && (galleryControl.GetMediaObjectId() > int.MinValue)) { // We need to render in single media object mode (pages/media.ascx). control = ConfigureMediaObjectControl(); } if ((page == PageId.mediaobject) && (AllowUrlOverride == false) && (AlbumId > int.MinValue) && (ViewMode == ViewMode.Multiple)) { // We need to render in album thumbnail mode (pages/album.ascx). control = ConfigureAlbumThumbnailControl(); } return(control); }
public void GalleryImageAddRemoveTest( string userName, string password, string imageTitle, string imageType, string imageFilePath) { var imageFullPath = Path.Combine(GetBaseDirectory(), imageFilePath); using (var galleryPage = new GalleryPage(_driver, _applicationUrl)) { galleryPage.Login(userName, password); galleryPage.AddImageToGallery(imageTitle, imageType, imageFullPath); TakeScreenshot(galleryPage); var successMessage = galleryPage.GetSuccessMessage(); Assert.Equal("Image has been added successfully!", successMessage); } }
private void ConfigureControls() { IAlbum album = GalleryPage.GetAlbum(); lblTitle.Text = album.Title; lblSummary.Text = album.Summary; litStats.Text = getAlbumStats(album); lblDate.Text = getAlbumDates(album); if (String.IsNullOrEmpty(lblDate.Text)) { dateContainer.Attributes["class"] = "gsp_invisible gsp_minimargin"; } else { dateContainer.Attributes["class"] = "gsp_minimargin"; } pADC.Visible = (this.GalleryPage.GallerySettings.EnableGalleryObjectZipDownload && EnableAlbumDownload); }
/// <summary> /// Load the requested page and add it to the current <see cref="UserControl.Controls" /> collection. /// </summary> private void LoadRequestedPage() { PageId page = GetPageFromQueryString(); if ((page == PageId.install) || (page == PageId.upgrade)) { // We don't want the error handler to fire for install or upgrade scenarios. Since it talks to the database, which often // isn't working on these pages, it might throw an error, which masks the "real" error. this.Page.Error -= Gallery_Error; } string src = GetUserControlPath(page); try { Control control = LoadControl(src); // This will fire Util.InitializeApplication() for pages that implement <see cref="GalleryPage" />. // If the control is an instance of Pages.GalleryPage, then assign its GalleryControl property to the current instance. // This gives the control convenient access to the Page property. GalleryPage galleryControl = control as GalleryPage; if (galleryControl != null) { galleryControl.GalleryControl = this; galleryControl.PageId = page; // Verify we loaded the right control. The initial decision was based on the query string, but there are other // configuration settings that can override it. control = ValidateRequestedPage(galleryControl, page); } this.Controls.Add(control); } catch (FileNotFoundException) { throw new ApplicationException(String.Format(Resources.GalleryServerPro.Error_Cannot_Load_User_Control_Ex_Msg, src)); } }
public AlbumWebEntity GetAlbumInfo(int albumId) { try { AlbumWebEntity albumEntity = new AlbumWebEntity(); if (GalleryPage.IsUserAuthorized(SecurityActions.ViewAlbumOrMediaObject, albumId)) { IAlbum album = Factory.LoadAlbumInstance(albumId, false); albumEntity.Title = album.Title; albumEntity.Summary = album.Summary; albumEntity.DateStart = album.DateStart; albumEntity.DateEnd = album.DateEnd; albumEntity.IsPrivate = album.IsPrivate; } return(albumEntity); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }