public int Run() { CompatTuple <int, string, ApplicationServer> res = Server.DebugMain(new [] { "--applications", "/:.", "--port", "9000", "--nonstop" }); server = res.Item3; return(res.Item1); }
public void GetByServerAppAndGroupTest() { string serverName = "server4"; ApplicationServer server = ApplicationServerLogic.GetByName(serverName); string appName = "app8"; Application app = ApplicationLogic.GetByName(appName); ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = app; InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(server, appWithGroup); InstallationSummary mostRecentSummaryInMemory = TestUtility.AllInstallationSummaries .Where(summary => summary.ApplicationServer.Id == server.Id && summary.ApplicationWithOverrideVariableGroup.ApplicationId == appWithGroup.Application.Id && summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupId == null) .OrderByDescending(x => x.InstallationStart) .First(); Assert.AreEqual(mostRecentSummaryInMemory.InstallationStart, mostRecentInstallationSummary.InstallationStart); Assert.AreEqual(serverName, mostRecentInstallationSummary.ApplicationServer.Name); Assert.AreEqual(appName, mostRecentInstallationSummary.ApplicationWithOverrideVariableGroup.Application.Name); }
public XSPWorker(Socket client, EndPoint localEP, ApplicationServer server, bool secureConnection, SecurityProtocolType securityProtocol, X509Certificate cert, PrivateKeySelectionCallback keyCB, bool allowClientCert, bool requireClientCert) { if (secureConnection) { ssl = new SslInformation { AllowClientCertificate = allowClientCert, RequireClientCertificate = requireClientCert, RawServerCertificate = cert.GetRawCertData() }; netStream = new LingeringNetworkStream(client, true); var s = new SslServerStream(netStream, cert, requireClientCert, false); s.PrivateKeyCertSelectionDelegate += keyCB; s.ClientCertValidationDelegate += ClientCertificateValidation; stream = s; } else { netStream = new LingeringNetworkStream(client, false); stream = netStream; } sock = client; this.server = server; remoteEP = (IPEndPoint)client.RemoteEndPoint; this.localEP = (IPEndPoint)localEP; }
public static void Main() { if (File.Exists("Readme.md")) { Console.WriteLine(File.ReadAllText("Readme.md")); } // persistence var store = CreateFileStoreForTesting(); var events = new EventStore(store); // various domain services var pricing = new PricingService(); var server = new ApplicationServer(); server.Handlers.Add(new LoggingWrapper(new CustomerApplicationService(events, pricing))); // send some sample commands server.Dispatch(new CreateCustomer { Id = new CustomerId(12), Name = "Lokad", Currency = Currency.Eur }); server.Dispatch(new RenameCustomer { Id = new CustomerId(12), NewName = "Lokad SAS" }); server.Dispatch(new ChargeCustomer { Id = new CustomerId(12), Amount = 20m.Eur(), Name = "Forecasting" }); Console.WriteLine("Press any key to exit"); Console.ReadKey(true); }
private static void HydrateApplicationServer(ApplicationServer appServer) { lock (_locker) // prevent any thread silliness { // Not using this, at least for now, because it increased the NumberOfRequests on the session... //appServer.CustomVariableGroups = new ObservableCollection<CustomVariableGroup>( // QueryAndCacheEtags(session => session.Load<CustomVariableGroup>(appServer.CustomVariableGroupIds)).Cast<CustomVariableGroup>()); // ... however, this kept the NumberOfRequests to just one. Not sure why the difference. appServer.CustomVariableGroups = new ObservableCollection <CustomVariableGroup>(); foreach (string groupId in appServer.CustomVariableGroupIds) { appServer.CustomVariableGroups.Add(QuerySingleResultAndSetEtag(session => session.Load <CustomVariableGroup>(groupId)) as CustomVariableGroup); } foreach (ApplicationWithOverrideVariableGroup appGroup in appServer.ApplicationsWithOverrideGroup) { appGroup.Application = QuerySingleResultAndSetEtag(session => session.Load <Application>(appGroup.ApplicationId)) as Application; ApplicationData.HydrateApplication(appGroup.Application); LoadAppGroupCustomVariableGroups(appGroup); } appServer.InstallationEnvironment = QuerySingleResultAndSetEtag(session => session.Load <InstallationEnvironment>(appServer.InstallationEnvironmentId)) as InstallationEnvironment; } }
private static bool IndividualChecksPass(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { if (AppGroupEnabled(appServer, appWithGroup) == false) { return(false); } // This is forcing an APPLICATION SERVER / APP GROUP instance if (ForceInstallIsThisAppWithGroup(appServer, appWithGroup)) { return(true); } // This is forcing an APPLICATION // If there is no force installation time, then no need to install. if (!ForceInstallationExists(appServer, appWithGroup)) { return(false); } if (ForceInstallationShouldHappenBasedOnTimeAndEnvironment(appServer, appWithGroup)) { return(true); } return(false); }
public void ApplicationServerManager_FindByName_Test() { string _serverShortName = "nsg memb"; ApplicationServer _actual = _sut.FindByName(_serverShortName); Assert.AreEqual(_serverShortName, _actual.ServerShortName.ToLower()); }
public void Effort_ServerStore_DeleteAsync_Fail_Test() { // Task DeleteAsync(ApplicationServer server) ApplicationServer _server = _sut.FindByName(existServerName); int _expectedCount = _dbContext.Servers.Count() - 1; Task.Run(async() => { try { // Foreign key violation [dbo_IncidentIncidentNotes :: Incident_IncidentId]. The key value [1] does not exists in the referenced table [dbo_Incident :: IncidentId].. Error code: RelationError await _sut.DeleteAsync(_server); Assert.Fail(); } catch (DbEntityValidationException _entityEx) { // extension method string _errors = _entityEx.EntityValidationErrors.GetDbValidationErrors(); Console.WriteLine(_errors); Assert.Fail(); } catch (Exception _ex) { _ex = _ex.GetBaseException(); Console.WriteLine(_ex.Message); } }).GetAwaiter().GetResult(); }
private static bool ForceInstallationShouldHappenBasedOnTimeAndEnvironment( ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { // Note: To even get to this method, a force installation exists. DateTime now = DateTime.Now; // Get the list of InstallationStatus entities for this server. InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(appServer, appWithGroup); bool shouldForce; if (mostRecentInstallationSummary == null) { shouldForce = now > appWithGroup.Application.ForceInstallation.ForceInstallationTime && appWithGroup.Application.ForceInstallation.ForceInstallEnvironment.Id == appServer.InstallationEnvironment.Id; LogForceInstallExistsWithNoInstallationSummaries(appServer, appWithGroup, now, shouldForce); return(shouldForce); } // Check the latest installation. If it's before ForceInstallationTime, then we need to install shouldForce = (mostRecentInstallationSummary.InstallationStart <appWithGroup.Application.ForceInstallation.ForceInstallationTime && now> appWithGroup.Application.ForceInstallation.ForceInstallationTime && appWithGroup.Application.ForceInstallation.ForceInstallEnvironment.Id == appServer.InstallationEnvironment.Id); LogForceInstallBasedOnInstallationSummary(appServer, appWithGroup, now, mostRecentInstallationSummary, shouldForce); return(shouldForce); }
public void NetworkLogTestInitialize() { // _dbContext = WebSrv_Tests.Effort_Helper.GetEffortEntity(_entityConnStr, _fullPath); _sut = new ServerStore(_dbContext); int _companyId = 1; Company _company1 = _dbContext.Companies.FirstOrDefault(c => c.CompanyId == _companyId); testServer = new ApplicationServer() { CompanyId = _companyId, Company = _company1, ServerShortName = testServerName, ServerName = testServerName, ServerDescription = "Public facing members Web-site", WebSite = "Web-site address: www.any.com", ServerLocation = "We are in Michigan, USA.", FromName = "Phil Huhn", FromNicName = "Phil", FromEmailAddress = "*****@*****.**", TimeZone = "EST (UTC-5)", DST = true, TimeZone_DST = "EDT (UTC-4)", DST_Start = new DateTime(2018, 3, 11, 2, 0, 0), DST_End = new DateTime(2018, 11, 4, 2, 0, 0) }; // }
// /// <summary> /// Return one user translated to DTO, /// including the server DTO if found. /// </summary> /// <param name="userName"></param> /// <param name="serverShortName"></param> /// <returns></returns> public UserServerData GetUserServerByUserName(string userName, string serverShortName) { UserServerData _user = null; if (serverShortName == null) { serverShortName = ""; } var _usersEntity = _niEntities.Users. FirstOrDefault(_r => _r.UserName == userName); if (_usersEntity != null) { _user = _usersEntity.ToUserServerData(); if (serverShortName != "") { serverShortName = serverShortName.ToLower(); ApplicationServer _srv = _usersEntity.Servers.FirstOrDefault(_s => _s.ServerShortName.ToLower() == serverShortName); if (_srv != null) { _user.Server = _srv.ToServerData( ); _user.ServerShortName = serverShortName; } } } return(_user); }
public static void InstallApplications(ApplicationServer appServer) { if (appServer == null) { throw new ArgumentNullException("appServer"); } HydrateForceInstallationsToDo(appServer); // If we find an app that needs to be installed, install it. foreach (ApplicationWithOverrideVariableGroup appWithGroup in appServer.ApplicationsWithOverrideGroup) { bool shouldInstall = ApplicationShouldBeInstalled(appServer, appWithGroup); RemoveForceInstallation(appServer, appWithGroup); if (!shouldInstall) { continue; } Logger.LogInformation(string.Format(CultureInfo.CurrentCulture, PrestoServerResources.AppWillBeInstalledOnAppServer, appWithGroup, appServer.Name)); PrestoServerUtility.Container.Resolve <IAppInstaller>().InstallApplication(appServer, appWithGroup); } }
private static ApplicationServer CreateAppServer(string rootName, Application app, CustomVariableGroup group) { ApplicationServer server = new ApplicationServer(); server.Name = rootName + " server"; server.InstallationEnvironment = _defaultEnv; server.Description = rootName + " server description"; server.EnableDebugLogging = false; server.ApplicationsWithOverrideGroup.Add(new ApplicationWithOverrideVariableGroup() { Enabled = true, Application = app }); // Add the generic apps to the server, so we have more than just the one above. _genericApps.ForEach(x => server.ApplicationsWithOverrideGroup.Add( new ApplicationWithOverrideVariableGroup() { Enabled = true, Application = x })); server.CustomVariableGroups.Add(group); ApplicationServerLogic.Save(server); return(server); }
private static void AddAppServers() { IEnumerable <InstallationEnvironment> environments = InstallationEnvironmentLogic.GetAll(); for (int i = 1; i <= TotalNumberOfEachEntityToCreate; i++) { ApplicationServer server = new ApplicationServer(); server.Name = "server" + i; server.InstallationEnvironment = environments.Where(x => x.LogicalOrder == 1).First(); // 1st env is dev server.Description = "Description " + i; server.EnableDebugLogging = false; Application app = ApplicationLogic.GetByName("app" + i); server.ApplicationsWithOverrideGroup.Add(new ApplicationWithOverrideVariableGroup() { Enabled = true, Application = app }); CustomVariableGroup group = CustomVariableGroupLogic.GetByName("group" + i); server.CustomVariableGroups.Add(group); ApplicationServerLogic.Save(server); } }
private static void AddManyInstallationSummariesForOneServerAndApp() { string serverName = "server4"; ApplicationServer server = ApplicationServerLogic.GetByName(serverName); string appName = "app8"; Application app = ApplicationLogic.GetByName(appName); ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = app; // Save many installation summaries, for one server, to test Raven's 128 or 1024 limit. DateTime originalStartTime = DateTime.Now.AddDays(-1); for (int i = 1; i <= NumberOfExtraInstallationSummariesForServer4AndApp8; i++) { DateTime startTime = originalStartTime.AddMinutes(i); InstallationSummary summary = new InstallationSummary(appWithGroup, server, startTime); summary.InstallationEnd = startTime.AddSeconds(4); summary.InstallationResult = InstallationResult.Success; AllInstallationSummaries.Add(summary); InstallationSummaryLogic.Save(summary); } }
// /// <summary> /// Delete one row from Servers /// </summary> /// <param name="serverId"></param> /// <returns></returns> public int ServerDelete(int serverId) { string _invalidServerInUse = "{0}, Server shortName: {1} in use by incident {2}."; int _return = 0; var _servers = from _r in _niEntities.Servers where _r.ServerId == serverId select _r; if (_servers.Count() > 0) { ApplicationServer _server = _servers.First(); var netlogs = _niEntities.NetworkLogs.Where(_nl => _nl.ServerId == serverId); foreach (NetworkLog _l in netlogs) { if (_l.IncidentId > 0) { throw new ArgumentNullException( string.Format(_invalidServerInUse, "CompanyServerAccess.ServerDelete", _server.ServerShortName, _l.IncidentId)); } _niEntities.NetworkLogs.Remove(_l); } _niEntities.Servers.Remove(_server); _niEntities.SaveChanges(); _return = 1; // one row updated } return(_return); }
private static void TestInstallationSummaryData() { var server = new ApplicationServer(); server.Id = "ApplicationServers/10"; var appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = new Application(); appWithGroup.Application.Id = "applications/5"; appWithGroup.CustomVariableGroups = new PrestoObservableCollection <CustomVariableGroup>(); appWithGroup.CustomVariableGroups.Add(new CustomVariableGroup()); appWithGroup.CustomVariableGroupIds = new List <string>(); appWithGroup.CustomVariableGroupIds.Add("CustomVariableGroups/296"); appWithGroup.CustomVariableGroupIds.Add("CustomVariableGroups/302"); appWithGroup.CustomVariableGroupIds.Add("CustomVariableGroups/268"); var data = new InstallationSummaryData(); data.SetAsInitialDalInstanceAndCreateSession(); var installationSummary = data.GetMostRecentByServerAppAndGroup(server, appWithGroup); Debug.WriteLine(installationSummary == null); }
// /// <summary> /// Update one row of Servers /// </summary> /// <param name="serverId"></param> /// <param name="companyId"></param> /// <param name="serverShortName"></param> /// <param name="serverName"></param> /// <param name="serverDescription"></param> /// <param name="serverLocation"></param> /// <param name="fromName"></param> /// <param name="fromNicName"></param> /// <param name="fromEmailAddress"></param> /// <param name="timeZone"></param> /// <param name="dST"></param> /// <param name="timeZone_DST"></param> /// <param name="dST_Start"></param> /// <param name="dST_End"></param> /// <returns>Updated row count</returns> public int Update(int serverId, int companyId, string serverShortName, string serverName, string serverDescription, string serverLocation, string fromName, string fromNicName, string fromEmailAddress, string timeZone, bool dST, string timeZone_DST, DateTime dST_Start, DateTime dST_End) { int _return = 0; var _servers = from _r in _niEntities.Servers where _r.ServerId == serverId select _r; if (_servers.Count() > 0) { ApplicationServer _server = _servers.First(); _server.CompanyId = companyId; _server.ServerShortName = serverShortName; _server.ServerName = serverName; _server.ServerDescription = serverDescription; _server.ServerLocation = serverLocation; _server.FromName = fromName; _server.FromNicName = fromNicName; _server.FromEmailAddress = fromEmailAddress; _server.TimeZone = timeZone; _server.DST = dST; _server.TimeZone_DST = timeZone_DST; _server.DST_Start = dST_Start; _server.DST_End = dST_End; _niEntities.SaveChanges(); _return = 1; // one row updated } return(_return); }
public ApplicationServer GetByName(string serverName) { // Note: RavenDB queries are case-insensitive, so no ToUpper() conversion is necessary here. return(ExecuteQuery <ApplicationServer>(() => { ApplicationServer appServer = QuerySingleResultAndSetEtag(session => session.Query <ApplicationServer>() .Include(x => x.CustomVariableGroupIds) .Include(x => x.ApplicationIdsForAllAppWithGroups) .Include(x => x.CustomVariableGroupIdsForAllAppWithGroups) .Include(x => x.CustomVariableGroupIdsForGroupsWithinApps) .Include(x => x.InstallationEnvironmentId) .Customize(x => x.WaitForNonStaleResults()) .FirstOrDefault(server => server.Name == serverName)) as ApplicationServer; if (appServer != null) { HydrateApplicationServer(appServer); } return appServer; })); }
public void ApplicationShouldBeInstalledTest_UseCase5() { // Use Case #5 -- app exists in the server's ApplicationWithGroupToForceInstallList, // but the custom variable is different string rootName = "UseCase05"; TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, 0); ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName)); ApplicationWithOverrideVariableGroup appWithDifferentGroup = new ApplicationWithOverrideVariableGroup(); appWithDifferentGroup.Application = appServer.ApplicationsWithOverrideGroup[0].Application; // Set the group to something that doesn't already exist within the server... appWithDifferentGroup.CustomVariableGroups[0] = TestHelper.CreateCustomVariableGroup(rootName + " " + Guid.NewGuid().ToString()); ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithDifferentGroup)); SetGlobalFreeze(false); ApplicationServerLogic.InstallApplications(appServer); _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(), It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never()); }
private static bool FinalInstallationChecksPass(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { GlobalSetting globalSetting = GlobalSettingLogic.GetItem(); string warning = string.Empty; if (globalSetting == null) { warning = string.Format(CultureInfo.CurrentCulture, PrestoServerResources.GlobalSettingNullSoNoInstallation, appWithGroup.ToString(), appServer.Name); Logger.LogWarning(warning); LogMessageLogic.SaveLogMessage(warning); return(false); } if (globalSetting.FreezeAllInstallations) { warning = string.Format(CultureInfo.CurrentCulture, PrestoServerResources.FreezeAllInstallationsTrueSoNoInstallation, appWithGroup.ToString(), appServer.Name); Logger.LogWarning(warning); LogMessageLogic.SaveLogMessage(warning); return(false); } return(true); }
public void ApplicationShouldBeInstalledTest_UseCase6() { // Use Case #6 -- app does not exist in the server's ApplicationWithGroupToForceInstallList, // but the custom variable does. string rootName = "UseCase06"; TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, 0); ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName)); appServer.ApplicationsWithOverrideGroup[0].CustomVariableGroups[0] = TestHelper.CreateCustomVariableGroup(rootName); ApplicationServerLogic.Save(appServer); // To save with a valid group. // Create a new app group with a new app, but an existing group var appWithValidGroup = new ApplicationWithOverrideVariableGroup(); appWithValidGroup.Application = TestHelper.CreateApp(rootName + " " + Guid.NewGuid().ToString()); appWithValidGroup.CustomVariableGroups[0] = appServer.ApplicationsWithOverrideGroup[0].CustomVariableGroups[0]; // Set the app to something that doesn't already exist within the server... // Leave the group alone because it already exists. ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithValidGroup)); SetGlobalFreeze(false); ApplicationServerLogic.InstallApplications(appServer); _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(), It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never()); }
// /// <summary> /// Insert one row into Servers /// </summary> /// <param name="serverId"></param> /// <param name="companyId"></param> /// <param name="serverShortName"></param> /// <param name="serverName"></param> /// <param name="serverDescription"></param> /// <param name="serverLocation"></param> /// <param name="fromName"></param> /// <param name="fromNicName"></param> /// <param name="fromEmailAddress"></param> /// <param name="timeZone"></param> /// <param name="dST"></param> /// <param name="timeZone_DST"></param> /// <param name="dST_Start"></param> /// <param name="dST_End"></param> /// <returns>Inserted row count and ref to new server id</returns> public int Insert(ref int serverId, int companyId, string serverShortName, string serverName, string serverDescription, string serverLocation, string fromName, string fromNicName, string fromEmailAddress, string timeZone, bool dST, string timeZone_DST, DateTime dST_Start, DateTime dST_End) { int _return = 0; ApplicationServer _server = new ApplicationServer(); _server.CompanyId = companyId; _server.ServerShortName = serverShortName; _server.ServerName = serverName; _server.ServerDescription = serverDescription; _server.ServerLocation = serverLocation; _server.FromName = fromName; _server.FromNicName = fromNicName; _server.FromEmailAddress = fromEmailAddress; _server.TimeZone = timeZone; _server.DST = dST; _server.TimeZone_DST = timeZone_DST; _server.DST_Start = dST_Start; _server.DST_End = dST_End; _niEntities.Servers.Add(_server); _niEntities.SaveChanges(); _return = 1; // one row updated serverId = _server.ServerId; return(_return); }
private static void InstallPrestoSelfUpdaterPrivate(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { // ToDo: Todd Pike mentioned using NET USE without using a mapped drive. Maybe check into that. lock (_locker) // only allow one at a time (x: drive gets mapped on WCF server) { if (appServer == null) { throw new ArgumentNullException("appServer"); } string selfUpdatingAppName = ConfigurationManager.AppSettings["selfUpdatingAppName"]; if (appWithGroup == null) { // User wants the default self-updater installed (with no override group). appWithGroup = appServer.ApplicationsWithOverrideGroup.FirstOrDefault( x => x.Application.Name == selfUpdatingAppName && (x.CustomVariableGroups == null || x.CustomVariableGroups.Count < 1)); } if (appWithGroup == null || appWithGroup.Application == null) { string message = string.Format(CultureInfo.CurrentCulture, PrestoServerResources.PrestoSelfUpdaterAppNotFound, selfUpdatingAppName); throw new InvalidOperationException(message); } PrestoServerUtility.Container.Resolve <IAppInstaller>().InstallApplication(appServer, appWithGroup); } }
public XSPWorker (Socket client, EndPoint localEP, ApplicationServer server, bool secureConnection, SecurityProtocolType securityProtocol, X509Certificate cert, PrivateKeySelectionCallback keyCB, bool allowClientCert, bool requireClientCert) { if (secureConnection) { ssl = new SslInformation { AllowClientCertificate = allowClientCert, RequireClientCertificate = requireClientCert, RawServerCertificate = cert.GetRawCertData () }; netStream = new LingeringNetworkStream (client, true); var s = new SslServerStream (netStream, cert, requireClientCert, false); s.PrivateKeyCertSelectionDelegate += keyCB; s.ClientCertValidationDelegate += ClientCertificateValidation; stream = s; } else { netStream = new LingeringNetworkStream (client, false); stream = netStream; } sock = client; this.server = server; remoteEP = (IPEndPoint) client.RemoteEndPoint; this.localEP = (IPEndPoint) localEP; }
public void Effort_ServerStore_FindById_Test() { // ApplicationServer FindById(int ServerId) int _serverId = 1; ApplicationServer _actual = _sut.FindById(_serverId); Assert.AreEqual(_serverId, _actual.ServerId); }
public void Effort_ServerStore_FindByName_Test() { // ApplicationServer FindByName(string ServerName) string _server = existServerName; ApplicationServer _actual = _sut.FindByName(_server); Assert.AreEqual(_server, _actual.ServerShortName); }
public ApplicationServer SaveServer(ApplicationServer applicationServer) { return(Invoke(() => { ApplicationServerLogic.Save(applicationServer); return applicationServer; })); }
public void GetByNameTest() { string name = "server2"; ApplicationServer server = ApplicationServerLogic.GetByName(name); Assert.AreEqual(name, server.Name); }
private static bool AppGroupEnabled(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { Logger.LogDebug(string.Format(CultureInfo.CurrentCulture, "Checking if app should be installed. ApplicationWithOverrideVariableGroup enabled: {0}.", appWithGroup.Enabled), appServer.EnableDebugLogging); return(appWithGroup.Enabled); }
static void CreateAppServer(ConfigurationManager configurationManager, string rootDir) { var webSource = new WebSource(); appserver = new ApplicationServer(webSource, rootDir) { Verbose = configurationManager.Verbose }; }
private void StartServer() { ServerApplication serverApplication = new XpandServerApplication(); serverApplication.ApplicationName = "SecurityDemo"; serverApplication.DatabaseVersionMismatch += new EventHandler<DatabaseVersionMismatchEventArgs>(serverApplication_DatabaseVersionMismatch); serverApplication.SetupComplete+=ServerApplicationOnSetupComplete; foreach(ModuleBase module in GetModules()) { if(!serverApplication.Modules.Contains(module)) { serverApplication.Modules.Add(module); } } serverApplication.ConnectionString = serverConnectionString; SecurityDemoAuthentication authentication = new SecurityDemoAuthentication(); //AuthenticationActiveDirectory authentication = new AuthenticationActiveDirectory(typeof(SecurityDemo.Module.SecurityUser), null); //authenticationActiveDirectory.CreateUserAutomatically = true; //#region DEMO_REMOVE //authentication = new AuthenticationStandardForTests(); //#endregion serverApplication.Security = new SecurityStrategyComplex(typeof(SecurityDemoUser), typeof(SecurityRole), authentication); ((ISupportFullConnectionString) serverApplication).ConnectionString = serverConnectionString; serverApplication.Setup(); serverApplication.DatabaseUpdateMode=DatabaseUpdateMode.UpdateDatabaseAlways; serverApplication.CheckCompatibility(); ApplicationServer applicationServer = new ApplicationServer(connectionString, "SecurityDemoApplicationServer", serverConnectionString); applicationServer.ObjectSpaceProvider = serverApplication.ObjectSpaceProvider; applicationServer.Security = serverApplication.Security; applicationServer.SecurityService = new ServerSecurityStrategyService(authentication); try { applicationServer.Start(); SecurityModule.StrictSecurityStrategyBehavior = false; } catch (Exception e) { Console.WriteLine(e); } }
public static void Main() { if (File.Exists("Readme.md")) Console.WriteLine(File.ReadAllText("Readme.md")); // persistence var store = CreateFileStoreForTesting(); var events = new EventStore(store); // various domain services var pricing = new PricingService(); var server = new ApplicationServer(); server.Handlers.Add(new LoggingWrapper(new CustomerApplicationService(events, pricing))); // send some sample commands server.Dispatch(new CreateCustomer {Id = new CustomerId(12), Name = "Lokad", Currency = Currency.Eur}); server.Dispatch(new RenameCustomer {Id = new CustomerId(12), NewName = "Lokad SAS"}); server.Dispatch(new ChargeCustomer {Id = new CustomerId(12), Amount = 20m.Eur(), Name = "Forecasting"}); Console.WriteLine("Press any key to exit"); Console.ReadKey(true); }
public int Run () { CompatTuple<int, string, ApplicationServer> res = Server.DebugMain (new [] { "--applications", "/:.", "--port", "9000", "--nonstop" }); server = res.Item3; return res.Item1; }
// // Parameters: // // args - original args passed to the program // root - true means caller is in the root domain // ext_apphost - used when single app mode is used, in a recursive call to // RealMain from the single app domain // quiet - don't show messages. Used to avoid double printing of the banner // public int RealMain(string [] args, bool root, IApplicationHost ext_apphost, bool v_quiet) { var configurationManager = new ConfigurationManager (v_quiet, ext_apphost == null ? null : ext_apphost.Path); if (!configurationManager.LoadCommandLineArgs (args)) return 1; // Show the help and exit. if (configurationManager.Help) { configurationManager.PrintHelp (); #if DEBUG Console.WriteLine("Press any key..."); Console.ReadKey (); #endif return 0; } // Show the version and exit. if (configurationManager.Version) { Version.Show (); return 0; } var hash = GetHash (args); if (hash == -1) { Logger.Write(LogLevel.Error, "Couldn't calculate hash - should have left earlier - something is really wrong"); return 1; } if (hash == -2) { Logger.Write(LogLevel.Error, "Couldn't calculate hash - unrecognized parameter"); return 1; } if (!configurationManager.LoadConfigFile ()) return 1; configurationManager.SetupLogger (); ushort port = configurationManager.Port ?? 0; bool useTCP = port != 0; string lockfile = useTCP ? Path.Combine (Path.GetTempPath (), "mod_mono_TCP_") : configurationManager.Filename; lockfile = String.Format ("{0}_{1}", lockfile, hash); ModMonoWebSource webSource = useTCP ? new ModMonoTCPWebSource (configurationManager.Address, port, lockfile) : new ModMonoWebSource (configurationManager.Filename, lockfile); if(configurationManager.Terminate) { if (configurationManager.Verbose) Logger.Write (LogLevel.Notice, "Shutting down running mod-mono-server..."); bool res = webSource.GracefulShutdown (); if (configurationManager.Verbose) if (res) Logger.Write (LogLevel.Notice, "Done"); else Logger.Write (LogLevel.Error, "Failed."); return res ? 0 : 1; } var server = new ApplicationServer (webSource, configurationManager.Root) { Verbose = configurationManager.Verbose, SingleApplication = !root }; #if DEBUG Console.WriteLine (Assembly.GetExecutingAssembly ().GetName ().Name); #endif if (configurationManager.Applications != null) server.AddApplicationsFromCommandLine (configurationManager.Applications); if (configurationManager.AppConfigFile != null) server.AddApplicationsFromConfigFile (configurationManager.AppConfigFile); if (configurationManager.AppConfigDir != null) server.AddApplicationsFromConfigDirectory (configurationManager.AppConfigDir); if (!configurationManager.Master && configurationManager.Applications == null && configurationManager.AppConfigDir == null && configurationManager.AppConfigFile == null) server.AddApplicationsFromCommandLine ("/:."); // TODO: do we really want this? VPathToHost vh = server.GetSingleApp (); if (root && vh != null) { // Redo in new domain vh.CreateHost (server, webSource); var svr = (Server)vh.AppHost.Domain.CreateInstanceAndUnwrap (GetType ().Assembly.GetName ().ToString (), GetType ().FullName); webSource.Dispose (); return svr.RealMain (args, false, vh.AppHost, configurationManager.Quiet); } if (ext_apphost != null) { ext_apphost.Server = server; server.AppHost = ext_apphost; } if (!configurationManager.Quiet) { if (!useTCP) Logger.Write (LogLevel.Notice, "Listening on: {0}", configurationManager.Filename); else { Logger.Write (LogLevel.Notice, "Listening on port: {0}", port); Logger.Write (LogLevel.Notice, "Listening on address: {0}", configurationManager.Address); } Logger.Write (LogLevel.Notice, "Root directory: {0}", configurationManager.Root); } try { if (server.Start (!configurationManager.NonStop, (int)configurationManager.Backlog) == false) return 2; if (!configurationManager.NonStop) { Logger.Write (LogLevel.Notice, "Hit Return to stop the server."); while (true) { try { Console.ReadLine (); break; } catch (IOException) { // This might happen on appdomain unload // until the previous threads are terminated. Thread.Sleep (500); } } server.Stop (); } } catch (Exception e) { if (!(e is ThreadAbortException)) Logger.Write (e); else server.ShutdownSockets (); return 1; } return 0; }
public ApplicationServerAttribute(ApplicationServer appServer) { app = appServer; }
public override Worker CreateWorker(System.Net.Sockets.Socket socket, ApplicationServer server) { return null; }
public override void Configure(ApplicationServer server, DirectoryInfo BaseDir, XmlDocument ConfigFile) { base.Configure(server,BaseDir,ConfigFile); _Port=int.Parse(ReadAppSetting(ConfigFile,"WebApplication.Port","21")); _VirtDir="/"; }
static void CreateAppServer(ConfigurationManager configurationManager, string rootDir) { var webSource = new WebSource (); appserver = new ApplicationServer (webSource, rootDir) { Verbose = configurationManager.Verbose }; }
/// <param name="args">Original args passed to the program.</param> /// <param name="root">If set to <c>true</c> it means the caller is in the root domain.</param> /// <param name="ext_apphost">Used when single app mode is used, in a recursive call to RealMain from the single app domain.</param> /// <param name="quiet">If set to <c>true</c> don't show messages. Used to avoid double printing of the banner.</param> internal CompatTuple<int, string, ApplicationServer> DebugMain (string [] args, bool root, IApplicationHost ext_apphost, bool quiet) { var configurationManager = new ConfigurationManager ("xsp", quiet); var security = new SecurityConfiguration (); if (!ParseOptions (configurationManager, args, security)) return new CompatTuple<int,string,ApplicationServer> (1, "Error while parsing options", null); // Show the help and exit. if (configurationManager.Help) { configurationManager.PrintHelp (); #if DEBUG Console.WriteLine ("Press any key..."); Console.ReadKey (); #endif return success; } // Show the version and exit. if (configurationManager.Version) { Version.Show (); return success; } if (!configurationManager.LoadConfigFile ()) return new CompatTuple<int,string,ApplicationServer> (1, "Error while loading the configuration file", null); configurationManager.SetupLogger (); WebSource webSource; if (security.Enabled) { try { key = security.KeyPair; webSource = new XSPWebSource (configurationManager.Address, configurationManager.RandomPort ? default(ushort) : configurationManager.Port, security.Protocol, security.ServerCertificate, GetPrivateKey, security.AcceptClientCertificates, security.RequireClientCertificates, !root); } catch (CryptographicException ce) { Logger.Write (ce); return new CompatTuple<int,string,ApplicationServer> (1, "Error while setting up https", null); } } else { webSource = new XSPWebSource (configurationManager.Address, configurationManager.Port, !root); } var server = new ApplicationServer (webSource, configurationManager.Root) { Verbose = configurationManager.Verbose, SingleApplication = !root }; if (configurationManager.Applications != null) server.AddApplicationsFromCommandLine (configurationManager.Applications); if (configurationManager.AppConfigFile != null) server.AddApplicationsFromConfigFile (configurationManager.AppConfigFile); if (configurationManager.AppConfigDir != null) server.AddApplicationsFromConfigDirectory (configurationManager.AppConfigDir); if (configurationManager.Applications == null && configurationManager.AppConfigDir == null && configurationManager.AppConfigFile == null) server.AddApplicationsFromCommandLine ("/:."); VPathToHost vh = server.GetSingleApp (); if (root && vh != null) { // Redo in new domain vh.CreateHost (server, webSource); var svr = (Server) vh.AppHost.Domain.CreateInstanceAndUnwrap (GetType ().Assembly.GetName ().ToString (), GetType ().FullName); webSource.Dispose (); return svr.DebugMain (args, false, vh.AppHost, configurationManager.Quiet); } server.AppHost = ext_apphost; if (!configurationManager.Quiet) { Logger.Write(LogLevel.Notice, Assembly.GetExecutingAssembly().GetName().Name); Logger.Write(LogLevel.Notice, "Listening on address: {0}", configurationManager.Address); Logger.Write(LogLevel.Notice, "Root directory: {0}", configurationManager.Root); } try { if (!server.Start (!configurationManager.NonStop, (int)configurationManager.Backlog)) return new CompatTuple<int,string,ApplicationServer> (2, "Error while starting server", server); if (!configurationManager.Quiet) { // MonoDevelop depends on this string. If you change it, let them know. Logger.Write(LogLevel.Notice, "Listening on port: {0} {1}", server.Port, security); } if (configurationManager.RandomPort && !configurationManager.Quiet) Logger.Write (LogLevel.Notice, "Random port: {0}", server.Port); if (!configurationManager.NonStop) { if (!configurationManager.Quiet) Console.WriteLine ("Hit Return to stop the server."); while (true) { bool doSleep; try { Console.ReadLine (); break; } catch (IOException) { // This might happen on appdomain unload // until the previous threads are terminated. doSleep = true; } catch (ThreadAbortException) { doSleep = true; } if (doSleep) Thread.Sleep (500); } server.Stop (); } } catch (Exception e) { if (!(e is ThreadAbortException)) Logger.Write (e); else server.ShutdownSockets (); return new CompatTuple<int,string,ApplicationServer> (1, "Error running server", server); } return new CompatTuple<int,string,ApplicationServer> (0, null, server); }
public ModMonoWorker (Socket client, ApplicationServer server) { Stream = new NetworkStream (client, true); this.client = client; this.server = server; }