public static void InviteUserToWorkflow(AssetWorkflowUser assetWorkflowUser, string inviteeEmail, string message) { // Ensure message is specified if (StringUtils.IsBlank(message)) { throw new ValidationException("Message is required (this will be sent to the user being invited to comment)"); } // Ensure email address is specified if (StringUtils.IsBlank(inviteeEmail)) { throw new ValidationException("Email address is required"); } // Get the user by email address User invitedUser = User.GetByEmail(inviteeEmail); // Ensure email address belongs to a registered user if (invitedUser.IsNull) { throw new ValidationException("Email does not belong to a registered user"); } // Ensure invited user has upload privileges if (invitedUser.UserRoleId < Convert.ToInt32(UserRole.UploadUser)) { throw new ValidationException("Email does not belong to a user with upload privileges"); } // Create the commenter record AssetWorkflowCommenter awfc = AssetWorkflowCommenter.New(); awfc.AssetWorkflowId = assetWorkflowUser.AssetWorkflowId; awfc.InvitingAssetWorkflowUserId = assetWorkflowUser.AssetWorkflowUserId.GetValueOrDefault(); awfc.InvitingUserId = assetWorkflowUser.UserId; awfc.InvitingUserMessage = message; awfc.UserId = invitedUser.UserId.GetValueOrDefault(); awfc.CreateDate = DateTime.Now; awfc.LastUpdate = DateTime.Now; AssetWorkflowCommenter.Update(awfc); // Refresh from DB // awfc = AssetWorkflowCommenter.Get(awfc.AssetWorkflowCommenterId); // Now we need to notify them if (AssetWorkflowCommenterInvited != null) { AssetWorkflowCommenterInvited(null, new AssetWorkflowCommenterEventArgs(awfc)); } }
public static void SaveAssetWorkflowCommenter(AssetWorkflowCommenter awfc) { if (awfc.AssetWorkflow.IsComplete) { throw new ValidationException("Asset workflow is complete and comments have been disabled"); } if (StringUtils.IsBlank(awfc.Comments)) { throw new ValidationException("Comments are required"); } // Save the commenter AssetWorkflowCommenter.Update(awfc); // Now notify the user who invited this commenter if (AssetWorkflowCommenterUpdated != null) { AssetWorkflowCommenterUpdated(null, new AssetWorkflowCommenterEventArgs(awfc)); } }
public static void AssetWorkflowCommenterInvited(AssetWorkflowCommenter assetWorkflowCommenter) { Email email = NotifyEngine.GetEmailTemplate("Admin.AssetWorkflowCommenterInvited"); email.Recipients.Add(assetWorkflowCommenter.User.Email); email.Subject = NotifyEngine.GetSubject("You have been invited to comment on an asset"); // Add body parameters email.AddBodyParameter("inviter-name", assetWorkflowCommenter.InvitingUser.FullName); email.AddBodyParameter("inviter-message", assetWorkflowCommenter.InvitingUserMessage); email.AddBodyParameter("asset-id", assetWorkflowCommenter.AssetWorkflow.Asset.AssetId); email.AddBodyParameter("asset-type", assetWorkflowCommenter.AssetWorkflow.Asset.AssetType.Name); email.AddBodyParameter("upload-user-name", assetWorkflowCommenter.AssetWorkflow.Asset.UploadedByUser.FullName); // ACI = Asset Commenter Invited string url = SiteUtils.GetWebsiteUrl(string.Format("~/Go.ashx/ACI/AWFID{0}/", assetWorkflowCommenter.AssetWorkflowId)); email.AddBodyParameter("url", url); // Send it NotifyEngine.SendMessage(email); }
public static void AssetWorkflowCommenterUpdated(AssetWorkflowCommenter assetWorkflowCommenter) { Email email = NotifyEngine.GetEmailTemplate("Admin.AssetWorkflowCommenterUpdated"); email.Recipients.Add(assetWorkflowCommenter.InvitingUser.Email); email.Subject = NotifyEngine.GetSubject("An invited user has made a comment on a workflow"); // Add body parameters email.AddBodyParameter("inviter-name", assetWorkflowCommenter.InvitingUser.FullName); email.AddBodyParameter("commenter-name", assetWorkflowCommenter.User.FullName); email.AddBodyParameter("commenter-comments", assetWorkflowCommenter.Comments); email.AddBodyParameter("asset-id", assetWorkflowCommenter.AssetWorkflow.Asset.AssetId); email.AddBodyParameter("asset-type", assetWorkflowCommenter.AssetWorkflow.Asset.AssetType.Name); email.AddBodyParameter("upload-user-name", assetWorkflowCommenter.AssetWorkflow.Asset.UploadedByUser.FullName); // AAW = Approve Asset Workflow string url = SiteUtils.GetWebsiteUrl(string.Format("~/Go.ashx/AAW/AWFID{0}/", assetWorkflowCommenter.AssetWorkflowId)); email.AddBodyParameter("url", url); // Send it NotifyEngine.SendMessage(email); }
public AssetWorkflowCommenterEventArgs(AssetWorkflowCommenter assetWorkflowCommenter) { AssetWorkflowCommenter = assetWorkflowCommenter; }
protected void AssetsRepeater_OnItemDataBound(object sender, RepeaterItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.Header: HtmlTableCell CheckBoxHeaderCell = (HtmlTableCell)e.Item.FindControl("CheckBoxHeaderCell"); CheckBoxHeaderCell.Visible = ShowCheckBoxes; HtmlTableCell ThumbnailHeaderCell = (HtmlTableCell)e.Item.FindControl("ThumbnailHeaderCell"); ThumbnailHeaderCell.Visible = ShowThumbnails; break; case (ListItemType.Item): case (ListItemType.AlternatingItem): Asset asset = (Asset)e.Item.DataItem; HtmlTableCell CheckBoxCell = (HtmlTableCell)e.Item.FindControl("CheckBoxCell"); CheckBoxCell.Visible = ShowCheckBoxes; HtmlTableCell ThumbnailCell = (HtmlTableCell)e.Item.FindControl("ThumbnailCell"); ThumbnailCell.Visible = ShowThumbnails; if (ThumbnailCell.Visible) { AssetThumbnail assetThumbnail = (AssetThumbnail)e.Item.FindControl("AssetThumbnail"); assetThumbnail.Initialise(asset); } HiddenField AssetIdHiddenField = (HiddenField)e.Item.FindControl("AssetIdHiddenField"); AssetIdHiddenField.Value = asset.AssetId.ToString(); HyperLink AssetIdHyperLink = (HyperLink)e.Item.FindControl("AssetIdHyperLink"); AssetIdHyperLink.Text = asset.AssetId.ToString(); AssetIdHyperLink.NavigateUrl = string.Format("~/Admin/Assets/AssetForm.aspx?assetId={0}&source=assetlist", asset.AssetId); Label AssetTypeLabel = (Label)e.Item.FindControl("AssetTypeLabel"); AssetTypeLabel.Text = asset.AssetType.Name; Label UploadedByUserNameLabel = (Label)e.Item.FindControl("UploadedByUserNameLabel"); UploadedByUserNameLabel.Text = asset.UploadedByUser.FullName; Label TitleLabel = (Label)e.Item.FindControl("TitleLabel"); TitleLabel.Text = asset.Title; SiteUtils.PopulateBlankControl(TitleLabel); Label FileSizeLabel = (Label)e.Item.FindControl("FileSizeLabel"); FileSizeLabel.Text = FileUtils.FriendlyFileSize(asset.FileSize); Label ProductionDateLabel = (Label)e.Item.FindControl("ProductionDateLabel"); ProductionDateLabel.Text = asset.GetProductionDate(); SiteUtils.PopulateBlankControl(ProductionDateLabel); Label IsExpiredLabel = (Label)e.Item.FindControl("IsExpiredLabel"); IsExpiredLabel.Text = (asset.ExpiryDate < DateTime.Now) ? "Y" : "N"; if (IsExpiredLabel.Text == "Y") { IsExpiredLabel.CssClass = "bold"; } Label ExpiryDateLabel = (Label)e.Item.FindControl("ExpiryDateLabel"); ExpiryDateLabel.Text = asset.ExpiryDate.ToString(Global.DateFormat); HyperLink IsPublishedHyperLink = (HyperLink)e.Item.FindControl("IsPublishedHyperLink"); IsPublishedHyperLink.Text = asset.AssetPublishStatusName; PromptLinkButton DeleteLinkButton = (PromptLinkButton)e.Item.FindControl("DeleteLinkButton"); DeleteLinkButton.CommandArgument = asset.AssetId.ToString(); EnhancedHyperLink AuditLogHyperLink = (EnhancedHyperLink)e.Item.FindControl("AuditLogHyperLink"); SiteUtils.SetHyperLink("Reports.AssetAuditTrail", string.Format("?AssetId={0}&Source=AssetList", asset.AssetId), AuditLogHyperLink); switch (asset.AssetPublishStatus) { case (AssetPublishStatus.Published): IsPublishedHyperLink.CssClass += " Bold"; break; case (AssetPublishStatus.PendingApproval): IsPublishedHyperLink.CssClass += " Bold"; if (asset.AssetWorkflowList.Count > 0) { AssetWorkflow aw = asset.AssetWorkflowList[0]; // Only link the pending text to the approval screen if the current user is in the workflow AssetWorkflowUser cawfu = aw.AssetWorkflowUserList.Find(awfu => awfu.UserId == CurrentUser.UserId.GetValueOrDefault()); if (cawfu != null) { SiteUtils.SetHyperLink("Workflow.Approve", string.Format("?AssetWorkflowId={0}", aw.AssetWorkflowId), IsPublishedHyperLink); } else { AssetWorkflowCommenter awc = aw.AssetWorkflowCommenterList.Find(awfc => awfc.UserId == CurrentUser.UserId.GetValueOrDefault()); if (awc != null) { SiteUtils.SetHyperLink("Workflow.Comment", string.Format("?AssetWorkflowId={0}", aw.AssetWorkflowId), IsPublishedHyperLink); } } } break; } break; } }