public void SendRegData(UserInfo u) { try { if (!TenantExtra.Saas || !CoreContext.Configuration.CustomMode) { return; } var salesEmail = AdditionalWhiteLabelSettings.Instance.SalesEmail ?? SetupInfo.SalesEmail; if (string.IsNullOrEmpty(salesEmail)) { return; } var recipient = new DirectRecipient(salesEmail, null, new[] { salesEmail }, false); client.SendNoticeToAsync( Actions.SaasCustomModeRegData, null, new IRecipient[] { recipient }, new[] { EMailSenderName }, null, new TagValue(Tags.UserName, u.FirstName.HtmlEncode()), new TagValue(Tags.UserLastName, u.LastName.HtmlEncode()), new TagValue(Tags.UserEmail, u.Email.HtmlEncode()), new TagValue(Tags.Phone, u.MobilePhone != null ? u.MobilePhone.HtmlEncode() : "-"), new TagValue(Tags.Date, u.CreateDate.ToShortDateString() + " " + u.CreateDate.ToShortTimeString()), new TagValue(CommonTags.Footer, null), TagValues.WithoutUnsubscribe()); } catch (Exception error) { LogManager.GetLogger("ASC.Notify").Error(error); } }
private SendResponse CreateNoticeMessageFromNotifyRequest(NotifyRequest request, string sender, out NoticeMessage noticeMessage) { if (request == null) { throw new ArgumentNullException("request"); } var recipientProvider = request.NotifySource.GetRecipientsProvider(); var recipient = request.Recipient as IDirectRecipient; var addresses = recipient.Addresses; if (addresses == null || !addresses.Any()) { addresses = recipientProvider.GetRecipientAddresses(request.Recipient as IDirectRecipient, sender, request.ObjectID); recipient = new DirectRecipient(request.Recipient.ID, request.Recipient.Name, addresses); } recipient = recipientProvider.FilterRecipientAddresses(recipient); noticeMessage = request.CreateMessage(recipient); addresses = recipient.Addresses; if (addresses == null || !addresses.Any(a => !string.IsNullOrEmpty(a))) { //checking addresses return(new SendResponse(request.NotifyAction, sender, recipient, new NotifyException(string.Format("For recipient {0} by sender {1} no one addresses getted.", recipient, sender)))); } var pattern = request.GetSenderPattern(sender); if (pattern == null) { return(new SendResponse(request.NotifyAction, sender, recipient, new NotifyException(String.Format("For action \"{0}\" by sender \"{1}\" no one patterns getted.", request.NotifyAction, sender)))); } noticeMessage.Pattern = pattern; noticeMessage.ContentType = pattern.ContentType; noticeMessage.AddArgument(request.Arguments.ToArray()); var patternProvider = request.NotifySource.GetPatternProvider(); var formatter = patternProvider.GetFormatter(pattern); try { if (formatter != null) { formatter.FormatMessage(noticeMessage, noticeMessage.Arguments); } sysTagFormatter.FormatMessage( noticeMessage, new[] { new TagValue(Context._SYS_RECIPIENT_ID, request.Recipient.ID), new TagValue(Context._SYS_RECIPIENT_NAME, request.Recipient.Name), new TagValue(Context._SYS_RECIPIENT_ADDRESS, addresses != null && addresses.Length > 0 ? addresses[0] : null) } ); //Do styling here if (!string.IsNullOrEmpty(pattern.Styler)) { //We need to run through styler before templating StyleMessage(noticeMessage); } } catch (Exception exc) { return(new SendResponse(request.NotifyAction, sender, recipient, exc)); } return(null); }