This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
using DTS.Core.DbAPIWrapper;
using System.Text.Json;
using System.Windows;
namespace WpfAppCore
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private readonly DbApiWrapper _dbApiWrapper;
public MainWindow()
{
InitializeComponent();
_dbApiWrapper = new DbApiWrapper("Burrito-Supreme", "DataPRO", "", "", true, true);
_dbApiWrapper.AuthenticateUser("Admin", "DTSAdmin");
}
private void Clear()
{
errors.Text = string.Empty;
result.Text = string.Empty;
}
private void EnableButtons(bool enable)
{
testsetupget.IsEnabled = enable;
dasget.IsEnabled = enable;
testId.IsEnabled = enable;
dasSerial.IsEnabled = enable;
}
private async void GetTestSetups_Button_Click(object sender, RoutedEventArgs e)
{
try
{
Clear();
EnableButtons(false);
result.Text = "Calling TestSetupsGetAsync";
int? testSetupId = null;
if (int.TryParse(testId.Text, out var tid))
{
testSetupId = tid;
}
var ts = await _dbApiWrapper.TestSetupsGetAsync(testSetupId);
EnableButtons(true);
//Show only the first 10 records in json format
var x = ts.Item1.Take(10);
if (ts.Item2.Any())
{
foreach(var err in ts.Item2)
{
errors.Text += err + Environment.NewLine;
}
}
var res = JsonSerializer.Serialize(x, new JsonSerializerOptions { WriteIndented = true });
result.Text = res;
}
catch (Exception ex)
{
//Log the error
MessageBox.Show(ex.Message,"Error");
}
}
private async void GetDAS_Button_Click(object sender, RoutedEventArgs e)
{
Clear();
EnableButtons(false);
result.Text = "Calling TestSetupsGetAsync";
string? dasSerailText = null;
if (!string.IsNullOrWhiteSpace(dasSerial.Text))
{
dasSerailText = dasSerial.Text;
}
var ds = await _dbApiWrapper.DASGetAsync(dasSerailText);
EnableButtons(true);
//Show only the first 10 records in json format
var x = ds.Item1.Take(10);
if(ds.Item2 != 0)
{
MessageBox.Show("Error code "+ds.Item2);
}
var res = JsonSerializer.Serialize(x, new JsonSerializerOptions { WriteIndented = true });
result.Text = res;
}
private void Responsive_Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Responsive UI");
}
}
}