예제 #1
0
        public HttpResponseMessage Process()
        {
            FileSystemCommand command;

            Enum.TryParse(CurrentContext.Request["command"], out command);
            string arguments = CurrentContext.Request["arguments"];

            AzureStorageAccount account = AzureStorageAccount.FileManager.Value;
            var provider = new AzureBlobFileProvider(account.AccountName, account.AccessKey, account.ContainerName, TempDirectoryPath);

            var config = new FileSystemConfiguration {
                Request            = new HttpContextWrapper(CurrentContext).Request,
                FileSystemProvider = provider,
                //uncomment the code below to enable file/folder management
                //AllowCopy = true,
                //AllowCreate = true,
                //AllowMove = true,
                //AllowDelete = true,
                //AllowRename = true,
                //AllowUpload = true,
                AllowDownload       = true,
                UploadConfiguration = new UploadConfiguration {
                    MaxFileSize = 1048576
                },
                TempDirectory = TempDirectoryPath
            };
            var processor     = new FileSystemCommandProcessor(config);
            var commandResult = processor.Execute(command, arguments);
            var result        = commandResult.GetClientCommandResult();

            return(command == FileSystemCommand.Download && commandResult.Success ? CreateDownloadResponse(result) : Request.CreateResponse(result));
        }
예제 #2
0
        public static ObservableCollection <string> GetList(AzureStorageAccount acct)
        {
            var t = acct.ListContainersAsync();

            t.Wait();
            return(t.Result);
        }
예제 #3
0
        static void Main(string[] args)
        {
            AzureStorageAccount acct = new AzureStorageAccount();
            var contlist             = GetList(acct);

            acct.GetContainer("testing")
            .BlobHandler <EncryptedBlockBlobHandler>()
            .UploadBlob("Encrypted", "Files/textfile1.txt");
            acct.GetContainer("testing")
            .BlobHandler <BlockBlobHandler>()
            .UploadBlob("Non-Encrypted", "Files/textfile1.txt");


            acct.GetContainer("testing")
            .BlobHandler <EncryptedBlockBlobHandler>()
            .DownloadBlob("Encrypted", "Files/dl-textfile.txt");

            IEnumerable <Uri> list = acct
                                     .GetContainer("testing")
                                     .ListBlobs();

            var url = acct
                      .GetContainer("testing")
                      .BlobHandler <EncryptedBlockBlobHandler>()
                      .GetBlobUrl("encrypted");

            var sas = acct
                      .GetContainer("testing")
                      .GetDefaultBlobHandler()
                      .GetSasToken("Non-Encrypted");

            System.Diagnostics.Process.Start(sas);
        }
        public void OnNavigatedTo(ContainerEditorNavigationContext context)
        {
            // first initialize the storage account meta data
            this.StorageAccount = context.Account;
            // then initialize the client
            InitializeClient();

            this.IsNew = context.IsNew;
            if (this.IsNew)
            {
                this.CurrentContainer = new AzureStorageContainer();
                Messenger.Default.Send <PageTitleChangedEvent>(new PageTitleChangedEvent()
                {
                    Title = "Creating New Container"
                });
                // make sure we reset this on new containers
                this.CurrentContainer.AccessLevel = privateAccess;
                this.CanEditName = true;
            }
            else
            {
                this.CurrentContainer = context.Container;
                Messenger.Default.Send <PageTitleChangedEvent>(new PageTitleChangedEvent()
                {
                    Title = this.CurrentContainer.Name
                });
                // TODO: find the right access level from the container's internal value
                var existingMatch = this.AccessLevels.Where(f => f.Code == this.CurrentContainer.AccessLevel.Code).FirstOrDefault();
                this.CurrentContainer.AccessLevel = existingMatch;
                this.CanEditName = false;
                Validate();
            }
            // turn on validation monitoring
            this.CurrentContainer.PropertyChanged += (s, e) => { Validate(); };
        }
예제 #5
0
        public AzureStorageClient(AzureStorageAccount account)
        {
            var credentials = new StorageCredentials(account.Name, account.Key);

            this.storageAccount = new CloudStorageAccount(credentials, true);
            this.blobClient     = this.storageAccount.CreateCloudBlobClient();
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseSession();
            app.UseCors("CorsPolicy");

            app.UseMvc(routes => {
                routes.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Default", action = "Index" }
                    );
            });

            app.UseSignalR(routes => {
                routes.MapHub <LiveUpdateSignalRHub>("/liveUpdateSignalRHub");
                routes.MapHub <StockTickDataHub>("/stockTickDataHub");
                routes.MapHub <DataGridCollaborativeEditingHub>("/dataGridCollaborativeEditingHub");
                routes.MapHub <SchedulerSignalRHub>("/schedulerSignalRHub");
            });

            Models.SampleData.SampleData.RootPath = env.WebRootPath;

            AzureStorageAccount.Load(Configuration.GetSection("AzureStorage"));
        }
예제 #7
0
        public static CloudBlobContainer GetBlobContainer(MSGorillaBlobContainer container)
        {
            var client      = AzureStorageAccount.CreateCloudBlobClient();
            var azcontainer = client.GetContainerReference(_containerDict[container]);

            azcontainer.CreateIfNotExists();
            return(azcontainer);
        }
예제 #8
0
        static AzureBlobFileProvider CreateAzureBlobFileProvider(IServiceProvider serviceProvider)
        {
            var    hosting              = serviceProvider.GetRequiredService <IHostingEnvironment>();
            string tempDirPath          = Path.Combine(hosting.ContentRootPath, "UploadTemp");
            AzureStorageAccount account = AzureStorageAccount.FileManager;

            return(new AzureBlobFileProvider(account.AccountName, account.AccessKey, account.ContainerName, tempDirPath));
        }
예제 #9
0
        public static CloudQueue GetQueue(MSGorillaQueue queue)
        {
            var client  = AzureStorageAccount.CreateCloudQueueClient();
            var azqueue = client.GetQueueReference(_queueDict[queue]);

            azqueue.CreateIfNotExists();
            return(azqueue);
        }
        private static CloudTable GetCloudTable(IComponentContext context, AzureStorageAccount account, string tableName)
        {
            var storageService = context.Resolve <IAzureStorageAccountService>();
            var storageAccount = storageService.GetStorageAccount(account);
            var table          = storageAccount.GetStorageTable(tableName);

            table.CreateIfNotExists();
            return(table);
        }
 public static IRegistrationBuilder <CloudTable, SimpleActivatorData, SingleRegistrationStyle> RegisterNamedCloudTable(
     this ContainerBuilder builder,
     AzureStorageAccount account,
     string tableName)
 {
     return(builder.Register(c => GetCloudTable(c, account, tableName))
            .Named <CloudTable>(tableName)
            .SingleInstance());
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (AwsAccessKey != null ? AwsAccessKey.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AwsSecretKey != null ? AwsSecretKey.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AzureStorageAccount != null ? AzureStorageAccount.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AzureStorageKey != null ? AzureStorageKey.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #13
0
 protected void InitAzure()
 {
     //Azure Configuration
     if (AzureStorageAccount != null)
     {
         AzureBlobClient = AzureStorageAccount.CreateCloudBlobClient();
     }
     else
     {
         AzureBlobClient = null;
     }
 }
예제 #14
0
        public HttpResponseMessage Get(string widgetType)
        {
            AzureStorageAccount account = widgetType == "fileManager"
                ? AzureStorageAccount.FileManager.Value : AzureStorageAccount.FileUploader.Value;

            bool active = !account.IsEmpty();
            var  result = new {
                active = active
            };

            return(Request.CreateResponse(result));
        }
        private void LoadSettings(AzureStorageAccountSettings settings)
        {
            StorageSettings = settings;

            LoadSchemaMapping(StorageSettings.SchemaDefinition);

            try {
                AzureStorageAccount = CloudStorageAccount.Parse(settings.ConnectionString);
                AzureTableClient    = AzureStorageAccount.CreateCloudTableClient();
                StorageTable        = AzureTableClient.GetTableReference(StorageSettings.TableName);
            } catch (Exception e) {
                throw new TelemetryReportingException("Unable to connect to the Azure Storage Table (" + e.Message + "). See InnerException for additional details.", e);
            }
        }
예제 #16
0
        public async Task RemoveStorageAccount(AzureStorageAccount account)
        {
            var list = await GetStorageAccounts();

            var match = list.Where(f => f.Name == account.Name).FirstOrDefault();

            if (match != null)
            {
                list.Remove(match);

                await SaveList(list);

                Messenger.Default.Send <AccountDeletedEvent>(new AccountDeletedEvent());
            }
        }
예제 #17
0
        public static AWCloudTable GetTable(MSGorillaTable table)
        {
            if (_tableCache.ContainsKey(table))
            {
                return(_tableCache[table]);
            }

            var        client  = AzureStorageAccount.CreateCloudTableClient();
            CloudTable aztable = client.GetTableReference(_tableDict[table]);

            aztable.CreateIfNotExists();
            CloudTable wosstable = null;

            if (WossStorageAccount != null)
            {
                client    = WossStorageAccount.CreateCloudTableClient();
                wosstable = client.GetTableReference(_tableDict[table]);
                DateTimeOffset startTime = DateTimeOffset.UtcNow;

                OperationContext opContext = new OperationContext();
                try
                {
                    wosstable.Create(null, opContext);
                }
                catch (Exception e)
                {
                    if (!(e is StorageException && e.InnerException != null && e.InnerException.Message.Equals("The remote server returned an error: (409) Conflict.")))
                    {
                        Logger.Error(e, startTime, DateTime.Now, wosstable.Uri.ToString(), "CreateTable", opContext);
                    }
                }
            }

            AWCloudTable awTable = new AWCloudTable(aztable, wosstable);

            _tableCache[table] = awTable;
            return(awTable);
        }
 public FileController()
 {
     _storageAccount = new AzureStorageAccount();
 }
예제 #19
0
        public ICloudStorageAccount GetStorageAccount(AzureStorageAccount storageAccount)
        {
            var tableStorageAccount = storageAccount.GetTableStorageAccount();

            return(new AzureStorageAccountWrapper(tableStorageAccount));
        }
예제 #20
0
 public SampleAzureTableContext(AzureStorageAccount acc) : base(acc)
 {
     MapObjects();
 }