コード例 #1
0
        public void Should_Update_Email_Second()
        {
            NotificationEmail notificationEmail = new NotificationEmail(cr, currentEmail, title, content, notificationSettingId, link, key);

            notificationEmail.Update(title, content);
            Assert.Equal(title, notificationEmail.Title);
        }
コード例 #2
0
        public IEnumerable <NotificationEmail> CollectNotifications()
        {
            // get users which have opted to receive the digest
            var users = DbService.db().Query <PipelineUser>("select Id, userName, userEmail from umbracoUser where id in (select userId from pipelinePreferences where ReceiveDigest = 1)").ToList();
            var notificationService = new GrowCreate.PipelineCRM.Services.NotificationService();
            var notifications       = new List <NotificationEmail>();

            foreach (var user in users)
            {
                var userTasks    = notificationService.GetUserTasks(user.Id);
                var notification = new NotificationEmail()
                {
                    userName     = user.userName,
                    userEmail    = user.userEmail,
                    todaysTasks  = userTasks.Where <Task>(x => x.DateDue != null && x.DateDue.Date == DateTime.Now.Date),
                    reminders    = userTasks.Where <Task>(x => x.Reminder != null && x.Reminder.Date == DateTime.Now.Date),
                    overdueTasks = userTasks.Where(x => x.DateDue.Date < DateTime.Now.Date),
                    newPipelines = notificationService.GetNewPipelines()
                };

                if (notification.todaysTasks.Any() || notification.overdueTasks.Any() || notification.upcomingTasks.Any() || notification.newPipelines.Any())
                {
                    notifications.Add(notification);
                }
            }

            return(notifications);
        }
コード例 #3
0
 public async Task <ActionResult> Create([Bind(Include = "NotificationEmailID,NotificationID,Email")] NotificationEmail notificationEmail)
 {
     if (ModelState.IsValid)
     {
         try
         {
             DAL.uof.NotificationEmailRepository.Insert(notificationEmail);
             DAL.uof.Save();
             if (Request.IsAjaxRequest())
             {
                 return(PartialView("_Index", await DAL.uof.NotificationEmailRepository.GetAsync()));
             }
             return(RedirectToAction("Index"));
         }
         catch (DataException)
         {
             ModelState.AddModelError("", "Ошибка записи в БД!");
         }
     }
     if (Request.IsAjaxRequest())
     {
         return(Content("<p class = 'text-danger'>Ошибка записи в БД!</p><p>Попробуйте еще раз или обновите страницу.</p>"));
     }
     return(View(notificationEmail));
 }
コード例 #4
0
        public bool Email(string penerima, string subject, string message)
        {
            bool exe = false;

            try
            {
                if (string.IsNullOrEmpty(penerima) || string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(message))
                {
                    return(exe);
                }

                using (AppDb context = new AppDb())
                {
                    NotificationEmail data = new NotificationEmail()
                    {
                        To           = penerima,
                        SubjectEmail = subject,
                        Email        = message
                    };
                    context.NotificationEmails.Add(data);
                    context.SaveChanges();
                    exe = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(exe);
        }
コード例 #5
0
 public void RemoveNotificationEmail(NotificationEmail notificationMail)
 {
     Require.NotNull(notificationMail, nameof(notificationMail));
     _databaseSessionProvider.OpenSession();
     Session.Delete(notificationMail);
     _databaseSessionProvider.CloseSession();
 }
コード例 #6
0
        private NotificationEmail MapNotificationEmail(NotificationEntity objectToMap)
        {
            var notificationEmail = new NotificationEmail(objectToMap.NotificationId);

            _notificationPopulator.Populate(objectToMap, notificationEmail);

            NotificationEmailEntity notificationEmailEntity = objectToMap.NotificationEmail;

            notificationEmail.Body     = notificationEmailEntity.Body;
            notificationEmail.FromName = notificationEmailEntity.FromName;
            try
            {
                notificationEmail.FromEmail = new Email(notificationEmailEntity.FromEmail);
            }
            catch
            {
                // no from email?
            }
            try
            {
                notificationEmail.ToEmail = new Email(notificationEmailEntity.ToEmail);
            }
            catch
            {
                // no to email?
            }
            notificationEmail.Subject = notificationEmailEntity.Subject;

            return(notificationEmail);
        }
コード例 #7
0
 public void SaveNotificationEmail(NotificationEmail email)
 {
     Require.NotNull(email, nameof(email));
     _databaseSessionProvider.OpenSession();
     Session.Save(email);
     _databaseSessionProvider.CloseSession();
 }
コード例 #8
0
        private void ServiceNotification(NotificationEmail notification)
        {
            EmailMessage message;

            try
            {
                message = new EmailMessage
                {
                    Body      = notification.Body,
                    FromEmail = (notification.FromEmail ?? _settings.EmailNotificationIssuedFrom).ToString(),
                    FromName  = notification.FromName,
                    Subject   = notification.Subject,
                    ToEmail   = notification.ToEmail.ToString()
                };
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Could not create message for notifcation {0} to {1}", notification.Id, notification.ToEmail), exception);
                throw;
            }

            try
            {
                _notificationEmailSender.SendEmail(message);
            }
            catch (Exception exception)
            {
                string errorMessage = string.Format("Could not send email for notification {0} to {1}", notification.Id, message.ToEmail);
                _logger.Error(errorMessage, exception);
                _logger.Error("Message: " + exception.Message);
                _logger.Error("StackTrace: " + exception.StackTrace);
                throw;
            }
        }
コード例 #9
0
        public void Constructor_SetsNullData_ToEmptyString()
        {
            // empty string used as default following NotificationManager.Email's default value for data
            var email = new NotificationEmail("*****@*****.**", "subject", "message", null);

            Assert.AreEqual(string.Empty, email.Data);
        }
コード例 #10
0
        public void Constructor_SetsNullMessage_ToEmptyString()
        {
            // empty string used if message is null
            var email = new NotificationEmail("*****@*****.**", "subject", null, "data");

            Assert.AreEqual(string.Empty, email.Message);
        }
コード例 #11
0
        public void Should_Update_Email()
        {
            NotificationEmail notificationEmail = new NotificationEmail(cr, currentEmail, title, content, notificationSettingId, link, key);

            notificationEmail.Update(NotifacationStatus.Send);
            Assert.Equal((int)NotifacationStatus.Send, notificationEmail.NotifacationStatusId);
        }
コード例 #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            NotificationEmail notificationemail = db.NotificationEmails.Find(id);

            db.NotificationEmails.Remove(notificationemail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #13
0
ファイル: SaveTester.cs プロジェクト: sahvishal/matrix
        public void CanSaveNewEmailNotification()
        {
            NotificationEmail domainObject = GetNewNotificationEmail();

            Notification savedNotification = _notificationRepository.Save(domainObject);

            Assert.AreNotEqual(0, savedNotification.Id);
        }
コード例 #14
0
        public object Post(Reservation reservation)
        {
            Check.NotNull(reservation, "reservation");
            var id = reservationEngine.AddReservation(reservation);

            NotificationEmail.Send(reservation);
            return(new { Id = id });
        }
コード例 #15
0
        public async Task <IActionResult> Mandrill()
        {
            //log.Info($"C# HTTP trigger function processed a request. HTTP Method: {req.Method}");
            var req = HttpContext.Request;

            try
            {
                if (req.Method.ToUpper() == "HEAD")
                {
                    return(new OkObjectResult("Hello Mandrill!"));
                }

                if (!req.HasFormContentType)
                {
                    return(new BadRequestObjectResult("No form content received"));
                }
                var content   = req.Form;
                var validJson = content["mandrill_events"].First().Replace("mandrill_events =", string.Empty);

                if (string.IsNullOrWhiteSpace(validJson))
                {
                    return(new BadRequestObjectResult("No valid JSON found"));
                }

                var webhookEvents = JsonConvert.DeserializeObject <List <WebHookEvent> >(validJson);
                if (webhookEvents == null)
                {
                    return(new BadRequestObjectResult("No webhook events found"));
                }
                //log.Info($"Processing {webhookEvents.Count} event(s)...");

                foreach (var webhookEvent in webhookEvents)
                {
                    var msg  = webhookEvent.Msg;
                    var mail = new NotificationEmail
                    {
                        Sender = msg.FromEmail,
                        //Recipient = msg.
                        Subject = msg.Subject,

                        BodyHtml = msg.Html,
                        BodyText = msg.Text,
                    };

                    var jobExecution = await jobExecutionService.ConvertMailToJobExecution(mail);

                    //log.Info(JsonConvert.SerializeObject(jobExecution, Formatting.None));

                    await jobExecutionService.Create(jobExecution);
                }
            }
            catch (Exception e)
            {
                //log.Error(e.Message + "\r\n" + e.StackTrace);
                throw;
            }
            return(new OkObjectResult("Event processed successfully"));
        }
コード例 #16
0
ファイル: TaskWService.cs プロジェクト: hinteadan/croom
        private static void CheckForReservations()
        {
            var user = new User("mircea.nistor", "Mircea Nistor", "*****@*****.**");

            var reservation = new Reservation(user, "Daily LPL Meeting", new DateTime(2013, 9, 13), new DateTime(2013, 9, 13).AddHours(1));

            reservation.AddParticipant(user);
            NotificationEmail.Send(reservation);
        }
コード例 #17
0
ファイル: SaveTester.cs プロジェクト: sahvishal/matrix
        public void CanSaveExistingEmailNotification()
        {
            NotificationEmail domainObject = GetNewNotificationEmail();

            Notification savedNotification   = _notificationRepository.Save(domainObject);
            Notification updatedNotification = _notificationRepository.Save(savedNotification);

            Assert.AreEqual(savedNotification.Id, updatedNotification.Id);
        }
コード例 #18
0
 public ActionResult Edit(NotificationEmail notificationemail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notificationemail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(notificationemail));
 }
コード例 #19
0
        //
        // GET: /NotificationEmail/Delete/5

        public ActionResult Delete(long id = 0)
        {
            NotificationEmail notificationemail = db.NotificationEmails.Find(id);

            if (notificationemail == null)
            {
                return(HttpNotFound());
            }
            return(View(notificationemail));
        }
コード例 #20
0
    public void NotifyNewComment(int id)
    {
        var email = new NotificationEmail
        {
            To      = "*****@*****.**",
            Comment = comment.Text
        };

        email.Send();
    }
コード例 #21
0
        public ActionResult Create(NotificationEmail notificationemail)
        {
            if (ModelState.IsValid)
            {
                db.NotificationEmails.Add(notificationemail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(notificationemail));
        }
コード例 #22
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit([Bind(Include = "EmailId,PresenterRegistration,ParticipantRegistration,ParticipantConfirmation,AbstractSubmission,AbstractAcceptance,AbstractRejection,FullPaperSubmission,PaperAcceptance,PaperRejection,CameraReadyPaper,ReviewerInvitation,PaperForReviewing,FinishReview,UserInvitation,ConferenceId")] NotificationEmail notificationemail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notificationemail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Menu", "Conference", new { id = notificationemail.ConferenceId }));
     }
     ViewBag.ConferenceId = new SelectList(db.Conferences, "ConferenceId", "Username", notificationemail.ConferenceId);
     return(View(notificationemail));
 }
コード例 #23
0
        private async Task SendNotificationForUsers(QueryResult <EmployeeIntegrationModel> idmUsers, List <UserNotificationSetting> userNotificationSettings, MainNotificationTemplateModel mainNotificationTemplateModel)
        {
            try
            {
                string output = JsonConvert.SerializeObject(mainNotificationTemplateModel);
                MainNotificationTemplateModel mainView = JsonConvert.DeserializeObject <MainNotificationTemplateModel>(output);

                var userNotificationsModel = userNotificationSettings.Select(x => new UserNotificationSettingModel {
                    UserId = x.UserProfileId.Value, Email = idmUsers.Items.Where(i => i.userId == x.User.Id).FirstOrDefault().email, Mobile = idmUsers.Items.Where(i => i.userId == x.User.Id).FirstOrDefault().mobileNumber
                }).ToList();

                var  entityKey             = TempletKey(mainView.EntityValue, mainView.EntityType);
                bool IsNullEmailFirstArrgs = string.IsNullOrEmpty(Convert.ToString(mainView.Args.BodyEmailArgs[0]));
                bool IsNullSmsmFirstArrgs  = string.IsNullOrEmpty(Convert.ToString(mainView.Args.SMSArgs[0]));
                NotificationEmail email;
                NotificationSMS   sms;
                NotificationPanel panel;
                foreach (var setting in userNotificationSettings)
                {
                    if (IsNullEmailFirstArrgs)
                    {
                        mainView.Args.BodyEmailArgs[0] = Convert.ToString(setting.User.FullName);
                    }
                    if (IsNullSmsmFirstArrgs)
                    {
                        mainView.Args.SMSArgs[0] = Convert.ToString(setting.User.FullName);
                    }
                    NotificationDataModel template = await BuildNotificationTemplate(userNotificationSettings.FirstOrDefault().IsArabic, userNotificationSettings.FirstOrDefault().NotificationCodeId, mainView.Args);

                    if (setting.Email)
                    {
                        email = new NotificationEmail(setting.UserProfileId.Value, userNotificationsModel.FirstOrDefault(u => u.UserId == setting.UserProfileId.Value).Email, template.Email.Title, template.Email.Body, setting.Id, mainView.Link, entityKey);
                        await _notifayCommands.AddNotifayWithOutSave(email);
                    }
                    if (setting.Sms)
                    {
                        sms = new NotificationSMS(setting.UserProfileId.Value, userNotificationsModel.FirstOrDefault(u => u.UserId == setting.UserProfileId.Value).Mobile, template.SMS.Body, setting.Id, mainView.Link, entityKey);
                        await _notifayCommands.AddNotifayWithOutSave(sms);
                    }
                    panel = new NotificationPanel(setting.UserProfileId.Value, template.PanelMessage, template.PanelMessage, setting.Id, mainView.Link, mainView.BranchId, mainView.CommitteeId, entityKey);
                    await _notifayCommands.AddNotifayWithOutSave(panel);
                }
                if (userNotificationSettings.Count > 0)
                {
                    await _notifayCommands.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
            }
        }
コード例 #24
0
        public List <BaseNotification> getBaseNotification()
        {
            NotificationEmail       notificationEmail = new NotificationEmail(1, "*****@*****.**", "testTitle", "TestContent", 1, "link", "key");
            List <BaseNotification> baseNotifications = new List <BaseNotification>();

            baseNotifications.Add(notificationEmail);

            NotificationSMS notificationSMS = new NotificationSMS(1, "0533286913", "content", 1, "link", "key");

            baseNotifications.Add(notificationEmail);
            baseNotifications.Add(notificationSMS);
            return(baseNotifications);
        }
コード例 #25
0
        public void Should_Construct_NotificationEmail()
        {
            NotificationEmail notificationEmail = new NotificationEmail(userId, currentEmail, title, content, notificationSettingId, link);
            var notification = new NotificationEmail();

            _ = notification.Id;
            _ = notification.User;
            _ = notification.Supplier;
            _ = notification.NotifacationStatusEntity;
            _ = notification.NotificationSetting;

            notificationEmail.ShouldNotBeNull();
        }
コード例 #26
0
        public async Task <NotificationEmail> CreateMyWondersEmailAndSend(AspNetUser user)
        {
            string emailPlainText = "MyWonders = \n";
            string emailHtmlText  = "";

            if (!useDefaultEmail)
            {
                _emailToUse = user.Email;
            }

            var email = new NotificationEmail
            {
                Created        = DateTime.UtcNow,
                RecipientEmail = _emailToUse,
                RecipientName  = user.UserName
            };

            var amountToSkip  = user.MyWonders.Count <= NumberOfWonders ? 0 : user.MyWonders.Count - NumberOfWonders;
            var recentWonders = user.MyWonders.Where(x => x.Archived != true).Skip(amountToSkip).Reverse();
            //var recentWonders = user.MyWonders.Skip(user.MyWonders.Count - NumberOfWonders);

            var model = new EmailTemplateViewModel();

            model.User    = Mapper.Map <UserModel>(user);
            model.Wonders = Mapper.Map <List <DealModel> >(recentWonders);

            //TODO: move these to config properties
            model.UrlString       = "https://cms.thewonderapp.co/content/images/";
            model.UnsubscribeLink = "mailto:[email protected] ";

            foreach (var wonder in recentWonders)
            {
                emailPlainText += wonder.Title + "\n";
            }


            Template templateToUse = _dataContext.Templates.FirstOrDefault(t => t.Name.Equals("MyWondersEmail"));

            if (templateToUse != null)
            {
                emailHtmlText = await LoadTemplate(templateToUse.File.Trim(), model);

                email.Template_Id = templateToUse.Id;
            }
            else
            {
                emailHtmlText = emailPlainText;
            }

            return(await SendEmail(email, emailPlainText, emailHtmlText));
        }
コード例 #27
0
        // GET: /NotificationEmail/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NotificationEmail notificationemail = db.NotificationEmails.Find(id);

            if (notificationemail == null)
            {
                return(HttpNotFound());
            }
            return(View(notificationemail));
        }
コード例 #28
0
ファイル: SendNotifByEmail.cs プロジェクト: kia9372/Filmstan
        public async override Task <OperationResult <string> > SendCodeAsync(string content, string to, CancellationToken cancellationToken)
        {
            SendNotification notif = new SendNotification();
            var emailSetting       = await unitOfWork.SettingRepository.Get <AddEmailSetting>(SettingEnum.EmailSetting.EnumToString(), cancellationToken);

            NotificationEmail emailSend = new NotificationEmail(notif);

            //   var sendEmail = await emailSend.Send(emailSetting.Result.From, "Email Confirm Code", content, emailSetting.Result.Username, emailSetting.Result.Password,MailboxAddress, emailSetting.Result.Port, emailSetting.Result.SmtpServer);
            if (true)
            {
                return(OperationResult <string> .BuildSuccessResult("Success Send Email"));
            }
            return(OperationResult <string> .BuildFailure("Fail Send Email"));
        }
コード例 #29
0
        public async Task SendNotificationByUserId(int notificationCodeId, int userId, string userName, MainNotificationTemplateModel mainNotificationTemplateModel)
        {
            string output = JsonConvert.SerializeObject(mainNotificationTemplateModel);
            MainNotificationTemplateModel mainView = JsonConvert.DeserializeObject <MainNotificationTemplateModel>(output);
            var userNotificationSetting            = await _iNotificationQuerie.GetNotificationSettingByUserId(notificationCodeId, userId);

            var entityKey = TempletKey(mainView.EntityValue, mainView.EntityType);

            if (userNotificationSetting == null)
            {
                return;
            }
            var userDataFromIDM = await _idmProxy.GetUserbyUserName(userName);

            var userNotificationsModel = new UserNotificationSettingModel
            {
                UserId = userNotificationSetting.UserProfileId.Value,
                Email  = userDataFromIDM != null ? userDataFromIDM.Email : userNotificationSetting.User.Email,
                Mobile = userDataFromIDM != null ? userDataFromIDM.PhoneNumber : userNotificationSetting.User.Mobile,
            };
            bool IsNullEmailFirstArrgs = string.IsNullOrEmpty(Convert.ToString(mainView.Args.BodyEmailArgs[0]));
            bool IsNullSmsmFirstArrgs  = string.IsNullOrEmpty(Convert.ToString(mainView.Args.SMSArgs[0]));

            if (IsNullEmailFirstArrgs)
            {
                mainView.Args.BodyEmailArgs[0] = Convert.ToString(userNotificationSetting.User.FullName);
            }
            if (IsNullSmsmFirstArrgs)
            {
                mainView.Args.SMSArgs[0] = Convert.ToString(userNotificationSetting.User.FullName);
            }
            NotificationDataModel template = await BuildNotificationTemplate(userNotificationSetting.IsArabic, userNotificationSetting.NotificationCodeId, mainView.Args);

            if (userNotificationSetting.Email)
            {
                var email = new NotificationEmail(userId, userNotificationsModel.Email, template.Email.Title, template.Email.Body, userNotificationSetting.Id, mainView.Link, entityKey);
                await _notifayCommands.AddNotifayWithOutSave(email);
            }
            if (userNotificationSetting.Sms)
            {
                var sms = new NotificationSMS(userNotificationSetting.UserProfileId.Value, userNotificationsModel.Mobile, template.SMS.Body, userNotificationSetting.Id, mainView.Link, entityKey);
                await _notifayCommands.AddNotifayWithOutSave(sms);
            }
            var panel = new NotificationPanel(userNotificationSetting.UserProfileId.Value, template.PanelMessage, template.PanelMessage, userNotificationSetting.Id, mainView.Link, mainView.BranchId, mainView.CommitteeId, entityKey);
            await _notifayCommands.AddNotifayWithOutSave(panel);

            await _notifayCommands.SaveChangesAsync();
        }
コード例 #30
0
        public override async Task <OperationResult <string> > SendCodeAsync(string content, string to, CancellationToken cancellationToken)
        {
            SendNotification notif = new SendNotification();
            var smsSetting         = await unitOfWork.SettingRepository.Get <AddSMSSetting>(SettingEnum.SMSSetting.EnumToString(), cancellationToken);

            var emailSetting = await unitOfWork.SettingRepository.Get <AddEmailSetting>(SettingEnum.EmailSetting.EnumToString(), cancellationToken);

            NotificationSms   smsSend   = new NotificationSms(notif);
            NotificationEmail emailSend = new NotificationEmail(smsSend);
            var sendSms = await smsSend.Send(smsSetting.Result.LineNumber, smsSetting.Result.userApikey, to, content, smsSetting.Result.secretKey);

            if (sendSms.Success)
            {
                // var sendEmail = await emailSend.Send(emailSetting.Result.From, "Email Confirm Code", content, emailSetting.Result.Username, emailSetting.Result.Password, to, emailSetting.Result.Port, emailSetting.Result.SmtpServer);
            }
            return(OperationResult <string> .BuildFailure("Fail Send SMS"));
        }