public AddImporterConfigurationToProjectCommand(ImporterConfiguration configuration) { _configuration = configuration; _configurationId = _configuration.Id; CommandType = Assets.Command.CommandTypeAdd; ObjectType = ObjectTypes.ImporterConfiguration; }
void ShowHeightmaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing heightmaps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for heightmap files."); importCfg.HeightmapTag = EGL.TextField("Name postfix", importCfg.HeightmapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Heightmap file specifications. Please use raw file\nwith x^2+1 dimensions."); importCfg.HeightmapExtention = EGL.TextField("File extention", importCfg.HeightmapExtention); importCfg.HeightmapFlipX = EGL.Toggle("Mirror X", importCfg.HeightmapFlipX); importCfg.HeightmapFlipY = EGL.Toggle("Mirror Y", importCfg.HeightmapFlipY); importCfg.HeightFormat = (HeightfileFormat)EditorGUILayout.EnumPopup("Byte Format", importCfg.HeightFormat); } EGL.EndVertical(); } EGL.EndVertical(); }
public void Then_The_Bearer_Token_Is_Not_Added_If_Local( ImporterConfiguration config) { //Arrange var configuration = new Mock <IOptions <ImporterConfiguration> >(); config.DataLoaderBaseUrlsAndIdentifierUris = "https://test.local/"; configuration.Setup(x => x.Value).Returns(config); var response = new HttpResponseMessage { Content = new StringContent(""), StatusCode = HttpStatusCode.Accepted }; var httpMessageHandler = SetupMessageHandlerMock(response, $"{config.DataLoaderBaseUrlsAndIdentifierUris}ops/dataload"); var client = new HttpClient(httpMessageHandler.Object); var service = new ImportDataService(client, configuration.Object, Mock.Of <IAzureClientCredentialHelper>(), new ImporterEnvironment("LOCAL")); //Act service.Import(); //Assert httpMessageHandler.Protected() .Verify <Task <HttpResponseMessage> >( "SendAsync", Times.Once(), ItExpr.Is <HttpRequestMessage>(c => c.Method.Equals(HttpMethod.Post) && c.RequestUri.AbsoluteUri.Equals($"{config.DataLoaderBaseUrlsAndIdentifierUris}ops/dataload") && c.Headers.Authorization == null), ItExpr.IsAny <CancellationToken>() ); }
void ShowSettings() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { EGL.Separator(); GUILayout.Label("LOD Levels"); EGL.BeginVertical(GuiUtils.Skin.box); { if (importCfg.LodLevels.Count >= 4) { GUI.enabled = false; } if (GUILayout.Button("Add LOD Level")) { importCfg.LodLevels.Add(new LodLevel()); importCfg.IsDirty = true; // Todo: Nasty } GUI.enabled = true; // Show the list of LODS EGL.BeginVertical(); { _lodScrollPos = EGL.BeginScrollView(_lodScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { var removeThese = new List <LodLevel>(); int i = 0; foreach (LodLevel lod in importCfg.LodLevels) { if (ShowLodLevel(lod, i)) { removeThese.Add(lod); importCfg.IsDirty = true; // Nasty } i++; } foreach (LodLevel lod in removeThese) { importCfg.LodLevels.Remove(lod); } } EGL.EndScrollView(); } EGL.EndVertical(); EGL.Space(); GUILayout.Label("Control how many assets are processed in one go."); importCfg.BatchLimit = EGL.IntField("Batch limit", importCfg.BatchLimit); GUILayout.Label("Larger batches mean faster processing but require\nmore memory. Change this with care, or Unity's\nmemory might run out!"); } EGL.EndVertical(); } EGL.EndVertical(); }
public ImportDataService(HttpClient client, IOptions <ImporterConfiguration> configuration, IAzureClientCredentialHelper azureClientCredentialHelper, ImporterEnvironment importerEnvironment) { _client = client; _azureClientCredentialHelper = azureClientCredentialHelper; _importerEnvironment = importerEnvironment; _configuration = configuration.Value; }
public void AddImporterConfigurationToProject(ImporterConfiguration configuration) { if (importerConfigurationAlreadyExistsInProject(configuration)) { return; } _executionContext.AddToHistory(new AddImporterConfigurationToProjectCommand(configuration).Run(_executionContext)); }
public void Then_The_Dataload_Is_Called_For_Multiple_Endpoints( string authToken, ImporterConfiguration config) { //Arrange var azureClientCredentialHelper = new Mock <IAzureClientCredentialHelper>(); azureClientCredentialHelper .Setup(x => x.GetAccessTokenAsync(It.Is <string>(c => c.StartsWith("tenant")))) .ReturnsAsync(authToken); var configuration = new Mock <IOptions <ImporterConfiguration> >(); var urls = new List <string> { "https://local.url1/|tenant1", "https://local.url2/|tenant2", "https://local.url3/|tenant3", "https://local.url4/|tenant4" }; config.DataLoaderBaseUrlsAndIdentifierUris = string.Join(",", urls); configuration.Setup(x => x.Value).Returns(config); var response = new HttpResponseMessage { Content = new StringContent(""), StatusCode = HttpStatusCode.Accepted }; var httpMessageHandler = SetupMessageHandlerMock(response, $"/ops/dataload"); var client = new HttpClient(httpMessageHandler.Object); var service = new ImportDataService(client, configuration.Object, azureClientCredentialHelper.Object, new ImporterEnvironment("TEST")); //Act service.Import(); //Assert foreach (var url in urls) { var dataUrl = url.Split("|").First(); httpMessageHandler.Protected() .Verify <Task <HttpResponseMessage> >( "SendAsync", Times.Once(), ItExpr.Is <HttpRequestMessage>(c => c.Method.Equals(HttpMethod.Post) && c.RequestUri.AbsoluteUri.Equals($"{dataUrl}ops/dataload") && c.Headers.Authorization.Scheme.Equals("Bearer") && c.Headers.FirstOrDefault(h => h.Key.Equals("X-Version")).Value.Single() == "1.0" && c.Headers.Authorization.Parameter.Equals(authToken)), ItExpr.IsAny <CancellationToken>() ); } }
void ShowTerrainSettings() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; TerrainConfiguration terrainStreamingConfiguration = importCfg.TerrainConfiguration; EGL.BeginVertical(); { EGL.BeginVertical(GuiUtils.Skin.box); { if (GUILayout.Button("Apply to selected TerrainData assets")) { QueueCall(editorUtilities.ApplyDimensionsToSelection); } } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("In-game terrain LOD settings."); terrainStreamingConfiguration.HeightmapPixelError = EGL.Slider("Pixel Error", terrainStreamingConfiguration.HeightmapPixelError, 1f, 200f); terrainStreamingConfiguration.BasemapDistance = EGL.FloatField("Basemap Dist.", terrainStreamingConfiguration.BasemapDistance); terrainStreamingConfiguration.CastShadows = EGL.Toggle("Cast Shadows", terrainStreamingConfiguration.CastShadows); EGL.Separator(); terrainStreamingConfiguration.DetailObjectDistance = EGL.Slider("Detail Distance", terrainStreamingConfiguration.DetailObjectDistance, 0f, 250f); terrainStreamingConfiguration.DetailObjectDensity = EGL.Slider("Detail Density", terrainStreamingConfiguration.DetailObjectDensity, 0f, 1f); terrainStreamingConfiguration.TreeDistance = EGL.Slider("Tree Distance", terrainStreamingConfiguration.TreeDistance, 0f, 2000f); terrainStreamingConfiguration.TreeBillboardDistance = EGL.Slider("Billboard Start", terrainStreamingConfiguration.TreeBillboardDistance, 50f, 2000f); terrainStreamingConfiguration.TreeCrossFadeLength = EGL.Slider("Fade Length", terrainStreamingConfiguration.TreeCrossFadeLength, 0f, 200f); terrainStreamingConfiguration.TreeMaximumFullLODCount = EGL.IntSlider("Max Mesh Trees", terrainStreamingConfiguration.TreeMaximumFullLODCount, 0, 500); EGL.Separator(); if (GUILayout.Button("Apply to selected Scene assets")) { QueueCall(editorUtilities.ApplyTerrainLODSettingsToSelection); } } EGL.EndVertical(); } EGL.EndVertical(); }
public void Then_The_Dataload_Endpoint_Is_Called( string authToken, ImporterConfiguration config) { //Arrange var azureClientCredentialHelper = new Mock <IAzureClientCredentialHelper>(); azureClientCredentialHelper .Setup(x => x.GetAccessTokenAsync(It.Is <string>(c => c.StartsWith("tenant")))) .ReturnsAsync(authToken); var configuration = new Mock <IOptions <ImporterConfiguration> >(); var dataUrl = "https://test.local/"; config.DataLoaderBaseUrlsAndIdentifierUris = $"{dataUrl}|tenant"; configuration.Setup(x => x.Value).Returns(config); var response = new HttpResponseMessage { Content = new StringContent(""), StatusCode = HttpStatusCode.Accepted }; var httpMessageHandler = SetupMessageHandlerMock(response, $"{dataUrl}ops/dataload"); var client = new HttpClient(httpMessageHandler.Object); var service = new ImportDataService(client, configuration.Object, azureClientCredentialHelper.Object, new ImporterEnvironment("TEST")); //Act service.Import(); //Assert httpMessageHandler.Protected() .Verify <Task <HttpResponseMessage> >( "SendAsync", Times.Once(), ItExpr.Is <HttpRequestMessage>(c => c.Method.Equals(HttpMethod.Post) && c.RequestUri.AbsoluteUri.Equals($"{dataUrl}ops/dataload") && c.Headers.Authorization.Scheme.Equals("Bearer") && c.Headers.Authorization.Parameter.Equals(authToken)), ItExpr.IsAny <CancellationToken>() ); }
void ShowSaveButtons() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { EGL.BeginHorizontal(); { EGL.Separator(); if (GUILayout.Button("Save Settings")) { editorUtilities.SaveSettings(); } if (GUILayout.Button("Load Settings")) { editorUtilities.LoadSettings(); } GUI.enabled = true; EGL.Separator(); } EGL.EndHorizontal(); EGL.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (importCfg.IsDirty) { GUILayout.Label("You have unsaved settings."); } GUILayout.FlexibleSpace(); } EGL.EndHorizontal(); } EGL.EndVertical(); }
public override void RestoreExecutionData(IOSPSuiteExecutionContext context) { _configuration = context.Deserialize <ImporterConfiguration>(_serializationStream); }
protected override void ClearReferences() { _configuration = null; }
/// <summary> /// Loads the model specified file path. /// </summary> /// <param name="filePath">The file path.</param> /// <param name="config">The configuration.</param> /// <returns></returns> public HelixToolkitScene Load(string filePath, ImporterConfiguration config) { Configuration = config; return(Load(filePath)); }
void ShowDetailMaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing detail maps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for detailmap files."); importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Splatmap file specifications. Please use x^2."); importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention); importCfg.SplatmapFlipX = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX); importCfg.SplatmapFlipY = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.DetailPrototypes.Count + ")"); EGL.Separator(); EGL.BeginHorizontal(); { if (editorUtilities.DetailPrototypes.Count >= 8) { GUI.enabled = false; } if (GUILayout.Button("Add Prototype")) { editorUtilities.DetailPrototypes.Add(new DetailPrototype()); importCfg.IsDirty = true; // Todo: Nasty, because the above prototypes still need to be converted to a serializable format, which is not directly done here } GUI.enabled = true; } EGL.EndHorizontal(); // Show the list EGL.BeginVertical(); { _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { List <DetailPrototype> removeThese = new List <DetailPrototype>(); int i = 0; foreach (DetailPrototype prototype in editorUtilities.DetailPrototypes) { if (ShowDetailPrototype(prototype, i)) { removeThese.Add(prototype); importCfg.IsDirty = true; // Nasty } i++; } foreach (DetailPrototype prototype in removeThese) { editorUtilities.DetailPrototypes.Remove(prototype); } } EGL.EndScrollView(); } EGL.EndVertical(); } EGL.EndVertical(); } EGL.EndVertical(); }
public override void RestoreExecutionData(IOSPSuiteExecutionContext context) { _configuration = context.Project.ImporterConfigurationBy(_configurationId); }
private bool importerConfigurationAlreadyExistsInProject(ImporterConfiguration configuration) { return(_executionContext.Project.AllImporterConfigurations.ExistsById(configuration.Id)); }
void ShowSingleImport() { ImporterConfiguration config = LandmassEditorUtilities.Instance.ImportCfg; EGL.BeginVertical(); { EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Target Terrain"); _singleTargetTerrain = EGL.ObjectField(_singleTargetTerrain, typeof(Terrain), true, GUILayout.Width(240f)) as Terrain; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ----- Heightmap ----- */ GUILayout.Label("Heightmap"); GUILayout.BeginHorizontal(); { EGL.LabelField("Path", _singleHeightmapPath); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { _singleHeightmapPath = EditorUtility.OpenFilePanel("Browse to Heightmap file", _singleHeightmapPath, "r16"); } } GUILayout.EndHorizontal(); GUI.enabled = _singleHeightmapPath != ""; { if (GUILayout.Button("Apply")) { LandmasImporter.ParseHeightmapFileToTerrain( _singleHeightmapPath, _singleTargetTerrain.terrainData, config.HeightFormat, config.HeightmapFlipX, config.HeightmapFlipY ); } } GUI.enabled = true; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ----- Splatmaps ------ */ GUILayout.Label("Splatmap"); _singleSplatmap = EGL.ObjectField(_singleSplatmap, typeof(Texture2D), false, GUILayout.Width(100f), GUILayout.Height(100f)) as Texture2D; EGL.Separator(); GUI.enabled = _singleSplatmap != null && _singleTargetTerrain != null; { if (GUILayout.Button("Apply")) { var splatmap = new float[_singleSplatmap.width, _singleSplatmap.height, 4]; LandmasImporter.TextureToSplatMap( _singleSplatmap, ref splatmap, false, true); LandmasImporter.Instance.NormalizeSplatmap(ref splatmap, config.NormalizationMode); LandmasImporter.Instance.ParseSplatmapToTerrain(splatmap, _singleTargetTerrain.terrainData); } } GUI.enabled = true; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ------ Treemaps ----- */ GUILayout.Label("Treemap"); _singleTreemap = EGL.ObjectField(_singleTreemap, typeof(Texture2D), false, GUILayout.Width(100f), GUILayout.Height(100f)) as Texture2D; GUI.enabled = _singleTreemap != null; { if (GUILayout.Button("Apply")) { LandmasImporter.ParseTreemapTexturesToTerrain(_singleTreemap, _singleTargetTerrain.terrainData); } } GUI.enabled = true; EGL.Separator(); if (GUILayout.Button("Flush Terrain")) { Terrain terrain = Selection.activeGameObject.GetComponent <Terrain>(); if (terrain) { Debug.Log("Flushing Terrain"); terrain.Flush(); } } } EGL.EndVertical(); } EGL.EndVertical(); }
public virtual void AddOImporterConfiguration(ImporterConfiguration importerConfiguration) { _allImporterConfigurations.Add(importerConfiguration); }
public virtual void RemoveImporterConfiguration(ImporterConfiguration importerConfigurationToRemove) { _allImporterConfigurations.Remove(importerConfigurationToRemove.Id); }
public virtual void AddImporterConfiguration(ImporterConfiguration configurationToAdd) { _allImporterConfigurations.Add(configurationToAdd); }
void ShowSplatmaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing splatmaps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for splatmap files."); importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Splatmap file specifications. Please use x^2."); importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention); importCfg.SplatmapFlipX = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX); importCfg.SplatmapFlipY = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY); importCfg.TrimEmptyChannels = EGL.Toggle("Trim empty", importCfg.TrimEmptyChannels); importCfg.NormalizationMode = (NormalizationMode)EditorGUILayout.EnumPopup("Normalize mode", importCfg.NormalizationMode); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.SplatPrototypes.Count + ")"); EGL.Separator(); EGL.BeginHorizontal(); { if (editorUtilities.SplatPrototypes.Count >= 8) { GUI.enabled = false; } if (GUILayout.Button("Add Prototype")) { editorUtilities.SplatPrototypes.Add(new SplatPrototype()); importCfg.IsDirty = true; // Todo: Nasty } GUI.enabled = true; if (GUILayout.Button("Grab from Selected Terrain Object or Asset")) { GetPrototypesFromSelectedTerrain(); importCfg.IsDirty = true; // Todo: Nasty } } EGL.EndHorizontal(); // Show the list EGL.BeginVertical(); { _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { List <SplatPrototype> removeThese = new List <SplatPrototype>(); int i = 0; foreach (SplatPrototype splatPrototype in editorUtilities.SplatPrototypes) { if (ShowSplatPrototype(splatPrototype, i)) { removeThese.Add(splatPrototype); importCfg.IsDirty = true; // Nasty } i++; } foreach (SplatPrototype splatPrototype in removeThese) { editorUtilities.SplatPrototypes.Remove(splatPrototype); } } EGL.EndScrollView(); } EGL.EndVertical(); } EGL.EndVertical(); } EGL.EndVertical(); }
static int Main(string[] args) { bool hasError = false; var result = 0; try { Logger.GetLogger().MessageAsync("Hello world"); var configPath = args.FirstOrDefault(x => x.ToUpper().StartsWith("/C:"))?.Substring(3); if (string.IsNullOrEmpty(configPath)) { PrintUsage(); Logger.GetLogger().Flush(); return(-1); } var importerConfig = ImporterConfiguration.ReadConfiguration(configPath); var df = new DataFlow(importerConfig); return(0); var config = new Configuration.Configuration(configPath); var files = new System.Collections.Generic.Dictionary <string, string>(config.Files); foreach (var a in args) { if (ExtractFile(a, out Tuple <string, string> file)) { files[file.Item1] = file.Item2; } } var readers = config.GetReaders(); var writers = config.GetWriters(); foreach (var reader in config.GetReaders()) { if (!files.TryGetValue(reader.Key, out string file) || string.IsNullOrWhiteSpace(file)) { Logger.GetLogger().ErrorAsync($"No file defined for reader configuration {reader.Key}"); hasError = true; break; } reader.Value.SetDataSource(new BufferedTextReader(File.OpenRead(file))); } foreach (var writer in config.GetWriters()) { if (!files.TryGetValue(writer.Key, out string file) || string.IsNullOrWhiteSpace(file)) { Logger.GetLogger().ErrorAsync($"No file defined for writer configuration {writer.Key}"); hasError = true; break; } if (File.Exists(file)) { File.Delete(file); } FileWriter errorOutput = null; if (files.TryGetValue(ERROR_OUTPUT_NAME, out string errorFile)) { if (File.Exists(errorFile)) { File.Delete(errorFile); } errorOutput = new FileWriter(); errorOutput.SetDataDestination(File.Open(errorFile, FileMode.Create, FileAccess.Write, FileShare.Read)); } writer.Value.SetDataDestination(File.Open(file, FileMode.Create, FileAccess.Write, FileShare.Read), errorOutput); } var processor = new Processor(config); processor.ProcessAsync().Wait(); } catch (Exception ex) { Logger.GetLogger().ErrorAsync(ex.Message); hasError = true; } finally { if (hasError) { Logger.GetLogger().ErrorAsync("Execution failed"); result = -1; } Logger.GetLogger().Flush(); } return(result); }
void ShowTreemaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing tree maps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for treemap files."); importCfg.TreemapTag = EGL.TextField("Name postfix", importCfg.TreemapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Treemap file specifications. Please use x^2."); importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("The prototypes to assign. (Current count: " + editorUtilities.TreePrototypes.Count + ")"); EGL.Separator(); EGL.BeginHorizontal(); { if (editorUtilities.TreePrototypes.Count >= 8) { GUI.enabled = false; } if (GUILayout.Button("Add Prototype")) { editorUtilities.TreePrototypes.Add(new TreePrototype()); importCfg.IsDirty = true; // Todo: Nasty } GUI.enabled = true; } EGL.EndHorizontal(); // Show the list EGL.BeginVertical(); { _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { List <TreePrototype> removeThese = new List <TreePrototype>(); int i = 0; foreach (TreePrototype prototype in editorUtilities.TreePrototypes) { if (ShowTreePrototype(prototype, i)) { removeThese.Add(prototype); importCfg.IsDirty = true; // Nasty } i++; } foreach (TreePrototype prototype in removeThese) { editorUtilities.TreePrototypes.Remove(prototype); } } EGL.EndScrollView(); } EGL.EndVertical(); } EGL.EndVertical(); } EGL.EndVertical(); }
public RemoveImporterConfigurationFromProjectCommand(ImporterConfiguration configuration) { _configuration = configuration; CommandType = Assets.Command.CommandTypeDelete; ObjectType = ObjectTypes.ImporterConfiguration; }
public DataFlow(ImporterConfiguration configuration) { try { var stopwatch = new Stopwatch(); stopwatch.Start(); Logger.GetLogger().SetLogginLevel(Logger.LogLevel.Debug); if (configuration.Files.TryGetValue("Error_Output", out string errorPath)) { ErrorOutput.SetOutputTarget(File.Open(errorPath, FileMode.Create, FileAccess.Write, FileShare.Read)); } this.LoadDictionaries(configuration.Files, configuration.Readers).Wait(); this.writers = configuration.Writers.Where(x => !x.Disabled) .Select( x => { if (configuration.Files.TryGetValue(x.Name, out string filePath)) { return(FileWriter.GetFileWriter(File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.Read), x)); } throw new ArgumentOutOfRangeException($"There is no file path defined for \"{x.Name}\""); }) .ToList(); var reader = configuration.Readers.FirstOrDefault(x => !x.Disabled && !DataDictionary.GetDictionaryNames().Contains(x.Name)); if (reader != null) { if (configuration.Files.TryGetValue(reader.Name, out string readerFilePath)) { if (!File.Exists(readerFilePath)) { throw new FileNotFoundException($"File \"{readerFilePath}\" not found"); } using (var fileReader = FileReader.GetFileReader(File.Open(readerFilePath, FileMode.Open, FileAccess.Read, FileShare.Read), reader)) { var cancellationTokenSource = new CancellationTokenSource(); var tasks = new Task[Environment.ProcessorCount]; for (var i = 0; i < Environment.ProcessorCount; i++) { tasks[i] = Task.Run(() => this.WriterTask(cancellationTokenSource.Token)); } foreach (var record in fileReader.ReadData()) { if (this.buffer.Count > MAX_BUFFER_SIZE) { Logger.GetLogger().DebugAsync("Reached record buffer limit"); Thread.Sleep(50); } this.buffer.Add(record); } cancellationTokenSource.Cancel(); Task.WaitAll(tasks); Logger.GetLogger().InfoAsync($"Successfully saved {this.successfulRecordCount} records"); Logger.GetLogger().InfoAsync($"Failed to process {this.exceptionRecordCount} records"); } } } stopwatch.Stop(); Logger.GetLogger() .InfoAsync($"Finished data processing in {stopwatch.Elapsed.Hours:00}:{stopwatch.Elapsed.Minutes:00}:{stopwatch.Elapsed.Seconds:00}.{stopwatch.Elapsed.Milliseconds}"); } finally { ErrorOutput.Flush(); } }
protected override void Context() { base.Context(); sut = Api.GetDataImporterTask(); _configuration = sut.CreateConfiguration(); }