IO-233 2 Way Paint Scale.

This commit is contained in:
Patrick Fic
2022-04-28 09:46:47 -07:00
parent 1a1cc67402
commit 6eff2dbb31
15 changed files with 277 additions and 23 deletions

View File

@@ -75,6 +75,12 @@
<setting name="ArmsExportPath" serializeAs="String">
<value>c:\program files\armsbusinesssolutions\repairorderpumpagentservice\export</value>
</setting>
<setting name="PaintScaleImportPath" serializeAs="String">
<value>C:\Color\PPGImport</value>
</setting>
<setting name="PaintScaleImportTimer" serializeAs="String">
<value>0</value>
</setting>
</BodyshopPartner.Properties.Settings>
</userSettings>
</configuration>

View File

@@ -398,6 +398,9 @@
<PackageReference Include="Ookii.Dialogs.Wpf">
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="RestSharp">
<Version>107.3.0</Version>
</PackageReference>
<PackageReference Include="Simple-HTTP">
<Version>1.0.6</Version>
</PackageReference>

View File

@@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.34.0")]
[assembly: AssemblyVersion("1.0.35.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//Setting Squirrel Aware Version.
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

View File

@@ -196,7 +196,16 @@ namespace BodyshopPartner.Properties {
}
/// <summary>
/// Looks up a localized string similar to Browse Paint Scale Path.
/// Looks up a localized string similar to Browse Paint Scale -&gt; IO Path.
/// </summary>
public static string Label_BrowsePaintScaleImportPath {
get {
return ResourceManager.GetString("Label_BrowsePaintScaleImportPath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Browse IO-&gt; Paint Scale Path.
/// </summary>
public static string Label_BrowsePaintScalePath {
get {
@@ -259,7 +268,25 @@ namespace BodyshopPartner.Properties {
}
/// <summary>
/// Looks up a localized string similar to Paint Scale Path.
/// Looks up a localized string similar to Paint Scale -&gt; IO Path.
/// </summary>
public static string Label_PaintScaleImportPath {
get {
return ResourceManager.GetString("Label_PaintScaleImportPath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Paint Scare Import Timer (mins).
/// </summary>
public static string Label_PaintScaleImportTimer {
get {
return ResourceManager.GetString("Label_PaintScaleImportTimer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IO -&gt;Paint Scale Path.
/// </summary>
public static string Label_PaintScalePath {
get {

View File

@@ -162,8 +162,11 @@
<data name="Label_BrowseForQb" xml:space="preserve">
<value>Browse for QuickBooks File</value>
</data>
<data name="Label_BrowsePaintScaleImportPath" xml:space="preserve">
<value>Browse Paint Scale -&gt; IO Path</value>
</data>
<data name="Label_BrowsePaintScalePath" xml:space="preserve">
<value>Browse Paint Scale Path</value>
<value>Browse IO-&gt; Paint Scale Path</value>
</data>
<data name="Label_ConfigureArmsExport" xml:space="preserve">
<value>(Re)configure ARMS Export</value>
@@ -183,8 +186,14 @@
<data name="Label_MonitorStatus" xml:space="preserve">
<value>Monitor Status</value>
</data>
<data name="Label_PaintScaleImportPath" xml:space="preserve">
<value>Paint Scale -&gt; IO Path</value>
</data>
<data name="Label_PaintScaleImportTimer" xml:space="preserve">
<value>Paint Scare Import Timer (mins)</value>
</data>
<data name="Label_PaintScalePath" xml:space="preserve">
<value>Paint Scale Path</value>
<value>IO -&gt;Paint Scale Path</value>
</data>
<data name="Label_QbFilePath" xml:space="preserve">
<value>QuickBooks File Path</value>

View File

@@ -176,5 +176,29 @@ namespace BodyshopPartner.Properties {
this["ArmsExportPath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Color\\PPGImport")]
public string PaintScaleImportPath {
get {
return ((string)(this["PaintScaleImportPath"]));
}
set {
this["PaintScaleImportPath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public string PaintScaleImportTimer {
get {
return ((string)(this["PaintScaleImportTimer"]));
}
set {
this["PaintScaleImportTimer"] = value;
}
}
}
}

View File

@@ -41,5 +41,11 @@
<Setting Name="ArmsExportPath" Type="System.String" Scope="User">
<Value Profile="(Default)">c:\program files\armsbusinesssolutions\repairorderpumpagentservice\export</Value>
</Setting>
<Setting Name="PaintScaleImportPath" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\Color\PPGImport</Value>
</Setting>
<Setting Name="PaintScaleImportTimer" Type="System.String" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -65,3 +65,5 @@ D441404BE86E0A676462DD367D4355894C2FFDBA ImEXOnlinePartner-1.0.30-delta.nupkg 62
01123C15D95479FCE91F2C24CCEFEE4F08A6FC8A ImEXOnlinePartner-1.0.33-full.nupkg 5608151
48AB8CC396744B4A8A4C18009104D4F34A51D8C3 ImEXOnlinePartner-1.0.34-delta.nupkg 41320
F487943208C465042E626845FF729EAAA2260DD0 ImEXOnlinePartner-1.0.34-full.nupkg 5608469
CC056E5BB72DFBD1DB7E2F025A6FAA249C0FE5AA ImEXOnlinePartner-1.0.35-delta.nupkg 57386
4F23E6E008B56EC556E17EFF7318C128245E5817 ImEXOnlinePartner-1.0.35-full.nupkg 5609687

View File

@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.IO;
using RestSharp;
namespace BodyshopPartner.Utils
{
public static class AppMetaData
@@ -23,6 +23,9 @@ namespace BodyshopPartner.Utils
private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
public static string globalScriptsPath = @"C:\ImEX\PartnerScripts";
public static RestClient RestClient;
public static void CreateEndpoints()
{
logger.Debug("Creating endpoints for graphql.");
@@ -31,14 +34,18 @@ namespace BodyshopPartner.Utils
{
#if DEBUG
graphQlEndpoint = "https://bodyshop-dev-db.herokuapp.com/v1/graphql";
RestClient = new RestClient("http://localhost:4000");
FirebaseAPIKey = "AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc";
#elif TEST
graphQlEndpoint = "https://db.test.bodyshop.app/v1/graphql";
RestClient = new RestClient("https://api.test.imex.online");
FirebaseAPIKey = "AIzaSyBw7_GTy7GtQyfkIRPVrWHEGKfcqeyXw0c";
#else
graphQlEndpoint = "https://db.imex.online/v1/graphql";
RestClient = new RestClient("https://api.imex.online");
FirebaseAPIKey = "AIzaSyDSezy-jGJreo7ulgpLdlpOwAOrgcaEkhU";
#endif
}
@@ -49,16 +56,20 @@ namespace BodyshopPartner.Utils
IsTest = true;
graphQlEndpoint = "https://db.test.bodyshop.app/v1/graphql";
RestClient = new RestClient("https://api.test.imex.online");
FirebaseAPIKey = "AIzaSyBw7_GTy7GtQyfkIRPVrWHEGKfcqeyXw0c";
}
else
{
#if DEBUG
graphQlEndpoint = "https://bodyshop-dev-db.herokuapp.com/v1/graphql";
RestClient = new RestClient("http://localhost:4000");
FirebaseAPIKey = "AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc";
#else
graphQlEndpoint = "https://db.imex.online/v1/graphql";
RestClient = new RestClient("https://api.imex.online");
FirebaseAPIKey = "AIzaSyDSezy-jGJreo7ulgpLdlpOwAOrgcaEkhU";
#endif
}

View File

@@ -31,8 +31,8 @@ namespace BodyshopPartner.Utils
await authlink.RefreshUserDetails();
authlink.FirebaseAuthRefreshed += Authlink_FirebaseAuthRefreshed;
logger.Trace("Firebase Auth Token {0}.", authlink.FirebaseToken);
logger.Trace("Firebase Auth Token expires in {0} seconds.", authlink.ExpiresIn);
//logger.Trace("Firebase Auth Token {0}.", authlink.FirebaseToken);
// logger.Trace("Firebase Auth Token expires in {0} seconds.", authlink.ExpiresIn);
tokenTimer.Interval = (authlink.ExpiresIn - 600) * 1000; //Set the token to refresh 10 minutes before it has to.
logger.Trace("Refresh timer interval set to {0}ms", (authlink.ExpiresIn - 600) * 1000);
tokenTimer.Elapsed += TokenTimer_Tick;
@@ -81,8 +81,8 @@ namespace BodyshopPartner.Utils
logger.Trace("Firebase Auth Token {0}.", authlink.FirebaseToken);
logger.Trace("Firebase Auth Token expires in {0} seconds.", authlink.ExpiresIn);
// logger.Trace("Firebase Auth Token {0}.", authlink.FirebaseToken);
// logger.Trace("Firebase Auth Token expires in {0} seconds.", authlink.ExpiresIn);
tokenTimer.Interval = (authlink.ExpiresIn - 600) * 1000; //Set the token to refresh 10 minutes before it has to.
logger.Trace("Refresh timer interval set to {0}ms", (authlink.ExpiresIn - 600) * 1000);
tokenTimer.Elapsed += TokenTimer_Tick;
@@ -119,26 +119,26 @@ namespace BodyshopPartner.Utils
public static async Task Refresh()
{
logger.Trace("Old Token {0}", authlink.RefreshToken);
//logger.Trace("Old Token {0}", authlink.RefreshToken);
await authlink.GetFreshAuthAsync();
authlink = await ap.RefreshAuthAsync(authlink);
logger.Trace("new Token {0}", authlink.FirebaseToken);
// logger.Trace("new Token {0}", authlink.FirebaseToken);
}
private static void Authlink_FirebaseAuthRefreshed(object sender, FirebaseAuthEventArgs e)
{
logger.Debug("Auth token refreshed!");
logger.Debug("New token: {0}", e.FirebaseAuth.FirebaseToken);
// logger.Debug("Auth token refreshed!");
// logger.Debug("New token: {0}", e.FirebaseAuth.FirebaseToken);
}
private static async Task RefreshToken()
{
//Gotta do some stuff now that i got a new token!
//Maybe the token auto refreshes?
logger.Info("Timer Old Token {0}", authlink.FirebaseToken);
// logger.Info("Timer Old Token {0}", authlink.FirebaseToken);
authlink = await authlink.GetFreshAuthAsync();
logger.Info("new Token {0}", authlink.FirebaseToken);
// logger.Info("new Token {0}", authlink.FirebaseToken);
tokenTimer.Stop();
tokenTimer.Interval = (authlink.ExpiresIn - 600) * 1000; //Set the token to refresh 10 minutes before it has to.
tokenTimer.Start();

View File

@@ -7,6 +7,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.IO;
using System.Timers;
using RestSharp;
namespace BodyshopPartner.Utils
{
@@ -59,6 +61,106 @@ v_paint_codes
}
";
private static Timer MixDataImportTimer = new Timer();
public static void StartMixTimer()
{
MixDataImportTimer.Stop();
double Interval =0;
bool parseSuccesful = double.TryParse(Properties.Settings.Default.PaintScaleImportTimer, out Interval);
if (parseSuccesful && Interval > 0)
{
logger.Debug("Starting Mix Data Import timer. ", Interval * 1000 * 60);
MixDataImportTimer.Interval = Interval * 1000*60;
MixDataImportTimer.Elapsed += MixDataImportTimer_Tick;
MixDataImportTimer.Start();
}
}
public static async Task test()
{
logger.Info("Starting MixData import.");
//Check to make sure that the directory exists.
Directory.CreateDirectory(Properties.Settings.Default.PaintScaleImportPath);
Directory.CreateDirectory(Path.Combine(Properties.Settings.Default.PaintScaleImportPath, "archive"));
//Check to see if there is a file that exists.
string[] fileEntries = Directory.GetFiles(Properties.Settings.Default.PaintScaleImportPath);
foreach (string fileName in fileEntries)
{
try
{
logger.Debug("Reading file in directory: " + fileName);
RestRequest request = new RestRequest("/mixdata/upload", Method.Post);
request.AddHeader("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken);
request.AddFile("file", fileName);
request.AddJsonBody(new { bodyshopid = AppMetaData.ActiveShopId });
RestResponse _ = await AppMetaData.RestClient.ExecuteAsync(request);
if (_.IsSuccessful)
{
logger.Info("Successful upload");
string newPath = Path.Combine(Properties.Settings.Default.PaintScaleImportPath, "archive") + @"\\" + DateTime.Now.Ticks + ".xml";
File.Move(fileName, newPath);
}
else
{
logger.Error("Unable to process file " + fileName + ". " + _.ErrorMessage);
}
}catch (Exception ex)
{
Directory.CreateDirectory(Path.Combine(Properties.Settings.Default.PaintScaleImportPath, "errored"));
string newPath = Path.Combine(Properties.Settings.Default.PaintScaleImportPath, "errored") + @"\\" + DateTime.Now.Ticks + ".xml";
File.Move(fileName, newPath);
logger.Error(ex);
}
}
}
public static async void MixDataImportTimer_Tick(object sender, ElapsedEventArgs e)
{
logger.Info("Starting MixData import ");
//Check to make sure that the directory exists.
Directory.CreateDirectory(Properties.Settings.Default.PaintScaleImportPath);
Directory.CreateDirectory(Path.Combine(Properties.Settings.Default.PaintScaleImportPath, "archive"));
//Check to see if there is a file that exists.
string[] fileEntries = Directory.GetFiles(Properties.Settings.Default.PaintScaleImportPath);
foreach (string fileName in fileEntries)
{
logger.Debug("Reading file in directory: " + fileName);
RestRequest request = new RestRequest("/mixdata/upload",Method.Post);
request.AddHeader("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken);
request.AddFile("file", Path.Combine(Properties.Settings.Default.PaintScaleImportPath, fileName));
RestResponse _ = await AppMetaData.RestClient.ExecuteAsync(request);
if (_.IsSuccessful)
{
logger.Info("Successful upload");
}
}
//If a file does exist, read it, and send it up to the API with the Active Shop ID & job.
//On succesful send, archive the file
//Make sure the archive directory exists
//Rename and move the file to the archive directory.
}
public static async Task PushDataToPPG()
{
try

View File

@@ -202,6 +202,22 @@ namespace BodyshopPartner.ViewModels
}
}
private ICommand _browseForPaintScaleImportPathCommand;
public ICommand BrowseForPaintScaleImportPathCommand
{
get
{
if (_browseForPaintScaleImportPathCommand == null)
{
_browseForPaintScaleImportPathCommand = new RelayCommand(
p => true,
p => BrowseForPaintScaleImportPath()
);
}
return _browseForPaintScaleImportPathCommand;
}
}
private ICommand _configurePaintScaleCommand;
public ICommand ConfigurePaintScaleCommand
{

View File

@@ -67,6 +67,8 @@ namespace BodyshopPartner.ViewModels
MonitoringPaths.CollectionChanged += MonitoringPathsChanged;
Utils.PPGMixData.StartMixTimer();
_callingThread.ReportProgress(30);
_updateCheckTimer.Elapsed += _updateTimer_Elapsed;
@@ -254,9 +256,20 @@ namespace BodyshopPartner.ViewModels
Properties.Settings.Default.PaintScalePath = dialog.SelectedPath;
Properties.Settings.Default.Save();
}
}
public void BrowseForPaintScaleImportPath()
{
var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
dialog.SelectedPath = Properties.Settings.Default.PaintScaleImportPath;
if (dialog.ShowDialog().GetValueOrDefault())
{
Properties.Settings.Default.PaintScaleImportPath = dialog.SelectedPath;
Properties.Settings.Default.Save();
}
}
public void BrowseForArmsPath()
{
@@ -369,7 +382,7 @@ namespace BodyshopPartner.ViewModels
public async Task TestGql()
{
Utils.SquirrelAwareHelper.CopyScripts();
Utils.PPGMixData.test();
}

View File

@@ -162,6 +162,9 @@
<Button Command="{Binding BrowseForPaintScalePathCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
Content="{x:Static p:Resources.Label_BrowsePaintScalePath}" />
<Button Command="{Binding BrowseForPaintScaleImportPathCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
Content="{x:Static p:Resources.Label_BrowsePaintScaleImportPath}" />
<Button Command="{Binding BrowseForArmsPathPathCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
Content="{x:Static p:Resources.Label_BrowseArmsExportPath}" />
@@ -175,7 +178,7 @@
Content="{x:Static p:Resources.Label_ConfigureArmsExport}" />
<!--<Button Command="{Binding TestCommand}"
Margin="8"
Content="OE Test" />-->
Content="Test Command" />-->
<!--<Button Click="Button_Click"
Margin="8"
Content="Test" />
@@ -262,6 +265,25 @@
Path=PaintScalePath}"
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_PaintScalePath}"
TextChanged="PaintScalePath_TextChanged" />
<Grid DockPanel.Dock="Top"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0"
Text="{Binding Source={x:Static properties:Settings.Default},
Path=PaintScaleImportPath}"
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_PaintScaleImportPath}"
TextChanged="PaintScaleImportPath_TextChanged" />
<TextBox Grid.Column="1"
Text="{Binding Source={x:Static properties:Settings.Default},
Path=PaintScaleImportTimer}"
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_PaintScaleImportTimer}"
TextChanged="PaintScaleImportTimer_TextChanged" />
</Grid>
<TextBox DockPanel.Dock="Top"
Text="{Binding Source={x:Static properties:Settings.Default},
Path=ArmsExportPath}"

View File

@@ -49,6 +49,19 @@ namespace BodyshopPartner.Views
Properties.Settings.Default.Save();
}
private void PaintScaleImportPath_TextChanged(object sender, TextChangedEventArgs e)
{
Properties.Settings.Default.PaintScaleImportPath = ((System.Windows.Controls.TextBox)sender).Text;
Properties.Settings.Default.Save();
}
private void PaintScaleImportTimer_TextChanged(object sender, TextChangedEventArgs e)
{
Properties.Settings.Default.PaintScaleImportTimer = ((System.Windows.Controls.TextBox)sender).Text;
Properties.Settings.Default.Save();
Utils.PPGMixData.StartMixTimer();
}
private void ArmsExportPath_TextChanged(object sender, TextChangedEventArgs e)
{
Properties.Settings.Default.ArmsExportPath = ((System.Windows.Controls.TextBox)sender).Text;