protected void CatalogueSelectedAssetsButton_Click(object sender, EventArgs e) { try { // Get selected asset ID's List <Int32> assetIdList = (from ListItem li in SessionAssetsListBox.Items where li.Selected select Convert.ToInt32(li.Value)).ToList(); // Get the template ID int templateId = NumericUtils.ParseInt32(AssetTemplateIdTextBox.Text, -1); // Validate assets and use the specified template if required // This only applies if we're using a template - not the first asset AssetCataloguer.CatalogueAssets(assetIdList, UseTemplateRadioButton.Checked, templateId, AssetTypeDropDownList1.SelectedId); // Create a session-based asset pager for the selected assets SessionInfo.Current.AdminSessionInfo.AssetPager = new AssetPager(assetIdList); // Using the first asset for cataloguing works differently. We store a boolean // in the session so that we know to use the first asset ID in the catalogue as // the template, and then when that asset is edited, we run the merge operation. SessionInfo.Current.AdminSessionInfo.AssetPager.UseFirstAssetAsTemplate = FirstAssetRadioButton.Checked; // Redirect to the asset form for the first asset in the list string redirectUrl = string.Format("AssetForm.aspx?assetId={0}", SessionInfo.Current.AdminSessionInfo.AssetPager.FirstAssetId()); Response.Redirect(redirectUrl, false); } catch (CatalogueAssetsException ceax) { FeedbackLabel1.SetErrorMessage(ceax.Message); return; } }
protected void DeleteButton_Click(object sender, EventArgs e) { CheckAssetList(); string password = PasswordTextBox.Text.Trim(); if (StringUtils.IsBlank(password)) { FeedbackLabel1.SetErrorMessage("Please enter your password"); return; } if (!CurrentUser.CheckPassword(password)) { FeedbackLabel1.SetErrorMessage("Incorrect password. Please try again."); return; } foreach (int assetId in AssetIdList) { AssetManager.DeleteAsset(CurrentUser, assetId); } Response.Redirect("AssetList.aspx?PostAction=BulkAssetDeleteSuccessful"); }
protected void DeletePreview_Click(object sender, EventArgs e) { AssetPreviewInfo info = new AssetPreviewInfo(Asset); if (info.FileExists) { try { File.Delete(info.FilePath); AssetPreview1.Asset = Asset; FeedbackLabel1.SetSuccessMessage("Preview deleted successfully"); ConfigurePreviewSettings(); PreviewExtensionLabel.Text = String.Empty; } catch (Exception ex) { ExceptionHandler.HandleException(ex, "Error deleting preview"); FeedbackLabel1.SetErrorMessage("Error deleting preview: " + ex.Message); } } else { FeedbackLabel1.SetErrorMessage("Preview file does not exist"); } }
protected void RegenerateThumbnail_Click(object sender, EventArgs e) { try { if (APSGateway.Instance.ProcessFile(Asset, false, FileOutputs.Thumbnail)) { // Mark asset as unprocessed Asset.IsProcessed = false; Asset.Update(Asset); // Update the thumbnail AssetThumbnail1.Initialise(Asset); // Update the UI FeedbackLabel1.SetSuccessMessage("New thumbnail will be generated shortly"); } else { FeedbackLabel1.SetErrorMessage("An error occurred when submitting asset to processing service. Thumbnail will not be regenerated."); } } catch (InvalidAssetException iaex) { FeedbackLabel1.SetErrorMessage(iaex.Message); } catch (Exception ex) { ExceptionHandler.HandleException(ex, "Error regenerating thumbnail"); FeedbackLabel1.SetErrorMessage("Error regenerating thuumbnail: " + ex.Message); } }
protected void RegeneratePreview_Click(object sender, EventArgs e) { try { if (APSGateway.Instance.ProcessFile(Asset, false, FileOutputs.Preview)) { // Mark asset as unprocessed Asset.IsProcessed = false; Asset.Update(Asset); // Update preview AssetPreview1.Asset = Asset; // Update UI FeedbackLabel1.SetSuccessMessage("New preview will be generated shortly"); PreviewExtensionLabel.Text = String.Empty; } else { FeedbackLabel1.SetErrorMessage("An error occurred when submitting asset to processing service. Preview will not be regenerated."); } } catch (InvalidAssetException iaex) { FeedbackLabel1.SetErrorMessage(iaex.Message); } catch (Exception ex) { ExceptionHandler.HandleException(ex, "Error regenerating preview"); FeedbackLabel1.SetErrorMessage("Error regenerating preview: " + ex.Message); } }
protected void SavePreviewButton_Click(object sender, EventArgs e) { BinaryFile file = new BinaryFile(PreviewFileUpload.PostedFile); if (file.IsEmpty) { FeedbackLabel1.SetErrorMessage("No file uploaded"); return; } bool feedbackSet = false; if (!m_AllowedPreviewExtensions.Contains(file.FileExtension)) { string acceptExtensions = string.Join(",", m_AllowedPreviewExtensions.ToArray()); if (m_ForcePreviewFormat) { //allow upload but display warning FeedbackLabel1.SetErrorMessage(String.Format("You have supplied a file with the extension {0}, but only files with {1} extensions are supported by this viewer. Your file may not display correctly.", file.FileExtension, acceptExtensions)); feedbackSet = true; } else { //prevent upload and display warning FeedbackLabel1.SetErrorMessage(String.Format("You have supplied a file with the extension {0}, but only files with {1} extensions are supported by this viewer. Please choose another.", file.FileExtension, acceptExtensions)); return; } } try { // Save the preview AssetFileManager.SaveAssetFile(Asset, file, AssetFileType.AssetPreview); // Mark asset as processed Asset.IsProcessed = true; Asset.Update(Asset); // Update preview AssetPreview1.Asset = Asset; // Update UI if (!feedbackSet) { FeedbackLabel1.SetSuccessMessage("Preview updated successfully"); } ConfigurePreviewSettings(); } catch (Exception ex) { ExceptionHandler.HandleException(ex, "Error saving preview"); FeedbackLabel1.SetErrorMessage("Error saving preview: " + ex.Message); } }
protected void RegenerateAssetBitmapsButton_Click(object sender, EventArgs e) { try { AssetBitmapGroupManager.Generate(Asset); FeedbackLabel1.SetSuccessMessage("New asset bitmaps will be generated shortly"); } catch (Exception ex) { FeedbackLabel1.SetErrorMessage("Unable to regenerate asset bitmaps: " + ex.Message); } }
protected void RegisterButton_Click(object sender, EventArgs e) { // Get new user with default values set User user = UserManager.GetNewUser(); // Set the default account expiry date user.AccountExpiryDate = DateTime.Now.AddDays(UserManager.AccountExpiryDays); // Initialise user from posted values user.FirstName = UserDetailsForm1.FirstName; user.LastName = UserDetailsForm1.LastName; user.Email = UserDetailsForm1.Email; user.SetPassword(UserDetailsForm1.Password); user.SetConfirmPassword(UserDetailsForm1.ConfirmPassword); user.IsEmployee = UserDetailsForm1.IsStaffUser; user.CompanyName = UserDetailsForm1.CompanyName; user.CountryId = UserDetailsForm1.CountryId; user.PhoneNumber = UserDetailsForm1.PhoneNumber; user.MobileNumber = UserDetailsForm1.MobileNumber; // Give the user access to the selected brand and set this as // the primary brand. Additional brands can be added by an admin user.PrimaryBrandId = UserDetailsForm1.BrandId; user.Brands.Add(user.PrimaryBrand); try { UserManager.Register(user); FormPanel.Visible = false; FeedbackPanel.Visible = true; PendingEmailMessage.Visible = (user.UserStatus == FocusOPEN.Shared.UserStatus.PendingEmailConfirmation); AdminApprovalMessage.Visible = (user.UserStatus == FocusOPEN.Shared.UserStatus.PendingAdminApproval); } catch (InvalidUserException iuex) { FeedbackLabel1.SetErrorMessage("the following errors occured:", iuex.Errors); } catch (RegistrationSecurityException rsuex) { FeedbackLabel1.SetErrorMessage(rsuex.Message); NotifyEngine.InvalidRegistrationAttempt(rsuex); } catch (Exception ex) { FeedbackLabel1.SetErrorMessage("An unknown error occured:", ex.ToString()); } }
protected void RemoveSelectedAssetsLinkButton_Click(object sender, EventArgs e) { if (SelectedCartItemIdList.Count == 0) { FeedbackLabel1.SetErrorMessage("no assets selected"); return; } foreach (int cartId in SelectedCartItemIdList) { ContextInfo.CartManager.RemoveCartItemFromCart(cartId); } SelectedCartItemIdList.Clear(); FeedbackLabel1.SetSuccessMessage("selected assets removed from cart"); Bind(CurrentPage); }
protected void SaveChangesButton_Click(object sender, EventArgs e) { // Get the user data from the database // This is to ensure it is up-to-date, rather than just using the current user in // session in case the user has been updated by an admin since the user logged in. User user = Data.User.Get(CurrentUser.UserId); // Initialise user from posted values user.FirstName = UserDetailsForm1.FirstName; user.LastName = UserDetailsForm1.LastName; user.Email = UserDetailsForm1.Email; user.SetConfirmPassword(UserDetailsForm1.ConfirmPassword); user.IsEmployee = UserDetailsForm1.IsStaffUser; user.CompanyName = UserDetailsForm1.CompanyName; user.PrimaryBrandId = UserDetailsForm1.BrandId; user.CountryId = UserDetailsForm1.CountryId; user.PhoneNumber = UserDetailsForm1.PhoneNumber; user.MobileNumber = UserDetailsForm1.MobileNumber; if (!StringUtils.IsBlank(UserDetailsForm1.Password)) { user.SetPassword(UserDetailsForm1.Password); if (user.PasswordChanged) { user.PasswordExpiryDate = DateTime.Now.AddDays(UserManager.PasswordExpiryDays); } } try { UserManager.Update(user); SessionInfo.Current.User = user; AuditLogManager.LogUserAction(user, AuditUserAction.AccountUpdate, "Profile updated successfully."); FeedbackLabel1.SetSuccessMessage("Your profile has been updated"); } catch (InvalidUserException iuex) { FeedbackLabel1.SetErrorMessage("the following errors occured:", iuex.Errors); } }
protected void ProcessCartButton_Click(object sender, EventArgs e) { if (!AgreeTermsConditionsCheckBox.Checked) { FeedbackLabel2.SetErrorMessage("you must agree to Terms & Conditions of Use before your order can be processed"); return; } try { SaveNotes(); Order order = OrderManager.CreateOrderFromCart(CurrentUser); Response.Redirect("ViewOrders.aspx?orderId=" + order.OrderId); } catch (InvalidOrderException ioex) { FeedbackLabel1.SetErrorMessage(ioex.Message); } }
protected void ChangePasswordButton_Click(object sender, EventArgs e) { string existingPassword = ExistingPasswordTextBox.Text; string newPassword = NewPasswordTextBox.Text; string newPasswordConfirmation = ConfirmPasswordTextBox.Text; try { UserManager.ChangePassword(CurrentUser, existingPassword, newPassword, newPasswordConfirmation); SessionInfo.Current.User = CurrentUser; LoginManager.UpdateLastLoginAuditInfo(SessionInfo.Current.User); Login.SetupSessionForCurrentSessionUser(); Response.Redirect("~/Default.aspx"); } catch (ChangePasswordException cpex) { FeedbackLabel1.SetErrorMessage(cpex.Message); } }
private bool AreAssetsSelected() { int count = 0; // Count how many order items should be downloaded if (CurrentOrder.OrderItemList.Any(ShouldDownload)) { count++; } // Ensure there's at least one if (count == 0) { FeedbackLabel1.SetErrorMessage("no assets have been selected"); return(false); } return(true); }
protected void RegeneratePreviewAndThumbnailLinkButton_Click(object sender, EventArgs e) { try { if (APSGateway.Instance.ProcessFile(Asset, false, FileOutputs.All)) { Asset.IsProcessed = false; Asset.Update(Asset); PreviewExtensionLabel.Text = String.Empty; FeedbackLabel1.SetSuccessMessage("New preview and thumbnail wil be regenerated shortly."); } else { FeedbackLabel1.SetErrorMessage("An error occurred when submitting asset to processing service. Preview and thumbnail will not be regenerated."); } } catch (Exception ex) { ExceptionHandler.HandleException(ex, "Error regenerating thumbnail and preview"); FeedbackLabel1.SetErrorMessage("Error regenerating thumbnail and preview: " + ex.Message); } }
protected void GenerateReportButton_Click(object sender, EventArgs e) { // Ensure at least one activity is checked bool anyChecked = (UploadedCheckBox.Checked || DownloadedCheckBox.Checked || OrderRequestsCheckBox.Checked || ViewsCheckBox.Checked || SearcHitsCheckBox.Checked || CartCheckBox.Checked || LightboxCheckBox.Checked); if (!anyChecked) { FeedbackLabel1.SetErrorMessage("the following errors occured", "at least one activity must be selected"); return; } InitialPanel.Visible = false; ResultsPanel.Visible = true; ResultsHeaderPanel.Visible = true; InitialFooterPanel.Visible = false; ResultsFooterPanel.Visible = true; string panel = AssetListPanel.Visible ? "assetlist" : "activitysummary"; DisplayPanel(panel); }
private void UpdateCategory(int categoryId) { try { string name = NameTextBox.Text; string reference = ExternalRefTextBox.Text; string message = MessageTextBox.Text; string synonyms = SynonymsTextBox.Text; CategoryManager.UpdateCategory(categoryId, name, reference, message, synonyms, CurrentUser); FeedbackLabel1.SetSuccessMessage("Category updated successfully"); } catch (CategoryException categoryEx) { FeedbackLabel1.SetErrorMessage("the following errors occured:", categoryEx.Errors); } catch (Exception ex) { m_Logger.Fatal(string.Format("Error editing category with id: {0}", categoryId), ex); FeedbackLabel1.SetErrorMessage("An unhandled error occured", ex.ToString()); } }
protected void DeleteThumbnail_Click(object sender, EventArgs e) { AssetThumbnailInfo info = new AssetThumbnailInfo(Asset); if (info.FileExists) { try { File.Delete(info.FilePath); AssetThumbnail1.Initialise(Asset); FeedbackLabel1.SetSuccessMessage("Thumbnail deleted successfully"); } catch (Exception ex) { ExceptionHandler.HandleException(ex, "Error deleting thumbnail"); FeedbackLabel1.SetErrorMessage("Error deleting thumbnail: " + ex.Message); } } else { FeedbackLabel1.SetErrorMessage("Thumbnail file does not exist"); } }
protected void SaveThumbnailButton_Click(object sender, EventArgs e) { BinaryFile file = new BinaryFile(ThumbnailFileUpload.PostedFile); if (file.IsEmpty) { FeedbackLabel1.SetErrorMessage("No file uploaded"); return; } if (!m_AllowedThumbnailExtensions.Contains(file.FileExtension)) { FeedbackLabel1.SetErrorMessage("Invalid file uploaded"); return; } try { // Save the thumbnail AssetFileManager.SaveAssetFile(Asset, file, AssetFileType.AssetThumbnail); // Mark asset as processed Asset.IsProcessed = true; Asset.Update(Asset); // Update thumbnail display AssetThumbnail1.Initialise(Asset); // Update UI FeedbackLabel1.SetSuccessMessage("Thumbnail updated successfully"); } catch (Exception ex) { FeedbackLabel1.SetErrorMessage("Error saving thumbnail: " + ex.Message); ExceptionHandler.HandleException(ex, "Error saving thumbnail"); } }
protected void NextButton_Click(object sender, EventArgs e) { ErrorList errors = new ErrorList(); if (StringUtils.IsBlank(FtpHostTextBox.Text)) { errors.Add("Ftp host is required"); } if (NumericUtils.ParseInt32(FtpPortTextBox.Text, 0) == 0) { errors.Add("Ftp host port must be a number"); } if (StringUtils.IsBlank(FtpUsernameTextBox.Text)) { errors.Add("Username is required"); } if (errors.Count > 0) { FeedbackLabel1.SetErrorMessage("Please check the following and try again:", errors); return; } // List of files to upload List <FtpFile> assetFilePaths = new List <FtpFile>(); // Get all of the order items in the current order foreach (OrderItem orderItem in SelectedOrder.OrderItemList) { // Get the order item id int orderItemId = orderItem.OrderItemId.GetValueOrDefault(); // Check if the order item can be downloaded and is in the list of selected order items if (ViewOrders.CanDownload(orderItem) && SelectedOrderItems.Contains(orderItemId)) { // Get the asset Asset asset = orderItem.Asset; // Get the selected order item SelectedOrderItem soi = SelectedOrderItems.Get(orderItemId); // Initialise path and filename to FTP string path, filename; // Check if zip asset files is enabled and we're not doing any kind of transcoding. // If so, we want to FTP the zipped asset file instead, so set the path and filename accordingly. // However, if the zip file doesn't exist, then we want to FTP the original asset instead. if (AssetFileManager.ZipAssetFiles && soi.AssetImageSizeId == 0) { // First get the path to the zipped asset file ZippedAssetFileInfo zippedFileInfo = new ZippedAssetFileInfo(asset); if (zippedFileInfo.FileExists) { // Ensure that a path was returned, and if so, set the filename accordingly path = zippedFileInfo.FilePath; filename = Path.GetFileNameWithoutExtension(asset.Filename) + ".zip"; } else { // Otherwise, the zip file doesn't exist, so get the path to the original // asset file, and set the filename to the asset filename AssetFileInfo info = new AssetFileInfo(asset); path = info.FilePath; filename = asset.Filename; } } else { // Get the file path to the asset AssetFileInfo info = new AssetFileInfo(asset); path = info.FilePath; // For images, get the filepath to the resized image if (AssetTypeChecker.IsImage(asset.FileExtension)) { path = AssetImageManager.GetResizedAssetImage(asset, soi.AssetImageSizeId, soi.DownloadFormat, true); } // Construct the asset filename filename = Path.GetFileNameWithoutExtension(asset.Filename) + Path.GetExtension(path); } // Add the file path to the list FtpFile file = new FtpFile(path, filename); assetFilePaths.Add(file); } } try { // Instantiate FTP downloader FtpDownloader ftpDownloader = new FtpDownloader { BackgroundTransfer = true, Host = FtpHostTextBox.Text.Trim(), Port = NumericUtils.ParseInt32(FtpPortTextBox.Text, 0), PassiveMode = FtpPassiveModeCheckBox.Checked, Username = FtpUsernameTextBox.Text.Trim(), Password = FtpPasswordTextBox.Text.Trim(), RemoteFolder = FtpRemoteFolderTextBox.Text.Trim(), User = CurrentUser }; // Specify files to send to FTP server foreach (FtpFile file in assetFilePaths) { ftpDownloader.Files.Add(file); } // Wire up events ftpDownloader.UploadComplete += new FtpDownloadCompleteEventHandler(NotifyEngine.FtpDownloadComplete); // Go do it! ftpDownloader.Go(); // Log the assets as downloaded foreach (SelectedOrderItem soi in SelectedOrderItems) { OrderItem orderItem = OrderItem.Get(soi.OrderItemId); Asset asset = orderItem.Asset; AuditLogManager.LogAssetAction(asset, CurrentUser, AuditAssetAction.DownloadedAssetFile); AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.DownloadAsset, string.Format("Downloaded AssetId: {0} as part of FTP download to: {1} for OrderId: {2}", asset.AssetId, ftpDownloader.Host, orderItem.OrderId)); } // Lets cookie the settings as well, so we can pre-populate // the form when the user returns to download more assets CookieManager.SetValue("FtpHost", ftpDownloader.Host); CookieManager.SetValue("FtpPort", ftpDownloader.Port); CookieManager.SetValue("FtpPassiveMode", FtpPassiveModeCheckBox.Checked ? "1" : "0"); CookieManager.SetValue("FtpUsername", ftpDownloader.Username); // Update UI FormPanel.Visible = false; SuccessPanel.Visible = true; } catch (FtpDownloadException fdex) { // Remove the error code from the start of the error message string message = Regex.Replace(fdex.Message, @"(\d+\s-\s)", string.Empty); // Display the error to the user FeedbackLabel1.SetErrorMessage("Error downloading assets", message); // Log the error m_Logger.Warn(string.Format("Error downloading files to FTP. User: {0}, Host: {1}. Error: {2}", CurrentUser.FullName, FtpHostTextBox.Text, message), fdex); } }