public void ProtectProtectsConnectionStrings()
 {
     var helper = new ConnectionStringHelper();
     helper.Protect();
     var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     Assert.IsTrue(config.ConnectionStrings.SectionInformation.IsProtected);
 }
Exemple #2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            var arguments = string.Join(" ", args);
            if (string.IsNullOrEmpty(arguments))
            {
                var servicesToRun = new ServiceBase[]
                    {
                        new Service()
                    };
                ServiceBase.Run(servicesToRun);
            }
            else if (arguments.StartsWith("--i "))
            {
                try
                {
                    var connectionString = arguments.Substring("--i ".Length);
                    var connectionStringHelper = new ConnectionStringHelper();
                    connectionStringHelper.Set(PHmiConstants.PHmiConnectionStringName, connectionString);
                    connectionStringHelper.Protect();

                    ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                }

                Console.WriteLine(Res.PressAnyKeyToContinue);
                Console.ReadKey();
            }
            else if (arguments.StartsWith("--u"))
            {
                try
                {
                    ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                }

                Console.WriteLine(Res.PressAnyKeyToContinue);
                Console.ReadKey();
            }
        }
Exemple #3
0
        protected override void OnStart(string[] args)
        {
            try
            {
                var connectionStringHelper = new ConnectionStringHelper();
                var connectionString = connectionStringHelper.Get(PHmiConstants.PHmiConnectionStringName);
                connectionStringHelper.Protect();
                var connectionParameters = new NpgConnectionParameters();
                connectionParameters.Update(connectionString);

                _runner = _runnerFactory.Create(connectionParameters.Database, connectionString);
                _runner.Start();
            }
            catch (Exception exception)
            {
                _reporter.Report(Res.StartError, exception);
            }
        }