예제 #1
0
        public void TestFixtureSetUp()
        {
            var settings = new TextFileSettings("~/azureconfig.txt".MapProjectPath());

            Host             = settings.GetString("Host");
            Port             = settings.Get("Port", 6379);
            Password         = settings.GetString("Password");
            connectionString = "{0}@{1}".Fmt(Password, Host);
        }
        private void SeedAppSettings()
        {
            var customSettings = new FileInfo(@"~/../appsettings.txt".MapHostAbsolutePath());
            var appSettings    = new TextFileSettings(customSettings.FullName);

            foreach (var key in appSettings.GetAllKeys())
            {
                appHost.AppSettings.Set(key, appSettings.Get(key));
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            var appSettingsFile = Path.Combine(AppContext.BaseDirectory, "app.settings");
            var appSettings     = new TextFileSettings(appSettingsFile);
            var checkInterval   = appSettings.Get <TimeSpan>("CheckInterval");
            var definitions     = appSettings.Get <List <ProcessDefinition> >("Definitions");

            HostFactory.Run(windowsService =>
            {
                windowsService.Service <HungProcessMonitor>(s =>
                {
                    s.ConstructUsing(service => new HungProcessMonitor(checkInterval, definitions));
                    s.WhenStarted(service => service.Start());
                    s.WhenStopped(service => service.Stop());
                });

                windowsService.RunAsLocalSystem();
                windowsService.StartAutomatically();

                windowsService.SetServiceName("HungProcessKiller");
                windowsService.SetDisplayName("HungProcessKiller");
                windowsService.SetDescription("A Windows background service which monitors hung processes and kills them after a fixed time period");
            });
        }
예제 #4
0
        public PasswordResetRequest ResetPassword(PasswordResetRequest request, IUserAuth user)
        {
            request.Id = Guid.NewGuid().ToString().Replace("-", "");
            var    settings = new TextFileSettings("appsettings.txt");
            string subject  = "Password Reset Requested";
            string html     = String.Format(String.Concat(
                                                "Hello {0},",
                                                "<br /><br />",
                                                "You recently requested to change your password at <a href=\"{1}\">{1}</a>",
                                                "<br/><br/>",
                                                "You may use the following link to set your passowrd: {2}",
                                                "<br/><br/>",
                                                "This link will be valid for 1 hour"),
                                            user.UserName,
                                            settings.Get <string>("BaseUrl"),
                                            String.Format("<a href=\"{0}/reset/{1}\">{0}/reset/{1}</a>", settings.Get <string>("BaseUrl"), request.Id)
                                            );

            var mimeMessage = new MimeMessage();

            mimeMessage.From.Add(new MailboxAddress(settings.GetString("EmailFromName"), settings.GetString("EmailFrom")));
            mimeMessage.To.Add(new MailboxAddress(user.Email, user.Email));
            mimeMessage.Subject = subject;
            var builder = new BodyBuilder();

            builder.HtmlBody = html;
            mimeMessage.Body = builder.ToMessageBody();
            using (var client = new SmtpClient())
            {
                client.Connect(settings.GetString("SMTPHost"), 587, false);
                // Note: only needed if the SMTP server requires authentication
                // Error 5.5.1 Authentication
                client.Authenticate(settings.GetString("SMTPUser"), settings.GetString("SMTPPass"));
                client.Send(mimeMessage);
                client.Disconnect(true);
            }
            return(request);
        }