ソースを参照

Cleaning up some dumb employee caching stuff in factory panel

Kenric Nugteren 1 年間 前
コミット
7759fc4b20
1 ファイル変更9 行追加84 行削除
  1. 9 84
      prs.desktop/Panels/Factory/FactoryPanel.xaml.cs

+ 9 - 84
prs.desktop/Panels/Factory/FactoryPanel.xaml.cs

@@ -136,11 +136,6 @@ namespace PRSDesktop
             Sections = setups.Get<ManufacturingSection>().Rows.Select(x => x.ToObject<ManufacturingSection>()).ToArray();
             Trolleys = setups.Get<ManufacturingTrolley>().Rows.Select(x => x.ToObject<ManufacturingTrolley>()).ToArray();
 
-            Employees = setups.Get<Employee>().ToDictionary<Employee, Guid, string>(x => x.ID, x => x.Name);
-            var myRow = setups.Get<Employee>().Rows.FirstOrDefault(r => r.Get<Employee, Guid>(c => c.UserLink.ID).Equals(ClientFactory.UserGuid));
-            myID = myRow?.Get<Employee, Guid>(c => c.ID) ?? Guid.Empty;
-            myName = myRow?.Get<Employee, string>(c => c.Name) ?? "(Unknown Employee)";
-
             Shipments = setups.Get<Shipment>();
 
             CurrentSection = Sections.FirstOrDefault(x => x.ID.Equals(_settings.Section))
@@ -281,7 +276,7 @@ namespace PRSDesktop
             {
                 var history = new ManufacturingHistory();
                 history.Date = DateTime.Today;
-                history.Employee.ID = myID;
+                history.Employee.ID = App.EmployeeID;
                 history.Packet.ID = Guid.Empty;
                 history.LostTime.ID = LostTime.ID;
                 history.Description = LostTime.Description;
@@ -329,7 +324,7 @@ namespace PRSDesktop
                 {
                     var history = new ManufacturingHistory();
                     history.Date = DateTime.Today;
-                    history.Employee.ID = myID;
+                    history.Employee.ID = App.EmployeeID;
                     history.Packet.ID = id;
                     history.Description = CheckedPackets[id].Item5;
                     //history.Setout.ID = CheckedPackets[id].Item3;
@@ -691,9 +686,9 @@ namespace PRSDesktop
             //).Rows.FirstOrDefault()?.ToObject<Supplier>());
             order.SupplierLink.ID = window.SupplierID;
             order.SupplierLink.Name = window.SupplierName; //supplier != null ? supplier.Name : "Unknown Supplier";
-            order.Description = string.Format("Materials Processing Request raised by {0} from Factory Floor", Employees[myID]);
-            order.RaisedBy.ID = myID;
-            order.IssuedBy.ID = myID;
+            order.Description = string.Format("Materials Processing Request raised by {0} from Factory Floor", App.EmployeeName);
+            order.RaisedBy.ID = App.EmployeeID;
+            order.IssuedBy.ID = App.EmployeeID;
             order.IssuedDate = DateTime.Today;
             order.DueDate = DateTime.Today.AddDays(7);
             new Client<PurchaseOrder>().Save(order, "Created Treatment Purchase Order");
@@ -784,19 +779,18 @@ namespace PRSDesktop
             var delivery = new Delivery();
             delivery.Date = DateTime.Today;
             delivery.Due = DateTime.Today;
-            delivery.Employee.ID = myID;
+            delivery.Employee.ID = App.EmployeeID;
 
             var sb = new StringBuilder();
             sb.Append("Serial # ");
             sb.AppendLine();
-            if (Employees.ContainsKey(myID))
-                sb.AppendLine();
+            sb.AppendLine();
 
             delivery.Notes = string.Format("Delivery of Items for processing to {0}\nOrder #{1} (raised on {2:dd MMM yy} by {3})\nItems: {4}",
                 order.SupplierLink.Name,
                 order.PONumber,
                 delivery.Date,
-                myName,
+                App.EmployeeName,
                 string.Join(", ",
                     orderitems.Select(x =>
                         string.Format("{0}{1}", x.Description.Split('\n').FirstOrDefault(), x.Qty > 1 ? " (x" + x.Qty.ToString("F0") + ")" : "")))
@@ -826,7 +820,7 @@ namespace PRSDesktop
                     Title = string.Format("Treatment PO #{0} has been raised", PONumber),
                     Description = "The above Purchase Order has been created, and is ready to be checked and issued to the relevant supplier."
                 };
-                notification.Sender.ID = myID;
+                notification.Sender.ID = App.EmployeeID;
                 notification.Employee.ID = role.Get<EmployeeRole, Guid>(x => x.EmployeeLink.ID);
                 updates.Add(notification);
             }
@@ -2017,14 +2011,6 @@ namespace PRSDesktop
             new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
         }
 
-        #region Employee Stuff
-
-        private Dictionary<Guid, string> Employees = new() { { Guid.Empty, "" } };
-        private Guid myID = Guid.Empty;
-        private string myName = "";
-
-        #endregion
-
         #region ManufacturingPacket Stuff
 
         //FactorySetup settings = new GlobalConfiguration<FactorySetup>().Load();
@@ -2584,67 +2570,6 @@ namespace PRSDesktop
                 Task.Run(() => { new Client<ManufacturingPacketStage>().Save(updates, "", (o, e) => { }); });
         }
 
-        private void UpdateQuality(QualityStatus status, string note = null)
-        {
-            var selected = new List<ManufacturingPacket>();
-            var stages = new List<ManufacturingPacketStage>();
-            foreach (var kanban in Kanbans.Where(x => x.Checked || x.IsSelected))
-            {
-                selected.Add(KanbanToPacket(kanban));
-                var pktid = Guid.Parse(kanban.ID);
-                var stagerows = Stages.Rows.Where(r =>
-                    r.Get<ManufacturingPacketStage, Guid>(c => c.SectionID).Equals(CurrentSection.ID) &&
-                    r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(pktid));
-                stages.AddRange(stagerows.Select(r => r.ToObject<ManufacturingPacketStage>()));
-            }
-
-            if (note == null)
-            {
-                var form = new NotesForm(Employees) { Caption = "Please detail the quality issues identified with these item(s)" };
-                if (form.ShowDialog() != true) return;
-
-                note = form.Text;
-                if (form.EmployeeID != Guid.Empty)
-                {
-                    var task = new Kanban();
-                    task.DueDate = DateTime.Today;
-                    task.Status = KanbanStatus.Open;
-                    task.EmployeeLink.ID = form.EmployeeID;
-                    task.ManagerLink.ID = myID;
-                    task.Title = "QA Issues : " + CurrentSection.Factory.Name + ": " + CurrentSection.Name;
-                    //task.JobLink.ID = packet.JobLink.ID;
-                    var details = new List<string>();
-                    details.Add(form.Text);
-                    details.Add("");
-                    details.Add("The following packets are affected by this issue:");
-                    foreach (var sel in selected)
-                        details.Add(string.Format("- {0}: {1} ({2})", sel.SetoutLink.Number, sel.Title,
-                            string.IsNullOrEmpty(sel.Location) ? sel.SetoutLink.Location : sel.Location));
-                    task.Notes = new[] { string.Join("\n", details) };
-                    new Client<Kanban>().Save(task, "Created task from Factory Floor");
-                    note = note + "\n" + "** Task Created for " + task.EmployeeLink.Name;
-                }
-            }
-
-            foreach (var stage in stages)
-            {
-                stage.Station = 0;
-                stage.QualityStatus = status;
-                if (!string.IsNullOrWhiteSpace(note))
-                {
-                    if (!string.IsNullOrWhiteSpace(stage.QualityNotes))
-                        stage.QualityNotes = string.Format("{0}\n\n{1}", stage.QualityNotes, note);
-                    else
-                        stage.QualityNotes = note;
-                }
-            }
-
-            Progress.Show("");
-            new Client<ManufacturingPacketStage>().Save(stages, note);
-            DoRefresh(true);
-            Progress.Close();
-        }
-
         #endregion
 
         private void RequestMaterials_Click(object sender, RoutedEventArgs e)