Esempio n. 1
0
 internal NotificationEventArgs(DataEntry entry, string userKey, NotificationReason reason, object oldValue)
 {
     this._Entry    = entry;
     this._reason   = reason;
     this._userKey  = userKey;
     this._owner    = entry.lastOwnerID;
     this._value    = entry.value;
     this._oldValue = oldValue;
 }
 internal NotificationEventArgs(DataEntry entry, string userKey, NotificationReason reason, object oldValue)
 {
     this._Entry = entry;
     this._reason = reason;
     this._userKey = userKey;
     this._owner = entry.lastOwnerID;
     this._value = entry.value;
     this._oldValue = oldValue;
 }
Esempio n. 3
0
 public PlatformConnectionUpdateNotificationMessage(string platformId, string userId, string appId,
                                                    PlatformConnectionState platformConnectionState, string syncLogId,
                                                    NotificationReason reason = NotificationReason.DataUpdate)
 {
     PlatformId = platformId;
     UserId     = userId;
     AppId      = appId;
     PlatformConnectionState = platformConnectionState;
     SyncLogId = syncLogId;
     Reason    = reason;
 }
Esempio n. 4
0
        private async Task NotifyPlatformDataUpdate(string userId, IList <string> appIds, string platformId,
                                                    IAsyncDocumentSession session, NotificationReason reason, PlatformConnectionState connectionState = PlatformConnectionState.Connected,
                                                    string syncLogId = null,
                                                    CancellationToken cancellationToken = default)
        {
            var apps = await session.LoadAsync <App>(appIds, cancellationToken);

            foreach (var message in apps.Values.Select(app => new Common.Messages.PlatformConnectionUpdateNotificationMessage(platformId, userId,
                                                                                                                              app.Id, connectionState, syncLogId, reason)))
            {
                await _bus.Send(message);
            }
        }
Esempio n. 5
0
        protected void AddNotification(
            LastComponentNotification lastComponentNotification,
            StatusInfo statusInfo,
            Subscription subscription,
            AccountDbContext accountDbContext,
            NotificationReason reason)
        {
            var realEvent = accountDbContext.Events.Find(statusInfo.EventId);

            if (realEvent == null)
            {
                return;
            }

            Interlocked.Increment(ref CreatedNotificationsCount);

            var newNotification = new Notification()
            {
                Id             = Guid.NewGuid(),
                Address        = lastComponentNotification.Address,
                CreationDate   = Now(),
                EventId        = statusInfo.EventId,
                Status         = NotificationStatus.InQueue,
                SubscriptionId = subscription.Id,
                Type           = lastComponentNotification.Type,
                UserId         = subscription.UserId,
                Reason         = reason
            };

            if (newNotification.Type == NotificationType.Http)
            {
                newNotification.NotificationHttp = new NotificationHttp()
                {
                    Notification = newNotification
                                   //Json = GetNotificationJson(lastComponentNotification.Component, eventObj)
                };
            }

            var notificationRepository = accountDbContext.GetNotificationRepository();

            notificationRepository.Add(newNotification);

            lastComponentNotification.Update(newNotification, statusInfo.Importance);

            accountDbContext.SaveChanges();
        }
 private void SetNotificationFlag(NotificationReason reason, bool value)
 {
     if (value)
     {
         applicationSettings.NotificationPreference |= reason;
     }
     else
     {
         applicationSettings.NotificationPreference = (applicationSettings.NotificationPreference | reason) ^ reason;
     }
 }
 private bool GetNotificationFlag(NotificationReason reason)
 {
     return (applicationSettings.NotificationPreference & reason) != 0;
 }
        private static PlatformConnectionUpdateNotificationPayload CreatePayload(Guid externalPlatformId, Guid externalUserId,
                                                                                 string appSecret, string platformName, PlatformConnectionState platformConnectionState,
                                                                                 DateTimeOffset updated, NotificationReason notificationReason, PlatformData platformData = null,
                                                                                 PlatformDataClaim?platformDataClaim = null)
        {
            var payload = new PlatformConnectionUpdateNotificationPayload
            {
                PlatformId              = externalPlatformId,
                UserId                  = externalUserId,
                AppSecret               = appSecret,
                PlatformName            = platformName,
                PlatformConnectionState = platformConnectionState,
                Updated                 = updated.ToUnixTimeSeconds(),
                Reason                  = notificationReason
            };

            if (platformData != null)
            {
                //if no platform data claim is provided, set to lowest claim by default
                platformDataClaim ??= PlatformDataClaim.Aggregated;

                var platformDataPayload = new PlatformDataPayload
                {
                    NumberOfGigs    = platformData.NumberOfGigs,
                    PeriodStart     = platformData.PeriodStart,
                    PeriodEnd       = platformData.PeriodEnd,
                    NumberOfRatings = platformData.Ratings?.Count() ?? 0
                };

                if (platformData.AverageRating != null)
                {
                    platformDataPayload.AverageRating =
                        new PlatformRatingPayload(
                            platformData.AverageRating);
                }

                if (platformData.Ratings != null &&
                    platformData.Ratings.Any())
                {
                    platformDataPayload.NumberOfRatingsThatAreDeemedSuccessful =
                        platformData.Ratings.Count(r =>
                                                   r.Value >= r.SuccessLimit);
                }

                if (platformDataClaim == PlatformDataClaim.Full)
                {
                    if (platformData.Reviews != null)
                    {
                        var reviewPayloads = new List <PlatformReviewPayload>();
                        foreach (var platformDataReview in platformData.Reviews
                                 )
                        {
                            var platformReviewPayload = new PlatformReviewPayload
                            {
                                ReviewId          = platformDataReview.ReviewIdentifier,
                                ReviewDate        = platformDataReview.ReviewDate,
                                ReviewerName      = platformDataReview.ReviewerName,
                                ReviewText        = platformDataReview.ReviewText,
                                ReviewHeading     = platformDataReview.ReviewHeading,
                                ReviewerAvatarUri = platformDataReview.ReviewerAvatarUri
                            };

                            if (platformDataReview.RatingId.HasValue)
                            {
                                platformReviewPayload.Rating = new PlatformRatingPayload(
                                    platformData.Ratings?.Single(r =>
                                                                 r.Identifier == platformDataReview.RatingId));
                            }

                            reviewPayloads.Add(platformReviewPayload);
                        }

                        if (reviewPayloads.Any())
                        {
                            platformDataPayload.Reviews = reviewPayloads;
                        }
                    }

                    if (platformData.Achievements != null)
                    {
                        var achievementPayloads = new List <PlatformAchievementPayload>();

                        foreach (var platformDataAchievement in platformData.Achievements)
                        {
                            PlatformAchievementScorePayload scorePayload = null;
                            if (platformDataAchievement.Score != null)
                            {
                                scorePayload = new PlatformAchievementScorePayload
                                {
                                    Value = platformDataAchievement.Score.Value,
                                    Label = platformDataAchievement.Score.Label
                                };
                            }

                            var platformAchievementPayload = new PlatformAchievementPayload
                            {
                                AchievementId           = platformDataAchievement.AchievementIdentifier,
                                AchievementPlatformType = platformDataAchievement.AchievementPlatformType,
                                AchievementType         = platformDataAchievement.AchievementType,
                                Description             = platformDataAchievement.Description,
                                ImageUrl = platformDataAchievement.ImageUri,
                                Name     = platformDataAchievement.Name,
                                Score    = scorePayload
                            };

                            achievementPayloads.Add(platformAchievementPayload);
                        }

                        platformDataPayload.Achievements = achievementPayloads;
                    }
                }

                payload.PlatformData = platformDataPayload;
            }
            else
            {
                payload.PlatformData = null;
            }

            return(payload);
        }
        private void SendNotifications(int surveyID, string feedbackUID)
        {
            string gagLocation = String.Empty;

            if (AlignedPropertyShortCode == GCCPropertyShortCode.GAG)
            {
                if (radGAG_Everett.Checked)
                {
                    gagLocation = "Everett";
                }
                else if (radGAG_Lakewood.Checked)
                {
                    gagLocation = "Lakewood";
                }
                else if (radGAG_Tukwila.Checked)
                {
                    gagLocation = "Tukwila";
                }
                else if (radGAG_DeMoines.Checked)
                {
                    gagLocation = "DeMoines";
                }
                if (gagLocation.Length > 0)
                {
                    gagLocation = " - " + gagLocation;
                }
            }



            // 2018 04 18 Adding notification users for no specific property
            // Adding proper PropertyID for No Specific Property Region Operations

            //if (AlignedPropertyShortCode == GCCPropertyShortCode.GCC && fbkProperty.SelectedIndex == 24)   // No specific Property
            //{


            //    if (Master.PropertyShortCode == GCCPropertyShortCode.GCC)
            //    {
            //        int selectedProp = Conversion.StringToInt(fbkDirectQuestion.SelectedValue, 0);
            //        if (selectedProp != 0)
            //        {
            //            try
            //            {
            //                GCCPropertyShortCode sc = (GCCPropertyShortCode)selectedProp;
            //                NoSpecificPropertyShortCode = sc;
            //            }
            //            catch
            //            {
            //                NoSpecificPropertyShortCode = GCCPropertyShortCode.GCC;
            //            }
            //        }
            //        else
            //        {
            //            NoSpecificPropertyShortCode = GCCPropertyShortCode.GCC;
            //        }
            //    }
            //    else
            //    {
            //        NoSpecificPropertyShortCode = Master.PropertyShortCode;
            //    }



            //  //  AlignedPropertyShortCode = (GCCPropertyShortCode)Convert.ToInt32(fbkDirectQuestion.SelectedValue.ToString());

            //}


            NotificationReason nr = (NotificationReason)fbkQ2.SelectedValue.StringToInt();

            //Send the notification
            SurveyTools.SendNotifications(
                Server,
                AlignedPropertyShortCode,
                SharedClasses.SurveyType.Feedback,
                nr,
                fbkQ3.Text.ToString(),
                new
            {
                Date             = DateTime.Now.ToString("yyyy-MM-dd"),
                CasinoName       = Master.CasinoName + gagLocation,
                FeedbackNoteHTML = String.IsNullOrEmpty(feedbackUID) ? String.Empty : "<p><b>This guest has requested a response.</b> You can view and respond to the feedback request by clicking on (or copying and pasting) the following link:</p>\n<p>" + GCCPortalUrl + "Admin/Feedback/" + feedbackUID + "</p>",
                FeedbackNoteTXT  = String.IsNullOrEmpty(feedbackUID) ? String.Empty : "The guest requested feedback. You can view and respond to the feedback request by clicking on (or copying and pasting) the following link:\n" + GCCPortalUrl + "Admin/Feedback/" + feedbackUID + "\n\n",
                SurveyLink       = GCCPortalUrl + "Display/Feedback/" + surveyID
            },
                String.Empty,
                String.Empty,
                fbkDirectQuestion.SelectedValue.StringToInt(-1)
                );
            //Determine triggers for feedback request
            if (!IsStaffSurvey &&
                !fbkQ5.SelectedValue.Equals("I do not want to be contacted") &&
                !String.IsNullOrEmpty(txtEmailContact.Text))
            {
                //Send thank you letter
                SurveyTools.SendNotifications(
                    Server,
                    AlignedPropertyShortCode,
                    SharedClasses.SurveyType.Feedback,
                    NotificationReason.ThankYou,
                    string.Empty,
                    new
                {
                    CasinoName = PropertyTools.GetCasinoName(Master.PropertyID),

                    Attachments = new SurveyTools.SurveyAttachmentDetails[]
                    {
                        new SurveyTools.SurveyAttachmentDetails()
                        {
                            Path = "~/Images/headers/" + PropertyTools.GetCasinoHeaderImage(AlignedPropertyShortCode), ContentID = "HeaderImage"
                        }
                    }
                },
                    txtEmailContact.Text,
                    String.Empty,
                    fbkDirectQuestion.SelectedValue.StringToInt(-1));
            }
        }
Esempio n. 10
0
        public static void SendFeedbackNotifications(HttpServerUtility server, string feedbackUID, bool toGuest)
        {
            SQLDatabase  sql          = new SQLDatabase();    sql.CommandTimeout = 120;
            SQLParamList sqlParams    = new SQLParamList().Add("GUID", feedbackUID);
            DataSet      ds           = sql.ExecStoredProcedureDataSet("spFeedback_GetItem", sqlParams);
            string       GCCPortalUrl = ConfigurationManager.AppSettings["GCCPortalURL"].ToString();

            if (!sql.HasError && ds.Tables[0].Rows.Count > 0)
            {
                DataRow fbkDR = ds.Tables[0].Rows[0];
                GCCPropertyShortCode property   = (GCCPropertyShortCode)fbkDR["PropertyID"].ToString().StringToInt();
                SurveyType           surveyType = (SurveyType)fbkDR["SurveyTypeID"].ToString().StringToInt();
                NotificationReason   reason     = (NotificationReason)fbkDR["ReasonID"].ToString().StringToInt();

                string emailAddress = String.Empty;
                if (toGuest)
                {
                    if (ds.Tables[2].Columns.Contains("ContactEmail"))
                    {
                        emailAddress = ds.Tables[2].Rows[0]["ContactEmail"].ToString();
                    }
                    if (String.IsNullOrWhiteSpace(emailAddress) && ds.Tables[2].Columns.Contains("Email"))
                    {
                        emailAddress = ds.Tables[2].Rows[0]["Email"].ToString();
                    }
                    if (String.IsNullOrWhiteSpace(emailAddress) && ds.Tables[2].Columns.Contains("Q5Email"))
                    {
                        emailAddress = ds.Tables[2].Rows[0]["Q5Email"].ToString();
                    }
                    if (String.IsNullOrWhiteSpace(emailAddress))
                    {
                        //Nothing to do
                        return;
                    }
                }

                string template = String.Empty;
                string title    = String.Empty;
                object replacementModel;

                title = PropertyTools.GetCasinoName((int)property) + " - Feedback Reply Notification";
                if (toGuest)
                {
                    template         = "GuestFeedbackNotification";
                    replacementModel = new {
                        CasinoName  = PropertyTools.GetCasinoName((int)property),
                        Link        = GCCPortalUrl + "F/" + feedbackUID,
                        Attachments = new SurveyTools.SurveyAttachmentDetails[] {
                            new SurveyTools.SurveyAttachmentDetails()
                            {
                                Path = "~/Images/headers/" + PropertyTools.GetCasinoHeaderImage(property), ContentID = "HeaderImage"
                            }
                        }
                    };
                }
                else
                {
                    template         = "StaffFeedbackNotification";
                    replacementModel = new {
                        Date       = DateTime.Now.ToString("yyyy-MM-dd"),
                        CasinoName = PropertyTools.GetCasinoName((int)property),
                        Link       = GCCPortalUrl + "Admin/Feedback/" + feedbackUID
                    };
                }

                MailMessage msg = null;
                try {
                    string path = server.MapPath("~/Content/notifications/");
                    msg = EmailManager.CreateEmailFromTemplate(
                        Path.Combine(path, template + ".htm"),
                        Path.Combine(path, template + ".txt"),
                        replacementModel);
                    PropertyInfo attachmentProp = replacementModel.GetType().GetProperty("Attachments");
                    if (attachmentProp != null)
                    {
                        SurveyAttachmentDetails[] attachments = attachmentProp.GetValue(replacementModel) as SurveyAttachmentDetails[];
                        foreach (SurveyAttachmentDetails att in attachments)
                        {
                            LinkedResource lr = new LinkedResource(server.MapPath(att.Path));
                            lr.ContentId = att.ContentID;
                            msg.AlternateViews[0].LinkedResources.Add(lr);
                        }
                    }
                    msg.From    = new MailAddress("*****@*****.**");
                    msg.Subject = title;
                    bool hasAddress = false;
                    if (!String.IsNullOrWhiteSpace(emailAddress))
                    {
                        msg.To.Add(emailAddress);
                        hasAddress = true;
                    }
                    else
                    {
                        sql = new SQLDatabase();
                        DataTable dt = sql.QueryDataTable(@"
SELECT [SendType], u.[FirstName], u.[LastName],  u.[Email]
FROM [tblNotificationUsers] ne
	INNER JOIN [tblNotificationPropertySurveyReason] psr
		ON ne.[PropertySurveyReasonID] = psr.[PropertySurveyReasonID]
	INNER JOIN [tblCOM_Users] u
		ON ne.UserID = u.UserID
WHERE psr.PropertyID = @PropertyID
	AND psr.SurveyTypeID = @SurveyID
	AND psr.ReasonID = @ReasonID
;",
                                                          new SQLParamList()
                                                          .Add("@PropertyID", (int)property)
                                                          .Add("@SurveyID", (int)surveyType)
                                                          .Add("@ReasonID", (int)reason)
                                                          );
                        if (!sql.HasError && dt.Rows.Count > 0)
                        {
                            StringBuilder addrs = new StringBuilder();
                            foreach (DataRow dr in dt.Rows)
                            {
                                switch (dr["SendType"].ToString())
                                {
                                case "1":
                                    msg.To.Add(dr["Email"].ToString());
                                    addrs.Append(dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + " <" + dr["Email"].ToString() + ">" + "\n");
                                    hasAddress = true;
                                    break;

                                case "2":
                                    msg.CC.Add(dr["Email"].ToString());
                                    //Colin requested that CC addresses not show on the call Aug 10,2015
                                    //addrs.Append( dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + " <" + dr["Email"].ToString() + ">" + "\n" );
                                    hasAddress = true;
                                    break;

                                case "3":
                                    msg.Bcc.Add(dr["Email"].ToString());
                                    hasAddress = true;
                                    break;
                                }
                            }
                            using (StreamReader sr = new StreamReader(msg.AlternateViews[0].ContentStream))
                            {
                                msg.AlternateViews[0] = AlternateView.CreateAlternateViewFromString(sr.ReadToEnd().Replace("{Recipients}", server.HtmlEncode(addrs.ToString()).Replace("\n", "<br />")), null, MediaTypeNames.Text.Html);
                            }
                            using (StreamReader sr = new StreamReader(msg.AlternateViews[1].ContentStream))
                            {
                                msg.AlternateViews[1] = AlternateView.CreateAlternateViewFromString(sr.ReadToEnd().Replace("{Recipients}", addrs.ToString()), null, MediaTypeNames.Text.Plain);
                            }



                            //using (StreamReader sr = new StreamReader(msg.AlternateViews[0].ContentStream))
                            //{
                            //    msg.AlternateViews[0] = AlternateView.CreateAlternateViewFromString(sr.ReadToEnd().Replace("{Recipients}", server.HtmlEncode(addrs.ToString()).Replace("\n", "<br />")).Replace("{Business}", server.HtmlEncode(reason.ToString()).Replace("\n", "<br />")).Replace("{Comments}", server.HtmlEncode(Comments.ToString()).Replace("\n", "<br />")), null, MediaTypeNames.Text.Html);
                            //}
                            //using (StreamReader sr = new StreamReader(msg.AlternateViews[1].ContentStream))
                            //{
                            //    msg.AlternateViews[1] = AlternateView.CreateAlternateViewFromString(sr.ReadToEnd().Replace("{Recipients}", addrs.ToString()).Replace("{Business}", reason.ToString()).Replace("{Comments}", Comments.ToString()), null, MediaTypeNames.Text.Plain);
                            //}
                        }
                    }

                    if (hasAddress)
                    {
                        msg.Send();
                    }
                } catch (Exception ex) {
                } finally {
                    if (msg != null)
                    {
                        msg.Dispose();
                        msg = null;
                    }
                }
            }
        }
Esempio n. 11
0
        //20170116 adding commentws for email notification
        //public static void SendNotifications<T>( HttpServerUtility server, GCCPropertyShortCode property, SurveyType surveyType, NotificationReason reason, T replacementModel, string emailAddress, string subjectPrefix )
        public static void SendNotifications <T>(HttpServerUtility server, GCCPropertyShortCode property, SurveyType surveyType, NotificationReason reason, string Comments, T replacementModel, string emailAddress, string subjectPrefix, int operationsArea)
            where T : class
        {
            string template     = String.Empty;
            string title        = String.Empty;
            string propertyName = PropertyTools.GetCasinoName((int)property);

            if (property == GCCPropertyShortCode.GAG)
            {
                PropertyInfo nameProp = replacementModel.GetType().GetProperty("CasinoName");
                if (nameProp != null)
                {
                    string name = nameProp.GetValue(replacementModel) as string;
                    if (!String.IsNullOrWhiteSpace(name))
                    {
                        propertyName = name;
                    }
                }
            }
            switch (surveyType)
            {
            case SurveyType.GEI:
                if (reason == NotificationReason.ThankYou)
                {
                    title    = "Thank You For Your Feedback";
                    template = "GEIThankYou";
                }
                else
                {
                    template = "GEITemplate";
                    title    = String.Format("{0}GEI Feedback Notification for {1} - {2}", subjectPrefix, propertyName, DateTime.Now.ToString("MMMM dd, yyyy"));
                }
                break;

            case SurveyType.GEIProblemResolution:
                if (reason == NotificationReason.ThankYou)
                {
                    title    = "Thank You For Your Feedback";
                    template = "GEIThankYou";
                }
                else
                {
                    if (replacementModel.ToString().Contains("FeedbackCategory"))
                    {
                        template = "GEIFeedbackCategoryTemplate";
                        title    = String.Format("{0}GEI Feedback Category Notification for {1} - {2}", subjectPrefix, propertyName, DateTime.Now.ToString("MMMM dd, yyyy"));
                    }
                    else
                    {
                        template = "GEITemplate";
                        title    = String.Format("{0}GEI Problem Resolution Feedback Notification for {1} - {2}", subjectPrefix, propertyName, DateTime.Now.ToString("MMMM dd, yyyy"));
                    }
                }
                break;

            case SurveyType.Hotel:
                if (reason == NotificationReason.ThankYou)
                {
                    title    = "Thank You For Your Feedback";
                    template = "HotelThankYou";
                }
                else
                {
                    template = "HotelTemplate";
                    title    = String.Format("{0}Hotel Survey Notification - {1}", subjectPrefix, DateTime.Now.ToString("MMMM dd, yyyy"));
                }
                break;

            case SurveyType.Feedback:
                if (reason == NotificationReason.ThankYou)
                {
                    title    = "Thank You For Your Feedback";
                    template = "FeedbackThankYou";
                }
                else if (reason == NotificationReason.Tier3Alert)
                {
                    title    = String.Format("{0}Tier 3 Alert for {1} - {2}", subjectPrefix, propertyName, DateTime.Now.ToString("MMMM dd, yyyy"));
                    template = "Tier3Alert";
                }
                else
                {
                    template = "FeedbackTemplate";
                    title    = String.Format("{0}Feedback Follow-up Notification for {1} - {2}", subjectPrefix, propertyName, DateTime.Now.ToString("MMMM dd, yyyy"));
                }
                break;

            case SurveyType.Donation:
                template = "DonationTemplate";
                title    = String.Format("{0}Sponsorship / Donation Request Notification for {1} - {2}", subjectPrefix, propertyName, DateTime.Now.ToString("MMMM dd, yyyy"));
                break;
            }
            if (template.Equals(String.Empty))
            {
                return;
            }
            MailMessage msg = null;

            try {
                string path = server.MapPath("~/Content/notifications/");
                msg = EmailManager.CreateEmailFromTemplate(
                    Path.Combine(path, template + ".htm"),
                    Path.Combine(path, template + ".txt"),
                    replacementModel);
                PropertyInfo attachmentProp = replacementModel.GetType().GetProperty("Attachments");
                if (attachmentProp != null)
                {
                    SurveyAttachmentDetails[] attachments = attachmentProp.GetValue(replacementModel) as SurveyAttachmentDetails[];
                    foreach (SurveyAttachmentDetails att in attachments)
                    {
                        LinkedResource lr = new LinkedResource(server.MapPath(att.Path));
                        lr.ContentId = att.ContentID;
                        msg.AlternateViews[0].LinkedResources.Add(lr);
                    }
                }
                msg.From    = new MailAddress("*****@*****.**");
                msg.Subject = title;
                //Add high priority flag to tier 3 alerts
                if (reason == NotificationReason.Tier3Alert)
                {
                    msg.Priority = MailPriority.High;
                }
                bool hasAddress = false;
                if (!String.IsNullOrEmpty(emailAddress))
                {
                    msg.To.Add(emailAddress);
                    hasAddress = true;
                }
                else
                {
                    SQLDatabase sql = new SQLDatabase();    sql.CommandTimeout = 120;
                    DataTable   dt  = sql.QueryDataTable(@"
SELECT [SendType], u.[FirstName], u.[LastName],  u.[Email]
FROM [tblNotificationUsers] ne
	INNER JOIN [tblNotificationPropertySurveyReason] psr
		ON ne.[PropertySurveyReasonID] = psr.[PropertySurveyReasonID]
	INNER JOIN [tblCOM_Users] u
		ON ne.UserID = u.UserID
WHERE psr.PropertyID = @PropertyID
	AND psr.SurveyTypeID = @SurveyID
	AND psr.ReasonID = @ReasonID
	
;",
                                                         //AND ( ( @OperationsAreaID < 0 AND psr.OperationsAreaID IS NULL ) OR psr.OperationsAreaID = @OperationsAreaID )
                                                         new SQLParamList()
                                                         .Add("@PropertyID", (int)property)
                                                         .Add("@SurveyID", (int)surveyType)
                                                         .Add("@ReasonID", (int)reason)
                                                         .Add("@OperationsAreaID", operationsArea)
                                                         );
                    if (!sql.HasError && dt.Rows.Count > 0)
                    {
                        StringBuilder addrs = new StringBuilder();
                        foreach (DataRow dr in dt.Rows)
                        {
                            switch (dr["SendType"].ToString())
                            {
                            case "1":
                                msg.To.Add(dr["Email"].ToString());
                                //201701 Testing Email error
                                //msg.Bcc.Add("*****@*****.**");
                                addrs.Append(dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + " <" + dr["Email"].ToString() + ">" + "\n");
                                hasAddress = true;
                                break;

                            case "2":
                                msg.CC.Add(dr["Email"].ToString());
                                //201701 Testing Email error
                                //msg.Bcc.Add("*****@*****.**");
                                //Colin requested that CC addresses not show on the call Aug 10,2015
                                //addrs.Append( dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + " <" + dr["Email"].ToString() + ">" + "\n" );
                                hasAddress = true;
                                break;

                            case "3":
                                msg.Bcc.Add(dr["Email"].ToString());
                                //201701 Testing Email error
                                // msg.Bcc.Add("*****@*****.**");
                                hasAddress = true;
                                break;
                            }
                        }
                        using (StreamReader sr = new StreamReader(msg.AlternateViews[0].ContentStream)) {
                            msg.AlternateViews[0] = AlternateView.CreateAlternateViewFromString(sr.ReadToEnd().Replace("{Recipients}", server.HtmlEncode(addrs.ToString()).Replace("\n", "<br />")).Replace("{Business}", server.HtmlEncode(reason.ToString()).Replace("\n", "<br />")).Replace("{Comments}", server.HtmlEncode(Comments.ToString()).Replace("\n", "<br />")), null, MediaTypeNames.Text.Html);
                        }
                        using (StreamReader sr = new StreamReader(msg.AlternateViews[1].ContentStream)) {
                            msg.AlternateViews[1] = AlternateView.CreateAlternateViewFromString(sr.ReadToEnd().Replace("{Recipients}", addrs.ToString()).Replace("{Business}", reason.ToString()).Replace("{Comments}", Comments.ToString()), null, MediaTypeNames.Text.Plain);
                        }
                    }
                }

                if (hasAddress)
                {
                    msg.Send();
                }
            } catch (Exception ex) {
            } finally {
                if (msg != null)
                {
                    msg.Dispose();
                    msg = null;
                }
            }
        }
Esempio n. 12
0
 public static void SendNotifications <T>(HttpServerUtility server, GCCPropertyShortCode property, SurveyType surveyType, NotificationReason reason, string Comments, T replacementModel, string emailAddress, string subjectPrefix)
     where T : class
 {
     SendNotifications(server, property, surveyType, reason, Comments, replacementModel, emailAddress, subjectPrefix, -1);
 }
Esempio n. 13
0
 public static void SendNotifications <T>(HttpServerUtility server, GCCPropertyShortCode property, SurveyType surveyType, NotificationReason reason, string Comments, T replacementModel)
     where T : class
 {
     SendNotifications(server, property, surveyType, reason, Comments, replacementModel, String.Empty);
 }