public void NotifyUsertest()
        {
            var notification = new EmailNotifier();

            notification.NotifyUser("Email Sent Succesfully");
            return;
        }
        public void NotifyUserMustNotifyUser()
        {
            var notification = new EmailNotifier();

            notification.NotifyUser("Test Message");
            return;
        }
Beispiel #3
0
        static void Main()
        {
            Console.WriteLine("------------------------------------");
            Console.WriteLine("CHECKING BERG LAKE FOR AVAILABILITY\n");

            var logger = new FileLogger();

            using var poller = new ReservationPoller();

            try
            {
                var isAvailable = poller.IsReservationAvailable(XPath.BergLake);

                if (isAvailable)
                {
                    Console.WriteLine("\nReservations ARE available currently");
                    logger.Logger.Information("Reservations are available");

                    var notifier = new EmailNotifier();
                    logger.Logger.Information("Notification email sent");

                    notifier.Notify();
                }
                else
                {
                    Console.WriteLine("\nReservations ARE NOT available currently");
                    logger.Logger.Information("Reservations are not available");
                }
            }
            catch (Exception e)
            {
                logger.Logger.Error($"Error encountered:\n{e}");
                throw;
            }
        }
Beispiel #4
0
        public IActionResult ChangePassword(string notificationType)
        {
            INotifier notifier = null;

            switch (notificationType)
            {
            case "email":
                notifier = new EmailNotifier();
                break;

            case "sms":
                notifier = new SMSNotifier();
                break;

            case "popup":
                notifier = new PopupNotifier();
                break;
            }

            UserManager mgr = new UserManager(notifier);

            mgr.ChangePassword("user1", "oldpwd", "newpwd");

            return(View("Success"));
        }
Beispiel #5
0
        public void Will_notify_all_Affiliates_each_once()
        {
            // Arrange
            var notifier = new EmailNotifier();

            var affiliate1 = MockRepository.GenerateMock <IAffiliate>();
            var affiliate2 = MockRepository.GenerateMock <IAffiliate>();
            var affiliate3 = MockRepository.GenerateMock <IAffiliate>();

            affiliate1.Expect(a => a.Update()).Return(true).Repeat.Once();
            affiliate2.Expect(a => a.Update()).Return(true).Repeat.Once();
            affiliate3.Expect(a => a.Update()).Return(true).Repeat.Once();

            var oberversToBeNotified = new List <IAffiliate>
            {
                affiliate1,
                affiliate2,
                affiliate3
            };

            // Act
            notifier.UpdateObservers(oberversToBeNotified);

            // Assert
            affiliate1.VerifyAllExpectations();
        }
Beispiel #6
0
        public void Will_contain_multiple_Affiliates_with_Id_and_Name_specified_in_message_returned()
        {
            // Arrange
            var oberversToBeNotified = new List <IAffiliate>
            {
                new EasyBooking {
                    Id = 111, Name = "EasyBooker A"
                },
                new EasyBooking {
                    Id = 22, Name = "EasyBooker B"
                },
                new EasyBooking {
                    Id = 333, Name = "EasyBooker C"
                },
            };
            var expectedMessage = string.Format(
                "Email notification sent to: {0} (ID={1}), {2} (ID={3}), {4} (ID={5})",
                oberversToBeNotified[0].Name,
                oberversToBeNotified[0].Id,
                oberversToBeNotified[1].Name,
                oberversToBeNotified[1].Id,
                oberversToBeNotified[2].Name,
                oberversToBeNotified[2].Id);

            // Act
            var actualMessage = new EmailNotifier().UpdateObservers(oberversToBeNotified);

            // Assert
            Assert.That(expectedMessage, Is.EqualTo(actualMessage));
        }
        public void CheckIfMailBodyDetailsIsValid()
        {
            var emailFormat = new EmailFormat("abc", "99999999", "*****@*****.**", "Illllkslk");
            var obj         = new EmailNotifier();

            Assert.False(obj.GetMailMessage(emailFormat) == null);
        }
        public void WhenNoAuthenticationIsProvidedThrowError()
        {
            var obj         = new EmailNotifier();
            var emailFormat = new EmailFormat("abc", "99999999", "*****@*****.**", "Illllkslk");

            Assert.Throws <SmtpException>(() => obj.SendCustomerInterestDetailsToMarketingTeam(emailFormat));
        }
Beispiel #9
0
        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.errMessage = "Please enter valid information.";
                return(View(model));
            }

            Account account = AccountDB.FindActivatedAccount(model.username);

            if (account == null)
            {
                model.errMessage = "Account not found";
                return(View(model));
            }

            string code = Guid.NewGuid().ToString();

            AccountDB.UpdateCode(account.Username, code);

            string subject = "Password Reset Link.";
            string url     = "http://*****:*****@"

<p><a href='" + url + @"'>" + url + @"<a/></p>

Thank you, <br>
hANNGry
";

            EmailNotifier.SendHtmlEmail(account.Email, subject, body);
            model.message = "Link Sent";
            return(View(model));
        }
        public void SendTest(bool expectReply)
        {
            //
            // IN PROGRESS - Please leave
            // This code is in development and switched off until email and SMS approvals are required by PM.
            //
            if (Factory.FeatureSwitch.Get("enableWfUserActionNotify"))
            {
                var notifier = new EmailNotifier
                {
                    Name = "Test email notifier",
                    EnEmailAddressExpression = "[Business email]",
                    EmailNotifierInbox       = Entity.Get <Inbox>("core:approvalsInbox")
                };

                var person = new Person();
                person.SetField("shared:businessEmail", "*****@*****.**");

                var notification = new Notification {
                    NMessage = "Test"
                }
                ;               EmailRouter.Instance.Send(notifier, notification, person.ToEnumerable(), expectReply);

                var result = Entity.Get <Notification>(notification.Id).SendRecords;
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result.First().SrErrorMessage, Is.Null);
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Creating stock dictionary");
            Dictionary <string, Stock> stocks = new Dictionary <string, Stock>();

            Console.WriteLine("Checking to see if there is already an data analysis for today");
            if (File.Exists("stocksWithIndicators.bin") && new FileInfo("stocksWithIndicators.bin").CreationTime.Date == DateTime.Now.Date)
            {
                Console.WriteLine("There is. Recovering file");
                StockState ss = new StockState();
                stocks = ss.Deserialize("stocksWithIndicators.bin");
            }
            else
            {
                Console.WriteLine("There is not. Procceding with Analysis.");
                Console.WriteLine("Getting most recent stock market file");
                HistoryFileSelector hfs = new HistoryFileSelector(@"C:\Users\Cliente\Downloads");
                string mostRecent       = hfs.GetMostRecentFileFullPath();

                Console.WriteLine("Reading data from file");
                stocks = Reader.GetAllStockData(mostRecent);

                Console.WriteLine("Analyzing data");
                sw.Start();
                MarketHistoryAnalyzer.FillAllWithDefaults(stocks, PrintProgress);
                sw.Stop();

                Console.WriteLine("Saving to disk");
                StockState sc1 = new StockState(stocks);
                sc1.Serialize("stocksWithIndicators.bin");
            }



            Console.WriteLine("Removing stocks not traded every day");
            List <Stock> tradedEveryday = StockComparer.RemoveStocksNotTradedEveryday(stocks);

            Console.WriteLine("Creating Stock Comparator");
            StockComparer sc = new StockComparer(tradedEveryday);

            Console.WriteLine("Running comparison");
            //List<Stock> rankedStocks = StockComparer.RankOfBestStocks(tradedEveryday);
            sc.RankStocksByCompare();

            Console.WriteLine("Saving to disk");
            StockState sc2 = new StockState(sc.RankedStocks);

            sc2.Serialize("rankedStocks.bin");

            Console.WriteLine("Emailing results");
            EmailNotifier en = new EmailNotifier("ff12sender", "33914047");

            en.Send(sc.RankedStocks);

            Console.WriteLine("All done. Check your email");
            Console.WriteLine("Press any key to exit");

            Console.ReadKey();
        }
Beispiel #12
0
        /// <summary>
        /// Send email.
        /// </summary>
        private void SendEmail(Account subscriber)
        {
            string email   = subscriber.Email;
            string subject = notification.Subject;
            string body    = ReplaceDatabaseField(subscriber, notification.Message, ref tags);

            EmailNotifier.SendEmail(email, subject, body);
        }
Beispiel #13
0
        public void FireExceptionThrowsExceptionWhenExceptionIsNull()
        {
            var notifier = new EmailNotifier(new EmailConfiguration());

            var exception = Assert.Throws <ExceptionMissingException>(() => notifier.FireNotification(null, null));

            Assert.Equal("FireNotification failure: exception is null.", exception.Message);
        }
Beispiel #14
0
        /// <summary>
        /// Send SMS.
        /// </summary>
        private void SendSMS(Account subscriber)
        {
            string carrier     = subscriber.Carrier;
            string phoneNumber = subscriber.PhoneNumber;
            string body        = ReplaceDatabaseField(subscriber, notification.Message, ref tags);
            string subject     = notification.Subject;

            EmailNotifier.SendSmsByEmail(carrier, phoneNumber, subject, body);
        }
Beispiel #15
0
        public void Notify_EmailNotifier()
        {
            //This is the refactored implementation that follows the DIP. We will plug in a notifier that we want on the UserManager
            var myEmailNotifier = new EmailNotifier();
            var myUserManager   = new UserManager(myEmailNotifier);

            var output = myUserManager.CreateUser("1", "testpassword", "*****@*****.**");

            Assert.AreEqual(output, "Email Notifier: User created successfully!");
        }
 public ServiceResponseAPI Invoke(String actionName, ServiceRequestAPI serviceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().Invoke(EmailNotifier.GetInstance(this.GetWho(), serviceRequest.configurationValues, "PluginSalesforceController.Invoke"), this.GetWho(), actionName, serviceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public ObjectDataResponseAPI Delete(ObjectDataRequestAPI objectDataRequestAPI)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().Delete(EmailNotifier.GetInstance(this.GetWho(), objectDataRequestAPI.configurationValues, "PluginSalesforceController.Delete"), this.GetWho(), objectDataRequestAPI));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public Task <MessageListAPI> GetStreamMessages(String streamId, SocialServiceRequestAPI socialServiceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().GetStreamMessages(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.GetStreamMessages"), this.GetWho(), streamId, socialServiceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public Task <String> FollowStream(String streamId, String follow, SocialServiceRequestAPI socialServiceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().FollowStream(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.FollowStream"), this.GetWho(), streamId, Boolean.Parse(follow), socialServiceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public Task <List <MentionedWhoAPI> > SearchUsersByName(String streamId, String name, SocialServiceRequestAPI socialServiceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().SearchUsersByName(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.SearchUsersByName"), this.GetWho(), streamId, name, socialServiceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public void Notification(ServiceNotificationRequestAPI serviceNotificationRequestAPI)
 {
     try
     {
         SalesforceServiceSingleton.GetInstance().Notify(EmailNotifier.GetInstance(this.GetWho(), serviceNotificationRequestAPI.configurationValues, "PluginSalesforceController.Notification"), this.GetWho(), serviceNotificationRequestAPI);
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
Beispiel #22
0
        public void Work()
        {
            var firstCase = new DefaultBirdNotifier();

            firstCase.Notify();

            INotifier secondCase = new SMSNotifier(firstCase);

            secondCase = new EmailNotifier(secondCase);
            secondCase = new SlackNotifier(secondCase);
            secondCase = new VKNotifier(secondCase);
            secondCase.Notify();
        }
Beispiel #23
0
        public void TestPasswordChangeConfirmationNotification()
        {
            _smtpClientMock.Setup(s => s.Send(It.IsAny <MailMessage>())).Callback <MailMessage>(
                m =>
            {
                Assert.AreEqual("*****@*****.**", m.To[0].Address);
                Assert.AreEqual("Project C.U.R.E - Password change confirmation", m.Subject);
                Assert.IsTrue(m.Body.Contains("Dear Test User"));
            });
            var testEmailer = new EmailNotifier(_smtpClientMock.Object);

            testEmailer.PasswordChangeConfirmationNotification(_repositoryMock.Object, "*****@*****.**");
        }
Beispiel #24
0
 public void Strart()
 {
     try
     {
         isActive = true;
         Task t = WorkerAsync();
         t.Wait();
     }
     catch (Exception ex)
     {
         EmailNotifier.CreateMessage($"Ошибка при парсинге! Текст: {ex.InnerException.Message}. Trace:{ex.InnerException.StackTrace}", "Error");
         throw;
     }
 }
Beispiel #25
0
        public void SaveObjective(ObjectiveSub sub)
        {
            EmailNotifier notifier = new EmailNotifier();

            InsertObjectiveSub(sub);
            GetUnitOfWork().Save();

            string email  = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email;
            string sender = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName;

            if (String.IsNullOrEmpty(email))
            {
                notifier.Send("/#/othersObjectives?id=" + CreatedBy, "Dear sir,<br/> I have submited my job objective on " + DateTime.Now.Date + ".", email, sender);
            }
        }
        private static void Main()
        {
            // Example of code-only setup, alternatively this can be in the App.config
            // rollupSeconds is 0 so a new file is always generated, for demonstration purposes
            ErrorStore.Setup("Samples.Console", new JSONErrorStore(new ErrorStoreSettings
            {
                Path         = "Errors",
                RollupPeriod = null
            }));
            // How to do it with no roll-up
            //ErrorStore.Setup("Samples.Console", new JSONErrorStore(path: "Errors"));

            // Example of a code-only email setup, alternatively this can be in the App.config
            EmailNotifier.Setup(new EmailSettings
            {
                SMTPHost        = "localhost", // Use Papercut here for testing: https://github.com/ChangemakerStudios/Papercut
                FromAddress     = "*****@*****.**",
                FromDisplayName = "Bob the Builder",
                ToAddress       = "*****@*****.**"
            });

            // Optional: for logging all unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += ExceptionalHandler;

            // Normally we wouldn't want to .GetAwaiter().GetResult(), but async Main is only on a the latest platforms at the moment
            DisplayExceptionStats().GetAwaiter().GetResult();
            PauseForInput();

            try
            {
                throw new Exception("Just a try/catch test");
            }
            catch (Exception ex)
            {
                // logged, but caught so we don't crash
                ex.LogNoContext();
            }

            DisplayExceptionStats().GetAwaiter().GetResult();
            PauseForInput();

            WriteLine("This next one will crash the program, but will be logged on the way out...");
            PauseForInput();

            // one not explicitly caught, will be logged by ExceptionHandler
            throw new Exception("I am an exception thrown on exit");
        }
 /// <summary>
 /// Loads the notifier.
 /// </summary>
 public void LoadNotifier()
 {
     try
     {
         _taskbarNotifier = new EmailNotifier();
         //_taskbarNotifier.StayOpenMilliseconds = 5000;
         //_taskbarNotifier.OpeningMilliseconds = 500;
         //_taskbarNotifier.HidingMilliseconds = 1000;
         _taskbarNotifier.Show();
         _taskbarNotifier.DisplayState = Pointel.TaskbarNotifier.TaskbarNotifier.DisplayStates.Hiding;
         _taskbarNotifier.ForceHidden();
     }
     catch (Exception exception)
     {
         logger.Error("Error in LoadNotifier" + exception.Message);
     }
 }
Beispiel #28
0
            internal void Populate(Settings settings)
            {
                var s = settings.Email;

                if (ToAddress.HasValue())
                {
                    s.ToAddress = ToAddress;
                }
                if (FromAddress.HasValue())
                {
                    s.FromAddress = FromAddress;
                }
                if (FromDisplayName.HasValue())
                {
                    s.FromDisplayName = FromDisplayName;
                }
                if (SMTPHost.HasValue())
                {
                    s.SMTPHost = SMTPHost;
                }
                if (SMTPPort.HasValue)
                {
                    s.SMTPPort = SMTPPort;
                }
                if (SMTPUserName.HasValue())
                {
                    s.SMTPUserName = SMTPUserName;
                }
                if (SMTPPassword.HasValue())
                {
                    s.SMTPPassword = SMTPPassword;
                }
                if (SMTPEnableSSL.HasValue)
                {
                    s.SMTPEnableSSL = SMTPEnableSSL.Value;
                }
                if (PreventDuplicates.HasValue)
                {
                    s.PreventDuplicates = PreventDuplicates.Value;
                }

                if (s.ToAddress.HasValue())
                {
                    EmailNotifier.Setup(s);
                }
            }
Beispiel #29
0
        public void ApproveObjectiveByReportee(string id)
        {
            var desc = GetUnitOfWork().ObjectiveSubRepository.Get().FirstOrDefault(a => a.Id == id);

            if (desc != null)
            {
                EmailNotifier notifier = new EmailNotifier();
                desc.IsObjectiveApproved = true;
                GetUnitOfWork().Save();
                string email  = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email;
                string sender = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName;
                notifier.Send("", "Dear employee,\n I have reviewed your job objective on " + DateTime.Now.Date + ".", email, sender);
            }
            else
            {
                throw new Exception("This employee has not set his/her job description yet!");
            }
        }
Beispiel #30
0
        public void Save(JobDescription description)
        {
            UnitOfWork unitOfWork = new UnitOfWork();

            if (description.Id != Guid.Empty)
            {
                JobDescription descriptions = unitOfWork.JobDescriptionRepository.GetById(description.Id);
                if (descriptions == null)
                {
                    throw new Exception("We can't find your job description ");
                }
                descriptions.KeyAccountabilities = description.KeyAccountabilities;
                descriptions.JobPurposes         = description.JobPurposes;
                descriptions.UpdatedBy           = CreatedBy;
                descriptions.UpdatedDate         = DateTime.Now;
                unitOfWork.JobDescriptionRepository.Update(descriptions);
            }
            else
            {
                Validation validation = new Validation(new UnitOfWork());

                if (validation.HasSetJobDescription(CreatedBy))
                {
                    throw new Exception("You already set a job description.");
                }
                description.CreatedBy           = CreatedBy;
                description.EmployeeId          = CreatedBy;
                description.IsReportToConfirmed = false;
                description.IsHOBUConfirmed     = false;
                description.CreatedDate         = DateTime.Now;
                description.Id = Guid.NewGuid();
                unitOfWork.JobDescriptionRepository.Insert(description);
            }
            unitOfWork.Save();
            EmailNotifier notifier = new EmailNotifier();
            string        email    = unitOfWork.EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email;
            string        sender   = unitOfWork.EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName;

            if (String.IsNullOrEmpty(email))
            {
                notifier.Send("/#/MyEmployee?id=" + CreatedBy, "Dear sir,<br/> I have submited my job description on " + DateTime.Now.Date + ".", email, sender);
            }
        }
 public NewsFeedController(InfoHubDbContext dbContext)
 {
     _dbContext = dbContext;
     _emailNotifier = new EmailNotifier();
 }
Beispiel #32
0
        /// <summary>
        /// This sends a notification via Email
        /// </summary>
        private static void SendEmail()
        {
            var notifier = new EmailNotifier()
                {
                    Message = "This is a message via email. It got the job done...",
                    Subject = "Email Message",
                    NotificationAddress = "*****@*****.**"
                };

            notifier.SendNotification();
        }