Esempio n. 1
0
        public static string GetGuildLogZipped(ulong guildId)
        {
            if (!Directory.Exists($@"{Environment.CurrentDirectory}/ZipWorkspace"))
            {
                Directory.CreateDirectory($@"{Environment.CurrentDirectory}/ZipWorkspace");
            }
            else
            {
                Directory.Delete($@"{Environment.CurrentDirectory}/ZipWorkspace", true);
                Directory.CreateDirectory($@"{Environment.CurrentDirectory}/ZipWorkspace");
            }

            try
            {
                if (File.Exists($@"{Environment.CurrentDirectory}/guild_{guildId}_log.zip"))
                {
                    File.Delete($@"{Environment.CurrentDirectory}/guild_{guildId}_log.zip");
                }

                File.Copy($@"{Environment.CurrentDirectory}/Logs/guild_{guildId}.log", $@"{ Environment.CurrentDirectory}/ZipWorkspace/guild_{guildId}.log");
                ZipFile.CreateFromDirectory($@"{Environment.CurrentDirectory}/ZipWorkspace", $@"{Environment.CurrentDirectory}/guild_{guildId}_log.zip");
                return($@"{Environment.CurrentDirectory}/guild_{guildId}_log.zip");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Esempio n. 2
0
        private void CreateZipFile(string finalZipFolder, string finalZipFile, string tempFolder, bool createWithPassword, string id)
        {
            try
            {
                if (Directory.Exists(finalZipFolder))
                {
                    Directory.Delete(finalZipFolder, true);
                }

                if (File.Exists(finalZipFile))
                {
                    File.Delete(finalZipFile);
                }

                Directory.GetParent(finalZipFolder)?.Create();
                Directory.Move(tempFolder, finalZipFolder);

                if (createWithPassword)
                {
                    CreateZipFileWithPasswordFromDirectory(finalZipFolder, finalZipFile, passwordHelper.GetHashPassword(id));
                }
                else
                {
                    ZipFile.CreateFromDirectory(finalZipFolder, finalZipFile);
                }
            }
            finally
            {
                if (Directory.Exists(finalZipFolder))
                {
                    Directory.Delete(finalZipFolder, true);
                }
            }
        }
        public void AssembleDataTableFromFileArchive()
        {
            var zip = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData.zip");
            var dir = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData");

            if (File.Exists(zip))
            {
                File.Delete(zip);
            }

            ZipFile.CreateFromDirectory(dir, zip);

            var fileCount = Directory.GetFiles(dir, "*.dcm").Count();

            var source = new DicomFileCollectionSource();

            source.FilenameField = "RelativeFileArchiveURI";
            source.PreInitialize(new FlatFileToLoadDicomFileWorklist(new FlatFileToLoad(new FileInfo(zip))), new ThrowImmediatelyDataLoadEventListener());
            var toMemory = new ToMemoryDataLoadEventListener(true);
            var result   = source.GetChunk(toMemory, new GracefulCancellationToken());

            //processed every file once
            Assert.AreEqual(fileCount, toMemory.LastProgressRecieivedByTaskName.Single().Value.Progress.Value);

            Assert.Greater(result.Columns.Count, 0);
        }
Esempio n. 4
0
 public static string GetAllLogsZipped()
 {
     if (File.Exists($@"{Environment.CurrentDirectory}/Logs.zip"))
     {
         File.Delete($@"{Environment.CurrentDirectory}/Logs.zip");
     }
     ZipFile.CreateFromDirectory($@"{Environment.CurrentDirectory}/Logs", $@"{Environment.CurrentDirectory}/Logs.zip");
     return($@"{Environment.CurrentDirectory}/Logs.zip");
 }
Esempio n. 5
0
 public static string GetLatestLogZipped()
 {
     if (!Directory.Exists($@"{Environment.CurrentDirectory}/ZipWorkspace"))
     {
         Directory.CreateDirectory($@"{Environment.CurrentDirectory}/ZipWorkspace");
     }
     else
     {
         Directory.Delete($@"{Environment.CurrentDirectory}/ZipWorkspace", true);
         Directory.CreateDirectory($@"{Environment.CurrentDirectory}/ZipWorkspace");
     }
     if (firstRun)
     {
         Setup();
     }
     File.Copy(logPath, $@"{Environment.CurrentDirectory}/ZipWorkspace/{Path.GetFileName(logPath)}");
     ZipFile.CreateFromDirectory($@"{Environment.CurrentDirectory}/ZipWorkspace", $@"{Environment.CurrentDirectory}/{Path.GetFileNameWithoutExtension(logPath)}.zip");
     return($@"{Environment.CurrentDirectory}/{Path.GetFileNameWithoutExtension(logPath)}.zip");
 }