private void NewArchiveToolstripMenuItem_Clicked(object sender, EventArgs e) { if (CreateArchiveDialog.ShowDialog() == DialogResult.Cancel) { return; } if (NewArchiveForm.ShowDialog() == DialogResult.Cancel) { return; } string filename = CreateArchiveDialog.FileName; string password = NewArchiveForm.Password; bool compression = NewArchiveForm.Compression; // Jeżeli bieżące archiwum istnieje i jest otwarte, zamknięcie go if (WorkingArchive != null) { WorkingArchive.Close(); } // Utworzenie nowego archiwum WorkingArchive = FileArchive.Create(filename, password, compression); UpdateGui(); }
public static void FileArchiver(FileArchive archive) { try { string[] dirs = Directory.GetFiles(archive.FolderPath); foreach (string dir in dirs) { //console.writeLine(dir); //console.writeLine(DateTime.Now.ToString("yyyyMMdd")); //Directory.Move(@"C:\Test\test", @"c:\test\archive\test" ); //console.writeLine(archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", "")); string[] FolderCheck = Directory.GetDirectories(archive.FolderPath + @"\" + archive.ArchiveName + @"\"); FolderValidator(archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd"), FolderCheck); //console.writeLine("Moving " + dir + " to " + archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", "")); Directory.Move(dir, archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", "")); ArchiveLog log = new ArchiveLog(); log.OriginalPath = dir; log.DestinationPath = archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", ""); log.ArchiveDate = DateTime.Now; log.FileArchiveId = archive.FileArchiveId; WriteLog(log); //console.writeLine(dir); } } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } }
private void UnpackSourcePackage() { if (Directory.Exists(this.compileDir)) { Directory.Delete(this.compileDir, true); } Directory.CreateDirectory(this.compileDir); // Extract file FileArchive.UnzipFile(this.compileDir, this.sourceFile); }
private static void WriteArchive(string directory) { var files = new List <FileArchiveFile>(); ReadFilesFromDirectory(ref files, directory, directory); Logging.Log($"Writing archive contents..."); FileArchive fileArchive = new FileArchive(files); fileArchive.WriteToFile($"{directory}.alex"); }
public IntegrationTestFixture() { Server.PreserveExecutionContext = true; Client = CreateClient(); Client.DefaultRequestHeaders.Add("X-Forwarded-For", "127.0.0.1"); Database = Services.GetService <Database>(); FileArchive = Services.GetService <FileArchive>(); CreateAndSeedDatabase(Database.ConnectionString); }
private void FileHandling(AudioHelper audioConverter) { song = new FileArchive(song_base64); //if (song.ContentLength == 0) // throw new Exception("O áudio recebido pelo nosso sistema está corrompido..."); //if (!song.ContentType.Contains("mp3") && !song.ContentType.Contains("wav")) // throw new Exception("A extensão do audio não é suportada, suportamos somente wav e mp3"); audioConverter.SaveSong(song); }
protected IntegrationTestBase(IntegrationTestFixture fixture) { Client = fixture.Client; Database = fixture.Database; FileArchive = fixture.FileArchive; if (Directory.Exists(FileArchive.BasePath)) { Directory.Delete(FileArchive.BasePath, true); } _transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); fixture.Services.GetService <StatProcessor>().ClearCache(); }
private void LoadThread(object archivePath_) { var archivePath = (string)archivePath_; var mountPoint = Path.GetFileNameWithoutExtension(archivePath); if (MountPoints.ContainsKey(mountPoint)) { Logging.Log($"{mountPoint} already exists as a mount point.", Logging.Severity.High); return; } MountPoints.Add(mountPoint, FileArchive.LoadFromFile(archivePath)); }
private void OpenArchiveToolstripMenuItem_Clicked(object sender, EventArgs e) { if (OpenArchiveDialog.ShowDialog() == DialogResult.Cancel) { return; } if (PasswordInputForm.ShowDialog() == DialogResult.Cancel) { return; } string filename = OpenArchiveDialog.FileName; string password = PasswordInputForm.Password; // Jeżeli bieżące archiwum istnieje i jest otwarte, przechowanie głębokiej kopii i bezpieczne zamknięcie go FileArchive backup = null; if (WorkingArchive != null) { backup = WorkingArchive.Clone(); WorkingArchive.Close(); } try { // Próba otwarcia archiwum z użyciem podanego hasła WorkingArchive = FileArchive.Open(filename, password); } catch (KeyDerivationException kde) { // Próba otwarcia archiwum z użyciem podanego hasła nie powiodła się // Komunikat MessageBox.Show(kde.Message, "Wystąpił błąd", MessageBoxButtons.OK, MessageBoxIcon.Stop); //Przywrócenie z zachowanej kopii dotychczas otwartego archiwum (jeżeli takie było) if (backup != null) { WorkingArchive = backup; } } UpdateGui(); }
public static void ExtractTextures(FileArchive archive, string texDir, string outDir) { FileInfo[] fileInfos = archive.GetChildFileInfos(texDir); foreach (FileInfo info in fileInfos) { try { byte[] file = archive.ReadFile(info); string filename = Path.GetFileNameWithoutExtension(info.Filename); ExportWilayTextures(file, filename, outDir); } catch (Exception ex) { Console.WriteLine($"{ex.Message} {info.Filename}"); } } }
public static void Main() { try { using (var db = new FileArchiveContext()) { FileArchive tmp = db.FileArchives.Find(1); var tests = db.FileArchives; foreach (FileArchive test in tests) { FolderArchiver(test); // moves all folders from {archive.FolderPath} to {archive.FolderPath}\{archive.ArchiveName}\{yyyyMMdd}\ FileArchiver(test); // moves all files from {archive.FolderPath} to {archive.FolderPath}\{archive.ArchiveName}\{yyyyMMdd}\ } } } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } }
public static void ExtractTextures(FileArchive archive, string texDir, string outDir, IProgressReport progress = null) { FileInfo[] fileInfos = archive.GetChildFileInfos(texDir); progress?.SetTotal(fileInfos.Length); foreach (FileInfo info in fileInfos) { try { byte[] file = archive.ReadFile(info); string filename = Path.GetFileNameWithoutExtension(info.Filename); ExportWilayTextures(file, filename, outDir, progress); } catch (Exception ex) { progress?.LogMessage($"{ex.Message} {info.Filename}"); } progress?.ReportAdd(1); } }
public static void ExtractTextures(FileArchive archive, string texDir, string outDir) { FileInfo[] fileInfos = archive.GetChildFileInfos(texDir); foreach (FileInfo info in fileInfos) { try { byte[] file = archive.ReadFile(info); string filename = Path.GetFileNameWithoutExtension(info.Filename); var wilay = new WilayRead(file); Directory.CreateDirectory(outDir); for (int i = 0; i < wilay.Textures.Length; i++) { byte[] png = wilay.Textures[i].ToPng(); if (png == null) { Console.WriteLine($"{wilay.Textures[i].Format} decoding not implemented"); byte[] dds = Dds.CreateDds(wilay.Textures[i]); File.WriteAllBytes(Path.Combine(outDir, filename + "_" + i + ".dds"), dds); continue; } File.WriteAllBytes(Path.Combine(outDir, filename + "_" + i + ".png"), png); } } catch (Exception ex) { Console.WriteLine($"{ex.Message} {info.Filename}"); } } }
static Task <int> Main() { return(Deployment.RunAsync(async() => { var config = new Pulumi.Config(); var environment = config.Require("environment"); var companyCode = config.Require("company_code"); var scope = config.Require("default_scope"); var location = config.Require("location"); var webAppPath = config.Require("webAppPath"); var sourcePath = config.Require("sourcePath"); ResourceFactory factory = new ResourceFactory(companyCode, location, environment, scope); Dictionary <string, string> scopeTag = new Dictionary <string, string>(); scopeTag.Add("scope", scope); // Create a resource group var resourceGroup = factory.GetResourceGroup(tags: scopeTag); // Create a storage account for Blobs var storageAccount = factory.GetStorageAccount("Standard", "LRS", resourceGroup.Name, tags: scopeTag); // The container to put our files into var storageContainer = factory.GetContainer(storageAccountName: storageAccount.Name); // Azure SQL Server that we want to access from the application var administratorLoginPassword = factory.GetRandomPassword(length: 16).Result; var sqlServer = factory.GetSqlServer(resourceGroupName: resourceGroup.Name, administratorLogin: "******", administratorLoginPassword: administratorLoginPassword, version: "12.0", tags: scopeTag); // Azure SQL Database that we want to access from the application var database = factory.GetDatabase(resourceGroupName: resourceGroup.Name, sqlServerName: sqlServer.Name, requestedServiceObjectiveName: "S0", tags: scopeTag); // The connection string that has no credentials in it: authertication will come through MSI var connectionString = Output.Format($"Server=tcp:{sqlServer.Name}.database.windows.net;Database={database.Name};"); // A file in Blob Storage that we want to access from the application var textBlob = factory.GetBlob(storageAccountName: storageAccount.Name, storageContainerName: storageContainer.Name, type: "block", source: sourcePath); // A plan to host the App Service var appServicePlanSku = factory.GetPlanSku(tier: "Basic", size: "B1"); var appServicePlan = factory.GetPlan(resourceGroupName: resourceGroup.Name, sku: appServicePlanSku, kind: "App", tags: scopeTag); // ASP.NET deployment package var content = new FileArchive(webAppPath); var blob = factory.GetZipBlob(storageAccountName: storageAccount.Name, storageContainerName: storageContainer.Name, type: "block", content: content); var clientConfig = await Pulumi.Azure.Core.Invokes.GetClientConfig(); var tenantId = clientConfig.TenantId; var currentPrincipal = clientConfig.ObjectId; // Key Vault to store secrets (e.g. Blob URL with SAS) var vaultAccessPolicies = factory.GetKeyVaultAccessPolicy(tenantId: Output.Create(tenantId), objectId: Output.Create(currentPrincipal), secretPermissions: new List <string> { "delete", "get", "list", "set" }); var vault = factory.GetKeyVault(resourceGroupName: resourceGroup.Name, tenantId: Output.Create(tenantId), accessPolicies: vaultAccessPolicies, tags: scopeTag); // Put the URL of the zip Blob to KV var secret = factory.GetSecret(keyVaultId: vault.Id, blob: blob, storageAccount: storageAccount, tags: scopeTag); var secretUri = Output.Format($"{secret.VaultUri}secrets/{secret.Name}/{secret.Version}"); // The application hosted in App Service var app = factory.GetAppService(resourceGroupName: resourceGroup.Name, appServicePlanId: appServicePlan.Id, blobUrl: textBlob.Url, secretUri: secretUri, connectionString: connectionString, connectionStringName: "db", connectionStringType: "SQLAzure", tags: scopeTag); // Work around a preview issue https://github.com/pulumi/pulumi-azure/issues/192 var principalId = app.Identity.Apply(id => id.PrincipalId ?? "11111111-1111-1111-1111-111111111111"); // Grant App Service access to KV secrets var policy = factory.GetAccessPolicy(keyVaultId: vault.Id, tenantId: Output.Create(tenantId), objectId: principalId, secretPermissions: new List <string> { "get" }); // Make the App Service the admin of the SQL Server (double check if you want a more fine-grained security model in your real app) var sqlAdmin = factory.GetActiveDirectoryAdministrator(resourceGroupName: resourceGroup.Name, tenantId: Output.Create(tenantId), objectId: principalId, loginUsername: "******", sqlServerName: sqlServer.Name); // Grant access from App Service to the container in the storage var blobPermission = factory.GetAssignment(principalId: principalId, storageAccountId: storageAccount.Id, storageContainerName: storageContainer.Name, roleDefinitionName: "Storage Blob Data Reader"); // Add SQL firewall exceptions var firewallRules = app.OutboundIpAddresses.Apply( ips => ips.Split(",").Select(ip => factory.GetFirewallRule(resourceGroupName: resourceGroup.Name, startIpAddress: ip, endIpAddress: ip, sqlServerName: sqlServer.Name)).ToList()); return new Dictionary <string, object?> { { "endpoint", Output.Format($"https://{app.DefaultSiteHostname}") }, }; })); }