// public Login() // { // InitializeComponent(); // this.StartPosition = FormStartPosition.CenterScreen; // } public Login(FuncionarioServices funcionarioServices, ManagerOptions managerOptions) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; _funcionarioServices = funcionarioServices; _managerOptions = managerOptions; }
private IManagerOptions GetManagerOptions(Action <IManagerOptions> onCreateManagerOptions, bool useLogging, bool processOnlyTypesDerivedFromIProcessable, ICollection <Type>?excludeTypes, IList <Type>?priorityTypes) { var managerOptions = new ManagerOptions(); onCreateManagerOptions(managerOptions); if (useLogging) { managerOptions.UseLogger(new TraceLogger()); } if (processOnlyTypesDerivedFromIProcessable) { managerOptions.UseOnlyClassesDerivedFromIProcessable(); } if (excludeTypes != null) { foreach (var type in excludeTypes) { managerOptions.Exclude(type); } } if (priorityTypes != null) { foreach (var type in priorityTypes) { managerOptions.Prioritize(type); } } return(managerOptions); }
/// <summary> /// Uses the Piranha Manager services if simple startup is used. /// </summary> /// <param name="serviceBuilder">The service builder</param> /// <param name="options">The optional options</param> /// <param name="jsonOptions">Optional JSON options</param> /// <returns>The updated builder</returns> public static PiranhaServiceBuilder UseManager(this PiranhaServiceBuilder serviceBuilder, Action <ManagerOptions> options = null, Action <MvcNewtonsoftJsonOptions> jsonOptions = null) { // Perform optional configuration var managerOptions = new ManagerOptions(); options?.Invoke(managerOptions); // Add manager services serviceBuilder.Services.AddPiranhaManager(); // Add dependent ASP.NET services serviceBuilder.Services.AddLocalization(o => o.ResourcesPath = "Resources" ); serviceBuilder.Services.AddControllersWithViews(); serviceBuilder.Services.AddRazorPages() .AddPiranhaManagerOptions(jsonOptions); serviceBuilder.Services.AddAntiforgery(o => { o.HeaderName = managerOptions.XsrfHeaderName; }); // Add options serviceBuilder.Services.Configure <ManagerOptions>(o => { o.JsonOptions = managerOptions.JsonOptions; o.XsrfCookieName = managerOptions.XsrfCookieName; o.XsrfHeaderName = managerOptions.XsrfHeaderName; }); return(serviceBuilder); }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); builder.AddEnvironmentVariables(); Configuration = builder.Build(); var isLogFileEnabled = bool.Parse(Configuration["Log:File:Enabled"]); var isElasticSearchEnabled = bool.Parse(Configuration["Log:Elasticsearch:Enabled"]); _opts = new ManagerOptions { PasswordService = new CustomPasswordService(), Logging = new LoggingOptions { ElasticsearchOptions = new ElasticsearchOptions { IsEnabled = isElasticSearchEnabled, Url = Configuration["Log:Elasticsearch:Url"] }, FileLogOptions = new FileLogOptions { IsEnabled = isLogFileEnabled, PathFormat = Configuration["Log:File:PathFormat"] } }, Introspection = new IntrospectOptions { ClientId = Configuration["OpenId:ClientId"], ClientSecret = Configuration["OpenId:ClientSecret"], IntrospectionUrl = Configuration["OpenId:IntrospectUrl"] } }; }
private void ImportBtn_Clicked(GUI.GUIItem item) { if (_GameStarted && _Manager != null) { MouseUI mouseUI = _Manager.GetComponent <MouseUI>(); GameObject tileMap = mouseUI._ModGet_TileMap(); Tiles shipTiles = tileMap.GetComponent <Tiles>(); ManagerJobs managerJobs = _Manager.GetComponent <ManagerJobs>(); ManagerMenu managerMenu = _Manager.GetComponent <ManagerMenu>(); ManagerOptions managerOptions = _Manager.GetComponent <ManagerOptions>(); if (shipTiles != null) { String json = System.IO.File.ReadAllText(System.IO.Path.Combine(ModFolder, "Design.json"), Encoding.UTF8); TileData[] tiles = Pathfinding.Serialization.JsonFx.JsonReader.Deserialize <TileData[]>(json); List <TileData> hull = new List <TileData>(); List <TileData> floor = new List <TileData>(); TileData shipCore = null; List <TileData> other = new List <TileData>(); foreach (TileData td in tiles) { List <TileData.Vec3> StructureParts = new List <TileData.Vec3>(); StructureParts.AddRange(td.StructureParts); td.StructureParts = StructureParts; if (td.TileType == "Hull" || td.TileType == "HullCorner") { hull.Add(td); } else if (td.TileType == "Floor") { floor.Add(td); } else if (td.TileType == "ShipCore") { shipCore = td; } else { other.Add(td); } } if (shipCore == null) { throw new Exception("Ship Design is missing required tile ShipCore"); } _IsImporting = true; _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); managerMenu.StartCoroutine(UpdateTiles(shipTiles, managerJobs, managerOptions, tileMap, hull, floor, shipCore, other)); managerMenu.StartCoroutine(OnImportFinished(tiles)); } } }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); builder.AddEnvironmentVariables(); Configuration = builder.Build(); _options = new ManagerOptions(); }
public ManagerFiles() { var optionsManager = new ManagerOptions(AppDomain.CurrentDomain.BaseDirectory); options = optionsManager.GetConfigurations <ImportantOptions>(); DatabaseProvider dataManager = new DatabaseProvider(options); logger = new ManagerOfLogging(dataManager.databaseManager); logger.Setup(); dataManager.CreateXMLFiles(); }
private static int StartRunnerAndReturnExitCode(ManagerOptions options) { var log = Log.Logger.ForContext <Program>(); log.Information("Starting manager process..."); var manager = new ManagerMain(); manager.StartManager(options).Wait(); log.Information("Manager process ended."); return(0); }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); builder.AddEnvironmentVariables(); Configuration = builder.Build(); var isLogFileEnabled = bool.Parse(Configuration["Log:File:Enabled"]); var isElasticSearchEnabled = bool.Parse(Configuration["Log:Elasticsearch:Enabled"]); _options = new ManagerOptions(); }
public BackupManager(ManagerOptions options) { _options = options; _watcher = new FileSystemWatcher { Path = SaveDataDirectory, Filter = "*.pcsave", NotifyFilter = NotifyFilters.LastWrite, IncludeSubdirectories = false }; _watcher.Changed += HandleBackupTrigger; _watcher.Created += HandleBackupTrigger; }
/// <summary> /// Event handler for the "Toggle Debug Mode" button /// </summary> /// <param name="item"></param> private void _ToggleBtn_Clicked(StarshipTheory.ModLib.GUI.GUIItem item) { //Check if the manager isn't null (It might be null if the game is still loading) if (_Manager != null) { MouseUI UI = _Manager.GetComponent <MouseUI>(); ManagerOptions options = _Manager.GetComponent <ManagerOptions>(); //Make sure we have both components before proceeding. They might be null if we are still loading if (UI != null && options != null) { options.enableDebug = true; //Tricks the in-game code to think that we are in the debug mode. UI.toggleDebugPanel(); //Toggles the debug panel on or off. } } }
public Startup(IConfiguration options) { ApplicationOptionsProvider = options; ManagerLogger = new CollectorLogger(); var managerOptions = new ManagerOptions() .UseLogger(ManagerLogger) .UseOnlyClassesDerivedFromIProcessable(); Manager = new Manager.Manager(managerOptions) .AddEntryAssembly() .AddAssemblyContainingType(typeof(ExtensionForInstantiatePerContainerAttribute)) .AddAssemblyContainingType(typeof(ExtensionForBoundedContextAttribute)) .AddKeyedOptionsProvider(ApplicationOptionsProvider); }
static bool OpenDatabase() { var isOpen = false; if (String.IsNullOrWhiteSpace(_cb_path)) { Environment.ExitCode = 101; OutputLineUsingColor(ConsoleColor.Red, "The provided database path was empty or contained only whitespace characters."); return(isOpen); } var cbPathDir = Path.GetDirectoryName(_cb_path); if (!Directory.Exists(cbPathDir)) { Environment.ExitCode = 101; OutputLineUsingColor(ConsoleColor.Red, "The parent directory must already exist for the path `{0}`", _cb_path); return(isOpen); } if (!Path.GetExtension(_cb_path).Equals(".cblite2")) { Environment.ExitCode = 101; OutputLineUsingColor(ConsoleColor.Red, "The file extension must be `.cblite2`."); return(isOpen); } try { var options = new ManagerOptions(); _manager = new Manager(new DirectoryInfo(cbPathDir), options); var cbPathInfo = new DirectoryInfo(_cb_path); if (!_skip && cbPathInfo.Exists) { if (Prompt(ConsoleColor.Yellow, "The database file `{0}` already exists. Overwrite? [Y/n]", _cb_path) == (int)ConsoleKey.Y) { try { Directory.Delete(_cb_path, true); } catch (Exception) { OutputLineUsingColor(ConsoleColor.Red, "Unable to delete existing database at `{0}`.", _cb_path); Environment.ExitCode = 103; return(false); } } } #if USE_SQLITE _database = _manager.GetDatabase(Path.GetFileNameWithoutExtension(_cb_path)); #else _database = _manager.OpenDatabase(Path.GetFileNameWithoutExtension(_cb_path), new DatabaseOptions { Create = true, StorageType = DatabaseOptions.FORESTDB_STORAGE }); #endif isOpen = true; } catch (Exception e) { Environment.ExitCode = 102; OutputLineUsingColor(ConsoleColor.Red, "Unable to open/create a database at path `{0}`", _cb_path); OutputLineUsingColor(ConsoleColor.DarkRed, e.ToString()); } return(isOpen); }
/// <summary> /// Default constructor. /// </summary> /// <param name="antiforgery">The antiforgery service</param> /// <param name="options">The manager options</param> public AuthController(IAntiforgery antiforgery, IOptions <ManagerOptions> options) { _antiForgery = antiforgery; _options = options.Value; }
private System.Collections.IEnumerator UpdateTiles(Tiles shipTiles, ManagerJobs managerJobs, ManagerOptions managerOptions, GameObject tileMap, List <TileData> hull, List <TileData> floor, TileData shipCore, List <TileData> other) { bool deadCrewEndGame = true; try { if (managerOptions != null) { deadCrewEndGame = managerOptions.deadCrewEndGame; managerOptions.deadCrewEndGame = false; } } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); Structures structures = null; int cargoGold = 0; int cargoMetal = 0; int cargoSilicon = 0; int cargoWater = 0; int cargoFood = 0; int cargoCredits = 0; try { structures = tileMap.GetComponent <Structures>(); cargoGold = structures.structure[0].reservesGold; cargoMetal = structures.structure[0].reservesMetal; cargoSilicon = structures.structure[0].reservesSilicon; cargoWater = structures.structure[0].reservesWater; cargoFood = structures.structure[0].reservesFood; cargoCredits = structures.structure[0].credits; List <Vector2> tilesToRemove = new List <Vector2>(); for (int x = shipTiles.tiles.GetLowerBound(0); x <= shipTiles.tiles.GetUpperBound(0); x++) { for (int y = shipTiles.tiles.GetLowerBound(1); y <= shipTiles.tiles.GetUpperBound(1); y++) { if (String.IsNullOrEmpty(shipTiles.tiles[x, y].toBecome) && String.IsNullOrEmpty(shipTiles.tiles[x, y].tileType) && String.IsNullOrEmpty(shipTiles.tiles[x, y].structureType)) { continue; } tilesToRemove.Add(new Vector2(x, y)); } } TileHelper.RemoveTiles(tilesToRemove); } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); if (hull.Count > 0) { try { TileHelper.BuildTiles(hull); } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); } if (floor.Count > 0) { try { TileHelper.BuildTiles(floor); } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); } if (shipCore != null) { try { TileHelper.BuildTiles(shipCore); } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); } if (other.Count > 0) { try { TileHelper.BuildTiles(other); } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); } try { shipTiles.updateTileColors(); shipTiles.updateTileMesh("All"); Crew crew = tileMap.GetComponent <Crew>(); foreach (GameObject crewMember in crew.crewList) { crewMember.transform.position = new Vector3(shipCore.X, crewMember.transform.position.y, shipCore.Y); } } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); try { if (managerOptions != null) { managerOptions.deadCrewEndGame = deadCrewEndGame; } ManagerResources managerResources = _Manager.GetComponent <ManagerResources>(); structures.structure[0].reservesGold = 0; structures.structure[0].reservesMetal = 0; structures.structure[0].reservesSilicon = 0; structures.structure[0].reservesWater = 0; structures.structure[0].reservesFood = 0; structures.structure[0].credits = 0; structures.structure[0].cargoCurrent = 0; managerResources.updateResourceReserves("Gold", cargoGold, tileMap, ""); managerResources.updateResourceReserves("Metal", cargoMetal, tileMap, ""); managerResources.updateResourceReserves("Silicon", cargoSilicon, tileMap, ""); managerResources.updateResourceReserves("Water", cargoWater, tileMap, ""); managerResources.updateResourceReserves("Food", cargoFood, tileMap, ""); managerResources.updateCredits(cargoCredits, false); } catch (Exception ex) { this.DisplayError(ex); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; yield break; } yield return(new WaitForSeconds(0.01f)); _Manager.GetComponent <ManagerMenu>().toggleMainMenu(); _IsImporting = false; }