Пример #1
0
        public async Task SendTelemetry([Microsoft.AspNetCore.Mvc.FromBody] TelemetrySendViewModel model) // Activity ID
        {
            if (!Program.UseShSend || !ModelState.IsValid)
            {
                return;
            }

            var imageUrl           = "";
            var telemetrySendModel = model;
            var blobStorage        = new BlobManager(_configuration["StorageConnectionString"]);

            if (telemetrySendModel.Image.Length > 0)
            {
                var imageData = Convert.FromBase64String(FixBase64(telemetrySendModel.Image));
                imageUrl = blobStorage.UploadByteBlob(
                    blobStorage.GetContainerReference(_configuration["BlobContainerName"]),
                    $"{telemetrySendModel.IdActivity}/{telemetrySendModel.IdUser}/{DateTime.Now}_{new Random().Next(0, 20)}.png",
                    "image/png",
                    imageData
                    ).GetAwaiter().GetResult();
            }


            _telemetryRepository.Insert(new Telemetry()
            {
                //      Id = 0,
                Longitude  = telemetrySendModel.Longitude,
                Latitude   = telemetrySendModel.Latitude,
                IdActivity = telemetrySendModel.IdActivity,
                IdUser     = telemetrySendModel.IdUser,
                ImageUrl   = imageUrl,
                Instant    = telemetrySendModel.Instant
            });
        }
Пример #2
0
    private string UpdateImage(string resourceId)
    {
        string updated = "";

        try
        {
            if (fuDocFirma.HasFile)
            {
                BlobManager manager = new BlobManager();
                if (resourceId != "")
                {
                    if (manager.DeleteByResourceId(resourceId))
                    {
                        updated = UploadImage();
                    }
                }
                else
                {
                    updated = UploadImage();
                }
            }
            else
            {
                updated = resourceId;
            }

            return(updated);
        }
        catch (Exception ex)
        {
            lblEstatusCarga.Text = "Error: El archivo no se pudo cargar: " + ex.Message;
            return(ex.Message);
        }
    }
Пример #3
0
    private string UploadImage()
    {
        string uploaded = "";

        try
        {
            if (fuDocFirma.HasFile)
            {
                dynamic dinfuDocFirma = fuDocFirma;

                string filename = Path.GetFileName(dinfuDocFirma.FileName);
                IList <HttpPostedFile> postedfile = dinfuDocFirma.PostedFiles;

                BlobManager manager = new BlobManager();

                string ImageUploaded = manager.UploadImage(postedfile);

                lblEstatusCarga.Text = "Imagen Adjunta: " + ImageUploaded;
                uploaded             = ImageUploaded;
            }
            return(uploaded);
        }
        catch (Exception ex)
        {
            lblEstatusCarga.Text = "Error: El archivo no se pudo cargar: " + ex.Message;
            return(ex.Message);
        }
    }
Пример #4
0
        public ActionResult List()
        {
            BlobManager     BManagerObj = new BlobManager("ArohiEmployeeTable");
            List <Employee> EmpListObj  = BManagerObj.RetrieveEntity <Employee>();

            return(View(EmpListObj));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    BlobManager        blobManager = new BlobManager();
                    CloudBlobContainer container   = blobManager.GetOrCreateBlobContainer(model.Email);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "PublicContent"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public void AddEditDeleteTest()
        {
            // Arrange
            IBlobManager blobManager       = new BlobManager(new ConfigManagerHelper());
            var          blobContainerName = Guid.NewGuid().ToString();
            var          blobFileName      = Guid.NewGuid().ToString();
            var          blobData          = Guid.NewGuid().ToString();

            // Act
            blobManager.AddOrUpdateBlobData(blobContainerName, blobFileName, blobData);
            string blobDataRetrieved;

            using (var blobDataStream = blobManager.GetBlobStream(blobContainerName, blobFileName))
            {
                blobDataStream.Position = 0;
                using (var reader = new StreamReader(blobDataStream, Encoding.UTF8))
                {
                    blobDataRetrieved = reader.ReadToEnd();
                }
            }
            // Cleanup
            blobManager.DeleteBlobData(blobContainerName, blobFileName);
            var blobExists = blobManager.BlobExists(blobContainerName, blobFileName);

            // Assert
            Assert.AreEqual(blobData, blobDataRetrieved);
            Assert.IsFalse(blobExists);
        }
Пример #7
0
        private static async Task RunBlobManagerTests(CloudStorageAccount storageAccount, string containerName, CancellationToken cancellationToken)
        {
            var blobManager = new BlobManager(containerName, storageAccount);

            await blobManager.CopyBlobAsync("test1.txt", "test1 - Copy of.txt", cancellationToken).ConfigureAwait(false);

            await blobManager.CopyBlobAsync("test2.txt", "test2 - Copy of.txt", cancellationToken).ConfigureAwait(false);

            await blobManager.UploadTextAsync("test4.txt", "Hello World", cancellationToken : cancellationToken).ConfigureAwait(false);

            await blobManager.AppendTextAsync("test4.txt", "\r\nqwerty", cancellationToken : cancellationToken).ConfigureAwait(false);

            await blobManager.AppendTextAsync("test4.txt", "\r\nazerty", cancellationToken : cancellationToken).ConfigureAwait(false);

            var blobs = await blobManager.ListBlobsAsync("test1", false, false, null, cancellationToken).ConfigureAwait(false);

            foreach (var blob in blobs)
            {
                Console.WriteLine(blob.Uri.AbsoluteUri);
            }

            await blobManager.DeleteBlobAsync("test1 - Copy of.txt", cancellationToken).ConfigureAwait(false);

            await blobManager.DeleteBlobAsync("test2 - Copy of.txt", cancellationToken).ConfigureAwait(false);

            await blobManager.DeleteBlobsWithPrefixAsync("test", cancellationToken).ConfigureAwait(false);
        }
        /// <summary>
        /// This function gets all of the users public files and uses it to populate
        /// a list of FileUIInfo objects. It then returns that list to the caller.
        /// requests only.
        /// <returns>
        /// A List of FileUIInfo objects corresponding to the users public files
        /// </returns>
        private List <Common.FileUIInfo> GetPublicFiles()
        {
            int         index;
            BlobManager blob = new BlobManager();
            List <Common.FileUIInfo> publicFileList    = blob.ListPublicBlobInfoForUI();
            List <Common.FileUIInfo> publicFileObjects = new List <Common.FileUIInfo>();

            foreach (Common.FileUIInfo x in publicFileList)
            {
                if (!x.FileName.Contains(".zip"))
                {
                    if (x.Author == User.Identity.Name)
                    {
                        index      = x.FileName.LastIndexOf(".");
                        x.FileName = x.FileName.Substring(0, index);

                        index        = x.Author.IndexOf('@');
                        x.Author     = x.Author.Substring(0, index);
                        x.UploadDate = x.UploadDate.ToLocalTime();

                        publicFileObjects.Add(x);
                    }
                }
            }
            return(publicFileObjects);
        }
Пример #9
0
        public void BlobManagerTest()
        {
            // Arrange
            var hostFileService   = new HostFileService();
            var fileDirectoryPath = hostFileService.SubdirectoryPath($"Files");
            var fileName          = "TestFile.csv";
            var TestFileData      = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(fileDirectoryPath, fileName)));
            var blobName          = fileName;
            var blobManager       = new BlobManager(
                "testfiles",
                "AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"
                );
            //var blobManager = new BlobManager(
            //    "testfiles",
            //    "DefaultEndpointsProtocol=https;AccountName=latvianvillagestorage;AccountKey=bgsc7zZEExRz0VPe56FOc/xRNxbTfZjv8A9JM6KTHwsXSwQQvhF8c2NQAFiuPi2qdQ0+43GDHmNH8Whncp4Jsg==;EndpointSuffix=core.windows.net;"
            //);
            // Act
            var isSuccessfullyStored = blobManager.StoreAsync(fileName, TestFileData).GetAwaiter().GetResult();

            // Assert
            Assert.IsTrue(isSuccessfullyStored, $"BlobManagerTest: BlobManager.StoreAsync failed for blob named: { fileName }.");
            var savedContents = blobManager.GetContentsAsync(fileName).GetAwaiter().GetResult();

            Assert.IsTrue(!string.IsNullOrEmpty(savedContents), $"BlobManagerTest: BlobManager.GetAsync failed for blob named: { fileName }.");
            var isBlobDeleted = blobManager.DeleteAsync(fileName).GetAwaiter().GetResult();

            Assert.IsTrue(isBlobDeleted, $"BlobManagerTest: BlobManager.ExistsAsync indicated that blob named: { fileName } was not deleted.");
        }
        public async Task <IActionResult> IndexAsync()
        {
            if (HttpContext.Request.Form.Files != null)
            {
                var files = HttpContext.Request.Form.Files;
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        var result = await BlobManager.AddImageAsync(file.FileName, file);

                        if (result.Successfull)
                        {
                        }
                    }
                }
            }

            /*CosmosManager.ImageDataCollection.InsertOne(new ImageDataModel
             * {
             *  FileName = file.FileName,
             *  FileSize = int.Parse(file.Length.ToString()),
             *  FileType = file.ContentType,
             *  ImageUrl = (String) result.Payload,
             *  LastModified = DateTime.Now.ToString()
             * }); ;
             * }
             * }
             * }
             * }
             * var mongoCollection = CosmosManager.ImageDataCollection;
             * var findResult = CosmosManager.ImageDataCollection.Find(e => e.Id != null).ToList();
             * return View(findResult);*/
            return(View());
        }
    internal void OnTriggerEnter(Collider other)
    {
        var carryObject = other.GetComponent <CarryObject>();

        if (carryObject != null)
        {
            SuckUp(carryObject);
            return;
        }

        var blob = other.GetComponent <BlobBase>();

        if (blob != null && blob.State == BlobState.GoingToTube)
        {
            SuckUp(blob.transform);
            blob.PlayThrowSound();
            BlobManager.ForgetBlob(blob);
            return;
        }

        var player = other.GetComponent <PlayerController>();

        if (player != null)
        {
            managerDisplay.gameObject.SetActive(true);
            managerDisplay.ActivateForPlayer(player);
            return;
        }
    }
Пример #12
0
 public virtual void OnDeath()
 {
     blobAnimator.SetBool("isDead", true);
     BlobManager.ForgetBlob(this);
     currentInteractable?.RemoveBlob(this);
     controller.RemoveBlobFromFollowers(this);
 }
 public void AddBlob()
 {
     if (BlobManager.CallBlob(currentBlobType))
     {
         tube.SpawnBlob(currentBlobType, player, UpdateButtons);
     }
 }
Пример #14
0
        //GET: /api/roomTypes/upload?id=1
        public async Task <IActionResult> UploadUserProfilePic(int id, IFormFile newFile)
        {
            _blobManager = new BlobManager(Configuration);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int currentRoomTypeId = id;

            var currentRoomType = await _context.RoomType.FindAsync(currentRoomTypeId);


            if (newFile != null)
            {
                Stream filestreamFromRequest = newFile.OpenReadStream();
                currentRoomType.Photo = await _blobManager.UploadFileToStorageAsync(filestreamFromRequest, "room_type_" + currentRoomType.Id.ToString() + ".jpg");
            }
            else
            {
                return(BadRequest());
            }


            _context.Entry(currentRoomType).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Пример #15
0
        public async Task <IActionResult> Create(CategoryModel categoryModel, IFormFile ThumbnailFile)
        {
            if (ModelState.IsValid && ThumbnailFile != null && ThumbnailFile.Length > 0)
            {
                categoryModel.Thumbnail =
                    await BlobManager.SaveBlob(_context, ThumbnailFile);

                _context.Add(categoryModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            foreach (var value in ModelState.Values)
            {
                foreach (var error in value.Errors)
                {
                    ViewData["Error"] += error.ErrorMessage + ";";
                }
            }

            if (ThumbnailFile == null || ThumbnailFile.Length == 0)
            {
                ViewData["Error"] += "No Thumbnail;";
            }
            return(View(categoryModel));
        }
Пример #16
0
        protected override object ProcessCommand(Infragistics.Guidance.Aqua.Model.Framework.CommandCriteria criteria)
        {
            accountName         = ConfigurationManager.AppSettings["AccountName"].ToString();
            sharedKey           = ConfigurationManager.AppSettings["SharedKey"].ToString();
            blobStorageEndPoint = ConfigurationManager.AppSettings["BlobStorageEndPoint"].ToString();
            string      container   = "medicalimages";
            BlobManager blobManager = new BlobManager();
            var         blobs       = blobManager.ListBlobs(container, blobStorageEndPoint, accountName, sharedKey);
            IEnumerator e           = blobs.GetEnumerator();
            DiagnosisLibraryItemCollection libraryItems = new DiagnosisLibraryItemCollection();

            while (e.MoveNext())
            {
                DiagnosisLibraryItem libraryItem = new DiagnosisLibraryItem
                {
                    ContentType      = ((BlobProperties)e.Current).ContentType,
                    ItemUri          = ((BlobProperties)e.Current).Uri,
                    Name             = ((BlobProperties)e.Current).Name,
                    LastModifiedTime = ((BlobProperties)e.Current).LastModifiedTime
                };
                libraryItems.Add(libraryItem);
            }

            return(libraryItems);
        }
Пример #17
0
        public async Task <IHttpActionResult> DeleteQuestionnaireAnswerAsync(string answerId)
        {
            bool result = await _answersRepository.DeleteEntityAsync(answerId);

            if (!result)
            {
                return(NotFound());
            }


            var documents = await _entitiesDb.FormDocuments.Where(b => b.FormId.ToString() == answerId).ToListAsync();

            if (documents.Count > 0)
            {
                _entitiesDb.FormDocuments.RemoveRange(documents);

                foreach (var document in documents)
                {
                    await BlobManager.DeleteFileAsync(document.Name);
                }

                await _entitiesDb.SaveChangesAsync();
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #18
0
    // Start is called before the first frame update
    void Start()
    {
        manager = GetComponent <BlobManager>();

        spawnedObjs = new List <GameObject>();
        Generate();
    }
Пример #19
0
    public void applyActions(BlobManager blobManager)
    {
        /*
        when a blob is in the process of moving its voxels to another blob, it keeps track
        of actions made to it like setCorrupt and setBroken, so it can apply them to the new blob
        as well once it finishes building.
        */
        IntVector3 blobPosition = blobManager.getRealPosition ();
        IntVector3 offset = new IntVector3 (blobPosition.x - getRealPosition ().x,
            blobPosition.y - getRealPosition ().y,
            blobPosition.z - getRealPosition ().z);
        /*
        Debug.Log ("applyActions blobPosition: "+ZTools.toString(blobPosition));
        Debug.Log ("applyActions position: "+ZTools.toString(position));
        Debug.Log ("applyActions getRealPosition: "+ZTools.toString(getRealPosition()));
        */
        foreach (BlobAction action in blobManager.blobActions) {
            IntVector3 point = new IntVector3 (action.point.x + offset.x,
            action.point.y + offset.y,
            action.point.z + offset.z);

            if (action.action == "setBroken") {
                //Debug.Log("zz setBroken "+iOffset+" joff "+jOffset+" koff "+kOffset);
                setBroken (point);
                continue;
            }
            if (action.action == "setCorrupt") {
                //Debug.Log("ioff "+iOffset+" joff "+jOffset+" koff "+kOffset);
                setCorrupt (point);
                continue;
            }
        }

        blobManager.blobActions = new ArrayList ();
    }
Пример #20
0
        /// <summary>
        /// This function gets all of the files labeled public and uses it to populate
        /// a list of FileUIInfo objects. It then returns that list to the caller.
        /// requests only.
        /// <returns>
        /// A List of FileUIInfo objects corresponding to all public files
        /// </returns>
        private List <Common.FileUIInfo> GetPublicFiles()
        {
            int               index;
            BlobManager       blob        = new BlobManager();
            var               fileList    = blob.ListPublicBlobInfoForUI();
            List <FileUIInfo> fileObjects = new List <FileUIInfo>();

            foreach (FileUIInfo info in fileList)
            {
                if (!info.FileName.Contains(".zip"))
                {
                    //remove file extension from file
                    index = info.FileName.LastIndexOf(".");
                    if (index >= 0)
                    {
                        info.FileName = info.FileName.Substring(0, index);
                    }

                    index = info.Author.IndexOf('@');

                    if (index >= 0)
                    {
                        info.Author = info.Author.Substring(0, index);
                    }

                    info.UploadDate = info.UploadDate.ToLocalTime();

                    fileObjects.Add(info);
                }
            }
            return(fileObjects);
        }
Пример #21
0
        public ActionResult Get()
        {
            BlobManager   blobManager = new BlobManager("picture");
            List <string> _blobList   = blobManager.BlobList();

            return(View(_blobList));
        }
Пример #22
0
        public void GetBlobContentAsync_blob_does_not_exist()
        {
            // Arrange
            var containerName     = "mycontainer";
            var mockBlobContainer = Misc.GetMockBlobContainer(containerName);
            var mockBlobClient    = Misc.GetMockBlobClient(mockBlobContainer);
            var storageAccount    = Misc.GetMockStorageAccount(mockBlobClient, null);
            var blobName          = "myblob.txt";
            var mockBlobUri       = new Uri(Misc.BLOB_STORAGE_URL + blobName);

            var mockBlob = new Mock <CloudBlockBlob>(MockBehavior.Strict, mockBlobUri);

            mockBlob
            .Setup(b => b.ExistsAsync(It.IsAny <BlobRequestOptions>(), It.IsAny <OperationContext>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(false)
            .Verifiable();

            mockBlobContainer
            .Setup(c => c.GetBlobReference(blobName))
            .Returns(mockBlob.Object)
            .Verifiable();

            // Act
            var blobManager = new BlobManager(containerName, storageAccount.Object);
            var result      = blobManager.GetBlobContentAsync(blobName, CancellationToken.None);

            result.Wait();
            var content = result.Result;

            // Assert
            mockBlobContainer.Verify();
            mockBlobClient.Verify();
            mockBlob.Verify();
            content.ShouldBeNull();
        }
Пример #23
0
        //GET: /api/hotels/upload
        public async Task <IActionResult> UploadUserProfilePic(IFormFile newFile)
        {
            _blobManager = new BlobManager(Configuration);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string userId = User.Claims.First(c => c.Type == "UserID").Value;

            var partner = await _context.Partner.FindAsync(userId);

            var hotel = await _context.Hotel.FindAsync(partner.HotelId);


            if (newFile != null)
            {
                Stream filestreamFromRequest = newFile.OpenReadStream();
                hotel.Photo = await _blobManager.UploadFileToStorageAsync(filestreamFromRequest, "hotel_" + hotel.Id.ToString() + ".jpg");
            }
            else
            {
                return(BadRequest());
            }


            _context.Entry(hotel).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Пример #24
0
        /// <summary>
        /// Attempt to upload the file to Azure Blob storage from temporary local storage.
        /// </summary>
        /// <param name="fileName">The name of the file stored in temporary local storage.</param>
        /// <param name="altFileName">The name to save the file as in Azure Blob storage.</param>
        /// <param name="subDir">The subdirectory that the file has been temporarily stored in.</param>
        /// <param name="description">The user-provided description of the file.</param>
        /// <param name="publicFile">Whether the file should be made publicly available or not.</param>
        /// <param name="overwrite">
        ///     Whether a file with the same name in Azure Blob storage should be overwritten or not.
        ///     The default value for this parameter is false.
        /// </param>
        private void UploadToBlob(string fileName, string altFileName, string subDir, string description, bool publicFile, bool overwrite = false)
        {
            BlobManager blobManager = new BlobManager();
            string      path        = Path.Combine(s_BasePath, subDir);
            string      fileNoExt   = fileName.Substring(0, fileName.LastIndexOf('.'));

            try
            {
                //convert, upload, delete converted, delete original
                if (!string.IsNullOrEmpty(altFileName))
                {
                    //rename converted file to provided altFileName
                    System.IO.File.Move(Path.Combine(path, $"{fileNoExt}.fbx"), Path.Combine(path, $"{altFileName}.fbx"));
                    fileNoExt = altFileName;
                }

                if (publicFile)
                {
                    if (!blobManager.UploadBlobToPublicContainer(User.Identity.Name, $"{fileNoExt}.fbx", path, description, overwrite))
                    {
                        ViewBag.FileExists = fileName;
                    }
                }
                else
                {
                    if (!blobManager.UploadBlobToUserContainer(User.Identity.Name, $"{fileNoExt}.fbx", path, description, overwrite))
                    {
                        ViewBag.FileExists = fileName;
                    }
                }
            }
            catch { ViewBag.Message = "File upload failed."; }
        }
 public async Task<string> PostAsync(IFormFile file)
 {
     
     BlobManager manager =new BlobManager();
     var imageUrl = manager.UploadImageAsBlob(file);
     return await imageUrl;
 }
Пример #26
0
        //public static void TransferTokenFrontTest(string FromAddress_Buyer, string ToAddress_Owner, string Amount)
        //{
        //    Task task = System.Threading.Tasks.Task.Run(async () => await (DoTransaction(FromAddress_Buyer, ToAddress_Owner, Amount)));
        //}

        public async static Task <CreateWalletModel> CreateUserWallet()
        {
            ITrace            telemetria   = new Trace();
            CreateWalletModel _walletModel = new CreateWalletModel();

            try
            {
                //Generate RandomPassword
                string _passphrase = Guid.NewGuid().ToString().Replace("-", "") + GetRandomNumber(1842).ToString();

                string _blobname = BlobManager.CreateUsrWalletBlobFile(_passphrase, ConfigurationManager.AppSettings["azure-storage-connectionstring"]);

                var web3           = new Nethereum.Web3.Web3(ConfigurationManager.AppSettings["BlockchainURL"]);
                var _walletAddress = await web3.Personal.NewAccount.SendRequestAsync(_passphrase);

                _walletModel = new CreateWalletModel()
                {
                    blobname = _blobname, walletaddress = _walletAddress
                };
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }

            return(_walletModel);
        }
Пример #27
0
        public async Task <Response <AppFileModel> > Save([FromBody] AppFileModel appFileModel)
        {
            Response <AppFileModel> appFileModelResponse = new Response <AppFileModel>();

            try
            {
                AppFile appFile = _mapper.Map <AppFile>(appFileModel);

                BlobManager <AppFile> manager   = new BlobManager <AppFile>();
                CloudBlobContainer    container = await manager.CreateFolderAsync(appFile);

                if (string.IsNullOrEmpty(appFile.BlobPath))
                {
                    CloudBlockBlob cloudBlockBlob = await manager.UploadFileAsync(container, appFile);

                    appFile.BlobPath = $"{cloudBlockBlob.Parent.Prefix}";
                    appFile.BlobPath = $"{ Configuration.ConfigurationManager.Instance.GetValue("FileUploadBlobContainer")}/{appFile.BlobPath.Substring(0, appFile.BlobPath.Length - 1) }";
                }

                appFile = await(appFileModel.Id != Guid.Empty ? _appFile.UpdateAsync(appFile) : _appFile.AddAsync(appFile));
                AppFileModel model = _mapper.Map <AppFileModel>(appFile);
                appFileModelResponse.Value = model;
            }
            catch (Exception ex)
            {
                appFileModelResponse.Exception = ex;
                appFileModelResponse.IsSuccess = false;
            }
            return(appFileModelResponse);
        }
Пример #28
0
        public ImageService()
        {
            var connectionString = "DefaultEndpointsProtocol=https;AccountName=sportapp;AccountKey=iObMXhyrN6dbB6tIcWWqJr0Z48r" +
                                   "UubSPnYnxefhbF4Ek5UnKCvEgG0/12X/cNjdcZ2/iephB4jUcAch3ve3azA==;EndpointSuffix=core.windows.net";

            manager = new BlobManager(connectionString, "images");
        }
 public void Update()
 {
     currentHealthText.text      = destructablePlayer.CurrentHealth.ToString();
     fieldBlobCountText.text     = BlobManager.GetBlobsInFieldCount().ToString();
     reserveBlobCountText.text   = BlobManager.GetCurrentReserveCount().ToString();
     followingBlobCountText.text = player.followingBlobs.Count.ToString();
 }
        public async void Post([FromBody] ImageMediaModels value, string diagramid)
        {
            string ImageName = value.FileName.ToLower();
            string UserId    = UserHelper.GetCurrentUserID().ToLower();
            string DiagramId = diagramid.ToLower();

            string       Blobname = UserId + "/" + DiagramId + "/" + ImageName;
            MemoryStream stream   = new MemoryStream(value.Buffer);

            try
            {
                if (!BlobManager.ImageExists(Blobname))
                {
                    await BlobManager.UploadImage(stream, Blobname);
                }
            }
            catch (Exception Ex)
            {
                string Err      = string.Format("Unable to upload the image {0}", value.FileName);
                var    response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Err);
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
                Log.LogError("ImageAPI: Unable to upload image {0}, Error: {1}", value.FileName, Ex.Message);
                throw new HttpResponseException(response);
            }
        }
Пример #31
0
        public ActionResult Index(FormCollection formData, HttpPostedFileBase uploadFile)
        {
            foreach (string file in Request.Files)
            {
                uploadFile = Request.Files[file];
            }


            string EmpFName = formData["EmpFName"];
            string EmpLName = formData["EmpLName"];

            if (!String.IsNullOrEmpty(EmpFName) && !String.IsNullOrEmpty(EmpLName))
            {
                Employee StudentObj = new Employee(EmpFName, EmpLName);
                StudentObj.Email   = formData["Email"] == "" ? null : formData["Email"];
                StudentObj.Mobile  = formData["Mobile"] == "" ? null : formData["Mobile"];
                StudentObj.Address = formData["Address"] == "" ? null : formData["Address"];
                FileManager fileManagerObj = new FileManager("trainingblobcontainer");
                string      AbsoluteUri    = fileManagerObj.UploadFile(uploadFile);
                StudentObj.FileUpload = AbsoluteUri;
                BlobManager BManagerObj = new BlobManager("ArohiEmployeeTable");
                BManagerObj.InsertEntity <Employee>(StudentObj, true);
            }



            return(RedirectToAction("List"));
        }
Пример #32
0
 public void initialize(VoxelData voxelData, BlobManager blobOwner, IntVector3 startPosition)
 {
     this.blobOwner = blobOwner;
     this.startPosition = startPosition;
     textureIndex = 0;
     status = new VoxelStatus ();
     setVoxelData (voxelData);
     setName ();
 }
Пример #33
0
    public void reassign(BlobManager newBlobOwner, IntVector3 newStartPosition)
    {
        lastBlobOwner = blobOwner;
        lastStartPosition = startPosition;

        blobOwner = newBlobOwner;
        startPosition = newStartPosition;
        setName ();
        transform.parent = blobOwner.transform;
    }
Пример #34
0
    public CollisionManager(WorldManager worldManager, string blobName2, BlobManager blobManager)
    {
        //make blobManager null when we just want to put blob2 contents into blob1
        this.worldManager = worldManager;

        blobName1 = "main blob";
        this.blobName2 = blobName2;
        this.newBlobManager = blobManager;
        isBlob2InsideBlob1 = newBlobManager == null;

        isDone = false;
        isStarted = false;
        subtaskCounter = 0;
    }
Пример #35
0
    public static Prism getPrismFromBlobs(BlobManager blob1, BlobManager blob2)
    {
        /*
        returns a Prism that just barely contains all of blob1 and blob2
        */
        Prism p1 = blob1.genPrism ();
        Prism p2 = blob2.genPrism ();

        int i = Mathf.Min (p1.x, p2.x);
        int j = Mathf.Min (p1.y, p2.y);
        int k = Mathf.Min (p1.z, p2.z);

        int iCorner = Mathf.Max (p1.x + p1.width, p2.x + p2.width);
        int jCorner = Mathf.Max (p1.y + p1.height, p2.y + p2.height);
        int kCorner = Mathf.Max (p1.z + p1.depth, p2.z + p2.depth);

        int width = iCorner - i;
        int height = jCorner - j;
        int depth = kCorner - k;

        return new Prism (i, j, k, width, height, depth);
    }
Пример #36
0
    private BlobManager startBlob(BlobManager blobManager, int [,,] mapData, IntVector3 position)
    {
        blobManager.setInitial (mapData, position, blobManager.blobName);
        blobManager.transform.position = new Vector3 (position.x, position.y, position.z);

        return blobManager;
    }
Пример #37
0
    private void setStart()
    {
        //only one collisionManager should be in progress at the same time for the whole scene
        isStarted = true;

        blobs = new ArrayList ();

        if (blobName1 == "main blob")
            blobName1 = worldManager.getMainBlobName ();
        blob1 = (BlobManager)worldManager.blobs [blobName1];
        blob2 = (BlobManager)worldManager.blobs [blobName2];

        blob1.setName (true);
        blob2.setName (true);
        if (newBlobManager != null)
            newBlobManager.setName (true);

        blobs.Add (blob2);

        if (isBlob2InsideBlob1) {
            //case: when blob2 collided with blob1, it was completely within blob1 bounds
            //Debug.Log ("inside collision");
            newBlobManager = blob1;

            iterPrism = blob2.genPrism ();
            combinedPrism = blob1.getPrism ();

            iterOffset = new IntVector3 (iterPrism.x - combinedPrism.x, iterPrism.y - combinedPrism.y, iterPrism.z - combinedPrism.z);

            //ZTools.show ("combinedPrism ", combinedPrism);
            newMapData = blob1.mapData;
            newVoxelGrid = blob1.voxels;
            newContagiousList = blob1.getContagiousList ();
        } else {
            //case: blob2 hit the outside of blob1. newblob bounds must become larger
            //Debug.Log ("outside collision");
            blobs.Add (blob1);
            iterPrism = getPrismFromBlobs (blob1, blob2);
            iterOffset = new IntVector3 (0, 0, 0);

            combinedPrism = iterPrism;
            newMapData = new int[iterPrism.width, iterPrism.height, iterPrism.depth];
            newVoxelGrid = new GameObject[iterPrism.width, iterPrism.height, iterPrism.depth];
            newContagiousList = new ArrayList ();
            newBlobManager.gameObject.transform.position = new Vector3 (iterPrism.x, iterPrism.y, iterPrism.z);
        }
        //ZTools.show("combined prism",combinedPrism);
    }
Пример #38
0
 private void addToBlobs(BlobManager blob)
 {
     blobs [blob.blobName] = blob;
 }
Пример #39
0
 public ViroidManager(BlobManager BlobManager)
 {
     blobManager = BlobManager;
 }