Skip to content

Commit

Permalink
Merge branch 'release/v1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilLord666 committed May 12, 2023
2 parents bd94011 + c637e96 commit f464c98
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface IFileStoreService
Task<FileInfo> GetFileInfoAsync(string fileName);
//Task<FileInfo> GetLastWrittenFileInfoAsync(string directory);
Task<IList<FileInfo>> GetAllDirectoryFilesInfoAsync(string directory);
Task<bool> RemoveDirectoryRecursiveAsync(string directory);
Task<Tuple<FileInfo, byte[]>> GetLastChangedFileAsync(string directory);
Task<byte[]> ReadAsync(string fileName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ private async Task<byte[]> ReadSpectrumFile(SpectrumEntity spectrum, string samp
// we should get from FTP, temporarily we can't do (FTP was not configured properly and we still in DEBUG)
using AsyncFtpClient ftp = new AsyncFtpClient(_config.FtpArchSettings.FtpSettings.Host, _config.FtpArchSettings.FtpSettings.Username,
_config.FtpArchSettings.FtpSettings.Password, _config.FtpArchSettings.FtpSettings.Port);
await ftp.SetWorkingDirectory(spectrum.Location);
await ftp.Connect();
//await ftp.SetWorkingDirectory(spectrum.Location);
byte[] spectrumSampleContent = await ftp.DownloadBytes(sampleFile, new CancellationToken());
return null;
await ftp.Disconnect();
return spectrumSampleContent;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private async Task<int> TransferSpectrumFiles(SpectrumEntity spectrum)
{
// todo (UMV): define roper PATH ....
string spectrumShareRootDir = GetSpectrumShareRootDir();
string spectrumPrevDir = spectrum.Location;
IList<FileInfo> spectrumSamples = await _storeService.GetAllDirectoryFilesInfoAsync(spectrum.Location);
//IList<string> spectrumSamples = await _storeService.GetChildrenAsync(spectrumN, spectrumShareRootDir);
string ftpSpectrumDir = Path.Combine(@$"{_config.FtpArchSettings.FtpArchRootDir}", spectrum.Name);
Expand Down Expand Up @@ -113,10 +114,10 @@ private async Task<int> TransferSpectrumFiles(SpectrumEntity spectrum)
else
{
spectrum.Location = ftpSpectrumDir;
// TODO(UMV): could safely remove file from share (temporarily, off)

}
}

await _storeService.RemoveDirectoryRecursiveAsync(spectrumPrevDir);
// going to ROOT dir
await ftp.SetWorkingDirectory("/");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public Task<IList<FileInfo>> GetAllDirectoryFilesInfoAsync(string directory)
throw new NotImplementedException();
}

public Task<bool> RemoveDirectoryRecursiveAsync(string directory)
{
throw new NotImplementedException();
}

public Task<Tuple<FileInfo, byte[]>> GetLastChangedFileAsync(string directory)
{
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ public async Task<IList<FileInfo>> GetAllDirectoryFilesInfoAsync(string director
}
}

public async Task<bool> RemoveDirectoryRecursiveAsync(string directory)
{
try
{
Directory.Delete(directory, true);
return true;

}
catch (Exception e)
{
_logger.LogError($"An error occurred during removing folder files: {e.Message}");
return false;
}
}

public async Task<Tuple<FileInfo, byte[]>> GetLastChangedFileAsync(string directory)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ private void ConfigureRegularJobs(IServiceCollection services)
.WithCronSchedule(_config.DefaultJobsSettings.DefaultSpectraNotifySchedule));
quartz.AddJob<FtpArchiveFilesJob>(job => job.WithIdentity(nameof(FtpArchiveFilesJob)));
quartz.AddTrigger(trigger => trigger.ForJob(nameof(FtpArchiveFilesJob))
.WithSimpleSchedule(SimpleScheduleBuilder.RepeatMinutelyForever(5)));
//.WithCronSchedule(_config.DefaultJobsSettings.DefaultFileArchSchedule));
//.WithSimpleSchedule(SimpleScheduleBuilder.RepeatMinutelyForever(5)));
.WithCronSchedule(_config.DefaultJobsSettings.DefaultFileArchSchedule));
});

services.AddQuartzHostedService(options =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"DefaultEventWatchSchedule": "",
"DefaultSpectraIndexerSchedule": "30/30 * * ? * * *",
"DefaultSpectraNotifySchedule": "0 0 10,17,22 ? * * *",
"DefaultFileArchiveingSchedule": "0 0 10,17,22 ? * * *"
"DefaultFileArchSchedule": "0 0 23 1/1 * ? *"
},
"ConnStr": "Data Source=Wissance.MossbauerLab.Watcher.db;"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"DefaultEventWatchSchedule": "",
"DefaultSpectraIndexerSchedule": "30/30 * * ? * * *",
"DefaultSpectraNotifySchedule": "0 0 10,17,22 ? * * *",
"DefaultFileArchSchedule": "30/30 * * ? * * *"
"DefaultFileArchSchedule": "0 0 23 1/1 * ? *"
},
"ConnStr": "Data Source=Wissance.MossbauerLab.Watcher.db;"
}
Expand Down

0 comments on commit f464c98

Please sign in to comment.