init
This commit is contained in:
1
DataPRO/WPF.DbAPI/.svn/entries
Normal file
1
DataPRO/WPF.DbAPI/.svn/entries
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
1
DataPRO/WPF.DbAPI/.svn/format
Normal file
1
DataPRO/WPF.DbAPI/.svn/format
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace WpfAppCore
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<Window x:Class="WpfAppCore.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:WpfAppCore"
|
||||
mc:Ignorable="d"
|
||||
Title="Core DbAPI WPF Client" Height="800" Width="800">
|
||||
<Grid >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"></ColumnDefinition>
|
||||
<ColumnDefinition Width="100"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Column="0" Margin="5" HorizontalAlignment="Left" Grid.Row="0" x:Name="testsetupget" Width="100" Click="GetTestSetups_Button_Click">Get TestSetups</Button>
|
||||
<TextBlock Grid.Column="1" Margin="5" >Test Id</TextBlock>
|
||||
<TextBox Grid.Column="2" Margin="5" Width="200" x:Name="testId" ></TextBox>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="1" Margin="5" HorizontalAlignment="Left" x:Name="dasget" Width="100" Click="GetDAS_Button_Click">Get DAS</Button>
|
||||
<TextBlock Grid.Column="1" Grid.Row="1" Margin="5" >DAS Serial</TextBlock>
|
||||
<TextBox Grid.Column="2" Grid.Row="1" Margin="5" Width="200" x:Name="dasSerial" ></TextBox>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="2" Margin="5" Click="Responsive_Button_Click">Responsive</Button>
|
||||
|
||||
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Margin="5" Grid.Column="0">Result in JSON</TextBlock>
|
||||
<TextBlock Margin="5"
|
||||
Grid.Column="1">Errors</TextBlock>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<TextBlock x:Name="result"></TextBlock>
|
||||
</ScrollViewer>
|
||||
<ScrollViewer Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<TextBlock x:Name="errors"></TextBlock>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
<Label Grid.Row="3" HorizontalContentAlignment="Center">© 2024 DTS</Label>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DTS.Core.DbAPIWrapper\DTS.Core.DbAPIWrapper.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="WpfAppCore.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WpfAppCore"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
DataPRO/WPF.DbAPI/.svn/wc.db
Normal file
BIN
DataPRO/WPF.DbAPI/.svn/wc.db
Normal file
Binary file not shown.
0
DataPRO/WPF.DbAPI/.svn/wc.db-journal
Normal file
0
DataPRO/WPF.DbAPI/.svn/wc.db-journal
Normal file
Reference in New Issue
Block a user