Esempio n. 1
0
        public async Task InitTests()
        {
            _client = new Certify.Client.CertifyServiceClient(new ServiceConfigManager());

            // create API server instance
            if (_svc == null)
            {
                _svc = new Certify.Service.OwinService();
                _svc.Start();

                await Task.Delay(2000);

                await _client.GetAppVersion();
            }
        }
Esempio n. 2
0
        private async void StartService()
        {
            try
            {
                Logger.PrintText(new Run("Iniciando serviço da API Web..."), new Run(" --> "), new DateOptions(TextDecorationOptions.BOLD));
                bool status = OwinService.Start();
                await ServiceStatusUC.ChangeStatus(status);

                Logger.PrintText(new Run("Serviço da API Web inicializado..."), new Run(" --> "), new DateOptions(TextDecorationOptions.BOLD));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Erro ao iniciar serviço", MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.PrintText(new Run("Erro na inicialização serviço da API Web..."), new Run(" --> "), new DateOptions(TextDecorationOptions.BOLD));
            }
        }
Esempio n. 3
0
 private async void StopService(bool logerror = true)
 {
     try
     {
         Logger.PrintText(new Run("Finalizando serviço..."), new Run(" --> "), new DateOptions(TextDecorationOptions.BOLD));
         bool status = OwinService.Stop();
         await ServiceStatusUC.ChangeStatus(!status);
     }
     catch (Exception ex)
     {
         if (logerror)
         {
             MessageBox.Show(ex.ToString(), "Erro ao finalizar serviço", MessageBoxButton.OK, MessageBoxImage.Error);
             Logger.PrintText(new Run("Erro na finalização do serviço..."), new Run(" --> "), new DateOptions(TextDecorationOptions.BOLD));
         }
     }
 }
        public void StartService(int port)
        {
            try
            {
                Logger.Info("Starting W3C Test Service.");

                // build owin service
                _owinService = new OwinServiceBuilder()
                               .RegisterController(typeof(W3CController))
                               .Build();

                // Start OWIN host
                _owinService.StartService(port);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Esempio n. 5
0
        //private readonly PackageManager PlatformPackageManager = new PackageManager(
        //    new AggregateRepository(new[]
        //    {
        //        PackageRepositoryFactory.Default.CreateRepository("http://54.187.86.186:10008/nuget/"),
        //        PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2")
        //    }),
        //    Environment.CurrentDirectory + "\\libTmp");


        public void Register(IAppBuilder app, HttpConfiguration config)
        {
            //HangfireBootstrapper.Instance.Start();
            //RecurringJob.AddOrUpdate(() => Console.WriteLine("Background job works!"),
            //    Cron.Minutely());

            var epaListUrl = ConfigurationManager.AppSettings["epaListUrl"];

            if (string.IsNullOrEmpty(epaListUrl))
            {
                throw new ConfigurationErrorsException("epaListUrl application setting should be specified as a valid url to EPA list.");
            }
            var epaConfigUrl = ConfigurationManager.AppSettings["epaConfigUrl"];

            if (string.IsNullOrEmpty(epaConfigUrl))
            {
                throw new ConfigurationErrorsException("epaConfigUrl application setting should be specified as a valid url to EPA config.");
            }
            var physicalSvcConfigUrl = ConfigurationManager.AppSettings["physicalSvcConfigUrl"];

            if (string.IsNullOrEmpty(physicalSvcConfigUrl))
            {
                throw new ConfigurationErrorsException("physicalSvcConfigUrl application setting should be specified as a valid url to Physical Svc config.");
            }

            var libsUrl = ConfigurationManager.AppSettings["epaLibsUrl"];

            if (string.IsNullOrEmpty(libsUrl))
            {
                throw new ConfigurationErrorsException("epaLibsUrl application setting should be specified as a valid url to Svc Libs List.");
            }

            using (WebClient wc = new WebClient())
            {
                var physicalSvcIdentity = ConfigurationManager.AppSettings["identity"];

                var json = wc.DownloadString(string.Format(physicalSvcConfigUrl, physicalSvcIdentity));

                var physicalCfgArray = JArray.Parse(json);
                var physicalCfg      = physicalCfgArray.ToDictionary(x => (string)x["Key"], x => (string)x["Value"]);

                //INIT MD MONGO
                var mongoPool =
                    IocContainerProvider.CurrentContainer.GetInstance <MongoDataProviderPool>();
                var mongoCs = $"{physicalCfg["mongocs"]}masterdata";
                mongoPool.AddProvider("masterdata", new MongoDataProvider(mongoCs));

                //INIT dictionaries CASSANDRA
                var casPool =
                    IocContainerProvider.CurrentContainer
                    .GetInstance <CassandraDataProviderPool>();
                casPool.AddProvider("dictionaries",
                                    new CassandraDataProvider(physicalCfg["DictionaryCassandraCs"], "dictionaries",
                                                              new Cassandra.Mapping.Mappings[] { new DictionaryMappings() }));

                //INIT Trans Cache CASSANDRA
                casPool.AddProvider("transactionCache",
                                    new CassandraDataProvider(physicalCfg["cassandraCs"], "TransactionCache",
                                                              new Cassandra.Mapping.Mappings[] { new MasterMappings() }));

                json = wc.DownloadString(string.Format(epaListUrl, physicalSvcIdentity));
                var epas = JArray.Parse(json);

                var epasList = epas.Select(x => (string)x["ServiceIdentity"]).ToList();
                this.logger.Debug($"Starting identities: {string.Join(", ", epasList)}");

                foreach (var epaIdentity in epasList)
                {
                    this.logger.Debug($"Starting EPA: {epaIdentity}");

                    var epaJson   = wc.DownloadString(string.Format(epaConfigUrl, epaIdentity));
                    var epaConfig = JArray.Parse(epaJson);

                    ConfigureEpa(epaConfig.ToDictionary(x => (string)x["Key"], x => (string)x["Value"]));

                    json = wc.DownloadString(string.Format(libsUrl, epaIdentity));
                    var libsList = JArray.Parse(json).ToDictionary(x => (string)x["LibraryName"], x => (string)x["Version"]);

#if !DEBUG
                    this.logger.Debug("Requesting libs");
                    var nugetRestoreOutput = CommandLineHelper.RunCommandLine("powershell",
                                                                              $".\\request_libs.ps1  -Identity \"{epaIdentity}\" -ServiceRootPath {Environment.CurrentDirectory}");
                    this.logger.Debug(nugetRestoreOutput);
#else
                    this.logger.Debug("Skip requesting libs");
#endif

                    var loadedAsses = OwinService.LoadExtensions();
                    OwinStartup.CallIOwinConfig(app, config, loadedAsses);

                    this.logger.Debug($"EPA {epaIdentity} started");
                }
            }
        }
 public ApplicationFixture()
 {
     _owinService = new OwinService();
     _owinService.Start();
 }