public static void LightboxSentToUser(LightboxSent lightboxSent) { Email email; if (lightboxSent.RecipientUser.IsNull) { email = NotifyEngine.GetEmailTemplate("User.LightboxSentToUnregisteredUser"); email.Recipients.Add(lightboxSent.RecipientEmail); string url = SiteUtils.GetWebsiteUrl(string.Format("~/Go.ashx/VCS/LSID{0}-SUID{1}-DST{2}/", lightboxSent.LightboxSentId, lightboxSent.SenderId, lightboxSent.DateSent.Ticks)); email.AddBodyParameter("url", url); } else { email = NotifyEngine.GetEmailTemplate("User.LightboxSentToRegisteredUser"); email.Recipients.Add(lightboxSent.RecipientUser.Email); string url = SiteUtils.GetWebsiteUrl(string.Format("~/Go.ashx/VLB/LID{0}/", (lightboxSent.LightboxLinkedId.GetValueOrDefault() > 0?lightboxSent.LightboxId:lightboxSent.CreatedLightboxId))); email.AddBodyParameter("url", url); email.AddBodyParameter("recipient-name", lightboxSent.RecipientUser.FullName); } email.AddBodyParameter("sender-name", lightboxSent.Sender.FullName); email.AddBodyParameter("asset-count", lightboxSent.Lightbox.GetAssetList().Count); email.AddBodyParameter("lightbox-name", lightboxSent.Lightbox.Name); email.AddBodyParameter("message", lightboxSent.Message); email.Subject = (StringUtils.IsBlank(lightboxSent.Subject)) ? string.Format("You have received a lightbox (Ref: {0}) : {1}", lightboxSent.LightboxId, lightboxSent.Lightbox.Name) : lightboxSent.Subject; NotifyEngine.SendMessage(email); }
protected void Page_Load(object sender, EventArgs e) { // Get the data from the querystring, to be used to get the sent lightbox int lightboxSentId = WebUtils.GetIntRequestParam("lsid", 0); int senderId = WebUtils.GetIntRequestParam("suid", 0); string ticks = WebUtils.GetRequestParam("dst", string.Empty); // Ensure that we have all required querystring data if (lightboxSentId == 0 || senderId == 0 || ticks == string.Empty) { Response.Redirect("~/Login.aspx?error=ContactSheetMissingData", false); return; } // Get the lightbox m_lightboxSent = LightboxSent.Get(lightboxSentId); // Check posted data - ensure that the sender id and ticks match (ie. to ensure user is not messing with the querystring) if (!m_lightboxSent.SenderId.Equals(senderId) || ticks.Length < 6 || !m_lightboxSent.DateSent.Ticks.ToString().Substring(0, 6).Equals(ticks.Substring(0, 6))) { Response.Redirect("~/Login.aspx?error=ContactSheetInvalidData", false); return; } // Ensure the lightbox has not expired if (m_lightboxSent.ExpiryDate.HasValue && m_lightboxSent.ExpiryDate < DateTime.Now) { Response.Redirect("~/Login.aspx?error=ContactSheetExpired", false); return; } // Get the lightbox Lightbox lightbox = m_lightboxSent.Lightbox; // Update the UI with the lightbox information LightboxTitleLabel.Text = lightbox.Name; LightboxSenderName.Text = m_lightboxSent.Sender.FullName; LightboxSenderEmail.EmailAddress = m_lightboxSent.Sender.Email; LightboxDateSentLabel.Text = m_lightboxSent.DateSent.ToString("HH:mm, dd MMMM yyyy"); LightboxDateExpiresLabel.Text = m_lightboxSent.ExpiryDate.HasValue ? m_lightboxSent.ExpiryDate.Value.ToString("HH:mm, dd MMMM yyyy") : "Never"; LightboxNotesLabel.Text = lightbox.Notes; // Get the lightbox assets EntityList <LightboxAsset> lightboxAssetList = lightbox.GetLightboxAssetList(); // Ensure we have at least one row while (lightboxAssetList.Count < LightboxDataList.RepeatColumns) { lightboxAssetList.Add(LightboxAsset.Empty); } // Bind the datalist to the lightbox assets LightboxDataList.DataSource = lightboxAssetList; LightboxDataList.DataBind(); }
public override object GetDataSource() { List <String> data = new List <String>(); LightboxSentFinder finder = new LightboxSentFinder(); finder.SenderId = SessionInfo.Current.User.UserId.GetValueOrDefault(); EntityList <LightboxSent> sentLightboxes = LightboxSent.FindMany(finder); foreach (LightboxSent lbs in sentLightboxes) { if (!data.Contains(lbs.RecipientEmail.ToLower())) { data.Add(lbs.RecipientEmail.ToLower()); } } return(data); }
public LightboxSentEventArgs(LightboxSent lightboxSent) { LightboxSent = lightboxSent; }
public override void ProcessRequest() { if (!SessionInfo.Current.User.IsNull) { //if valid user then process request //using normal AssetFileHandler base.ProcessRequest(); } else { // Get querystring values int assetId = GetIdFromFilename(); int assetImageSizeId = WebUtils.GetIntRequestParam("assetImageSizeId", 0); DownloadFormat downloadFormat = GeneralUtils.ParseEnum(WebUtils.GetRequestParam("AssetImageFormat"), DownloadFormat.Original); bool original = (WebUtils.GetIntRequestParam("original", 0) == 1); int lightboxSentId = WebUtils.GetIntRequestParam("lsid", 0); int senderId = WebUtils.GetIntRequestParam("suid", 0); string ticks = WebUtils.GetRequestParam("dst", string.Empty); // Ensure asset id is specified if (assetId == 0 || lightboxSentId == 0) { InvalidRequest(); return; } // Get the lightbox LightboxSent lightboxSent = LightboxSent.Get(lightboxSentId); //check that it's a valid lightboxsent object if (lightboxSent.IsNull) { InvalidRequest(); return; } // Check posted data - ensure that the sender id and ticks match (ie. to ensure user is not messing with the querystring) if (!lightboxSent.SenderId.Equals(senderId) || ticks.Length < 6 || !lightboxSent.DateSent.Ticks.ToString().Substring(0, 6).Equals(ticks.Substring(0, 6))) { InvalidRequest(); return; } // Make sure sender is a super user if (lightboxSent.Sender.UserRole != UserRole.SuperAdministrator) { InvalidRequest(); return; } //verify that lightbox has download links enabled if (!lightboxSent.DownloadLinks.GetValueOrDefault(false)) { InvalidRequest(); return; } //check that asset exists in the lightbox being sent LightboxAssetFinder finder = new LightboxAssetFinder { LightboxId = lightboxSent.LightboxId, AssetId = assetId }; LightboxAsset lightboxAsset = LightboxAsset.FindOne(finder); if (lightboxAsset.IsNull) { InvalidRequest(); return; } // Get the asset file info AssetFileInfo info = new AssetFileInfo(lightboxAsset.Asset); // Ensure file exists if (!info.FileExists) { InvalidRequest(); return; } // Asset file path string path = info.FilePath; // Always update the audit history for external downloads AuditLogManager.LogAssetAction(assetId, lightboxSent.Sender, AuditAssetAction.DownloadedAssetFile); AuditLogManager.LogUserAction(lightboxSent.Sender, AuditUserAction.DownloadAssetFromContactSheet, string.Format("Downloaded asset {0} via contact sheet, sent by: {1} download by: {2}", assetId, lightboxSent.Sender.FullName, lightboxSent.RecipientEmail)); DownloadAsset(lightboxAsset.Asset, path, original, downloadFormat, assetImageSizeId); } }
private void SendLightboxToUser(Lightbox lightbox, User user, string recipient, string subject, string message, DateTime?expiryDate, bool?downloadLinks, bool?linked, bool?editable) { m_Logger.Debug("SendLightboxToUser - start"); int?createdLightboxId = null; int?linkedLightboxId = null; if (!user.IsNull) { //check to see if should link the lightbox or //make a new copy of it if (linked.GetValueOrDefault(false)) { // create new linked lightbox LightboxLinked linkedLightbox = LightboxLinked.New(); linkedLightbox.UserId = user.UserId.GetValueOrDefault(); linkedLightbox.LightboxId = lightbox.LightboxId.GetValueOrDefault(); linkedLightbox.IsEditable = editable; linkedLightbox.ExpiryDate = expiryDate; LightboxLinked.Update(linkedLightbox); linkedLightboxId = linkedLightbox.LightboxLinkedId; } else { // copying lightbox string lightboxName = lightbox.Name; string newLightboxName = GetLightboxNameForSending(lightboxName); Lightbox createdLightbox = DuplicateLightbox(lightbox.LightboxId.GetValueOrDefault(), newLightboxName, user.UserId.GetValueOrDefault()); createdLightboxId = createdLightbox.LightboxId.GetValueOrDefault(); } } LightboxSent lbs = LightboxSent.New(); lbs.LightboxId = lightbox.LightboxId.GetValueOrDefault(); lbs.CreatedLightboxId = createdLightboxId; lbs.SenderId = User.UserId.GetValueOrDefault(); lbs.RecipientEmail = recipient; lbs.Subject = subject; lbs.Message = message; lbs.DateSent = DateTime.Now; lbs.ExpiryDate = expiryDate; lbs.DownloadLinks = downloadLinks; lbs.LightboxLinkedId = linkedLightboxId; if (lbs.RecipientEmail.Length > 150) { throw new SystemException("Recipient email cannot exceed 150 characters"); } if (lbs.Subject.Length > 150) { throw new SystemException("Subject cannot exceed 150 characters"); } if (lbs.Message.Length > 500) { throw new SystemException("Message cannot exceed 500 characters"); } LightboxSent.Update(lbs); if (LightboxSentToUser != null) { LightboxSentToUser(this, new LightboxSentEventArgs(lbs)); } AuditLogManager.LogUserAction(User, AuditUserAction.SendLightbox, string.Format("Sent LightboxId: {0} to: {1}", lightbox.LightboxId, recipient)); m_Logger.Debug("SendLightboxToUser - end"); }