예제 #1
0
        private void SaveNotes()
        {
            foreach (RepeaterItem ri in CartRepeater.Items)
            {
                switch (ri.ItemType)
                {
                case (ListItemType.Item):
                case (ListItemType.AlternatingItem):

                    HiddenField CartIdHiddenField = (HiddenField)ri.FindControl("CartIdHiddenField");
                    int         cartId            = Convert.ToInt32(CartIdHiddenField.Value);

                    TextBox NotesTextBox = (TextBox)ri.FindControl("NotesTextBox");
                    string  notes        = NotesTextBox.Text.Trim();

                    DatePicker DateRequiredPicker = (DatePicker)ri.FindControl("DateRequiredPicker");
                    DateTime?  requiredByDate     = DateRequiredPicker.SelectedDate;

                    Cart cart = ContextInfo.CartManager.GetCartById(cartId);
                    cart.Notes          = notes;
                    cart.RequiredByDate = requiredByDate;
                    Cart.Update(cart);

                    FeedbackLabel1.SetSuccessMessage("notes updated");

                    break;
                }
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
        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);
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
 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);
     }
 }
        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());
            }
        }
예제 #11
0
        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");
            }
        }
예제 #12
0
        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");
            }
        }
예제 #13
0
        protected void CopyDownloadSettingsToAllButton_Click(object sender, EventArgs e)
        {
            bool   found = false;
            Button btn   = (Button)sender;

            int            sourceAssetId    = 0;
            DownloadFormat downloadFormat   = DownloadFormat.Original;
            int            assetImageSizeId = 0;

            foreach (RepeaterItem ri in OrderItemsRepeater.Items)
            {
                if (!GeneralUtils.ValueIsInList(ri.ItemType, ListItemType.Item, ListItemType.AlternatingItem))
                {
                    continue;
                }

                Button CopyDownloadSettingsToAllButton = (Button)ri.FindControl("CopyDownloadSettingsToAllButton");

                if (CopyDownloadSettingsToAllButton.UniqueID != btn.UniqueID)
                {
                    continue;
                }

                HiddenField AssetIdHiddenField = (HiddenField)ri.FindControl("AssetIdHiddenField");
                DownloadFormatDropDownList DownloadFormatDropDownList1 = (DownloadFormatDropDownList)ri.FindControl("DownloadFormatDropDownList1");
                AssetImageSizeDropDownList AssetImageSizeDropDownList1 = (AssetImageSizeDropDownList)ri.FindControl("AssetImageSizeDropDownList1");

                sourceAssetId    = Convert.ToInt32(AssetIdHiddenField.Value);
                downloadFormat   = DownloadFormatDropDownList1.SelectedDownloadFormat;
                assetImageSizeId = AssetImageSizeDropDownList1.SelectedId;

                found = true;

                break;
            }

            if (!found)
            {
                return;
            }

            AssetFinder finder = new AssetFinder();

            finder.AssetIdList.Add(0);
            finder.AssetIdList.AddRange(CurrentOrder.OrderItemList.Select(o => o.AssetId));
            List <Asset> assetList = Asset.FindMany(finder);

            Asset sourceAsset = assetList.Where(a => a.AssetId == sourceAssetId).FirstOrDefault() ?? Asset.Empty;

            Debug.Assert(!sourceAsset.IsNull);

            foreach (OrderItem oi in CurrentOrder.OrderItemList)
            {
                // Get the asset for the order item
                Asset asset = assetList.Where(a => a.AssetId == oi.AssetId).FirstOrDefault() ?? Asset.Empty;

                // Non-images do not have download options so ignore them
                if (!AssetTypeChecker.IsImage(asset.FileExtension))
                {
                    continue;
                }

                // Update the selection
                SelectedOrderItems.AddUpdate(oi.OrderItemId.GetValueOrDefault(), downloadFormat, assetImageSizeId);
            }

            // Rebind the list
            Bind(CurrentPage);

            FeedbackLabel1.SetSuccessMessage("Download options updated successfully");
        }