public long AddAsset(string title, string filename, long folderId, int languageId, long externalTypeid, byte[] filestream, ContentMetaData[] potentialMeta) { try { assetManager = new AssetManager(); assetManager.ContentLanguage = languageId; if (string.IsNullOrEmpty(userauthHeader.AuthenticationToken)) throw new SoapException("User not logged in", SoapException.ClientFaultCode); this.ImpersonateUser(userauthHeader.AuthenticationToken, assetManager.RequestInformation); ContentAssetData contentassetdata = new ContentAssetData() { FolderId = folderId, Title = title, File = filestream, LanguageId = languageId, ExternalTypeId = externalTypeid, AssetData = new AssetData { FileName = filename }, MetaData = potentialMeta }; return assetManager.Add(contentassetdata).Id; } catch (Exception ex) { throw new SoapException("Error adding an asset:" + ex.Message, SoapException.ClientFaultCode); } }
public ActionResult Create(AssetModel assetModel) { try { // create new Asset object from AssetModel var asset = new Asset { TagNumber = assetModel.TagNumber, AssetTypeId = assetModel.AssetTypeId, //AssetType = AssetTypeManager.GetAssetTypeById(assetModel.AssetTypeId), Manufacturer = assetModel.Manufacturer, Model = assetModel.Model, Description = assetModel.Description, SerialNumber = assetModel.SerialNumber }; // Pass in new Asset object to AssetManager to add into database AssetManager.Add(asset); return(RedirectToAction("Index")); } catch { // simply return if failed return(View()); } }
public IActionResult Create(Asset newAsset) { try { AssetManager.Add(newAsset); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Create(Asset asset) { try { AssetManager.Add(asset); return(RedirectToAction("Search", "Assets")); } catch { return(View()); } }
public IActionResult Create(Asset asset) { try { AssetManager.Add(asset); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Asset asset) { try { // TODO: Add insert logic here AssetManager.Add(asset); return(RedirectToAction(nameof(Index))); } catch { return(View("Error")); } }
public ActionResult Create(Asset asset) { try { // call the Method to add an asset - see Asset manager class AssetManager.Add(asset); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void Build(string manifestFile, string outputFolder) { IEnumerable <IAsset> unresolvedAssets = null; var assets = AssetReader.Read(manifestFile); if (assets?.Any() == true) { foreach (var asset in assets) { _assetManager.Add(asset); unresolvedAssets = _assetManager.EvaluateUnfulfilledComponents(asset); } } if (unresolvedAssets?.Any() == true) { foreach (var asset in unresolvedAssets) { _logger.LogWarning($"Unable to resolve {asset.Type}"); var missingDependencyTypes = asset.Dependencies.Where(d => string.IsNullOrEmpty(d.Key)) .Select(d => d.Type); _logger.LogWarning($"Unresolved components: {string.Join(",", missingDependencyTypes)}"); } } if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } var sortedComponents = _assetManager.GetAllAssetsWithObjPath(); var valueYamlFile = Path.Combine(outputFolder, "values.yaml"); if (File.Exists(valueYamlFile)) { _logger.LogInformation(new FileInfo(valueYamlFile).FullName); File.Delete(valueYamlFile); } using (var writer = new StreamWriter(File.OpenWrite(valueYamlFile))) { foreach (var asset in sortedComponents) { asset.WriteYaml(writer, _assetManager, _loggerFactory); } } }
private void uxOk_Click(object sender, EventArgs e) { if (Asset == null) { // doing an insert Asset = new Asset(); SetAsset(); AssetManager.Add(Asset); } else { // doing an update SetAsset(); AssetManager.Update(Asset); } Close(); }
public async Task <IActionResult> Create([Bind("Id,TagNumber,AssetTypeId,Manufacturer,Model,Description,SerialNumber")] Asset asset) { if (ModelState.IsValid) { try { // TODO: Add insert logic here AssetManager.Add(asset); return(RedirectToAction(nameof(Index))); } catch { return(View(asset)); } } ViewData["AssetTypeId"] = new SelectList(AssetTypeManager.GetAll(), "Id", "Name", asset.AssetTypeId); return(View(asset)); }
public IActionResult AddAsset(Asset asset) { try { //Attempt to add the new object to the database context. AssetManager.Add(asset); //If the update is successful, redirect to index. return(RedirectToAction("Index")); } catch { //If the update fails, reinitialize the asset types DropDownList and return the view. var assetTypes = AssetTypeManager.GetAllAssetTypes(); ViewBag.AssetTypes = assetTypes; return(View()); } }
static void Main() { RenderWindow window = new RenderWindow(new VideoMode(1000, 500), "BattleShips", Styles.Close, new ContextSettings(16, 0, 4)); window.Closed += (sender, eventArg) => window.Close(); LanguageManager.Init("res/lang.json"); LanguageManager.SetCurrent("pl"); AssetManager.Add <Font>("Bungee", @"res/fonts/Bungee-Regular.ttf"); AssetManager.Add <Texture>("SettingsIcon", @"res/img/settingsIcon.png"); AssetManager.Add <Texture>("PlayIcon", @"res/img/playIcon.png"); AssetManager.Add <Texture>("PortBackground", @"res/img/portBackground.png"); InitializeGameStates(window); Stopwatch deltaTimer = new Stopwatch(); float deltaTime = 0; while (window.IsOpen) { deltaTime += deltaTimer.ElapsedMilliseconds; deltaTimer.Restart(); if (deltaTime > 1000 / 60) { deltaTime /= 1000; GameStates.GameStateManager.DeltaTime = deltaTime; GameStates.GameStateManager.Update(window); deltaTime = 0; } window.DispatchEvents(); GameStates.GameStateManager.Show(window); window.Display(); deltaTimer.Stop(); } }
public IActionResult Create(AssetViewModel newAssetMV) { var newAsset = new Asset() { Id = newAssetMV.Id, TagNumber = newAssetMV.TagNumber, AssetTypeId = newAssetMV.AssetTypeId, Manufacturer = newAssetMV.Manufacturer, Model = newAssetMV.Model, Description = newAssetMV.Description, SerialNumber = newAssetMV.SerialNumber }; try { AssetManager.Add(newAsset); return(RedirectToAction("Index", "Home")); } catch { return(View()); } }
/// <summary> /// Creates the asset. /// </summary> /// <param name="assetViewModel">The asset view model.</param> public void CreateAsset(CreateAssetViewModel createAssetViewModel, string uploadPath, int companyId) { try { AssetViewModel assetviewModel = AssetViewModelFactory.CreateAssetViewModelFromCreateAssetViewModel(createAssetViewModel, uploadPath, companyId, FileManager); if (assetviewModel.AssetType == 1) { if (IsYoutubeVideo(assetviewModel)) { assetviewModel = embedYoutubeVideo(assetviewModel); } } Asset asset = AssetViewModelFactory.CreateFromViewModelModel(assetviewModel, ObjectMapper); AssetManager.Add(asset); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } }
public void GenerateCode(string manifestFile, string solutionFolder) { IEnumerable <IAsset> unresolvedAssets = null; var assets = AssetReader.Read(manifestFile); if (assets?.Any() == true) { foreach (var asset in assets) { _assetManager.Add(asset); unresolvedAssets = _assetManager.EvaluateUnfulfilledComponents(asset); } } if (unresolvedAssets?.Any() == true) { foreach (var asset in unresolvedAssets) { _logger.LogWarning($"Unable to resolve {asset.Type}"); var missingDependencyTypes = asset.Dependencies.Where(d => string.IsNullOrEmpty(d.Key)) .Select(d => d.Type); _logger.LogWarning($"Unresolved components: {string.Join(",", missingDependencyTypes)}"); } } var sortedComponents = _assetManager.GetAllAssetsWithObjPath() .Where(c => c.Kind == AssetKind.Code || c.Kind == AssetKind.Shared) .OrderBy(c => c.SortOrder) .ToList(); var validator = new AssetValidator(_assetManager, _loggerFactory); validator.TryToValidateAssets(sortedComponents); // update solution file var product = _assetManager.Get(AssetType.Prodct) as Product; if (product == null) { throw new Exception("Missing dependency [Product]"); } var defaultSolutionFile = Path.Join(solutionFolder, $"{product.Name}.sln"); if (sortedComponents.FirstOrDefault(c => c.Type == AssetType.Service) is Services services) { foreach (var service in services.Items.OfType <Service>()) { service.SolutionFile = service.SolutionFile ?? defaultSolutionFile; } } if (!Directory.Exists(solutionFolder)) { Directory.CreateDirectory(solutionFolder); } var zipFilePath = Path.Join("Evidence", "solution.zip"); if (!File.Exists(zipFilePath)) { throw new Exception($"Unable to find solution bundle: {new FileInfo(zipFilePath).FullName}"); } ZipFile.ExtractToDirectory(zipFilePath, solutionFolder, true); var solutionFile = Directory.GetFiles(solutionFolder, "*.sln", SearchOption.TopDirectoryOnly) .FirstOrDefault(); if (!string.IsNullOrEmpty(solutionFile)) { File.Copy(solutionFile, defaultSolutionFile, true); File.Delete(solutionFile); } var manifestYamlFile = Path.Combine(solutionFolder, "services.yaml"); _logger.LogInformation($"Set manifest file to '{new FileInfo(manifestYamlFile).FullName}'"); if (File.Exists(manifestYamlFile)) { File.Delete(manifestYamlFile); } using (var writer = new StreamWriter(File.OpenWrite(manifestYamlFile))) { foreach (var asset in sortedComponents) { asset.WriteYaml(writer, _assetManager, _loggerFactory); } } // replace "True" and "False" var yamlContent = File.ReadAllText(manifestYamlFile); var trueRegex = new Regex("\\bTrue\\b"); yamlContent = trueRegex.Replace(yamlContent, "true"); var falseRegex = new Regex("\\bFalse\\b"); yamlContent = falseRegex.Replace(yamlContent, "false"); File.WriteAllText(manifestYamlFile, yamlContent); }
private void LoadEngineContent() { EngineContent = new ContentLoader(Content.ServiceProvider, "EngineContent", "Data/_MAIN/Content/"); if (Screen.IsFullHeadless) { return; } // Particle shader. AssetManager.Add(new AssetBuilder <Effect>() .ID("testshader") .Create(new GeneralContentProcessor <Effect>("EngineContent", "shader")) .FromContent(EngineContent) ); // Texture2Ds AssetManager.Add(new AssetBuilder <Texture2D>() .ID("tileset") .Create(new GeneralContentProcessor <Texture2D>("EngineContent", "Images/tileset")) .FromContent(EngineContent) ); AssetManager.Add(new AssetBuilder <Texture2D>() .ID("UI") .Create(new GeneralContentProcessor <Texture2D>("EngineContent", "UI")) .FromContent(EngineContent) ); AssetManager.Add(new AssetBuilder <Texture2D>() .ID("EditorUI") .Create(new GeneralContentProcessor <Texture2D>("EngineContent", "EditorUI")) .FromContent(EngineContent) ); // Sprite Textures AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("uiRect") .Create(new SpriteTextureProcessor("tileset", new Rectangle(0, 0, 64, 64))) .FromContent(EngineContent) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("leveleditorcursor") .Create(new SpriteTextureProcessor("tileset", new Rectangle(0, 64, 64, 64))) .FromContent(EngineContent) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("debugsmallsquare") .Create(new SpriteTextureProcessor("tileset", new Rectangle(0, 128, 16, 16))) .FromContent(EngineContent) ); // Sprite Fonts AssetManager.Add(new AssetBuilder <SpriteFont>() .ID("editor") .Create(new GeneralContentProcessor <SpriteFont>("EngineContent", "fonts/editor")) .FromContent(EngineContent) ); AssetManager.Add(new AssetBuilder <SpriteFont>() .ID("editor_subheading") .Create(new GeneralContentProcessor <SpriteFont>("EngineContent", "fonts/editor")) .FromContent(EngineContent) ); AssetManager.Add(new AssetBuilder <SpriteFont>() .ID("editor_heading") .Create(new GeneralContentProcessor <SpriteFont>("EngineContent", "fonts/editor_heading")) .FromContent(EngineContent) ); }
public void Add_NullAsset_ThrowsException() { _assetManager.Add(null, null); }
protected override void LoadAssets() { base.LoadAssets(); content = new ContentLoader(Content.ServiceProvider, "Content1", "Data/_MAIN/Content"); ContentLoader content2 = new ContentLoader(Content.ServiceProvider, "Content2", "Data/_MAIN/Content"); if (!Screen.IsFullHeadless) { AssetManager.Add(new AssetBuilder <Texture2D>() .ID("tileset2") .Create(new GeneralContentProcessor <Texture2D>("Content1", "Images/tileset2")) .FromContent(content2) ); AssetManager.Add(new AssetBuilder <Texture2D>() .ID("Smoke") .Create(new GeneralContentProcessor <Texture2D>("Content1", "Images/Smoke")) .FromContent(content) ); } AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("unload_test") .Create(new SpriteTextureProcessor("tileset2", new Rectangle(0, 0, 64, 64))) .FromContent(content2) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("floor") .Create(new SpriteTextureProcessor("tileset", new Rectangle(0, 0, 64, 64))) .FromContent(content) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("wall_down") .Create(new SpriteTextureProcessor("tileset", new Rectangle(64, 48, 64, 16))) .FromContent(content) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("wall_left") .Create(new SpriteTextureProcessor("tileset", new Rectangle(128, 0, 16, 64))) .FromContent(content) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("wall_right") .Create(new SpriteTextureProcessor("tileset", new Rectangle(240, 0, 16, 64))) .FromContent(content) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("wall_up") .Create(new SpriteTextureProcessor("tileset", new Rectangle(256, 0, 64, 16))) .FromContent(content) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("player") .Create(new SpriteTextureProcessor("tileset", new Rectangle(0, 0, 52, 52))) .FromContent(content) ); AssetManager.Add(new AssetBuilder <SpriteTexture>() .ID("circle") .Create(new SpriteTextureProcessor("tileset", new Rectangle(0, 128, 32, 32))) .FromContent(content) ); if (!Screen.IsFullHeadless) { AssetManager.Add(new AssetBuilder <SoundEffect>() .ID("assaultrifle") .Create(new GeneralContentProcessor <SoundEffect>("Content1", "assaultrifle")) .FromContent(content) ); } AssetManager.Add(new AssetBuilder <Func <Vector2, GameObject> >() .ID("0") .Create(new TileProcessor(pos => { Floor obj = new Floor(pos, 0f, Vector2.One); obj.GetComponent <Sprite>().Color = Color.White; return(obj); })) .FromContent(content) ); AssetManager.Add(new AssetBuilder <Func <Vector2, GameObject> >() .ID("1") .Create(new TileProcessor(pos => { WallUp obj = new WallUp(pos, 0f, Vector2.One); obj.GetComponent <Sprite>().Color = Color.Red; return(obj); })) .FromContent(content) ); AssetManager.Add(new AssetBuilder <Func <Vector2, GameObject> >() .ID("2") .Create(new TileProcessor(pos => { WallRight obj = new WallRight(pos, 0f, Vector2.One); obj.GetComponent <Sprite>().Color = Color.Blue; return(obj); })) .FromContent(content) ); AssetManager.Add(new AssetBuilder <Func <Vector2, GameObject> >() .ID("3") .Create(new TileProcessor(pos => { WallDown obj = new WallDown(pos, 0f, Vector2.One); obj.GetComponent <Sprite>().Color = Color.Orange; return(obj); })) .FromContent(content) ); AssetManager.Add(new AssetBuilder <Func <Vector2, GameObject> >() .ID("4") .Create(new TileProcessor(pos => { WallLeft obj = new WallLeft(pos, 0f, Vector2.One); obj.GetComponent <Sprite>().Color = Color.Purple; return(obj); })) .FromContent(content) ); AssetManager.Add(new AssetBuilder <Func <Vector2, GameObject> >() .ID("5") .Create(new TileProcessor(pos => { AnimatedFloor obj = new AnimatedFloor(pos, 0f, Vector2.One); obj.GetComponent <Sprite>().Color = Color.White; return(obj); })) .FromContent(content) ); //for (int i = 0; i < 50; i++) { // Database.Add<int, Func<Vector2, GameObject>>(6+i, pos => { // AnimatedFloor obj = new AnimatedFloor(pos, 0f, Vector2.One); // //obj.GetComponent<Sprite>().Color = Color.White; // return obj; // }); //} }
public string GetAssetContentQuickLink(string filename, string title, int languageid, long contentid, long folderid, byte[] filestream) { if (string.IsNullOrEmpty(userauthHeader.AuthenticationToken)) throw new SoapException("User not logged in", SoapException.ClientFaultCode); assetManager = new AssetManager(); assetManager.ContentLanguage = languageid; this.ImpersonateUser(userauthHeader.AuthenticationToken, assetManager.RequestInformation); if (contentid > 0) { ContentAssetData contentassetdata = assetManager.GetItem(contentid, true); if (contentassetdata == null) throw new SoapException("Error Updating Asset", SoapException.ClientFaultCode); contentassetdata.Title = title; contentassetdata.File = filestream; contentassetdata.AssetData.FileName = filename; contentassetdata.LanguageId = languageid; return assetManager.GetItem((assetManager.Update(contentassetdata).Id)).Quicklink; } else { ContentAssetData contentassetdata = new ContentAssetData() { FolderId = folderid, Title = title, File = filestream, LanguageId = languageid, AssetData = new AssetData { FileName = filename } }; return assetManager.GetItem((assetManager.Add(contentassetdata).Id)).Quicklink; } }
public void BuildInfraSetupScript(string manifestFile, string outputFolder) { IEnumerable <IAsset> unresolvedAssets = null; var assets = AssetReader.Read(manifestFile); if (assets?.Any() == true) { foreach (var asset in assets) { _assetManager.Add(asset); unresolvedAssets = _assetManager.EvaluateUnfulfilledComponents(asset); } } if (unresolvedAssets?.Any() == true) { foreach (var asset in unresolvedAssets) { _logger.LogWarning($"Unable to resolve {asset.Type}"); var missingDependencyTypes = asset.Dependencies.Where(d => string.IsNullOrEmpty(d.Key)) .Select(d => d.Type); _logger.LogWarning($"Unresolved components: {string.Join(",", missingDependencyTypes)}"); } } var sortedComponents = _assetManager.GetAllAssetsWithObjPath() .Where(c => c.Kind == AssetKind.Infra || c.Kind == AssetKind.Shared) .OrderBy(c => c.SortOrder) .ToList(); var validator = new AssetValidator(_assetManager, _loggerFactory); validator.TryToValidateAssets(sortedComponents); var envName = "dev"; var spaceName = Environment.UserName; if (sortedComponents.FirstOrDefault(c => c.Type == AssetType.Global) is Global global) { envName = global.EnvName; spaceName = global.SpaceName; } if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } var envFolder = Path.Join(outputFolder, "env", envName); if (!Directory.Exists(envFolder)) { Directory.CreateDirectory(envFolder); } var spaceFolder = envFolder; if (!string.IsNullOrEmpty(spaceName)) { spaceFolder = Path.Join(envFolder, spaceName); } if (!Directory.Exists(spaceFolder)) { Directory.CreateDirectory(spaceFolder); } var zipFilePath = Path.Join("Evidence", "scripts.zip"); if (!File.Exists(zipFilePath)) { throw new Exception($"Unable to find script bundle: {new FileInfo(zipFilePath).FullName}"); } ZipFile.ExtractToDirectory(zipFilePath, outputFolder, true); var valueYamlFile = Path.Combine(spaceFolder, "values.yaml"); _logger.LogInformation($"Set values yaml file to '{new FileInfo(valueYamlFile).FullName}'"); if (File.Exists(valueYamlFile)) { File.Delete(valueYamlFile); } using (var writer = new StreamWriter(File.OpenWrite(valueYamlFile))) { foreach (var asset in sortedComponents) { asset.WriteYaml(writer, _assetManager, _loggerFactory); } } // replace "True" and "False" var yamlContent = File.ReadAllText(valueYamlFile); var trueRegex = new Regex("\\bTrue\\b"); yamlContent = trueRegex.Replace(yamlContent, "true"); var falseRegex = new Regex("\\bFalse\\b"); yamlContent = falseRegex.Replace(yamlContent, "false"); File.WriteAllText(valueYamlFile, yamlContent); }