private void UploadFiles(IEnumerable <FileViewModel> allFileModels) { if (this.InvokeRequired) { this.Invoke(new UploadFilesHandler(this.UploadFiles), new Object[] { allFileModels }); } else { foreach (var runner in allFileModels) { runner.Status = "reading image...."; this.UpdateView(runner); var imageData = this.ReadImageToArray(runner); var targetGuid = Guid.NewGuid(); runner.Status = "uploading..."; this.UpdateView(runner); runner.CloudUrl = BlobHandler.WriteImage(imageData, targetGuid); runner.Status = "ready!"; this.UpdateView(runner); } this.filesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); this.filesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); } }
public bool UploadPhoto(UserInfo user, string file, bool isPrivate = true, bool isAvatar = false) { file = file.Substring(23); _blobHandler = new BlobHandler(user.BlobContainerName); var photoKey = Guid.NewGuid().ToString(); var photo = new UserPhoto { Author = user, BlobStorageLink = photoKey, IsPrivate = isPrivate, IsUserAvatar = isAvatar }; try { _blobHandler.Upload(photoKey, file); _objectFactory._context.Entry<UserInfo>(photo.Author).State = System.Data.Entity.EntityState.Modified; _objectFactory.GetRepositoryInstance<Guid, UserPhoto>().Add(photo); _objectFactory.Commit(); return true; } catch (Exception ex) { return false; } }
public async Task <HttpResponseMessage> PutBlobComp(string container, string blob, string comp) { var requestWrapper = DashHttpRequestWrapper.Create(this.Request); var operation = StorageOperations.GetBlobOperation(requestWrapper); switch (operation) { case StorageOperationTypes.SetBlobProperties: case StorageOperationTypes.SetBlobMetadata: case StorageOperationTypes.LeaseBlob: case StorageOperationTypes.SnapshotBlob: case StorageOperationTypes.PutPage: return(await BasicBlobHandler(container, blob, requestWrapper, operation)); case StorageOperationTypes.PutBlock: case StorageOperationTypes.PutBlockList: return(await PutBlobHandler(container, blob, requestWrapper, operation)); case StorageOperationTypes.AbortCopyBlob: /// Abort Copy Blob - http://msdn.microsoft.com/en-us/library/azure/jj159098.aspx return(ProcessResultResponse(await BlobHandler.AbortCopyBlobAsync( requestWrapper, container, blob, requestWrapper.QueryParameters.Value <string>("copyid")))); default: return(this.CreateResponse(HttpStatusCode.BadRequest, requestWrapper.Headers)); } }
public void SetSalesOrderParserSettings(SalesOrderParserSettingsBlob settings) { SalesOrderParserSettings = BlobHandler.Compress(settings); if (_cache.Contains("ParserBlob")) { _cache.Remove("ParserBlob"); } }
public async Task <HttpResponseMessage> AddCarImage() { IFormFile postedFile; string filename; GetImageFromHttpContext(out postedFile, out filename); await BlobHandler.UploadCarImage(postedFile, filename); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public async Task <HttpResponseMessage> AddCompanyImage() { IFormFile postedFile; string filename; GetImageFromHttpContext(out postedFile, out filename); //Save file locally and upload to blob await BlobHandler.UploadCompanyImage(postedFile, filename); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public PBSTurret(IStandingHandler standingHandler, PBSObjectHelper <PBSTurret> .Factory pbsObjectHelperFactory) { _standingHandler = standingHandler; _pbsObjectHelper = pbsObjectHelperFactory(this); _standingController = new PBSStandingController <PBSTurret>(this) { AlwaysEnabled = true }; _blobHandler = new BlobHandler <PBSTurret>(this); _blobEmitter = new BlobEmitter(this); _reinforceHandler = new PBSReinforceHandler <PBSTurret>(this); _coreUseHandler = new CoreUseHandler <PBSTurret>(this, new EnergyStateFactory(this)); }
public Player(IExtensionReader extensionReader, ICorporationManager corporationManager, MissionHandler.Factory missionHandlerFactory, ITeleportStrategyFactories teleportStrategyFactories, DockingBaseHelper dockingBaseHelper, CombatLogger.Factory combatLoggerFactory) { _extensionReader = extensionReader; _corporationManager = corporationManager; _missionHandlerFactory = missionHandlerFactory; _teleportStrategyFactories = teleportStrategyFactories; _dockingBaseHelper = dockingBaseHelper; _combatLoggerFactory = combatLoggerFactory; Session = ZoneSession.None; _movement = new PlayerMovement(this); _blobEmitter = new BlobEmitter(this); _blobHandler = new BlobHandler <Player>(this); }
public ActionResult Picture(long key, string fileName) { var fotoService = new AlbumFotoService(); var poze = fotoService.GetPoze(); var poza = poze.FirstOrDefault(p => p.Poza.Description == fileName); var url = poza.Poza.Url; var secureUrl = BlobHandler.GetBlobSasUri(url, fileName); var encodedUrl = BlobHandler.Base64Encode(secureUrl); return(View("PozaIndiv", new Poza() { Url = secureUrl })); }
public ActionResult Edit(HttpPostedFileBase file, [Bind(Include = "hummelId,name,trademark,description,fileLoc,active")] Hummel hummel) { if (ModelState.IsValid) { db.Entry(hummel).State = EntityState.Modified; db.SaveChanges(); BlobHandler bh = new BlobHandler(file.FileName); return(RedirectToAction("Index")); } return(View(hummel)); }
public async Task <HttpResponseMessage> UpdateCarImage() { IFormFile postedFile; string filename; GetImageFromHttpContext(out postedFile, out filename); string oldname = postedFile.FileName; await BlobHandler.DeleteCarImage(oldname); await BlobHandler.UploadCarImage(postedFile, filename); await FileHandler.Refresh(); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public SalesOrderParserSettingsBlob GetSalesOrderParserSettings() { if (SalesOrderParserSettings == null) { return(null); } if (_cache.Contains("ParserBlob")) { return(_cache["ParserBlob"] as SalesOrderParserSettingsBlob); } var settings = BlobHandler.Decompress <SalesOrderParserSettingsBlob>(SalesOrderParserSettings); _cache.Add("ParserBlob", settings, DateTime.Now.AddSeconds(30)); return(settings); }
public async Task <ActionResult> Create(Cause cause) { var token = Session["SpotifyToken"] as AuthenticationToken; if (token == null) { throw new Exception("Not logged in against Spotify"); } if (ModelState.IsValid) { if (cause.PostedPicture != null) { var bh = new BlobHandler("soundfunding"); bh.Upload(new List <HttpPostedFileBase> { cause.PostedPicture }); var blobUri = bh.GetBlobs().FirstOrDefault(b => b.Contains(cause.PostedPicture.FileName)); cause.Picture = blobUri; } var playlist = await PlaylistGenerator.GeneratePlaylist(token, cause); cause.SpotifyPlaylistId = playlist.Id; cause.SpotifyPlaylistUri = playlist.Uri; cause.SpotifyUserId = playlist.Owner.Id; var image = playlist.Owner.Images.FirstOrDefault(); if (image != null) { cause.SpotifyUserAvatarUrl = image.Url; } using (var db = new SoundFundingDbContext()) { db.Causes.Add(cause); db.SaveChanges(); } return(RedirectToAction("Cause", "Cause", new { id = cause.Id })); } return(View("Create")); }
public async Task <HttpResponseMessage> PutBlob(string container, string blob) { var requestWrapper = DashHttpRequestWrapper.Create(this.Request); var operation = StorageOperations.GetBlobOperation(requestWrapper); switch (operation) { case StorageOperationTypes.CopyBlob: /// Copy Blob - https://msdn.microsoft.com/en-us/library/azure/dd894037.aspx return(ProcessResultResponse(await BlobHandler.CopyBlobAsync(requestWrapper, container, blob, requestWrapper.Headers.Value <string>("x-ms-copy-source")))); case StorageOperationTypes.PutBlob: /// Put Blob - http://msdn.microsoft.com/en-us/library/azure/dd179451.aspx return(await PutBlobHandler(container, blob, requestWrapper, operation)); default: System.Diagnostics.Debug.Assert(false); return(this.CreateResponse(HttpStatusCode.BadRequest, requestWrapper.Headers)); } }
/// <summary> /// Gets the bitmap. /// </summary> /// <returns></returns> public static Bitmap GetBitmap(this Picture picture) { Bitmap result = null; try { MemoryStream stream = new MemoryStream(BlobHandler.ReadImage(picture.Guid)); result = new Bitmap(stream); if (picture?.PictureSource?.WatermarkPicture != null) { using (Bitmap watermark = picture.PictureSource.WatermarkPicture.GetBitmap()) { result.DrawWaterMark(watermark); } } } catch (Exception ex) { throw new Exception("Can't acquire bitmap", ex); } return(result); }
public static SystemRolePermissions FromBytes(byte[] bytes) { return(BlobHandler.Decompress <SystemRolePermissions>(bytes)); }
public static void Main(string[] args) { var count = BlobHandler.Count(); System.Console.WriteLine(count); }
public void DeletePhoto(Guid photoId) { var photo = _objectFactory.GetRepositoryInstance<Guid, UserPhoto>().GetById(photoId, p => p.Author); _blobHandler = new BlobHandler(photo.Author.BlobContainerName); _blobHandler.DeleteBlob(photo.BlobStorageLink); }
public Startup(IConfiguration configuration) { Configuration = configuration; BlobHandler.Init(); FileHandler.ClearImageDirs(); }
public byte[] ToBytes() { return(BlobHandler.Compress(this)); }
public static DocumentPermissions FromBytes(byte[] blob) { return(BlobHandler.Decompress <DocumentPermissions>(blob)); }
public async Task <int> DeleteCar(Kola kola) { var rezervacije = await _context.Zauzetost.ToListAsync(); // Da li su kola zauzeta? Ne mogu se obrisati foreach (Zauzetost z in rezervacije) { if (z.Kola == kola.Naziv && z.Renta == kola.NazivRente && z.Filijala == kola.Filijala) { if (!(z.BrzaRezervacija && z.User == "__BR__")) { if (z.Do > DateTime.Now) { return(-1); } } } } // else try { await BlobHandler.DeleteCarImage(kola.Naziv); //Obrisi sliku kola } catch (Exception e) { Console.WriteLine(e.Message); return(-2); } try { _context.Kola.Remove(kola); // Brisanje ocena var ocene = await _context.OceneKola.ToListAsync(); foreach (OcenaKola o in ocene) { if (o.Naziv == kola.Naziv && o.Kompanija == kola.NazivRente) { _context.OceneKola.Remove(o); } } foreach (Zauzetost z in rezervacije) { if (z.Kola == kola.Naziv && z.Renta == kola.NazivRente && z.Filijala == kola.Filijala) { _context.Zauzetost.Remove(z); } } } catch (Exception e) { Console.WriteLine(e.Message); return(-3); } await _context.SaveChangesAsync(); return(0); }