diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config
index 172e943..986065c 100644
--- a/BodyshopUploader/App.config
+++ b/BodyshopUploader/App.config
@@ -75,6 +75,12 @@
c:\program files\armsbusinesssolutions\repairorderpumpagentservice\export
+
+ C:\Color\PPGImport
+
+
+ 0
+
diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj
index 0050fc0..ca2a4ff 100644
--- a/BodyshopUploader/ImEXOnlinePartner.csproj
+++ b/BodyshopUploader/ImEXOnlinePartner.csproj
@@ -398,6 +398,9 @@
3.1.0
+
+ 107.3.0
+
1.0.6
diff --git a/BodyshopUploader/Properties/AssemblyInfo.cs b/BodyshopUploader/Properties/AssemblyInfo.cs
index 8967e89..498ecc4 100644
--- a/BodyshopUploader/Properties/AssemblyInfo.cs
+++ b/BodyshopUploader/Properties/AssemblyInfo.cs
@@ -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")]
\ No newline at end of file
diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs
index 4e2dd90..f80c3c4 100644
--- a/BodyshopUploader/Properties/Resources.Designer.cs
+++ b/BodyshopUploader/Properties/Resources.Designer.cs
@@ -196,7 +196,16 @@ namespace BodyshopPartner.Properties {
}
///
- /// Looks up a localized string similar to Browse Paint Scale Path.
+ /// Looks up a localized string similar to Browse Paint Scale -> IO Path.
+ ///
+ public static string Label_BrowsePaintScaleImportPath {
+ get {
+ return ResourceManager.GetString("Label_BrowsePaintScaleImportPath", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Browse IO-> Paint Scale Path.
///
public static string Label_BrowsePaintScalePath {
get {
@@ -259,7 +268,25 @@ namespace BodyshopPartner.Properties {
}
///
- /// Looks up a localized string similar to Paint Scale Path.
+ /// Looks up a localized string similar to Paint Scale -> IO Path.
+ ///
+ public static string Label_PaintScaleImportPath {
+ get {
+ return ResourceManager.GetString("Label_PaintScaleImportPath", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Paint Scare Import Timer (mins).
+ ///
+ public static string Label_PaintScaleImportTimer {
+ get {
+ return ResourceManager.GetString("Label_PaintScaleImportTimer", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to IO ->Paint Scale Path.
///
public static string Label_PaintScalePath {
get {
diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx
index 3a3a208..bdda7b9 100644
--- a/BodyshopUploader/Properties/Resources.resx
+++ b/BodyshopUploader/Properties/Resources.resx
@@ -162,8 +162,11 @@
Browse for QuickBooks File
+
+ Browse Paint Scale -> IO Path
+
- Browse Paint Scale Path
+ Browse IO-> Paint Scale Path
(Re)configure ARMS Export
@@ -183,8 +186,14 @@
Monitor Status
+
+ Paint Scale -> IO Path
+
+
+ Paint Scare Import Timer (mins)
+
- Paint Scale Path
+ IO ->Paint Scale Path
QuickBooks File Path
diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs
index ddebeda..6b778b1 100644
--- a/BodyshopUploader/Properties/Settings.Designer.cs
+++ b/BodyshopUploader/Properties/Settings.Designer.cs
@@ -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;
+ }
+ }
}
}
diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings
index 1f4fd3a..0b2bddf 100644
--- a/BodyshopUploader/Properties/Settings.settings
+++ b/BodyshopUploader/Properties/Settings.settings
@@ -41,5 +41,11 @@
c:\program files\armsbusinesssolutions\repairorderpumpagentservice\export
+
+ C:\Color\PPGImport
+
+
+ 0
+
\ No newline at end of file
diff --git a/BodyshopUploader/Releases/RELEASES b/BodyshopUploader/Releases/RELEASES
index 770daa5..7a9613b 100644
--- a/BodyshopUploader/Releases/RELEASES
+++ b/BodyshopUploader/Releases/RELEASES
@@ -64,4 +64,6 @@ D441404BE86E0A676462DD367D4355894C2FFDBA ImEXOnlinePartner-1.0.30-delta.nupkg 62
5C61CDF97FA03C44FF74EE4E2EE4514177CE1326 ImEXOnlinePartner-1.0.33-delta.nupkg 43893
01123C15D95479FCE91F2C24CCEFEE4F08A6FC8A ImEXOnlinePartner-1.0.33-full.nupkg 5608151
48AB8CC396744B4A8A4C18009104D4F34A51D8C3 ImEXOnlinePartner-1.0.34-delta.nupkg 41320
-F487943208C465042E626845FF729EAAA2260DD0 ImEXOnlinePartner-1.0.34-full.nupkg 5608469
\ No newline at end of file
+F487943208C465042E626845FF729EAAA2260DD0 ImEXOnlinePartner-1.0.34-full.nupkg 5608469
+CC056E5BB72DFBD1DB7E2F025A6FAA249C0FE5AA ImEXOnlinePartner-1.0.35-delta.nupkg 57386
+4F23E6E008B56EC556E17EFF7318C128245E5817 ImEXOnlinePartner-1.0.35-full.nupkg 5609687
\ No newline at end of file
diff --git a/BodyshopUploader/Utils/AppMetaData.cs b/BodyshopUploader/Utils/AppMetaData.cs
index 59eca03..98a88f5 100644
--- a/BodyshopUploader/Utils/AppMetaData.cs
+++ b/BodyshopUploader/Utils/AppMetaData.cs
@@ -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
}
diff --git a/BodyshopUploader/Utils/Auth.cs b/BodyshopUploader/Utils/Auth.cs
index f1b0714..d7cc09c 100644
--- a/BodyshopUploader/Utils/Auth.cs
+++ b/BodyshopUploader/Utils/Auth.cs
@@ -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();
diff --git a/BodyshopUploader/Utils/PPGMixData.cs b/BodyshopUploader/Utils/PPGMixData.cs
index bb5ec19..011f1b0 100644
--- a/BodyshopUploader/Utils/PPGMixData.cs
+++ b/BodyshopUploader/Utils/PPGMixData.cs
@@ -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
diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
index aaf1d8e..41ac8f7 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
@@ -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
{
diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs
index 7ff0864..f4ce3dc 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.cs
@@ -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();
}
diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml
index 6379aff..dd1ca71 100644
--- a/BodyshopUploader/Views/Main.xaml
+++ b/BodyshopUploader/Views/Main.xaml
@@ -162,20 +162,23 @@
+
-
+
-
+
+ Content="Test Command" />-->