public bool SendEmails()
        {
            try
            {
                PagingInfo pageInfo = new PagingInfo() {PageNumber = 1, PageSize = 20};
                var feedBacks = new FeedBackDataManager().GetAllUnseenFeedbacks(pageInfo);
                while (feedBacks.Count > 0)
                {
                    foreach (var feedBack in feedBacks)
                    {
                        try
                        {
                            string emailId = feedBack.EmailId.ToLower();
                            if (!reminderCounts.ContainsKey(emailId)) reminderCounts[emailId] = 0;
                            if (reminderCounts[emailId] < RemConfig.FeedbackReminderCountLimit)
                            {
                                _mailerQueue.Publish(new FeedBackMessageItem()
                                {
                                    RoutingKey = RoutingKeys.EMAIL_NOTIFICATION,
                                    FeedBack = feedBack,
                                });
                                reminderCounts[emailId] = reminderCounts[emailId] + 1;
                            }
                        }
                        catch (Exception ex)
                        {
                            ex.Data["EmailId"] = feedBack.EmailId;
                            Logger.LogException(ex, _source, "SendEmails", Severity.Critical);
                        }
                    }
                    pageInfo.PageNumber = pageInfo.PageNumber + 1;
                    feedBacks = new FeedBackDataManager().GetAllUnseenFeedbacks(pageInfo);
                }

                //Save new count in the file.
                StringBuilder emailCount = new StringBuilder();
                foreach (var email in reminderCounts.Keys)
                {
                    emailCount.AppendLine(string.Format("{0}|{1}",email, reminderCounts[email]));
                }
                File.WriteAllText(RemConfig.FeedbackReminderCountFilePath, emailCount.ToString());
            }
            catch (Exception ex)
            {
                Logger.LogException(ex, _source, "SendEmails", Severity.Critical);
                return false;
            }
            return true;
        }
Example #2
0
 public FeedBackManager()
 {
     _feedBackDataManager = new FeedBackDataManager();
     _queue = CreateQueue(ApplicationQueues.GameQueue, RoutingKeys.GAME_CREATED);
 }