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 system = ParseEnvFile(ref ret, _dir);
ParseAd1File(ref ret, _dir);
ParseAd2File(ref ret, _dir);
ParseVehFile(ref ret, _dir);
@@ -37,11 +39,51 @@ namespace BodyshopPartner.Utils.Decoder
ParsePfmFile(ref ret, _dir);
ParseStlFile(ref ret, _dir);
ParseTtlFile(ref ret, _dir);
ParseLinFile(ref ret, _dir);
ParseLinFile(ref ret, _dir, system);
ParsePfpFile(ref ret, _dir);
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)
{
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))
{
@@ -818,7 +860,7 @@ namespace BodyshopPartner.Utils.Decoder
"WHO_PAYS",
"LINE_DESC",
"PART_TYPE",
"PART_DESCJ",
system == "M"? "PART_DESCJ" : "PART_DES_J",
"GLASS_FLAG",
"OEM_PARTNO",
"PRICE_INC",
@@ -921,7 +963,7 @@ namespace BodyshopPartner.Utils.Decoder
dynamic lin = new JObject();
//Mising est_seq
lin.line_no = readValues[0];//LINE_NO
lin.line_ind = readValues[1];//LINE_IND
lin.line_ref = readValues[2];//LINE_REF

View File

@@ -26,7 +26,8 @@ namespace BodyshopPartner.Utils
{
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);
if (graphQLResponse.Errors == null)
{

View File

@@ -49,21 +49,15 @@ namespace BodyshopPartner.Utils
catch (Exception Ex)
{
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(() =>
{
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()
//{
// 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.Notifications.notifier.ShowError(msg);
});
Utils.SquirrelAwareHelper.AddHttpExcetion();
HttpServer.ListenAsync(1337, token, Route.OnHttpRequestAsync).Wait();
}
}

View File

@@ -61,7 +61,8 @@ namespace BodyshopPartner.Utils
break;
}
//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
@@ -74,8 +75,11 @@ namespace BodyshopPartner.Utils
catch (Exception ex)
{
ThreadPool.UnsafeQueueUserWorkItem(ProcessQueuedItems, null);
logger.Error(ex, "Error processing job queue item. ");
//throw;
logger.Error("Error processing job queue item. " + ex.ToString());
}
finally
{
// _jobs.Dequeue();
}
}
}
@@ -146,15 +150,15 @@ namespace BodyshopPartner.Utils
var r = new GraphQLRequest
{
Query = @"
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]}) {
returning {
id
}
}
}
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]}) {
returning {
id
}
}
}
",
",
Variables = new
{
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());
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()
@@ -59,7 +49,6 @@ namespace BodyshopPartner.Utils
{
bool successful = AddHttpExcetion();
if (successful)
{
logger.Debug("Successfully added exception.");

View File

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

View File

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