sftp settings premakjen

This commit is contained in:
David Štaleker
2024-09-11 06:07:11 +02:00
parent 1dc48d2d85
commit 34a081e8f9
4 changed files with 8 additions and 50 deletions

View File

@@ -13,31 +13,9 @@ namespace InfosysPublisher.Classes
{
public class Application
{
//SQL strežniki
//Privatna polja
[JsonProperty] private string _sftpUsername;
[JsonProperty] private string _sftpPassword;
//Javna polja
public string SftpServerAddress { get; set; }
public int SftpPort { get; set; }
public int BuildSeconds { get; set; }
public string LastFolder { get; set; }
[JsonIgnore]
public string SftpUsername
{
get => _sftpUsername.AesDecrypt();
set => _sftpUsername = value.AesEncrypt();
}
[JsonIgnore]
public string SftpPassword
{
get => _sftpPassword.AesDecrypt();
set => _sftpPassword = value.AesEncrypt();
}
public void Save(string iPath)
{
var json = JsonConvert.SerializeObject(this);

View File

@@ -49,6 +49,11 @@ namespace InfosysPublisher
private string _selectedProjectVersion = "";
private string _selectedProjectGuid = "";
private static readonly string SftpServerAddress = "192.168.111.75";
private static readonly int SftpPort = 300;
private static readonly string SftpUsername = "InfosysUpdate";
private static readonly string SftpPassword = "v&H6c$wTbTkgSgdWvL*8k$st3#z5X";
private const string SftpArchivePath = "Archive";
public WinMain()
{
@@ -341,8 +346,7 @@ namespace InfosysPublisher
{
try
{
using var sftpClient = new SftpClient(App._application.SftpServerAddress, App._application.SftpPort,
App._application.SftpUsername, App._application.SftpPassword);
using var sftpClient = new SftpClient(SftpServerAddress, SftpPort, SftpUsername, SftpPassword);
sftpClient.Connect();
if (!sftpClient.Exists(_selectedProjectPublishLocation))

View File

@@ -9,29 +9,13 @@
Title="WinSettings" Height="355" Width="355">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Label Grid.Row="0">SFTP strežnik:</Label>
<TextBox Grid.Row="1" Name="TbSftpServer"></TextBox>
<Label Grid.Row="2">SFTP port:</Label>
<TextBox Grid.Row="3" Name="TbSftpPort"></TextBox>
<Label Grid.Row="4">SFTP uporabniško ime:</Label>
<TextBox Grid.Row="5" Name="TbSftpUsername"></TextBox>
<Label Grid.Row="6">SFTP geslo:</Label>
<TextBox Grid.Row="7" Name="TbSftpPassword"></TextBox>
<Label Grid.Row="8">Trajanje build:</Label>
<TextBox Grid.Row="9" Name="TbBuildDuration"></TextBox>
<Label Grid.Row="0">Trajanje build:</Label>
<TextBox Grid.Row="1" Name="TbBuildDuration"></TextBox>
<Button Name="BtnSave" Grid.Row="20" Width="80" HorizontalAlignment="Right">Shrani</Button>
</Grid>
</Window>

View File

@@ -43,10 +43,6 @@ namespace InfosysPublisher
{
var settings = new Settings.Application
{
SftpServerAddress = TbSftpServer.Text,
SftpPort = Convert.ToInt32(TbSftpPort.Text),
SftpUsername = TbSftpUsername.Text,
SftpPassword = TbSftpPassword.Text,
BuildSeconds = Convert.ToInt32(TbBuildDuration.Text)
};
@@ -59,10 +55,6 @@ namespace InfosysPublisher
{
var settings = GetSettings() ?? new Settings.Application();
TbSftpServer.Text = settings.SftpServerAddress;
TbSftpPort.Text = settings.SftpPort.ToString();
TbSftpUsername.Text = settings.SftpUsername;
TbSftpPassword.Text = settings.SftpPassword;
TbBuildDuration.Text = settings.BuildSeconds.ToString();
}