Cleaned up Job Queue, Gql Logs, and fixed issue for audatex Lin Files with PART_DES_J

This commit is contained in:
Patrick Fic
2020-12-03 16:59:10 -08:00
parent 53372cce9f
commit 3324f4c3b4
7 changed files with 74 additions and 46 deletions

View File

@@ -29,6 +29,8 @@ namespace BodyshopPartner.Utils.Decoder
string _dir = Path.GetDirectoryName(FilePath) + @"\"; string _dir = Path.GetDirectoryName(FilePath) + @"\";
string system = ParseEnvFile(ref ret, _dir);
ParseAd1File(ref ret, _dir); ParseAd1File(ref ret, _dir);
ParseAd2File(ref ret, _dir); ParseAd2File(ref ret, _dir);
ParseVehFile(ref ret, _dir); ParseVehFile(ref ret, _dir);
@@ -37,11 +39,51 @@ namespace BodyshopPartner.Utils.Decoder
ParsePfmFile(ref ret, _dir); ParsePfmFile(ref ret, _dir);
ParseStlFile(ref ret, _dir); ParseStlFile(ref ret, _dir);
ParseTtlFile(ref ret, _dir); ParseTtlFile(ref ret, _dir);
ParseLinFile(ref ret, _dir); ParseLinFile(ref ret, _dir, system);
ParsePfpFile(ref ret, _dir); ParsePfpFile(ref ret, _dir);
return ret; return ret;
} }
public static string ParseEnvFile(ref dynamic j, string RootFilePath)
{
if (string.IsNullOrWhiteSpace(j.ciecaid.Value))
{
return "M";
}
logger.Trace(@"Parsing Env at: {0}{1}", RootFilePath, j.ciecaid.Value);
int retryNumber = 0;
while (retryNumber < 11)
{
try
{
using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + ".env", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var reader = new DBFReader(fis);
reader.SetSelectFields(new string[] { "EST_SYSTEM"
});
var readValues = reader.NextRecord();
reader.Dispose();
return readValues[0].ToString();
}
}
catch (IOException ex)
{
logger.Trace(ex, "Unable to open AD1 file. Retrying. ");
retryNumber++;
Thread.Sleep(3000);
}
}
return "M";
}
public static void ParseAd1File(ref dynamic j, string RootFilePath) public static void ParseAd1File(ref dynamic j, string RootFilePath)
{ {
if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) if (string.IsNullOrWhiteSpace(j.ciecaid.Value))
@@ -792,7 +834,7 @@ namespace BodyshopPartner.Utils.Decoder
} }
} }
public static void ParseLinFile(ref dynamic j, string RootFilePath) public static void ParseLinFile(ref dynamic j, string RootFilePath, string system)
{ {
if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) if (string.IsNullOrWhiteSpace(j.ciecaid.Value))
{ {
@@ -818,7 +860,7 @@ namespace BodyshopPartner.Utils.Decoder
"WHO_PAYS", "WHO_PAYS",
"LINE_DESC", "LINE_DESC",
"PART_TYPE", "PART_TYPE",
"PART_DESCJ", system == "M"? "PART_DESCJ" : "PART_DES_J",
"GLASS_FLAG", "GLASS_FLAG",
"OEM_PARTNO", "OEM_PARTNO",
"PRICE_INC", "PRICE_INC",
@@ -921,7 +963,7 @@ namespace BodyshopPartner.Utils.Decoder
dynamic lin = new JObject(); dynamic lin = new JObject();
//Mising est_seq //Mising est_seq
lin.line_no = readValues[0];//LINE_NO lin.line_no = readValues[0];//LINE_NO
lin.line_ind = readValues[1];//LINE_IND lin.line_ind = readValues[1];//LINE_IND
lin.line_ref = readValues[2];//LINE_REF lin.line_ref = readValues[2];//LINE_REF

View File

@@ -26,7 +26,8 @@ namespace BodyshopPartner.Utils
{ {
using (var g = Utils.GraphQL.CreateGQLClient()) using (var g = Utils.GraphQL.CreateGQLClient())
{ {
logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables); logger.Trace("Firing a GQL Query!");
// logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables);
var graphQLResponse = await g.SendQueryAsync<dynamic>(r); var graphQLResponse = await g.SendQueryAsync<dynamic>(r);
if (graphQLResponse.Errors == null) if (graphQLResponse.Errors == null)
{ {

View File

@@ -49,21 +49,15 @@ namespace BodyshopPartner.Utils
catch (Exception Ex) catch (Exception Ex)
{ {
logger.Fatal("Unable to start HTTP server. " + Ex.ToString()); logger.Fatal("Unable to start HTTP server. " + Ex.ToString());
hlog("ImEX Online connection server could not start. Please restart the partner to try again.");
App.Current.Dispatcher.Invoke(() => App.Current.Dispatcher.Invoke(() =>
{ {
string msg = "Unable to connect to ImEX Online Web App. Please ensure your firewall allows the connection."; string msg = "Unable to connect to ImEX Online Web App. Please ensure your firewall allows the connection.";
hlog("ImEX Online connection server could not start. Please restart the partner to try again.");
Utils.Notifications.notifier.ShowError(msg);
bool AddedException = Utils.SquirrelAwareHelper.AddHttpExcetion();
//Growler.AddNotification(new Notification() Utils.Notifications.notifier.ShowError(msg);
//{
// Title = Properties.Resources.Msg_NewJobUploaded,
// Subtitle = item.Job?.ownr_fn?.Value + " " + item.Job?.ownr_ln?.Value + " | " + item.Job?.clm_no?.Value,
// //Message = item.Job?.vehicle?.data?.v_model_yr?.Value + " " + item.Job?.vehicle?.data?.v_make_desc?.Value + " " + item.Job?.vehicle?.data?.v_model_desc?.Value
//});
}); });
Utils.SquirrelAwareHelper.AddHttpExcetion(); Utils.SquirrelAwareHelper.AddHttpExcetion();
HttpServer.ListenAsync(1337, token, Route.OnHttpRequestAsync).Wait();
} }
} }

View File

@@ -61,7 +61,8 @@ namespace BodyshopPartner.Utils
break; break;
} }
//Only peek at the first item in the queue so that it does not get added again while it is still getting processed. //Only peek at the first item in the queue so that it does not get added again while it is still getting processed.
item = _jobs.Peek(); // item = _jobs.Peek();
item = _jobs.Dequeue();
} }
try try
@@ -74,8 +75,11 @@ namespace BodyshopPartner.Utils
catch (Exception ex) catch (Exception ex)
{ {
ThreadPool.UnsafeQueueUserWorkItem(ProcessQueuedItems, null); ThreadPool.UnsafeQueueUserWorkItem(ProcessQueuedItems, null);
logger.Error(ex, "Error processing job queue item. "); logger.Error("Error processing job queue item. " + ex.ToString());
//throw; }
finally
{
// _jobs.Dequeue();
} }
} }
} }
@@ -146,15 +150,15 @@ namespace BodyshopPartner.Utils
var r = new GraphQLRequest var r = new GraphQLRequest
{ {
Query = @" Query = @"
mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) { mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) {
insert_available_jobs(objects: $jobInput, on_conflict: {constraint: available_jobs_clm_no_bodyshopid_key, update_columns: [clm_amt, cieca_id, est_data, issupplement, ownr_name, source_system, supplement_number, vehicle_info]}) { insert_available_jobs(objects: $jobInput, on_conflict: {constraint: available_jobs_clm_no_bodyshopid_key, update_columns: [clm_amt, cieca_id, est_data, issupplement, ownr_name, source_system, supplement_number, vehicle_info]}) {
returning { returning {
id id
} }
} }
} }
", ",
Variables = new Variables = new
{ {
jobInput = newJob, jobInput = newJob,
@@ -194,7 +198,7 @@ mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) {
//}); ; //}); ;
}); });
} }
_jobs.Dequeue();
} }
} }
} }

View File

@@ -33,16 +33,6 @@ namespace BodyshopPartner.Utils
logger.Error("Unable to register exception " + Ex.ToString()); logger.Error("Unable to register exception " + Ex.ToString());
return false; return false;
} }
// System.Diagnostics.Process process = new System.Diagnostics.Process();
// System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
// startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// startInfo.FileName = "cmd.exe";
// startInfo.Arguments = "netsh http add urlacl url=http://+:1337/ user=\"Everyone\"";
// startInfo.Verb = "runas";
// process.StartInfo = startInfo;
//return process.Start();
} }
public static void InitializeSquirrelAware() public static void InitializeSquirrelAware()
@@ -59,7 +49,6 @@ namespace BodyshopPartner.Utils
{ {
bool successful = AddHttpExcetion(); bool successful = AddHttpExcetion();
if (successful) if (successful)
{ {
logger.Debug("Successfully added exception."); logger.Debug("Successfully added exception.");

View File

@@ -49,12 +49,7 @@ namespace BodyshopPartner.ViewModels
private void Bw_ProgressChanged(object sender, ProgressChangedEventArgs e) private void Bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{ {
Progress = e.ProgressPercentage; Progress = e.ProgressPercentage;
logger.Trace("Starting monitors if able to.");
if (StartFolderMonitorsCommand.CanExecute(null))
StartFolderMonitorsCommand.Execute(null);
MonitoringPaths.CollectionChanged += MonitoringPathsChanged;
} }
private void bw_InitVm(object sender, DoWorkEventArgs e) private void bw_InitVm(object sender, DoWorkEventArgs e)
@@ -70,6 +65,8 @@ namespace BodyshopPartner.ViewModels
MonitoringPaths.Add(new Models.Monitor() { FilePath = p }); MonitoringPaths.Add(new Models.Monitor() { FilePath = p });
} }
MonitoringPaths.CollectionChanged += MonitoringPathsChanged;
_callingThread.ReportProgress(30); _callingThread.ReportProgress(30);
_updateCheckTimer.Elapsed += _updateTimer_Elapsed; _updateCheckTimer.Elapsed += _updateTimer_Elapsed;
@@ -84,6 +81,7 @@ namespace BodyshopPartner.ViewModels
logger.Debug("VM Init Complete"); logger.Debug("VM Init Complete");
Task.Run(() => Utils.HTTPServer.InitHttpServer(AddHttpStatus)); Task.Run(() => Utils.HTTPServer.InitHttpServer(AddHttpStatus));
Task.Run(() => updateCheck()); Task.Run(() => updateCheck());
StartAllFolderMonitors();
_callingThread.ReportProgress(100); _callingThread.ReportProgress(100);
} }

View File

@@ -148,12 +148,12 @@
<Button DockPanel.Dock="Top" <Button DockPanel.Dock="Top"
Margin="8" Margin="8"
Command="{Binding TestCommand}" Command="{Binding TestCommand}"
Background="Tomato" Content="DEVELOPER TEST" />
Content="_TEST COMMAND" />
<Label DockPanel.Dock="Top" <Label DockPanel.Dock="Top"
Margin="8" Margin="8"
Content="{Binding AppVersion}" /> Content="{Binding AppVersion}" />
<StackPanel Visibility="{Binding UpdateAvailable, Converter={StaticResource BoolVisibilityConverter}}"> <StackPanel Visibility="{Binding UpdateAvailable, Converter={StaticResource BooleanToVisibilityConverter}}">
<Button Content="Update" Command="{Binding InstallUpdatesCommand}" /> <Button Content="Update" Command="{Binding InstallUpdatesCommand}" />
<ProgressBar Margin="8" Value="{Binding UpdateProgress}"/> <ProgressBar Margin="8" Value="{Binding UpdateProgress}"/>
</StackPanel> </StackPanel>