Exemple #1
0
        public SatelliteServiceContainer()
        {
            InitializeComponent();

            ObjectFactoryConfigurator.Configure();

            bool   isAuthorizationEnabled = bool.Parse(ConfigurationManager.AppSettings["Authorization.Enabled"]);
            bool   isMetadataEnabled      = bool.Parse(ConfigurationManager.AppSettings["Metadata.Enabled"]);
            string certificateName        = ConfigurationManager.AppSettings["Authorization.CertificateFriendlyName"];

            Uri serviceGenericUri = new Uri(ConfigurationManager.AppSettings["Service.URI"]);

            Uri deploymentServiceUri         = new Uri(ConfigurationManager.AppSettings["DeploymentService.Endpoint.URI"] ?? (serviceGenericUri + "/DeploymentService"));
            Uri deploymentServicMetadataeUri = new Uri(ConfigurationManager.AppSettings["DeploymentService.Metadata.Uri"] ?? "http://localhost:8091/AspNetDeploySatellite/DeploymentServiceMetadata");

            Uri monitoringServiceUri         = new Uri(ConfigurationManager.AppSettings["MonitoringService.Endpoint.URI"] ?? (serviceGenericUri + "/MonitoringService"));
            Uri monitoringServiceMetadataUri = new Uri(ConfigurationManager.AppSettings["MonitoringService.Metadata.Uri"] ?? "http://localhost:8091/AspNetDeploySatellite/MonitoringServiceMetadata");

            Uri informationServiceUri         = new Uri(ConfigurationManager.AppSettings["InformationService.Endpoint.URI"] ?? (serviceGenericUri + "/InformationService"));
            Uri informationServiceMetadataUri = new Uri(ConfigurationManager.AppSettings["InformationService.Metadata.Uri"] ?? "http://localhost:8091/AspNetDeploySatellite/InformationServiceMetadata");

            this.hostContainers = new List <ServiceHostContainer>()
            {
                new ServiceHostContainer(
                    typeof(DeploymentService),
                    typeof(IDeploymentService),
                    deploymentServiceUri,
                    deploymentServicMetadataeUri,
                    isAuthorizationEnabled,
                    isMetadataEnabled,
                    certificateName),

                new ServiceHostContainer(
                    typeof(MonitoringService),
                    typeof(IMonitoringService),
                    monitoringServiceUri,
                    monitoringServiceMetadataUri,
                    isAuthorizationEnabled,
                    isMetadataEnabled,
                    certificateName),

                new ServiceHostContainer(
                    typeof(InformationService),
                    typeof(IInformationService),
                    informationServiceUri,
                    informationServiceMetadataUri,
                    isAuthorizationEnabled,
                    isMetadataEnabled,
                    certificateName),
            };
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            ObjectFactoryConfigurator.Configure();

            ControllerBuilder.Current.SetControllerFactory(typeof(ControllerFactory));

            if (bool.Parse(ConfigurationManager.AppSettings["Settings.EnableTaskRunner"] ?? "false"))
            {
                Factory.GetInstance <ITaskRunner>().Initialize();
            }

            if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Settings.WorkingFolder"]))
            {
                Factory.GetInstance <IEnvironmentResourcesService>().InitializeWorkingFolder(ConfigurationManager.AppSettings["Settings.WorkingFolder"]);
            }
        }
        static void Main(string[] args)
        {
            ObjectFactoryConfigurator.Configure();

            IPathRepository   pathRepository   = Factory.GetInstance <IPathRepository>();
            IBackupRepository backupRepository = Factory.GetInstance <IBackupRepository>();

            /*  IBackupRepository backupRepository = Factory.GetInstance<IBackupRepository>();
             *
             * backupRepository.RestoreDirectory(Guid.Parse("4487e739-5d2c-44b2-bf2a-a01692b60de0"));
             *
             * Guid storeDirectory = backupRepository.StoreFile(@"H:\AspNetDeploySatelliteWorkingFolder\TestFolder\Project15\Web.config");
             *
             * Console.WriteLine("STORED = " + storeDirectory);
             * Console.ReadKey();
             *
             * backupRepository.RestoreFile(storeDirectory);
             *
             * Console.WriteLine("RESTORED");
             * Console.ReadKey();
             */

            /*ConfigOperation configOperation = new ConfigOperation(backupRepository);
             *
             * configOperation.Configure(JsonConvert.DeserializeObject(@"
             * {
             *  file : 'H:\\AspNetDeploySatelliteWorkingFolder\\TestFolder\\Project15\\Web.config',
             *  content : '
             *      <configuration>
             *          <system.web>
             *              <compilation debug=""false"" />
             *          </system.web>
             *          <appSettings childNodesKeyName=""key"">
             *              <add key=""Site.Version"" value=""1.2"" />
             *              <add key=""BackgroundCMS.TargetAuthorizeUrl"" value=""{var:BackgroundCMS.TargetAuthorizeUrl}"" />
             *          </appSettings>
             *      </configuration>
             *  '
             * }"), new Dictionary<string, object>
             * {
             *  {"BackgroundCMS.TargetAuthorizeUrl", "http://omg.ru"}
             * });*/

            UpdateHostsOperation operation = new UpdateHostsOperation(backupRepository);

            operation.Configure(JsonConvert.DeserializeObject(@"
            {
                add : [
                    {ip: '127.0.0.1', domain: 'testing-1.local'},
                    {ip: '127.0.0.2', domain: 'testing-2.local'}
                ]
            }"));

            operation.Run();
            Console.WriteLine("UPDATED");
            Console.ReadKey();

            operation.Rollback();
            Console.WriteLine("REVERTED");
            Console.ReadKey();

            /*WebSiteOperation webSiteOperation = new WebSiteOperation(backupRepository, new PackageRepository(pathRepository.GetPackagePath(6)));
             *
             *
             * webSiteOperation.Configure(JsonConvert.DeserializeObject(@"
             * {
             *  destination : 'H:\\AspNetDeploySatelliteWorkingFolder\\TestFolder\\Project15',
             *  siteName : 'Project 15',
             *  applicationPoolName : 'Project 15',
             *  projectId : 15,
             *  bindings : [
             *
             *      {
             *          port : 80,
             *          protocol : 'http',
             *          url : 'project15.local'
             *      }
             *  ]
             * }"));
             *
             * webSiteOperation.Run();
             * webSiteOperation.Rollback();*/



            /*if (Directory.Exists(@"H:\AspNetDeploySatelliteWorkingFolder\TestFolder"))
             * {
             *  Directory.Delete(@"H:\AspNetDeploySatelliteWorkingFolder\TestFolder", true);
             *  Directory.CreateDirectory(@"H:\AspNetDeploySatelliteWorkingFolder\TestFolder");
             * }
             */
            /*IPathRepository pathRepository = Factory.GetInstance<IPathRepository>();*/

            /*PackageRepository packageRepository = new PackageRepository(pathRepository.GetPackagePath(6));
             * packageRepository.ExtractProject(15, @"H:\AspNetDeploySatelliteWorkingFolder\TestFolder\Project15");
             * packageRepository.ExtractProject(19, @"H:\AspNetDeploySatelliteWorkingFolder\TestFolder\Project19");
             */

            Console.WriteLine("Complete");
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            ObjectFactoryConfigurator.Configure();

            bool   isAuthorizationEnabled = bool.Parse(ConfigurationManager.AppSettings["Authorization.Enabled"]);
            bool   isMetadataEnabled      = bool.Parse(ConfigurationManager.AppSettings["Metadata.Enabled"]);
            string certificateName        = ConfigurationManager.AppSettings["Authorization.CertificateFriendlyName"];

            Uri serviceGenericUri = new Uri(ConfigurationManager.AppSettings["Service.URI"]);

            Uri deploymentServiceUri         = new Uri(ConfigurationManager.AppSettings["DeploymentService.Endpoint.URI"] ?? (serviceGenericUri + "/DeploymentService"));
            Uri deploymentServicMetadataeUri = new Uri(ConfigurationManager.AppSettings["DeploymentService.Metadata.Uri"] ?? "http://localhost:8091/AspNetDeploySatellite/DeploymentServiceMetadata");

            Uri monitoringServiceUri         = new Uri(ConfigurationManager.AppSettings["MonitoringService.Endpoint.URI"] ?? (serviceGenericUri + "/MonitoringService"));
            Uri monitoringServiceMetadataUri = new Uri(ConfigurationManager.AppSettings["MonitoringService.Metadata.Uri"] ?? "http://localhost:8091/AspNetDeploySatellite/MonitoringServiceMetadata");

            Uri informationServiceUri         = new Uri(ConfigurationManager.AppSettings["InformationService.Endpoint.URI"] ?? (serviceGenericUri + "/InformationService"));
            Uri informationServiceMetadataUri = new Uri(ConfigurationManager.AppSettings["InformationService.Metadata.Uri"] ?? "http://localhost:8091/AspNetDeploySatellite/InformationServiceMetadata");

            IList <ServiceHostContainer> hostContainers = new List <ServiceHostContainer>()
            {
                new ServiceHostContainer(
                    typeof(DeploymentService),
                    typeof(IDeploymentService),
                    deploymentServiceUri,
                    deploymentServicMetadataeUri,
                    isAuthorizationEnabled,
                    isMetadataEnabled,
                    certificateName),

                new ServiceHostContainer(
                    typeof(MonitoringService),
                    typeof(IMonitoringService),
                    monitoringServiceUri,
                    monitoringServiceMetadataUri,
                    isAuthorizationEnabled,
                    isMetadataEnabled,
                    certificateName),

                new ServiceHostContainer(
                    typeof(InformationService),
                    typeof(IInformationService),
                    informationServiceUri,
                    informationServiceMetadataUri,
                    isAuthorizationEnabled,
                    isMetadataEnabled,
                    certificateName),
            };

            foreach (ServiceHostContainer serviceHostContainer in hostContainers)
            {
                serviceHostContainer.StartService();
                serviceHostContainer.StartMonitoring();
            }

            Console.WriteLine("STARTED, press any key to terminate");
            Console.ReadKey();


            foreach (ServiceHostContainer serviceHostContainer in hostContainers)
            {
                serviceHostContainer.Stop();
            }

            /*
             *
             * netsh http add sslcert ipport=0.0.0.0:8090 certhash=111fdaf48275953db528be89fac8f0324c735297 appid={2f244ac1-9d8d-45d8-b46b-8ba79a326ebc}
             *
             * sc create "AspNetDeploy Satellite" binpath= "D:\Services\AspNetDeploySatellite\Service\SatelliteServiceHost.exe"
             *
             */
        }