Browse Source

- Changed icon for issues button
- Fixed documents grid linking to the wrong database.
- Added PRS versioning to notes
- Added "Attach logs" button to menu
- Update user name and password

Kenric Nugteren 9 months ago
parent
commit
c179fb69ca

+ 35 - 9
prs.desktop/Forms/Issues/IssuesGrid.cs

@@ -8,6 +8,7 @@ using InABox.WPF;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading;
@@ -19,15 +20,14 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
 {
     private readonly int ChunkSize = 500;
 
-    private IClient<Kanban> _client;
+    public IQueryProviderFactory ClientFactory { get; set; }
 
-    public Func<Type, IClient> ClientFactory { get; set; }
-
-    private IClient<Kanban> Client
+    private IQueryProvider<Kanban> _client;
+    private IQueryProvider<Kanban> Client
     {
         get
         {
-            _client ??= (ClientFactory(typeof(Kanban)) as IClient<Kanban>)!;
+            _client ??= ClientFactory.Create<Kanban>();
             return _client;
         }
     }
@@ -70,14 +70,37 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
         if (row is null) return;
 
         var menu = column.GetMenu();
-        menu.AddItem("Add Note", null, row, AddNote_Click);
-        menu.AddItem("Close Issue", null, row, CloseTask_Click);
+        menu.AddItem("Add note", null, row, AddNote_Click);
+        menu.AddItem("Attach system logs", null, row, AttachLogs_Click);
+        menu.AddSeparator();
+        menu.AddItem("Close issue", null, row, CloseTask_Click);
+    }
+
+    private void AttachLogs_Click(CoreRow row)
+    {
+        var logFile = CoreUtils.GetLogFile();
+        var data = File.ReadAllBytes(logFile);
+        var doc = new Document();
+        doc.Data = data;
+        doc.CRC = CoreUtils.CalculateCRC(data);
+        doc.FileName = Path.GetFileName(logFile);
+        doc.TimeStamp = File.GetLastWriteTime(logFile);
+
+        ClientFactory.Save(doc, "Attached logs to task.");
+
+        var kanbanDocument = new KanbanDocument();
+        kanbanDocument.DocumentLink.CopyFrom(doc);
+        kanbanDocument.EntityLink.CopyFrom(row.ToObject<Kanban>());
+        ClientFactory.Save(kanbanDocument, "Attached logs to task.");
     }
 
     public override Kanban CreateItem()
     {
         var item = base.CreateItem();
         item.UserProperties["CustomerID"] = CustomerID.ToString();
+        item.Notes = [
+            $"Created on PRS {CoreUtils.GetVersion()}"
+            ];
         // item.Status = KanbanStatus.Open;
         return item;
     }
@@ -122,7 +145,7 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
 
     public virtual CoreTable LookupValues(DataLookupEditor editor, Type parent, string columnname, BaseObject[]? items)
     {
-        var client = ClientFactory(editor.Type);
+        var client = ClientFactory.Create(editor.Type);
 
         var filter = LookupFactory.DefineLookupFilter(parent, editor.Type, columnname, items ?? (Array.CreateInstance(parent, 0) as BaseObject[])!);
         var columns = LookupFactory.DefineLookupColumns(parent, editor.Type, columnname);
@@ -192,7 +215,10 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
     {
         var pages = new DynamicEditorPages
         {
-            //new DynamicDocumentGrid<KanbanDocument, Kanban, KanbanLink>()
+            new DynamicDocumentGrid<KanbanDocument, Kanban, KanbanLink>
+            {
+                Client = ClientFactory
+            }
         };
         return pages;
     }

+ 13 - 3
prs.desktop/Forms/Issues/IssuesWindow.xaml.cs

@@ -23,7 +23,7 @@ namespace PRSDesktop.Forms.Issues;
 /// </summary>
 public partial class IssuesWindow : Window
 {
-    public Func<Type, IClient> ClientFactory
+    public IQueryProviderFactory ClientFactory
     {
         set => Grid.ClientFactory = value;
     }
@@ -56,7 +56,7 @@ public partial class IssuesWindow : Window
 
         var transport = new RpcClientSocketTransport(["remote.prsdigital.com.au:8006"]);
         var client = new RpcClient<Kanban>(transport);
-        if(client.Validate("ADMIN", "admin", Guid.Empty).Status != InABox.Clients.ValidationStatus.VALID)
+        if(client.Validate("SYSTEM", "DO!pt%Qi!R0_h@LW", Guid.Empty).Status != InABox.Clients.ValidationStatus.VALID)
         {
             MessageWindow.ShowMessage("Could not connect to PRS digital database.", "Connection error.");
             return;
@@ -71,7 +71,7 @@ public partial class IssuesWindow : Window
         DatabaseSchema.Load([IssuesGrid.CustomerProperty]);
 
         issues.Grid.CustomerID = customerID;
-        issues.ClientFactory = x => (Activator.CreateInstance(typeof(RpcClient<>).MakeGenericType(x), transport) as IClient)!;
+        issues.ClientFactory = new _Factory(transport);
         issues.ShowDialog();
 
         // Return DB schema to what it was.
@@ -81,4 +81,14 @@ public partial class IssuesWindow : Window
             DatabaseSchema.Load([prop]);
         }
     }
+
+    private class _Factory(IRpcClientTransport transport) : IQueryProviderFactory
+    {
+        IRpcClientTransport Transport = transport;
+
+        public InABox.Core.IQueryProvider Create(Type T)
+        {
+            return (Activator.CreateInstance(typeof(RpcClient<>).MakeGenericType(T), Transport) as IClient)!;
+        }
+    }
 }

+ 3 - 3
prs.desktop/Grids/EmployeeQualificationGrid.cs

@@ -87,7 +87,7 @@ public class EmployeeQualificationGrid : QualificationManyToManyGrid<Employee>
         {
             var templateID = dialog.IDs().First();
 
-            var qualificationIds = Client.Query(
+            var qualificationIds = InABox.Clients.Client.Query(
                 new Filter<EmployeeQualificationTemplateItem>(x => x.Template.ID).IsEqualTo(templateID),
                 Columns.None<EmployeeQualificationTemplateItem>().Add(x => x.Qualification.ID))
                 .ExtractValues<EmployeeQualificationTemplateItem, Guid>(x => x.Qualification.ID);
@@ -159,7 +159,7 @@ public class EmployeeQualificationGrid : QualificationManyToManyGrid<Employee>
                 new Filter<EmployeeQualificationTemplateItem>(x => x.Template.ID).IsEqualTo(templateID),
                 Columns.None<EmployeeQualificationTemplateItem>().Add(x => x.ID)).Rows.Select(x => x.ToObject<EmployeeQualificationTemplateItem>()).ToArray();
 
-            Client.Delete(templateItems, "Deleted because re-save of template");
+            InABox.Clients.Client.Delete(templateItems, "Deleted because re-save of template");
 
             List<EmployeeQualificationTemplateItem> newItems = new();
             foreach(var item in Data.Rows)
@@ -170,7 +170,7 @@ public class EmployeeQualificationGrid : QualificationManyToManyGrid<Employee>
                 newItems.Add(newItem);
             }
 
-            Client.Save(newItems, "Save to template");
+            InABox.Clients.Client.Save(newItems, "Save to template");
         }
 
         return false;

+ 1 - 1
prs.desktop/MainWindow.xaml

@@ -827,7 +827,7 @@
             
             <fluent:Button Grid.Row="1" Grid.Column="2"
                            Header="Issues"
-                           LargeIcon="Resources/bug.png"
+                           LargeIcon="Resources/appicon.png"
                            Click="Issues_Click"
                            ToolTip="Raise an issue with the PRS team"
                            Margin="0,0,5,20"/>

+ 1 - 1
prs.desktop/MainWindow.xaml.cs

@@ -3511,7 +3511,7 @@ public partial class MainWindow : IPanelHostControl
 
     private void SystemLogsButton_OnClick(object sender, RoutedEventArgs e)
     {
-        var logfile = Path.Combine(CoreUtils.GetPath(), string.Format("{0:yyyy-MM-dd}.log", DateTime.Today));
+        var logfile = CoreUtils.GetLogFile();
         if (File.Exists(logfile))
         {
             var startInfo = new ProcessStartInfo("notepad.exe", logfile);

+ 1 - 1
prs.desktop/Panels/Jobs/Digital Forms/JobFormDefinitionGrid.cs

@@ -20,7 +20,7 @@ public class JobFormDefinitionGrid : DynamicManyToManyGrid<JobFormDefinition, Jo
     private bool AddAllClick(Button arg1, CoreRow[] arg2)
     {
         var existingforms = ExtractValues(x => x.Form.ID, Selection.All).ToArray();
-        var newforms = Client.Query(
+        var newforms = InABox.Clients.Client.Query(
             new Filter<DigitalForm>(x => x.Active).IsEqualTo(true)
                 .And(x => x.AppliesTo).IsEqualTo("Job")
                 .And(x => x.ID).NotInList(existingforms)

+ 4 - 4
prs.desktop/Panels/Jobs/JobScopes/JobScopeDocumentGrid.cs

@@ -37,17 +37,17 @@ public class JobScopeDocumentGrid : DynamicDocumentGrid<JobScopeDocument, JobSco
 
     public override void SaveItem(JobScopeDocument item)
     {
-        Client.Save(item, "Updated by user.");
+        InABox.Clients.Client.Save(item, "Updated by user.");
     }
 
     public override void SaveItems(IEnumerable<JobScopeDocument> items)
     {
-        Client.Save(items, "Updated by user.");
+        InABox.Clients.Client.Save(items, "Updated by user.");
     }
 
     public override void DeleteItems(params CoreRow[] rows)
     {
-        Client.Delete(rows.Select(x => new JobScopeDocument { ID = x.Get<JobScopeDocument, Guid>(x => x.ID) }), "Deleted by user.");
+        InABox.Clients.Client.Delete(rows.Select(x => new JobScopeDocument { ID = x.Get<JobScopeDocument, Guid>(x => x.ID) }), "Deleted by user.");
     }
 
     public override JobScopeDocument LoadItem(CoreRow row)
@@ -82,6 +82,6 @@ public class JobScopeDocumentGrid : DynamicDocumentGrid<JobScopeDocument, JobSco
         {
             criteria.Add(new Filter<JobScopeDocument>(x => x.EntityLink.ID).IsEqualTo(Scope?.ID ?? Guid.Empty));
         }
-        Client.Query(criteria.Combine(), columns, sort, CoreRange.All, action);
+        InABox.Clients.Client.Query(criteria.Combine(), columns, sort, CoreRange.All, action);
     }
 }

+ 1 - 1
prs.stores/PurchaseOrderItemStore.cs

@@ -188,7 +188,7 @@ internal class PurchaseOrderItemStore : BaseStore<PurchaseOrderItem>
             entity.Dimensions.CopyFrom(productrow.ToObject<Product>().DefaultInstance.Dimensions);
         }
 
-        entity.ConvertDimensions(DbFactory.NewProvider(Logger.Main).QueryProvider<ProductDimensionUnit>());
+        entity.ConvertDimensions(DbFactory.NewProvider(Logger.Main).QueryProvider<ProductDimensionUnit>(UserID));
         // Actual logic begins here.
         
         var totalAllocations = allocations.Sum(x => x.Quantity);

+ 1 - 1
prs.stores/StockHoldingStore.cs

@@ -52,7 +52,7 @@ public class StockHoldingStore : BaseStore<StockHolding>
                 .Add(x => x.Available)
                 .Add(x => x.Weight)
                 .Add(x => x.AverageValue),
-            holdings, store.Provider.QueryProvider<StockHolding>());
+            holdings, store.QueryProvider<StockHolding>());
     }
 
     public static void ModifyHoldings(StockMovement[] mvts, HoldingDictionary holdings, Action action)