فهرست منبع

Loading APREJECT.txt in Bill poster

Kenric Nugteren 1 سال پیش
والد
کامیت
d4fd2fcd5e

+ 38 - 38
prs.shared/Editors/Dimensions/DimensionsEditorControl.cs

@@ -37,16 +37,16 @@ namespace PRS.Shared
         where TUnit : DimensionUnit, new()
     {
 
-        private Grid Grid;
-        private ComboBox Combo;
+        private Grid Grid = null!; // Late-initialized in CreateEditor
+        private ComboBox Combo = null!; // Late-initialized in CreateEditor
 
-        private DoubleTextBox Quantity;
-        private DoubleTextBox Length;
-        private DoubleTextBox Width;
-        private DoubleTextBox Height;
-        private DoubleTextBox Weight;
+        private DoubleTextBox QuantityBox = null!; // Late-initialized in CreateEditor
+        private DoubleTextBox LengthBox = null!; // Late-initialized in CreateEditor
+        private DoubleTextBox WidthBox = null!; // Late-initialized in CreateEditor
+        private DoubleTextBox HeightBox = null!; // Late-initialized in CreateEditor
+        private DoubleTextBox WeightBox = null!; // Late-initialized in CreateEditor
 
-        private List<Tuple<string, TUnit>> Units;
+        private List<Tuple<string, TUnit>> Units = null!; // Late-initialized in CreateEditor
 
         public override int DesiredHeight()
         {
@@ -60,11 +60,11 @@ namespace PRS.Shared
 
         public override void SetColor(Color color)
         {
-            Quantity.Background = new SolidColorBrush(color);
-            Length.Background = new SolidColorBrush(color);
-            Width.Background = new SolidColorBrush(color);
-            Height.Background = new SolidColorBrush(color);
-            Weight.Background = new SolidColorBrush(color);
+            QuantityBox.Background = new SolidColorBrush(color);
+            LengthBox.Background = new SolidColorBrush(color);
+            WidthBox.Background = new SolidColorBrush(color);
+            HeightBox.Background = new SolidColorBrush(color);
+            WeightBox.Background = new SolidColorBrush(color);
         }
 
         public override void SetFocus()
@@ -112,11 +112,11 @@ namespace PRS.Shared
             Combo.ItemsSource = Units;
             Combo.SelectionChanged += Combo_SelectionChanged;
 
-            Quantity = AddDimension("Quantity: ", 1);
-            Length = AddDimension("Length: ", 2);
-            Width = AddDimension("Width: ", 3);
-            Height = AddDimension("Height: ", 4);
-            Weight = AddDimension("Weight: ", 5);
+            QuantityBox = AddDimension("Quantity: ", 1);
+            LengthBox = AddDimension("Length: ", 2);
+            WidthBox = AddDimension("Width: ", 3);
+            HeightBox = AddDimension("Height: ", 4);
+            WeightBox = AddDimension("Weight: ", 5);
 
             return Grid;
         }
@@ -191,11 +191,11 @@ namespace PRS.Shared
             if (Combo.SelectedItem is not Tuple<string, TUnit> tuple) return;
             var unit = tuple.Item2;
 
-            UpdateColumn(1, unit.HasQuantity, Quantity);
-            UpdateColumn(2, unit.HasLength, Length);
-            UpdateColumn(3, unit.HasWidth, Width);
-            UpdateColumn(4, unit.HasHeight, Height);
-            UpdateColumn(5, unit.HasWeight, Weight);
+            UpdateColumn(1, unit.HasQuantity, QuantityBox);
+            UpdateColumn(2, unit.HasLength, LengthBox);
+            UpdateColumn(3, unit.HasWidth, WidthBox);
+            UpdateColumn(4, unit.HasHeight, HeightBox);
+            UpdateColumn(5, unit.HasWeight, WeightBox);
 
             foreach(var property in DatabaseSchema.Properties(typeof(TUnit)))
             {
@@ -211,11 +211,11 @@ namespace PRS.Shared
             if (!property.StartsWith($"{ColumnName}.")) return null;
             property = property[(ColumnName.Length + 1)..];
 
-            if (property == "Quantity") return Quantity.Value ?? 0.0;
-            if (property == "Length") return Length.Value ?? 0.0;
-            if (property == "Width") return Width.Value ?? 0.0;
-            if (property == "Height") return Height.Value ?? 0.0;
-            if (property == "Weight") return Weight.Value ?? 0.0;
+            if (property == "Quantity") return QuantityBox.Value ?? 0.0;
+            if (property == "Length") return LengthBox.Value ?? 0.0;
+            if (property == "Width") return WidthBox.Value ?? 0.0;
+            if (property == "Height") return HeightBox.Value ?? 0.0;
+            if (property == "Weight") return WeightBox.Value ?? 0.0;
             if (property == "Unit.ID") return Combo.SelectedValue is Guid guid ? guid : Guid.Empty;
 
             return null;
@@ -224,11 +224,11 @@ namespace PRS.Shared
         {
             var values = new Dictionary<string, object?>
             {
-                {$"{ColumnName}.Quantity", Quantity.Value ?? 0.0},
-                {$"{ColumnName}.Length", Length.Value ?? 0.0},
-                {$"{ColumnName}.Width", Width.Value ?? 0.0},
-                {$"{ColumnName}.Height", Height.Value ?? 0.0},
-                {$"{ColumnName}.Weight", Weight.Value ?? 0.0},
+                {$"{ColumnName}.Quantity", QuantityBox.Value ?? 0.0},
+                {$"{ColumnName}.Length", LengthBox.Value ?? 0.0},
+                {$"{ColumnName}.Width", WidthBox.Value ?? 0.0},
+                {$"{ColumnName}.Height", HeightBox.Value ?? 0.0},
+                {$"{ColumnName}.Weight", WeightBox.Value ?? 0.0},
                 {$"{ColumnName}.Unit.ID", Combo.SelectedValue is Guid guid ? guid : Guid.Empty }
             };
             return values;
@@ -247,11 +247,11 @@ namespace PRS.Shared
                 return;
             }
 
-            if (property == "Quantity") Quantity.Value = (double)value;
-            if (property == "Length") Length.Value = (double)value;
-            if (property == "Width") Width.Value = (double)value;
-            if (property == "Height") Height.Value = (double)value;
-            if (property == "Weight") Weight.Value = (double)value;
+            if (property == "Quantity") QuantityBox.Value = (double)value;
+            if (property == "Length") LengthBox.Value = (double)value;
+            if (property == "Width") WidthBox.Value = (double)value;
+            if (property == "Height") HeightBox.Value = (double)value;
+            if (property == "Weight") WeightBox.Value = (double)value;
         }
 
     }

+ 1 - 1
prs.shared/Grids/ScheduleItemGrid.cs

@@ -69,7 +69,7 @@ namespace PRS.Shared
                 {
                     schedules = Serialization.Deserialize<Schedule[]>(json);
                 }
-                catch (Exception e)
+                catch
                 {
                     Progress.Close();
                     MessageBox.Show("[" + Path.GetFileName(dlg.FileName) + "] is not a valid schedule file!");

+ 10 - 12
prs.shared/Posters/Timberline/BillTimberlinePoster.cs

@@ -456,20 +456,18 @@ public class Module
                     }
                 }
 
-                /*while (true)
+                while (true)
                 {
                     var logDlg = new OpenFileDialog
                     {
                         InitialDirectory = Path.GetDirectoryName(dlg.FileName),
-                        FileName = "JCREJECT.JCC",
-                        Filter = "Rejected Item Files (*.jcc) | *.jcc;*.JCC | All Files (*.*) | *.*",
-                        Title = "Please select JCREJECT.JCC"
+                        FileName = "APREJECT.txt",
+                        Filter = "All Files (*.*) | *.*",
+                        Title = "Please select APREJECT.txt"
                     };
                     if (logDlg.ShowDialog() == true)
                     {
                         var rejectedHeaders = new List<BillTimberlineHeader?>();
-                        var rejectedLines = new List<BillTimberlineDistribution?>();
-                        BillTimberlineHeader? lastHeader = null;
                         using (var reader = new StreamReader(logDlg.FileName))
                         {
                             using var csv = new CsvReader(reader, new CsvConfiguration(CultureInfo.InvariantCulture)
@@ -491,7 +489,6 @@ public class Module
                                         {
                                             (entry.Item1 as IPostable).FailPost("");
                                         }
-                                        lastHeader = header;
                                     }
                                     else
                                     {
@@ -501,7 +498,10 @@ public class Module
                                 }
                                 else if (id == "APDF")
                                 {
-                                    var line = csv.GetRecord<BillTimberlineDistribution>();
+                                    // Ignoring these because the reject file contains the header as well, and we don't need to fail BillLines, because
+                                    // they aren't postable.
+
+                                    /*var line = csv.GetRecord<BillTimberlineDistribution>();
                                     if (line is not null)
                                     {
                                         var entry = result.Items.FirstOrDefault(x => x.Item2?.Invoice.Equals(line.Invoice) == true);
@@ -514,7 +514,7 @@ public class Module
                                     {
                                         Logger.Send(LogType.Error, "", "Bill Timberline export: Unable to parse line from CSV line in rejection file.");
                                         MessageBox.Show("Invalid line in file; skipping.");
-                                    }
+                                    }*/
                                 }
                                 ++i;
                             }
@@ -532,9 +532,7 @@ public class Module
                             return result;
                         }
                     }
-                }*/
-
-                return result;
+                }
             }
             else
             {