Refactory

This commit is contained in:
PAL\cbo
2023-02-07 11:52:25 +01:00
parent 9431f85720
commit b6a6f92605
15 changed files with 206 additions and 213 deletions
@@ -1,9 +1,10 @@
<Window x:Class="wpf_ax_utility.MainWindow" <Window x:Class="wpf_ax_utility.AppMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converters="http://sharpvectors.codeplex.com/svgc/" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
dx:ThemeManager.ThemeName="None"
mc:Ignorable="d" mc:Ignorable="d"
MouseLeftButtonDown="MouseLeftDrag" MouseLeftButtonDown="MouseLeftDrag"
Height="300" Width="400" Height="300" Width="400"
@@ -13,7 +14,7 @@
AllowsTransparency="True" AllowsTransparency="True"
Background="Transparent" Background="Transparent"
Title="PAL Ax Utility" Title="PAL Ax Utility"
Icon="/axlogo.ico"> Icon="res/axlogo.ico">
<Window.Resources> <Window.Resources>
<Style TargetType="Button" x:Key="TabButton"> <Style TargetType="Button" x:Key="TabButton">
@@ -25,9 +26,6 @@
</Style> </Style>
</Style.Resources> </Style.Resources>
</Style> </Style>
<GeometryGroup x:Key="tashCan">
<PathGeometry Figures="M135.2 17.7C140.6 6.8 151.7 0 163.8 0H284.2c12.1 0 23.2 6.8 28.6 17.7L320 32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 96 0 81.7 0 64S14.3 32 32 32h96l7.2-14.3zM32 128H416V448c0 35.3-28.7 64-64 64H96c-35.3 0-64-28.7-64-64V128zm96 64c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16z"/>
</GeometryGroup>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
@@ -41,23 +39,31 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<DockPanel> <DockPanel>
<Border Height="25" Width="25" CornerRadius="5" Margin="4,3,0,0"> <Border Height="25" Width="25" CornerRadius="5" Margin="4,3,0,0">
<Border.Background> <Border.Background>
<ImageBrush Stretch="Fill" ImageSource="/axlogo.ico"/> <ImageBrush Stretch="Fill" ImageSource="res/axlogo.ico"/>
</Border.Background> </Border.Background>
</Border> </Border>
<TextBlock Margin="5,0,0,0" FontWeight="DemiBold" Text="PAL Ax Utility" VerticalAlignment="Center"/>
<TextBlock Margin="5,2,0,0" FontWeight="DemiBold" Text="PAL Ax Utility" VerticalAlignment="Center"/>
<Button Style="{StaticResource TabButton}" <Button Style="{StaticResource TabButton}"
Click="CloseButton" Click="CloseButton"
Height="25" Width="25" Height="25"
FontSize="18" Width="25"
FontSize="15"
FontWeight="DemiBold" FontWeight="DemiBold"
Background="Transparent" Background="Transparent"
HorizontalAlignment="Right" HorizontalAlignment="Right"
BorderBrush="{x:Null}" VerticalAlignment="Center"
Margin="0,3,3,0"> Margin="0,3,3,0"
<TextBlock Text="x" Margin="0,-5,0,0"/> BorderBrush="{x:Null}">
<TextBlock Text="x"
Height="25"
Width="25" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Button> </Button>
</DockPanel> </DockPanel>
<GroupBox Margin="10,2,10,2" <GroupBox Margin="10,2,10,2"
@@ -66,6 +72,7 @@
BorderThickness="1" BorderThickness="1"
Header="Ambienti" Header="Ambienti"
Grid.Row="1"> Grid.Row="1">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
@@ -79,56 +86,60 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Button Style="{StaticResource TabButton}" <Button Style="{StaticResource TabButton}"
x:Name="LIVE" x:Name="LIVE"
Click="ButtonClicked" Click="ButtonClicked"
Margin="5" Margin="5"
Content="LIVE" Content="LIVE"
FontSize="36" FontSize="36"
Background="LightGray" Background="LightGray"
Grid.ColumnSpan="4" /> Grid.ColumnSpan="4" />
<Button Style="{StaticResource TabButton}" <Button Style="{StaticResource TabButton}"
x:Name="LIVE02" x:Name="LIVE02"
Click="ButtonClicked" Click="ButtonClicked"
Margin="5" Margin="5"
Content="LIVE 02" Content="LIVE 02"
FontSize="16" FontSize="16"
FontWeight="DemiBold" FontWeight="DemiBold"
Background="LightGray" Background="LightGray"
Grid.Row="1"/> Grid.Row="1"/>
<Button Style="{StaticResource TabButton}" <Button Style="{StaticResource TabButton}"
x:Name="DEV" x:Name="DEV"
Click="ButtonClicked" Click="ButtonClicked"
Margin="5" Margin="5"
Content="DEV" Content="DEV"
FontSize="16" FontSize="16"
FontWeight="DemiBold" FontWeight="DemiBold"
Background="#00FF80" Background="#00FF80"
Grid.Row="1" Grid.Row="1"
Grid.Column="1"/> Grid.Column="1"/>
<Button Style="{StaticResource TabButton}" <Button Style="{StaticResource TabButton}"
x:Name="TEST" x:Name="TEST"
Click="ButtonClicked" Click="ButtonClicked"
Margin="5" Margin="5"
Content="TEST" Content="TEST"
FontSize="16" FontSize="16"
FontWeight="DemiBold" FontWeight="DemiBold"
Background="#8080FF" Background="#8080FF"
Grid.Row="1" Grid.Row="1"
Grid.Column="2"/> Grid.Column="2"/>
<Button Style="{StaticResource TabButton}" <Button Style="{StaticResource TabButton}"
x:Name="STAGING" x:Name="STAGING"
Click="ButtonClicked" Click="ButtonClicked"
Margin="5" Margin="5"
Content="STAGING" Content="STAGING"
FontSize="16" FontSize="16"
FontWeight="DemiBold" FontWeight="DemiBold"
Background="#FFFF00" Background="#FFFF00"
Grid.Row="1" Grid.Row="1"
Grid.Column="3"/> Grid.Column="3"/>
</Grid> </Grid>
</GroupBox> </GroupBox>
<GroupBox Margin="10,2,10,10" <GroupBox Margin="10,2,10,10"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
BorderBrush="LightGray" BorderBrush="LightGray"
@@ -149,7 +160,7 @@
Background="LightGray" Background="LightGray"
Grid.Column="0"> Grid.Column="0">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Margin="5,0,5,0" Height="15" Width="13.125" Stretch="Fill" Fill="Black" Stroke="Black" StrokeThickness="0.1" StrokeStartLineCap="Flat" StrokeEndLineCap="Round" Data="{StaticResource tashCan}" VerticalAlignment="Center"/> <!--<Path Margin="5,0,5,0" Height="15" Width="13.125" Stretch="Fill" Fill="Black" Stroke="Black" StrokeThickness="0.1" StrokeStartLineCap="Flat" StrokeEndLineCap="Round" Data="{StaticResource tashCan}" VerticalAlignment="Center"/>-->
<TextBlock>Elimina .AUC</TextBlock> <TextBlock>Elimina .AUC</TextBlock>
</StackPanel> </StackPanel>
</Button> </Button>
+44
View File
@@ -0,0 +1,44 @@
using System.Windows;
using System.Windows.Input;
namespace wpf_ax_utility
{
public partial class AppMainWindow : Window
{
public AppMainWindow()
{
InitializeComponent();
}
private void MouseLeftDrag(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void CloseButton(object sender, RoutedEventArgs e)
{
Close();
}
private void AucCleanerButton(object sender, RoutedEventArgs e)
{
Utility.AucCleaner();
const string message = "I file .auc sono stati cancellati!";
const string caption = "Informazioni";
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Information);
}
private void InfoButtonButton(object sender, RoutedEventArgs e)
{
const string message = "Durante il normale utilizzo del software Microsoft Dynamics Ax 2012, potrebbero generarsi dei conflitti nelle impostazioni utente, che bloccano l'apertura del programma.\r\n\r\nÈ possibile tentare di sbloccare la situazione eliminando i file AUC dalla cache locale dell'utente.";
const string caption = "Informazioni";
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Information);
}
private void ButtonClicked(object sender, RoutedEventArgs e)
{
Utility.AxEnvironmentSelection(sender, e);
}
}
}
@@ -1,8 +1,10 @@
<Window x:Class="wpf_ax_utility.UserWindow" <Window x:Class="wpf_ax_utility.AppUserWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
dx:ThemeManager.ThemeName="None"
mc:Ignorable="d" mc:Ignorable="d"
MouseLeftButtonDown="MouseLeftDrag" MouseLeftButtonDown="MouseLeftDrag"
Height="260" Width="400" Height="260" Width="400"
@@ -12,7 +14,7 @@
AllowsTransparency="True" AllowsTransparency="True"
Background="Transparent" Background="Transparent"
Title="PAL Ax Utility" Title="PAL Ax Utility"
Icon="/axlogo.ico"> Icon="res/axlogo.ico">
<Window.Resources> <Window.Resources>
<Style TargetType="Button" x:Key="TabButton"> <Style TargetType="Button" x:Key="TabButton">
@@ -41,7 +43,7 @@
<DockPanel> <DockPanel>
<Border Height="25" Width="25" CornerRadius="5" Margin="4,3,0,0"> <Border Height="25" Width="25" CornerRadius="5" Margin="4,3,0,0">
<Border.Background> <Border.Background>
<ImageBrush Stretch="Fill" ImageSource="/axlogo.ico"/> <ImageBrush Stretch="Fill" ImageSource="res/axlogo.ico"/>
</Border.Background> </Border.Background>
</Border> </Border>
<TextBlock Margin="5,0,0,0" FontWeight="DemiBold" Text="PAL Ax Utility" VerticalAlignment="Center"/> <TextBlock Margin="5,0,0,0" FontWeight="DemiBold" Text="PAL Ax Utility" VerticalAlignment="Center"/>
+32
View File
@@ -0,0 +1,32 @@
using Serilog;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace wpf_ax_utility
{
public partial class AppUserWindow : Window
{
public AppUserWindow()
{
InitializeComponent();
}
private void MouseLeftDrag(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void CloseButton(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonClicked(object sender, RoutedEventArgs e)
{
Utility.AxEnvironmentSelection(sender, e);
}
}
}
-86
View File
@@ -1,86 +0,0 @@
using Serilog;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace wpf_ax_utility
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void MouseLeftDrag(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void CloseButton(object sender, RoutedEventArgs e)
{
Close();
}
private void AucCleanerButton(object sender, RoutedEventArgs e)
{
Utility.AucCleaner();
const string message = "I file .auc sono stati cancellati!";
const string caption = "Informazioni";
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Information);
}
private void InfoButtonButton(object sender, RoutedEventArgs e)
{
const string message = "Durante il normale utilizzo del software Microsoft Dynamics Ax 2012, potrebbero generarsi dei conflitti nelle impostazioni utente, che bloccano l'apertura del programma.\r\n\r\nÈ possibile tentare di sbloccare la situazione eliminando i file AUC dalla cache locale dell'utente.";
const string caption = "Informazioni";
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Information);
}
private void ButtonClicked(object sender, RoutedEventArgs e)
{
Utility.AucCleaner();
string AxcFilePath = "";
switch (((Button)sender).Name)
{
case "LIVE":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.LIVE_axc_filename;
if(!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.LIVE_axc_filename;
break;
case "LIVE02":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.LIVE02_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.LIVE02_axc_filename;
break;
case "DEV":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.DEV_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.DEV_axc_filename;
break;
case "TEST":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.TEST_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.TEST_axc_filename;
break;
case "STAGING":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.STAGING_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.STAGING_axc_filename;
break;
}
var AxArgs = @"-regConfig=" + AxcFilePath;
Utility.AxExecution(AxArgs);
Log.Logger.Information("Running AX client with this parameter: " + AxArgs);
}
}
}
-56
View File
@@ -1,56 +0,0 @@
using Serilog;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace wpf_ax_utility
{
public partial class UserWindow : Window
{
public UserWindow()
{
InitializeComponent();
}
private void MouseLeftDrag(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void CloseButton(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonClicked(object sender, RoutedEventArgs e)
{
Utility.AucCleaner();
string AxcFilePath = "";
switch (((Button)sender).Name)
{
case "LIVE":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.LIVE_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.LIVE_axc_filename;
break;
case "TEST":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.TEST_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.TEST_axc_filename;
break; ;
}
var AxArgs = @"-regConfig=" + AxcFilePath;
Utility.AxExecution(AxArgs);
Log.Logger.Information("Running AX client with this parameter: " + AxArgs);
}
}
}
+45
View File
@@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls;
namespace wpf_ax_utility namespace wpf_ax_utility
{ {
@@ -14,6 +15,7 @@ namespace wpf_ax_utility
Informational, Informational,
Error Error
} }
public static class Utility public static class Utility
{ {
public static void AxExecution(string AxArgs) public static void AxExecution(string AxArgs)
@@ -67,6 +69,49 @@ namespace wpf_ax_utility
} }
} }
public static void AxEnvironmentSelection(object sender, RoutedEventArgs e)
{
Utility.AucCleaner();
string AxcFilePath = "";
switch (((Button)sender).Name)
{
case "LIVE":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.LIVE_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.LIVE_axc_filename;
break;
case "LIVE02":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.LIVE02_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.LIVE02_axc_filename;
break;
case "DEV":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.DEV_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.DEV_axc_filename;
break;
case "TEST":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.TEST_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.TEST_axc_filename;
break;
case "STAGING":
AxcFilePath = Properties.Resources.network_axc_path + Properties.Resources.STAGING_axc_filename;
if (!File.Exists(AxcFilePath))
AxcFilePath = Properties.Resources.local_axc_path + Properties.Resources.STAGING_axc_filename;
break;
}
var AxArgs = @"-regConfig=" + AxcFilePath;
Utility.AxExecution(AxArgs);
Log.Logger.Information("Running AX client with this parameter: " + AxArgs);
}
public static void WriteLogMessage(string message, LogMessageSeverity Severity = LogMessageSeverity.Informational, Exception exc = null) public static void WriteLogMessage(string message, LogMessageSeverity Severity = LogMessageSeverity.Informational, Exception exc = null)
{ {
try try

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

+13 -12
View File
@@ -5,36 +5,37 @@
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<ApplicationIcon>axlogo.ico</ApplicationIcon> <ApplicationIcon>res\axlogo.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="axlogo.ico" /> <None Remove="axlogo.ico" />
<None Remove="axlogo.png" /> <None Remove="axlogo.png" />
<None Remove="rdrect1197.png" /> <None Remove="rdrect1197.png" />
<None Remove="res\pallogo.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="axlogo.ico"> <Content Include="res\axlogo.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="res\pallogo.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DevExpress.Wpf.Core" Version="22.2.4" />
<PackageReference Include="Serilog" Version="2.12.0" /> <PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Sinks.Graylog" Version="2.3.0" /> <PackageReference Include="Serilog.Sinks.Graylog" Version="2.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="axlogo.ico"> <Resource Include="res\axlogo.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource> </Resource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="axc\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Properties\Resources.Designer.cs"> <Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
@@ -51,19 +52,19 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="axc\PAL_DEVELOP_USR.axc"> <None Update="res\axc\PAL_DEVELOP_USR.axc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="axc\PAL_LIVE_02_USR.axc"> <None Update="res\axc\PAL_LIVE_02_USR.axc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="axc\PAL_LIVE_USR.axc"> <None Update="res\axc\PAL_LIVE_USR.axc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="axc\PAL_STAGING_USR.axc"> <None Update="res\axc\PAL_STAGING_USR.axc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="axc\PAL_TEST_USR.axc"> <None Update="res\axc\PAL_TEST_USR.axc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>