Esempio n. 1
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (LineBreakOnTop || UseContainer)
            {
                writer.WriteLine("<br class=\"h5\"/>");
            }

            if (UseContainer)
            {
                writer.WriteLine("<div class=\"AppCtrlMrg\">");
            }

            string html = string.Format("<img src=\"{0}\" width=\"14\" height=\"14\" />", GetImagePath());

            writer.WriteLine(html);

            if (Header.Length > 0)
            {
                Header = SiteUtils.ConvertTextToHtml(Header, GetHeaderTextClass());
                html   = string.Format("<span class=\"{0}\">{1}<br /></span>", GetHeaderTextClass(), Header);
                writer.WriteLine(html);
            }

            if (m_Errors.Count > 0)
            {
                for (int i = 0; i < m_Errors.Count; i++)
                {
                    string error = m_Errors[i].ToString();

                    error = SiteUtils.ConvertTextToHtml(error, GetTextClass());
                    html  = string.Format("<span class=\"{0}\"> - {1}<br /></span>", GetTextClass(), error);
                    writer.Write(html);
                }
            }
            else if (Text.Length > 0)
            {
                Text = SiteUtils.ConvertTextToHtml(Text, GetTextClass());
                html = string.Format("<span class=\"{0}\">{1}{2}<br /></span>", GetTextClass(), TextPrefix, Text);
                writer.WriteLine(html);
            }

            for (int i = 0; i < LineBreaks; i++)
            {
                writer.WriteBreak();
            }

            if (UseContainer)
            {
                writer.WriteLine("</div>");
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (AssetWorkflowCommenter.IsNull)
                {
                    Response.Redirect("~/Admin/Assets/AssetList.aspx");
                }

                if (!StringUtils.IsBlank(AssetWorkflowCommenter.Comments))
                {
                    MessageLabel.SetErrorMessage("You have already commented on this workflow");
                    MessageLabel.Pinned = true;
                    DisableUI();
                }

                if (AssetWorkflow.IsComplete)
                {
                    MessageLabel.SetErrorMessage("Asset workflow is complete and comments have been disabled");
                    MessageLabel.Pinned = true;
                    DisableUI();
                }

                AssetWorkflowUserList.Repeater.DataSource = AssetWorkflow.AssetWorkflowUserList;
                AssetWorkflowUserList.Repeater.DataBind();

                Asset asset = AssetWorkflow.Asset;

                AssetReferenceLiteral.Text = asset.AssetId.ToString();
                UploadUserEmailHyperLink.SetNameEmail(asset.UploadedByUser.FullName, asset.UploadedByUser.Email);
                PublicationDateLiteral.Text        = asset.PublishDate.ToString(Global.DateFormat);
                DownloadAssetHyperLink.NavigateUrl = AssetFileUrlHelper.GetDownloadUrl(asset.AssetId);
                AssetThumbnail.Initialise(asset);
                AssetButtons1.Initialise(asset);
                AssetTypeCell.InnerText           = asset.AssetType.Name;
                BrandCell.InnerText               = asset.BrandName;
                ShortDescriptionCell.InnerHtml    = SiteUtils.ConvertTextToHtml(asset.Description);
                UsageRestrictionsCell.InnerText   = asset.UsageRestrictions;
                InvitingUserName.Text             = AssetWorkflowCommenter.InvitingUser.FullName;
                InvitingUserMessageCell.InnerText = AssetWorkflowCommenter.InvitingUserMessage;
                ResponseTextArea.Text             = AssetWorkflowCommenter.Comments;

                SiteUtils.SetHyperLink("Assets.AssetForm", string.Format("?assetId={0}", asset.AssetId), EditAssetHyperLink);

                AssetWorkflowLog.Bind(AssetWorkflow.Asset);
            }
        }
Esempio n. 3
0
        protected void ConversationRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:

                OrderItemComment orderItemComment = (OrderItemComment)e.Item.DataItem;

                Label UserNameLabel = (Label)e.Item.FindControl("UserNameLabel");
                UserNameLabel.Text = orderItemComment.UserFullName;

                Label DateLabel = (Label)e.Item.FindControl("DateLabel");
                DateLabel.Text = orderItemComment.CommentDate.ToString(Global.DateTimeFormat);

                Label CommentTextLabel = (Label)e.Item.FindControl("CommentTextLabel");
                CommentTextLabel.Text = SiteUtils.ConvertTextToHtml(orderItemComment.CommentText, e.Item.ItemType == ListItemType.Item ? "PosTxt" : "BodyTxt");

                break;
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (CurrentAsset.IsNull)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "close", "self.close();", true);
                    return;
                }

                // Get the asset ID
                int assetId = CurrentAsset.AssetId.GetValueOrDefault();

                // Get the asset type info
                AssetTypeInfo assetType = AssetTypeInfo.Get(CurrentAsset.FileExtension);


                //-----------------------------------------------------------------------------------------------------
                // Set up UI elements based on asset type
                //-----------------------------------------------------------------------------------------------------
                OrientationRow.Visible = assetType.HasOrientation;
                DurationRow.Visible    = assetType.HasDuration;
                DimensionsRow.Visible  = assetType.HasDimensions;

                //-----------------------------------------------------------------------------------------------------
                // Set up asset breadcrumbs based on category
                //-----------------------------------------------------------------------------------------------------
                AssetBreadcrumb.CategoryId = CurrentAsset.PrimaryCategoryId;

                //-----------------------------------------------------------------------------------------------------
                // Update the audit log
                //-----------------------------------------------------------------------------------------------------
                AuditLogManager.LogAssetAction(assetId, CurrentUser, AuditAssetAction.ViewedAssetDetail);
                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ViewedAssetDetail, string.Format("Viewed asset detail for AssetId: {0}", assetId));

                //-----------------------------------------------------------------------------------------------------
                // Initialise the asset preview and buttons
                //-----------------------------------------------------------------------------------------------------
                AssetPreview1.Asset = CurrentAsset;
                AssetButtons1.Initialise(CurrentAsset);

                //-----------------------------------------------------------------------------------------------------
                // Bind categories list
                //-----------------------------------------------------------------------------------------------------
                AssetCategoriesContainer.Visible = (CurrentAsset.CategoryList.Count > 0);
                CategoriesRepeater.DataSource    = CurrentAsset.CategoryList;
                CategoriesRepeater.DataBind();

                //-----------------------------------------------------------------------------------------------------
                // Bind attached files
                //-----------------------------------------------------------------------------------------------------
                List <AssetFile> attachedFiles = CurrentAsset.GetAttachedFiles();
                AttachedFilesRow.Visible         = (attachedFiles.Count > 0);
                AttachedFilesDataList.DataSource = attachedFiles;
                AttachedFilesDataList.DataBind();

                //-----------------------------------------------------------------------------------------------------
                // Bind linked assets
                //-----------------------------------------------------------------------------------------------------
                LinkedAssetsRow.Visible         = (CurrentAsset.ReciprocalLinkedAssetList.Count > 0);
                LinkedAssetsRepeater.DataSource = CurrentAsset.ReciprocalLinkedAssetList;
                LinkedAssetsRepeater.DataBind();

                //-----------------------------------------------------------------------------------------------------
                // Set up the file type icon
                //-----------------------------------------------------------------------------------------------------
                FileTypeIconImage.ImageUrl = SiteUtils.GetFileTypeImageUrl(CurrentAsset.FileExtension);
                FileTypeIconImage.ToolTip  = CurrentAsset.Filename;

                //-----------------------------------------------------------------------------------------------------
                // Brand controlled metadata
                //-----------------------------------------------------------------------------------------------------
                AssetIdCell.InnerText      = CurrentAsset.AssetId.ToString();
                DateUploadedLabel.Text     = CurrentAsset.UploadDate.ToString(Global.DateFormat);
                FilenameCell.InnerText     = FileUtils.GetTruncatedFilename(CurrentAsset.Filename, 25);
                FileHashLabel.Text         = StringUtils.IsBlank(CurrentAsset.FileHash) ? "[Not Available]" : CurrentAsset.FileHash.Substring(0, 15) + " ...";
                FileHashLabel.ToolTip      = CurrentAsset.FileHash;
                FilesizeCell.InnerText     = FileUtils.FriendlyFileSize(CurrentAsset.FileSize);
                AssetTypeCell.InnerText    = CurrentAsset.AssetType.Name;
                DateProducedCell.InnerText = CurrentAsset.GetProductionDate();
                OriginatorCell.InnerText   = CurrentAsset.Originator;
                TitleCell.InnerText        = CurrentAsset.Title;
                ProjectCodeCell.InnerText  = CurrentAsset.ProjectCode;
                BrandCell.InnerText        = CurrentAsset.Brand.Name;

                AssetDescriptionContainer.InnerHtml = SiteUtils.ConvertTextToHtml(CurrentAsset.Description);
                AdditionalKeywordsCell.InnerText    = CurrentAsset.Keywords;
                CopyrightOwnerCell.InnerHtml        = StringUtils.IgnoreCaseCompare(CurrentAsset.CopyrightOwner, WebsiteBrandManager.GetBrand().OrganisationName) ? "(c) " + CurrentAsset.CopyrightOwner : CurrentAsset.CopyrightOwner;
                UsageRestrictionsCell.InnerHtml     = CurrentAsset.UsageRestrictions;
                ContactEmailHyperLink.EmailAddress  = CurrentAsset.ContactEmail;
                PublicationDateCell.InnerText       = CurrentAsset.PublishDate.ToString(Global.DateFormat);
                ExpiryDateCell.InnerText            = CurrentAsset.ExpiryDate.ToString(Global.DateFormat);

                // order metas according to their meta settings asset detail order numbers
                TrBrand.Attributes["class"]              = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.BRAND).AssetDetailOrderNum.ToString();
                TrAssetType.Attributes["class"]          = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ASSET_TYPE).AssetDetailOrderNum.ToString();
                TrFilename.Attributes["class"]           = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.FILENAME).AssetDetailOrderNum.ToString();
                TrFileSize.Attributes["class"]           = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.FILESIZE).AssetDetailOrderNum.ToString();
                TrFileHash.Attributes["class"]           = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.FILEHASH).AssetDetailOrderNum.ToString();
                TrDateUploaded.Attributes["class"]       = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.DATE_UPLOADED).AssetDetailOrderNum.ToString();
                TrTitle.Attributes["class"]              = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.TITLE).AssetDetailOrderNum.ToString();
                TrProjectCode.Attributes["class"]        = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.PROJECT_CODE).AssetDetailOrderNum.ToString();
                TrOriginator.Attributes["class"]         = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ORIGINATOR).AssetDetailOrderNum.ToString();
                TrDateProduced.Attributes["class"]       = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.DATE_PRODUCED).AssetDetailOrderNum.ToString();
                TrContactEmail.Attributes["class"]       = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.CONTACT_EMAIL).AssetDetailOrderNum.ToString();
                TrCopyrightOwner.Attributes["class"]     = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.COPYRIGHT_OWNER).AssetDetailOrderNum.ToString();
                TrRestrictedDownload.Attributes["class"] = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.DOWNLOAD_RESTRICTIONS).AssetDetailOrderNum.ToString();
                TrUsageRestrictions.Attributes["class"]  = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.USAGE_RESTRICTIONS).AssetDetailOrderNum.ToString();
                TrAdditionalKeywords.Attributes["class"] = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ADDITIONAL_KEYWORDS).AssetDetailOrderNum.ToString();
                TrPublicationDate.Attributes["class"]    = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.PUBLICATION_DATE).AssetDetailOrderNum.ToString();
                TrExpiryDate.Attributes["class"]         = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.EXPIRY_DATE).AssetDetailOrderNum.ToString();
                LinkedAssetsRow.Attributes["class"]      = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.LINKED_ASSETS).AssetDetailOrderNum.ToString();
                AttachedFilesRow.Attributes["class"]     = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ATTACHED_FILES).AssetDetailOrderNum.ToString();

                var allSettings = BrandMetadataSettingManager.GetCustomMetadataSettings(CurrentAsset.Brand.BrandId.GetValueOrDefault());
                var lastNum     = allSettings.OrderBy(s => s.AssetDetailOrderNum).LastOrDefault().AssetDetailOrderNum;

                DimensionsRow.Attributes["class"]  = (lastNum++).ToString();
                DurationRow.Attributes["class"]    = (lastNum++).ToString();
                OrientationRow.Attributes["class"] = (lastNum++).ToString();

                //-----------------------------------------------------------------------------------------------------
                // Other stuff
                //-----------------------------------------------------------------------------------------------------
                OrientationCell.InnerText        = CurrentAsset.GetOrientation();
                DurationCell.InnerText           = SiteUtils.FriendlyDuration(CurrentAsset.Duration.GetValueOrDefault(), "Unknown");
                DimensionsCell.InnerText         = CurrentAsset.GetDimensions();
                RestrictedDownloadCell.InnerText = EntitySecurityManager.IsAssetRestricted(CurrentUser, CurrentAsset) ? "Yes" : "No";

                // Only show file metadata link if we have some available
                // ShowFileMeta data returns true if there is File metadata to display.
                FileMetadataLinkButton.Visible  = ShowFileMetadata();
                FileMetadataLinkDivider.Visible = FileMetadataLinkButton.Visible;

                //-----------------------------------------------------------------------------------------------------
                // Setup security in UI: Only display the edit and status links of the user has access
                //-----------------------------------------------------------------------------------------------------
                if (EntitySecurityManager.CanManageAsset(CurrentUser, CurrentAsset))
                {
                    string editUrl = "~/Admin/Assets/AssetForm.aspx?assetId=" + CurrentAsset.AssetId;
                    EditHyperLink.NavigateUrl = editUrl;
                    EditHyperLink.Attributes.Add("onClick", string.Format("GetParentWindow().location.href='{0}';self.close();return false;", ResolveUrl(editUrl)));

                    string statsUrl = "~/Admin/Reports/AssetStats.aspx?assetId=" + assetId;
                    StatsHyperLink.NavigateUrl = statsUrl;
                    StatsHyperLink.Attributes.Add("onClick", string.Format("GetParentWindow().location.href='{0}';self.close();return false;", ResolveUrl(statsUrl)));

                    string logHyperlink = "~/Admin/Reports/AssetAuditTrail.aspx?AssetId=" + CurrentAsset.AssetId;
                    LogHyperLink.NavigateUrl = logHyperlink;
                    LogHyperLink.Attributes.Add("onClick", string.Format("GetParentWindow().location.href='{0}';self.close();return false;", ResolveUrl(logHyperlink)));
                }
                else
                {
                    AssetLinksContainer.Visible = false;
                }

                //-----------------------------------------------------------------------------------------------------
                // Control access or AssetOrderHistory links.
                //-----------------------------------------------------------------------------------------------------
                if (!EntitySecurityManager.CanViewAssetOrderHistory(CurrentUser, CurrentAsset))
                {
                    // Get the asset order history, if there isn't any order history
                    // then hide the link.
                    // Set visiblity of order history link
                    OrderHistoryDivider.Visible    = false;
                    OrderHistoryLinkButton.Visible = false;
                }
                else
                {
                    // Get the asset order history, if there isn't any order history
                    // then hide the link.
                    if (!ShowOrderHistory())
                    {
                        // Set visiblity of order history link
                        OrderHistoryDivider.Visible    = false;
                        OrderHistoryLinkButton.Visible = false;
                    }
                }

                //-----------------------------------------------------------------------------------------------------
                // Populate blank cells
                //-----------------------------------------------------------------------------------------------------
                SiteUtils.PopulateBlankControl(AssetDescriptionContainer);
                SiteUtils.PopulateBlankControl(FilenameCell);
                SiteUtils.PopulateBlankControl(FilesizeCell);
                SiteUtils.PopulateBlankControl(TitleCell);
                SiteUtils.PopulateBlankControl(DurationCell);
                SiteUtils.PopulateBlankControl(ProjectCodeCell);
                SiteUtils.PopulateBlankControl(OriginatorCell);
                SiteUtils.PopulateBlankControl(DateProducedCell);
                SiteUtils.PopulateBlankControl(CopyrightOwnerCell);
                SiteUtils.PopulateBlankControl(OrientationCell);
                SiteUtils.PopulateBlankControl(UsageRestrictionsCell);
            }

            //sort metas on every request
            ClientScript.RegisterStartupScript(GetType(), "SortMetas2", "SortMetas();", true);

            //bind repeater on every request as otherwise labels stuff is lost
            MetadataRepeater.DataSource = BrandMetadataSettingManager.GetCustomMetadataSettings(CurrentAsset.BrandId);
            MetadataRepeater.DataBind();
        }
Esempio n. 5
0
        protected void CartRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case (ListItemType.Item):
            case (ListItemType.AlternatingItem):

                Cart  cart  = (Cart)e.Item.DataItem;
                Asset asset = cart.Asset;

                HiddenField AssetIdHiddenField = (HiddenField)e.Item.FindControl("AssetIdHiddenField");
                HiddenField CartIdHiddenField  = (HiddenField)e.Item.FindControl("CartIdHiddenField");

                AssetIdHiddenField.Value = asset.AssetId.ToString();
                CartIdHiddenField.Value  = cart.CartId.ToString();

                AssetThumbnail AssetThumbnail1 = (AssetThumbnail)e.Item.FindControl("AssetThumbnail1");
                AssetButtons   AssetButtons1   = (AssetButtons)e.Item.FindControl("AssetButtons1");

                AssetThumbnail1.Initialise(asset);
                AssetButtons1.Initialise(asset);

                HtmlTableCell  AssetIdCell = (HtmlTableCell)e.Item.FindControl("AssetIdCell");
                HtmlTableCell  AssetShortDescriptionCell  = (HtmlTableCell)e.Item.FindControl("AssetShortDescriptionCell");
                HtmlTableCell  AssetBrandNameCell         = (HtmlTableCell)e.Item.FindControl("AssetBrandNameCell");
                HtmlTableCell  AssetTypeCell              = (HtmlTableCell)e.Item.FindControl("AssetTypeCell");
                HtmlTableCell  UsageRestrictionsCell      = (HtmlTableCell)e.Item.FindControl("UsageRestrictionsCell");
                EmailHyperLink AssetContactEmailHyperLink = (EmailHyperLink)e.Item.FindControl("AssetContactEmailHyperLink");
                DatePicker     DateRequiredPicker         = (DatePicker)e.Item.FindControl("DateRequiredPicker");
                TextBox        NotesTextBox               = (TextBox)e.Item.FindControl("NotesTextBox");
                CheckBox       SelectAssetCheckBox        = (CheckBox)e.Item.FindControl("SelectAssetCheckBox");
                FeedbackLabel  CartItemMessageLabel       = (FeedbackLabel)e.Item.FindControl("CartItemMessageLabel");
                HtmlTableRow   IntendedUseRow             = (HtmlTableRow)e.Item.FindControl("IntendedUseRow");
                PlaceHolder    SaveNotesButtonPlaceHolder = (PlaceHolder)e.Item.FindControl("SaveNotesButtonPlaceHolder");

                AssetIdCell.InnerText = asset.AssetId.ToString();
                AssetShortDescriptionCell.InnerHtml     = SiteUtils.ConvertTextToHtml(asset.Description);
                AssetBrandNameCell.InnerText            = asset.Brand.Name;
                AssetTypeCell.InnerText                 = asset.AssetType.Name;
                UsageRestrictionsCell.InnerHtml         = asset.UsageRestrictions;
                AssetContactEmailHyperLink.EmailAddress = asset.ContactEmail;
                DateRequiredPicker.SelectedDate         = cart.RequiredByDate;
                NotesTextBox.Text           = cart.Notes;
                SelectAssetCheckBox.Checked = IsCartItemSelected(cart.CartId.GetValueOrDefault());

                // Ensure blank cells have content
                SiteUtils.PopulateBlankControl(AssetShortDescriptionCell);
                SiteUtils.PopulateBlankControl(UsageRestrictionsCell);

                AssetStatus assetStatus  = AssetManager.GetAssetStatusForUser(asset, CurrentUser);
                bool        isRestricted = EntitySecurityManager.IsAssetRestricted(CurrentUser, asset);

                switch (assetStatus)
                {
                case AssetStatus.Withdrawn:

                    CartItemMessageLabel.MessageType   = BaseMessageLabel.MessageTypes.Withdrawn;
                    CartItemMessageLabel.Header        = "this asset is not available for ordering";
                    IntendedUseRow.Visible             = false;
                    SaveNotesButtonPlaceHolder.Visible = false;
                    break;

                case AssetStatus.Expired:

                    CartItemMessageLabel.MessageType   = BaseMessageLabel.MessageTypes.Withdrawn;
                    CartItemMessageLabel.Header        = "this asset is not available for ordering";
                    IntendedUseRow.Visible             = false;
                    SaveNotesButtonPlaceHolder.Visible = false;
                    break;

                case AssetStatus.Available:

                    if (isRestricted)
                    {
                        CartItemMessageLabel.MessageType   = BaseMessageLabel.MessageTypes.Negative;
                        CartItemMessageLabel.Header        = "approval required";
                        CartItemMessageLabel.Text          = "Approval is required to use this asset. State intended usage in the notes (you may be asked for further information).";
                        IntendedUseRow.Visible             = true;
                        SaveNotesButtonPlaceHolder.Visible = true;
                    }
                    else
                    {
                        CartItemMessageLabel.MessageType   = BaseMessageLabel.MessageTypes.Positive;
                        CartItemMessageLabel.Header        = "no approval required";
                        CartItemMessageLabel.Text          = "Approval is not required to download and use this asset.";
                        IntendedUseRow.Visible             = false;
                        SaveNotesButtonPlaceHolder.Visible = false;
                    }

                    break;
                }

                // Only show the date required selector if the asset is available but restricted
                HtmlTableRow DateRequiredRow = (HtmlTableRow)e.Item.FindControl("DateRequiredRow");
                DateRequiredRow.Visible = (assetStatus == AssetStatus.Available && isRestricted);

                break;
            }
        }
Esempio n. 6
0
        protected void OrderItemsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case (ListItemType.Item):
            case (ListItemType.AlternatingItem):

                OrderItem orderItem = (OrderItem)e.Item.DataItem;
                Asset     asset     = orderItem.Asset;

                HiddenField OrderItemIdHiddenField = (HiddenField)e.Item.FindControl("OrderItemIdHiddenField");
                OrderItemIdHiddenField.Value = orderItem.OrderItemId.ToString();

                AssetThumbnail AssetThumbnail1 = (AssetThumbnail)e.Item.FindControl("AssetThumbnail1");
                AssetThumbnail1.Initialise(asset);

                AssetButtons AssetButtons1 = (AssetButtons)e.Item.FindControl("AssetButtons1");
                AssetButtons1.Initialise(asset);

                Label AssetIdLabel = (Label)e.Item.FindControl("AssetIdLabel");
                AssetIdLabel.Text = asset.AssetId.ToString();

                Label AssetDescriptionLabel = (Label)e.Item.FindControl("AssetDescriptionLabel");
                AssetDescriptionLabel.Text = SiteUtils.ConvertTextToHtml(asset.Description);

                Label BrandNameLabel = (Label)e.Item.FindControl("BrandNameLabel");
                BrandNameLabel.Text = asset.Brand.Name;

                Label AssetTypeLabel = (Label)e.Item.FindControl("AssetTypeLabel");
                AssetTypeLabel.Text = asset.AssetType.Name;

                Label AssetUsageRestrictionsLabel = (Label)e.Item.FindControl("AssetUsageRestrictionsLabel");
                AssetUsageRestrictionsLabel.Text = asset.UsageRestrictions;

                Label DeadlineDatelabel = (Label)e.Item.FindControl("DeadlineDateLabel");

                if (orderItem.RequiredByDate.HasValue)
                {
                    DeadlineDatelabel.Text = orderItem.RequiredByDate.Value.ToString(Global.DateFormat);
                }

                Label UserNotesLabel = (Label)e.Item.FindControl("UserNotesLabel");
                UserNotesLabel.Text = orderItem.Notes;

                Label        NoConversationLabel = (Label)e.Item.FindControl("NoConversationLabel");
                HtmlTableRow AddCommentRow       = (HtmlTableRow)e.Item.FindControl("AddCommentRow");

                RadioButtonList OrderItemStatusRadioButtonList = (RadioButtonList)e.Item.FindControl("OrderItemStatusRadioButtonList");
                OrderItemStatusRadioButtonList.SelectedValue = orderItem.OrderItemStatusId.ToString();

                FeedbackLabel OrderItemStatusMessageLabel = (FeedbackLabel)e.Item.FindControl("OrderItemStatusMessageLabel");

                switch (orderItem.OrderItemStatus)
                {
                case OrderItemStatus.Preapproved:

                    OrderItemStatusRadioButtonList.Visible = false;
                    OrderItemStatusMessageLabel.SetSuccessMessage("Asset is preapproved");

                    break;

                case OrderItemStatus.AwaitingApproval:
                {
                    HtmlTableRow AssignedToRow = (HtmlTableRow)e.Item.FindControl("AssignedToRow");
                    AssignedToRow.Visible = true;

                    Label AssignedToLabel = (Label)e.Item.FindControl("AssignedToLabel");
                    AssignedToLabel.Text    = orderItem.AssignedToUser.FullName;
                    AssignedToLabel.ToolTip = orderItem.AssignedToUser.UserRoleName;

                    if (CurrentUser.UserRole == UserRole.SuperAdministrator)
                    {
                        // Do nothing.  Super-admins can action any order item
                        // Keep the radio buttons visible.
                    }
                    else if (orderItem.AssignedToUserId == CurrentUser.UserId)
                    {
                        // Do nothing.  When an order item is assigned to the user viewing it,
                        // they are able to action it as desired. Keep the radio buttons visible.
                    }
                    else
                    {
                        // Show who the order item is awaiting approval from.
                        OrderItemStatusMessageLabel.SetErrorMessage("Awaiting approval from " + orderItem.AssignedToUser.FullName);

                        // Hide the action radio buttons
                        OrderItemStatusRadioButtonList.Visible = false;
                    }
                }

                break;

                case OrderItemStatus.Approved:

                    OrderItemStatusRadioButtonList.Visible = false;
                    string message = string.Format("Approved by {0} on {1}", orderItem.StatusChangedByUser.FullName, orderItem.OrderItemStatusDate.GetValueOrDefault().ToString(Global.DateFormat));
                    OrderItemStatusMessageLabel.SetSuccessMessage(message);

                    break;

                case OrderItemStatus.Rejected:

                    OrderItemStatusRadioButtonList.Visible = false;
                    message = string.Format("Rejected by {0} on {1}", orderItem.StatusChangedByUser.FullName, orderItem.OrderItemStatusDate.GetValueOrDefault().ToString(Global.DateFormat));
                    OrderItemStatusMessageLabel.SetErrorMessage(message);

                    break;
                }

                if (GeneralUtils.ValueIsInList(orderItem.OrderItemStatus, OrderItemStatus.Preapproved, OrderItemStatus.Approved, OrderItemStatus.Rejected))
                {
                    if (orderItem.OrderItemCommentList.Count == 0)
                    {
                        NoConversationLabel.Text        = "(none)";
                        NoConversationLabel.Font.Italic = true;
                    }

                    AddCommentRow.Visible = false;
                    OrderItemStatusRadioButtonList.Visible = false;
                }

                if (StringUtils.IsBlank(DeadlineDatelabel.Text))
                {
                    DeadlineDatelabel.Text     = "(none)";
                    DeadlineDatelabel.CssClass = "Italics";
                }

                if (StringUtils.IsBlank(AssetDescriptionLabel.Text))
                {
                    AssetDescriptionLabel.Text        = "(none)";
                    AssetDescriptionLabel.Font.Italic = true;
                }

                if (StringUtils.IsBlank(UserNotesLabel.Text))
                {
                    UserNotesLabel.Text        = "(none)";
                    UserNotesLabel.Font.Italic = true;
                }

                NoConversationLabel.Visible = (orderItem.OrderItemCommentList.Count == 0);

                Repeater ConversationRepeater = (Repeater)e.Item.FindControl("ConversationRepeater");
                ConversationRepeater.DataSource = orderItem.OrderItemCommentList;
                ConversationRepeater.DataBind();

                break;
            }
        }
        protected void OrderItemsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case (ListItemType.Item):
            case (ListItemType.AlternatingItem):

                // Get the order item and its corresponding asset
                OrderItem orderItem = (OrderItem)e.Item.DataItem;
                Asset     asset     = orderItem.Asset;

                // Get all controls we'll be using
                HiddenField                OrderItemIdHiddenField      = (HiddenField)e.Item.FindControl("OrderItemIdHiddenField");
                HiddenField                AssetIdHiddenField          = (HiddenField)e.Item.FindControl("AssetIdHiddenField");
                AssetThumbnail             AssetThumbnail1             = (AssetThumbnail)e.Item.FindControl("AssetThumbnail1");
                AssetButtons               AssetButtons1               = (AssetButtons)e.Item.FindControl("AssetButtons1");
                FileSizeMessageLabel       FileSizeLabel               = (FileSizeMessageLabel)e.Item.FindControl("FileSizeLabel");
                EmailHyperLink             AssetContactHyperlink       = (EmailHyperLink)e.Item.FindControl("AssetContactHyperlink");
                HyperLink                  DownloadHyperlink           = (HyperLink)e.Item.FindControl("DownloadHyperlink");
                CheckBox                   SelectAssetCheckBox         = (CheckBox)e.Item.FindControl("SelectAssetCheckBox");
                DownloadFormatDropDownList DownloadFormatDropDownList1 = (DownloadFormatDropDownList)e.Item.FindControl("DownloadFormatDropDownList1");
                AssetImageSizeDropDownList AssetImageSizeDropDownList1 = (AssetImageSizeDropDownList)e.Item.FindControl("AssetImageSizeDropDownList1");
                FeedbackLabel              OrderItemMessageLabel       = (FeedbackLabel)e.Item.FindControl("OrderItemMessageLabel");
                PlaceHolder                ImageOptionsPlaceHolder     = (PlaceHolder)e.Item.FindControl("ImageOptionsPlaceHolder");
                HtmlTableRow               FileSizeRow               = (HtmlTableRow)e.Item.FindControl("FileSizeRow");
                HtmlGenericControl         SelectorContainer         = (HtmlGenericControl)e.Item.FindControl("SelectorContainer");
                HtmlGenericControl         LinkButtonWrapper         = (HtmlGenericControl)e.Item.FindControl("LinkButtonWrapper");
                FileSizeMessageLabel       ImageFileSizeMessageLabel = (FileSizeMessageLabel)e.Item.FindControl("ImageFileSizeMessageLabel");

                // Populate table cells with basic information about the asset
                SetTableCellText(e.Item, "AssetReferenceCell", asset.AssetId.ToString());
                SetTableCellHtml(e.Item, "DescriptionCell", SiteUtils.ConvertTextToHtml(asset.Description));
                SetTableCellText(e.Item, "BrandCell", asset.Brand.Name);
                SetTableCellText(e.Item, "AssetTypeCell", asset.AssetType.Name);
                SetTableCellHtml(e.Item, "UsageRestrictionsCell", asset.UsageRestrictions);
                SetTableCellText(e.Item, "DateRequestedByCell", orderItem.RequiredByDate.HasValue ? orderItem.RequiredByDate.Value.ToString(Global.DateFormat) : "None");
                SetTableCellText(e.Item, "DateOfDecisionCell", orderItem.OrderItemStatusDate.HasValue ? orderItem.OrderItemStatusDate.Value.ToString(Global.DateFormat) : "None");
                SetTableCellText(e.Item, "NotesCell", orderItem.Notes);

                // Populate hidden fields as we'll need these for other stuff
                OrderItemIdHiddenField.Value = orderItem.OrderItemId.ToString();
                AssetIdHiddenField.Value     = asset.AssetId.ToString();

                // Get/Initialise other objects we'll need here
                AssetStatus       assetStatus = AssetManager.GetAssetStatusForUser(asset, CurrentUser);
                SelectedOrderItem soi         = SelectedOrderItems.Get(orderItem.OrderItemId.GetValueOrDefault());

                // Check if user can download this asset
                bool canDownload = CanDownload(orderItem);

                // Initialise the thumbnail and buttons
                AssetThumbnail1.Initialise(asset);
                AssetButtons1.Initialise(asset);

                // Populate other controls which are not dependent on the asset type
                AssetContactHyperlink.SetNameEmail(asset.UploadedByUser.FullName, asset.UploadedByUser.Email);
                SelectorContainer.Visible     = canDownload;
                SelectAssetCheckBox.Checked   = IsOrderItemSelected(orderItem.OrderItemId.GetValueOrDefault());
                DownloadHyperlink.NavigateUrl = string.Format("javascript:downloadAsset('{0}','{1}','{2}', '{3}', '{4}')", orderItem.AssetId, orderItem.OrderId, orderItem.OrderItemId, DownloadFormatDropDownList1.ClientID, AssetImageSizeDropDownList1.ClientID);

                // Do processing dependent on asset type
                if (AssetTypeChecker.IsImage(asset.FileExtension))
                {
                    // Only show download resolution row if user can download
                    ImageOptionsPlaceHolder.Visible = canDownload;

                    // Only do the image size stuff if the download resolution row is visible
                    if (ImageOptionsPlaceHolder.Visible)
                    {
                        // Populate the download format dropdown with the previously selected value (if any)
                        DownloadFormatDropDownList1.SafeSelectValue(soi.DownloadFormat);

                        // Populate the asset image size dropdown with the previously selected value (if any)
                        AssetImageSizeDropDownList1.SafeSelectValue(soi.AssetImageSizeId);

                        // Get the filename to the image *if it exists already*
                        string filename = AssetImageManager.GetResizedAssetImage(asset, AssetImageSizeDropDownList1.SelectedId, DownloadFormatDropDownList1.SelectedDownloadFormat, false);

                        // Only set the filesize if the scaled image already exists, as it will be too heavy to create a scaled image
                        // of each asset as the page loads. Maybe we should do this when assets are uploaded...
                        if (filename != string.Empty)
                        {
                            ImageFileSizeMessageLabel.SetFileSize(FileUtils.GetFileSize(filename));
                        }
                    }
                }

                // Only show file size row if download resolution row is hidden and user can download this asset
                // (No point showing them the filesize for an asset they can't download)
                if (ImageOptionsPlaceHolder.Visible)
                {
                    FileSizeRow.Visible = false;
                }
                else
                {
                    FileSizeRow.Visible = canDownload;
                    FileSizeLabel.SetFileSize(asset.FileSize);
                }

                // Only show the conversation row if we have a conversation
                HtmlTableRow ConversationRow = (HtmlTableRow)e.Item.FindControl("ConversationRow");
                ConversationRow.Visible = (orderItem.OrderItemCommentList.Count > 0);

                // Bind conversation
                Repeater ConversationRepeater = (Repeater)e.Item.FindControl("ConversationRepeater");
                ConversationRepeater.DataSource = orderItem.OrderItemCommentList;
                ConversationRepeater.DataBind();

                // Hide the row to add notes, as this is only visible whilst an order item is awaiting approval
                HtmlTableRow AddNotesRow = (HtmlTableRow)e.Item.FindControl("AddNotesRow");
                AddNotesRow.Visible = false;

                if (assetStatus == AssetStatus.Available)
                {
                    switch (orderItem.OrderItemStatus)
                    {
                    case (OrderItemStatus.Preapproved):

                        OrderItemMessageLabel.SetSuccessMessage("no approval required", "Approval is not required to download and use this asset.");
                        LinkButtonWrapper.Visible = false;

                        break;

                    case (OrderItemStatus.Approved):

                        OrderItemMessageLabel.SetSuccessMessage("approved", "Approval to use this asset has been granted. Refer to the response given in the approval details for any further information.");
                        LinkButtonWrapper.Visible = true;

                        break;

                    case (OrderItemStatus.AwaitingApproval):

                        OrderItemMessageLabel.MessageType = BaseMessageLabel.MessageTypes.Pending;
                        OrderItemMessageLabel.Header      = "approval pending";
                        OrderItemMessageLabel.Text        = "Approval to use this asset is pending a decision. An email will be sent to you when a decision is made.";
                        LinkButtonWrapper.Visible         = true;
                        AddNotesRow.Visible = true;

                        break;

                    case (OrderItemStatus.Rejected):

                        OrderItemMessageLabel.SetErrorMessage("approval rejected", "Approval to use this asset has been rejected. Refer to the response given in the approval notes for further information.");
                        LinkButtonWrapper.Visible = true;

                        break;
                    }
                }
                else
                {
                    OrderItemMessageLabel.MessageType = BaseMessageLabel.MessageTypes.Withdrawn;
                    OrderItemMessageLabel.Header      = "asset withdrawn";
                    OrderItemMessageLabel.Text        = "This asset has been withdrawn from the system and is no longer available to download.";
                    LinkButtonWrapper.Visible         = false;
                }

                if (WebUtils.GetIntRequestParam("OrderItemId", 0) == orderItem.OrderItemId)
                {
                    Panel ApprovalDetailsPanel = (Panel)e.Item.FindControl("ApprovalDetailsPanel");
                    ApprovalDetailsPanel.Visible = true;

                    LinkButton ToggleApprovalDetailsLinkButton = (LinkButton)e.Item.FindControl("ToggleApprovalDetailsLinkButton");
                    ToggleApprovalDetailsLinkButton.Text = "hide approval details [-]";
                }

                break;
            }
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ApproveRadioButton.Attributes.Add("onClick", "checkRadio()");
                RejectRadioButton.Attributes.Add("onClick", "checkRadio()");
                PendingRadioButton.Attributes.Add("onClick", "checkRadio()");
                InviteCommentsRadioButton.Attributes.Add("onClick", "checkRadio()");

                if (AssetWorkflowUser.IsNull)
                {
                    Response.Redirect("~/Admin/Assets/AssetList.aspx");
                }

                if (AssetWorkflow.IsComplete)
                {
                    MessageLabel.SetErrorMessage("Asset workflow is complete and comments have been disabled");
                    MessageLabel.Pinned = true;
                    DisableUI();
                }
                else
                {
                    if (AssetWorkflowUser.AssetWorkflowUserStatus == AssetWorkflowUserStatus.Waiting)
                    {
                        MessageLabel.SetErrorMessage("You do not have permission to action this workflow yet");
                        MessageLabel.Pinned = true;
                        DisableUI();
                    }
                    else if (AssetWorkflowUser.AssetWorkflowUserStatus != AssetWorkflowUserStatus.Pending)
                    {
                        MessageLabel.SetErrorMessage("You have already actioned this workflow");
                        MessageLabel.Pinned = true;
                        DisableUI();
                    }
                }

                AssetWorkflowUserList.Repeater.DataSource = AssetWorkflow.AssetWorkflowUserList;
                AssetWorkflowUserList.Repeater.DataBind();

                Asset asset = AssetWorkflow.Asset;

                AssetReferenceLiteral.Text = asset.AssetId.ToString();
                UploadUserEmailHyperLink.SetNameEmail(asset.UploadedByUser.FullName, asset.UploadedByUser.Email);
                PublicationDateLiteral.Text        = asset.PublishDate.ToString(Global.DateFormat);
                DownloadAssetHyperLink.NavigateUrl = AssetFileUrlHelper.GetDownloadUrl(asset.AssetId);
                AssetThumbnail.Initialise(asset);
                AssetButtons1.Initialise(asset);
                AssetTypeCell.InnerText         = asset.AssetType.Name;
                BrandCell.InnerText             = asset.BrandName;
                ShortDescriptionCell.InnerHtml  = SiteUtils.ConvertTextToHtml(asset.Description);
                UsageRestrictionsCell.InnerText = asset.UsageRestrictions;
                ResponseTextArea.Text           = AssetWorkflowUser.Comments;

                SiteUtils.SetHyperLink("Assets.AssetForm", string.Format("?assetId={0}", asset.AssetId), EditAssetHyperLink);

                switch (AssetWorkflowUser.AssetWorkflowUserStatus)
                {
                case (AssetWorkflowUserStatus.Pending):

                    PendingRadioButton.Checked = true;
                    break;

                case (AssetWorkflowUserStatus.Approved):

                    ApproveRadioButton.Checked = true;
                    break;

                case (AssetWorkflowUserStatus.Rejected):

                    RejectRadioButton.Checked = true;
                    break;
                }

                AssetWorkflowLog.Bind(asset);
            }
        }