private void AddAsset()
        {
            Console.WriteLine("Adding an asset requires that a city and owner " +
                              "exists in the system first.");
            Console.WriteLine("Would you like to continue? (y,n)");

            if (!(Console.ReadLine().Equals("y")))
            {
                return;
            }

            try
            {
                Owner   owner   = GetAssetOwner();
                Address address = GetAssetAddress();


                if (owner != null && address != null)
                {
                    manager.AddAsset(new Asset
                    {
                        Owner   = owner,
                        Address = address
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error adding asset: {ex}");
            }
        }
Example #2
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load and register resources with the Asset Manager
            var dummyTexture = new Microsoft.Xna.Framework.Graphics.Texture2D(GraphicsDevice, 1, 1);

            dummyTexture.SetData(new[] { Microsoft.Xna.Framework.Color.White });
            _assetManager.AddAsset("dummy", new Texture2D("dummy", dummyTexture, 1, 1));

            var boidTexture = Content.Load <Microsoft.Xna.Framework.Graphics.Texture2D>("boid");

            _assetManager.AddAsset("boid", new Texture2D("boid", boidTexture, boidTexture.Width, boidTexture.Height));

            base.LoadContent();
        }
Example #3
0
        /// <summary>
        /// Apply phrase detection and replace the asset by its phrases.
        /// </summary>
        public override void Do()
        {
            if (m_alAssets == null)
            {
                if (m_boolTime == true)
                {
                    m_alAssets = new ArrayList(m_Asset.ApplyPhraseDetection(m_lThreshold, m_dPhraseLength, m_dBefore));
                }
                else
                {
                    m_alAssets = new ArrayList(m_Asset.ApplyPhraseDetection(m_lThreshold, m_lPhraseLength, m_lBefore));
                }
            }

// Replace original asset in AssetManager with ArrayList assets
            m_Manager.RemoveAsset(m_Asset);

            for (int n = 0; n < m_alAssets.Count; n++)
            {
                m_Manager.AddAsset(m_alAssets [n] as IAudioMediaAsset);
            }
        }
        public async Task <IActionResult> UploadAsset([FromForm] FileModel fileModel)
        {
            if (fileModel == null)
            {
                return(StatusCode(500, "Failed to upload file."));
            }
            try
            {
                string assetId     = Guid.NewGuid().ToString();
                string uploadedURL = await _blobManager.UploadFile(fileModel);

                string metadata = null;
                if (fileModel.AssetType == AssetType.Image)
                {
                    metadata = await _analysisManager.AnalyzeImage(uploadedURL);
                }

                int count = await _assetManager.AddAsset(new Asset()
                {
                    AssetId     = assetId,
                    AssetName   = fileModel.FileName,
                    AssetPath   = uploadedURL.ToString(),
                    MainAssetId = fileModel.AssetId,
                    AssetType   = fileModel.AssetType,
                    Metadata    = metadata
                });

                if (count > 0)
                {
                    return(Ok(uploadedURL));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to save asset"));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
Example #5
0
 /// <summary>
 /// Add the asset again
 /// </summary>
 public override void Undo()
 {
     mAssetManager.AddAsset(mAsset);
 }