Ejemplo n.º 1
0
        private void FindUsersAndNotifications(NotificationFrequency frequency)
        {
            NotificationsController controller = new NotificationsController();

            foreach (var user in controller.GetEmailSubscribers(frequency))
            {
                NotificationViewModel notificationModel = new NotificationViewModel(user, controller);
                List <Notification>   notifications     = notificationModel.Notifications;
                if (notifications.Count > 0)
                {
                    string msg = "<table>";
                    msg += "<tr> <td> מחלקה </td> <td> בניין </td> <td> כיתה </td> <td> עמדה </td>  <td> פירוט התראה </td><th></th></tr> ";

                    foreach (var notification in notificationModel.Notifications)
                    {
                        msg += "<tr> <td>" + notification.DepartmentName + "</td> ";
                        msg += "<td>" + notification.Building + "</td> ";
                        msg += "<td>" + notification.RoomNumber + "</td> ";
                        msg += "<td>" + notification.ComputerName + "</td> ";
                        switch (notification.NotificationType)
                        {
                        case Constant.NotificationType.Disconnected:
                            msg += "<td> לא מחובר " + notification.Days + " ימים </td> ";
                            break;

                        case Constant.NotificationType.NotUsed:
                            msg += "<td> לא בשימוש " + notification.Days + " ימים </td> ";
                            break;
                        }
                        msg += "</tr>";
                    }
                    msg += "</table>";
                    SendEmail(msg, user);
                }
            }
        }