More backoffice fun
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
namespace PartSource.Automation.Services
|
||||
namespace PartSource.Backoffice.Services
|
||||
{
|
||||
public class FtpService
|
||||
{
|
||||
|
||||
public void Download(string filename)
|
||||
{
|
||||
//FtpWebRequest request = (FtpWebRequest)WebRequest.Create($"{_ftpConfiguration.Url}/{filename}");
|
||||
|
||||
30
PartSource.Backoffice/Services/GZipService.cs
Normal file
30
PartSource.Backoffice/Services/GZipService.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace PartSource.Backoffice.Services
|
||||
{
|
||||
|
||||
public class GZipService
|
||||
{
|
||||
public static void Decompress(string path)
|
||||
{
|
||||
FileInfo fileToDecompress = new FileInfo(path);
|
||||
|
||||
using (FileStream originalFileStream = fileToDecompress.OpenRead())
|
||||
{
|
||||
string currentFileName = fileToDecompress.FullName;
|
||||
string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);
|
||||
|
||||
using (FileStream decompressedFileStream = File.Create(newFileName))
|
||||
{
|
||||
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
|
||||
{
|
||||
decompressionStream.CopyTo(decompressedFileStream);
|
||||
Console.WriteLine($"Decompressed: {fileToDecompress.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
PartSource.Backoffice/Services/TaskService.cs
Normal file
18
PartSource.Backoffice/Services/TaskService.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PartSource.Backoffice.Services
|
||||
{
|
||||
public class TaskService
|
||||
{
|
||||
private readonly FtpService _ftpService;
|
||||
private readonly GZipService _gzipService;
|
||||
|
||||
public TaskService()
|
||||
{
|
||||
_ftpService = new FtpService();
|
||||
_gzipService = new GZipService();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user