Просмотр исходного кода

Removed ClientFactory.IsSupported

Kenric Nugteren 1 месяц назад
Родитель
Сommit
c06f16a1b4

+ 1 - 2
prs.classes/Entities/DataEntry/DataEntryTag.cs

@@ -15,8 +15,7 @@ namespace Comal.Classes
                 .Where(x => x.IsSubclassOf(typeof(Entity)) && CoreUtils.HasInterface<IDataEntryInstance>(x) && x.GetInterfaces().Contains(typeof(IPersistent)))
                 .OrderBy(x => x.EntityName().Split('.').Last()).ToArray();
             foreach (var entity in classes)
-                if (ClientFactory.IsSupported(entity))
-                    AddValue(entity.EntityName(), entity.GetCaption());
+                AddValue(entity.EntityName(), entity.GetCaption());
         }
     }
     

+ 2 - 1
prs.classes/SecurityDescriptors/System_Descriptors.cs

@@ -48,7 +48,8 @@ namespace Comal.Classes
     }
 
     [Caption("Administer Digital Forms Library")]
-    public class CanAdministerDigitalFormsLibrary : EnabledSecurityDescriptor<DigitalFormsLicense, DigitalForm>
+    public class CanAdministerDigitalFormsLibrary : EnabledSecurityDescriptor<DigitalFormsLicense, DigitalForm>,
+        IDependentSecurityDescriptor<AutoSecurityDescriptor<DigitalForm, CanView<DigitalForm>>>
     {
     }
 

+ 27 - 54
prs.desktop/MainWindow.xaml.cs

@@ -774,14 +774,13 @@ public partial class MainWindow : IPanelHostControl
         SetFrameworkItemVisibility(CompanyInformation, Security.CanView<CompanyInformation>());
 
         SetVisibleIfAny(BackstageSeparator0, CompanyInformation);
-        SetFrameworkItemVisibility(SecurityDefaultsButton,
-            ClientFactory.IsSupported<GlobalSecurityToken>() && Security.IsAllowed<CanCustomiseSecurityDefaults>());
+        SetFrameworkItemVisibility(SecurityDefaultsButton, Security.IsAllowed<CanCustomiseSecurityDefaults>());
         SetVisibleIfAny(BackstageSeparator1, SecurityDefaultsButton);
 
         BackstageSeparator1a.Visibility = Visibility.Visible;
         SystemLogsButton.Visibility = Visibility.Visible;
 
-        SetFrameworkItemVisibility(DocumentTypeList, ClientFactory.IsSupported<DocumentType>() && Security.IsAllowed<CanViewDocumentTypes>());
+        SetFrameworkItemVisibility(DocumentTypeList, Security.IsAllowed<CanViewDocumentTypes>());
         SetFrameworkItemVisibility(EventList, Security.IsAllowed<CanManageEvents>());
         SetVisibleIfAny(BackstageSeparator2, DocumentTypeList, EventList);
 
@@ -808,12 +807,10 @@ public partial class MainWindow : IPanelHostControl
         CreateTab<ViewDesktopDashboardsTab>("Dashboards", x => x
             .NewGroup(x => x
                 .Add<DatabaseActivityDashboard>("Database Activity", SvgImages.kpi,
-                    ClientFactory.IsSupported<UserTracking>()
-                    && Security.IsAllowed<CanViewDatabaseActivity>()
+                    Security.IsAllowed<CanViewDatabaseActivity>()
                     && Security.IsAllowed<ViewDesktopDatabaseActivityDashboard>())
                 .Add<UserActivity>("User Activity", SvgImages.kpi,
-                    ClientFactory.IsSupported<ModuleTracking>()
-                    && Security.IsAllowed<CanViewUserActivity>()
+                    Security.IsAllowed<CanViewUserActivity>()
                     && Security.IsAllowed<ViewDesktopUserActivityDashboard>())
                 .Add<WidgetDashboard>("Quick Status", SvgImages.kpi,
                     Security.IsAllowed<CanViewQuickStatus>() && Security.IsAllowed<ViewDesktopQuickStatusDashboard>())));
@@ -822,9 +819,7 @@ public partial class MainWindow : IPanelHostControl
         CreateTab<ViewDesktopDigitalFormsTab>("Digital Forms", x => x
             .NewGroup(x => x
                 .Add<DigitalFormsLibrary>("Forms Library", SvgImages.formslibrary,
-                    ClientFactory.IsSupported<DigitalForm>()
-                    && Security.CanView<DigitalForm>()
-                    && Security.IsAllowed<CanAdministerDigitalFormsLibrary>())
+                    Security.IsAllowed<CanAdministerDigitalFormsLibrary>())
                 .Add<CompletedFormsPanel>("Forms Dashboard", SvgImages.formsinstance,
                     Security.IsAllowed<CanViewDigitalFormsDashbaord>()
                     && Security.IsAllowed<ViewDesktopDigitalFormsDashboard>())));
@@ -833,17 +828,13 @@ public partial class MainWindow : IPanelHostControl
         CreateTab<ViewDesktopEquipmentTab>("Equipment", x => x
             .NewGroup(x => x
                 .Add<EquipmentPanel>("Equipment List", PRSDesktop.Resources.specifications,
-                    ClientFactory.IsSupported<Equipment>()
-                    && Security.CanView<Equipment>()
+                    Security.CanView<Equipment>()
                     && Security.IsAllowed<ViewDesktopEquipmentListScreen>())
                 .Add<EquipmentMaintenancePanel>("Planned Maintenance", PRSDesktop.Resources.service,
-                    ClientFactory.IsSupported<Equipment>()
-                    && Security.CanView<Equipment>()
+                    Security.CanView<Equipment>()
                     && Security.IsAllowed<ViewDesktopEquipmentMaintenanceScreen>())
                 .Add<EquipmentPlannerPanel>("Equipment Planner", PRSDesktop.Resources.calendar,
-                    ClientFactory.IsSupported<Equipment>()
-                    && Security.CanView<Equipment>()
-                    && ClientFactory.IsSupported<Assignment>()
+                    Security.CanView<Equipment>()
                     && Security.CanView<Assignment>()
                     && Security.IsAllowed<ViewDesktopEquipmentPlannerScreen>())
                 .Add<GPSTrackers>("GPS Trackers", PRSDesktop.Resources.milestone,
@@ -853,38 +844,31 @@ public partial class MainWindow : IPanelHostControl
         CreateTab<ViewDesktopAccountsTab>("Accounts Receivable", x => x
             .NewGroup(x => x
                 .Add<CustomerPanel>("Customers", PRSDesktop.Resources.customer,
-                    ClientFactory.IsSupported<Customer>()
-                    && Security.CanView<Customer>()
+                    Security.CanView<Customer>()
                     && Security.IsAllowed<ViewDesktopCustomersScreen>())
                 .Add<InvoicePanel>("Invoices", PRSDesktop.Resources.invoice,
-                    ClientFactory.IsSupported<Invoice>()
-                    && Security.CanView<Invoice>()
+                    Security.CanView<Invoice>()
                     && Security.IsAllowed<ViewDesktopInvoicesScreen>())
                 .Add<CustomerReceipts>("Receipts", PRSDesktop.Resources.receipt,
-                    ClientFactory.IsSupported<Receipt>()
-                    && Security.CanView<Receipt>()
+                    Security.CanView<Receipt>()
                     && Security.IsAllowed<ViewDesktopReceiptsScreen>())));
 
     private Fluent.RibbonTabItem? SetupAccountsPayableTab() =>
         CreateTab<ViewDesktopAccountsTab>("Accounts Payable", x => x
             .NewGroup(x => x
                 .Add<SupplierPanel>("Suppliers", PRSDesktop.Resources.supplier,
-                    ClientFactory.IsSupported<Supplier>()
-                    && Security.CanView<Supplier>()
+                    Security.CanView<Supplier>()
                     && Security.IsAllowed<ViewDesktopSuppliersScreen>())
                 .Add<DataEntryPanel>("Data Entry", PRSDesktop.Resources.pencil,
                     Security.IsAllowed<CanViewDataEntryPanel>())
                 .Add<SupplierPurchaseOrderPanel>("Purchase Orders", PRSDesktop.Resources.purchase,
-                    ClientFactory.IsSupported<PurchaseOrder>()
-                    && Security.CanView<PurchaseOrder>()
+                    Security.CanView<PurchaseOrder>()
                     && Security.IsAllowed<ViewDesktopPurchaseOrdersScreen>())
                 .Add<SupplierBillPanel>("Bills", PRSDesktop.Resources.bill,
-                    ClientFactory.IsSupported<Bill>()
-                    && Security.CanView<Bill>()
+                    Security.CanView<Bill>()
                     && Security.IsAllowed<ViewDesktopBillsScreen>())
                 .Add<SupplierPayments>("Payments", PRSDesktop.Resources.payment,
-                    ClientFactory.IsSupported<Payment>()
-                    && Security.CanView<Payment>()
+                    Security.CanView<Payment>()
                     && Security.IsAllowed<ViewDesktopPaymentsScreen>())));
 
     private Fluent.RibbonTabItem? SetupHumanResourcesTab() =>
@@ -906,7 +890,7 @@ public partial class MainWindow : IPanelHostControl
                 .Add<EmployeePanel>("Employee List", PRSDesktop.Resources.employee,
                     Security.CanView<Employee>() && Security.IsAllowed<ViewDesktopEmployeeListScreen>())
                 .Add<OrgChartPanel>("Org Chart", PRSDesktop.Resources.orgchart,
-                    ClientFactory.IsSupported<Employee>() && Security.IsAllowed<ViewDesktopOrgChartScreen>())));
+                    Security.IsAllowed<ViewDesktopOrgChartScreen>())));
 
     private Fluent.RibbonTabItem? SetupProductsTab() =>
         CreateTab<ViewDesktopProductManagementTab>("Products", x => x
@@ -928,8 +912,7 @@ public partial class MainWindow : IPanelHostControl
         CreateTab<ViewDesktopLogisticsTab>("Logistics", x => x
             .NewGroup(x => x
                 .Add<ReadyToGoPanel>("Ready To Go", SvgImages.truck,
-                    ClientFactory.IsSupported<DeliveryItem>()
-                    && Security.IsAllowed<CanViewLogisticsReadyToGo>()
+                    Security.IsAllowed<CanViewLogisticsReadyToGo>()
                     && Security.IsAllowed<ViewDesktopReadyToGoScreen>())
                 .Add<DispatchPanel>("Rack List", PRSDesktop.Resources.barcode,
                     Security.CanView<Shipment>()
@@ -940,8 +923,7 @@ public partial class MainWindow : IPanelHostControl
                 .Add<DeliveryPanel>("Deliveries", SvgImages.truck,
                     Security.IsAllowed<CanViewDeliveriesModule>() && Security.IsAllowed<ViewDesktopDeliveriesScren>())
                 .Add<DeliveredOnSitePanel>("Delivered On Site", PRSDesktop.Resources.lifter,
-                    ClientFactory.IsSupported<DeliveryItem>()
-                    && Security.IsAllowed<CanViewDeliveredOnSite>()
+                    Security.IsAllowed<CanViewDeliveredOnSite>()
                     && Security.IsAllowed<ViewDesktopDeliveredOnSiteScreen>()))
             .NewGroup(x => x
                 .Add<ConsignmentsPanel>("Incoming Consignments", PRSDesktop.Resources.consignment,
@@ -954,29 +936,23 @@ public partial class MainWindow : IPanelHostControl
                     Security.CanView<Job>() && Security.IsAllowed<ViewDesktopDesignManagementScreen>()))
             .NewGroup(x => x
                 .Add<ManufacturingPanel>("Manufacturing Status", PRSDesktop.Resources.factory,
-                    ClientFactory.IsSupported<ManufacturingFactory, ManufacturingPacket>()
-                    && Security.IsAllowed<CanViewFactoryStatus>()
+                    Security.IsAllowed<CanViewFactoryStatus>()
                     && Security.IsAllowed<ViewDesktopManufacturingStatusScreen>())
                 .Add<ManufacturingAllocationPanel>("Factory Allocation", PRSDesktop.Resources.assignments,
-                    ClientFactory.IsSupported<ManufacturingFactory, ManufacturingPacket, ManufacturingPacketStage>()
-                    && Security.IsAllowed<CanViewFactoryAllocation>()
+                    Security.IsAllowed<CanViewFactoryAllocation>()
                     && Security.IsAllowed<ViewDesktopFactoryAllocationScreen>())
                 .Add<FactoryPanel>("Factory Floor", PRSDesktop.Resources.wrench,
-                    ClientFactory.IsSupported<ManufacturingPacket>()
-                    && Security.IsAllowed<CanViewFactoryFloor>()
+                    Security.IsAllowed<CanViewFactoryFloor>()
                     && Security.IsAllowed<ViewDesktopFactoryFloorScreen>()))
             .NewGroup(x => x
                 .Add<FactoryProductivityDashboard>("Factory KPIs", SvgImages.kpi,
-                    ClientFactory.IsSupported<ManufacturingHistory>() 
-                    && Security.IsAllowed<CanViewFactoryKPIs>()
+                    Security.IsAllowed<CanViewFactoryKPIs>()
                     && Security.IsAllowed<ViewDesktopFactoryKPIsDashboard>())
                 .Add<ManufacturingTemplateAnalysis>("Template Analysis", SvgImages.kpi,
-                    ClientFactory.IsSupported<ManufacturingTemplate, ManufacturingHistory>() 
-                    && Security.IsAllowed<CanViewTemplateAnalysis>()
+                    Security.IsAllowed<CanViewTemplateAnalysis>()
                     && Security.IsAllowed<ViewDesktopTemplateAnalysisDashboard>())
                 .Add<FactoryFloorAnalysis>("Factory Analysis", SvgImages.kpi,
-                    ClientFactory.IsSupported<ManufacturingTemplate, ManufacturingHistory>() 
-                    && Security.IsAllowed<CanViewFactoryAnalysis>()
+                    Security.IsAllowed<CanViewFactoryAnalysis>()
                     && Security.IsAllowed<ViewDesktopFactoryAnalysisDashboard>())));
 
     private Fluent.RibbonTabItem? SetupProjectsTab() =>
@@ -1159,10 +1135,10 @@ public partial class MainWindow : IPanelHostControl
             .NewGroup(x => x
                 .Add<UtilityDashboard>("Dashboards", SvgImages.kpi, Security.IsAllowed<CanViewUserDefinedDashboards>())
                 .Add<NotificationPanel>("Notification Centre", PRSDesktop.Resources.email, Security.CanView<Notification>())
-                .Add<TaskPanel>("Task List", SvgImages.kanban, ClientFactory.IsSupported<Kanban>() && Security.IsAllowed<CanViewTasks>())
-                .Add<AttendancePanel>("In/Out Board", PRSDesktop.Resources.attendance, ClientFactory.IsSupported<TimeSheet>() && Security.IsAllowed<CanViewInOutBoard>())
+                .Add<TaskPanel>("Task List", SvgImages.kanban, Security.IsAllowed<CanViewTasks>())
+                .Add<AttendancePanel>("In/Out Board", PRSDesktop.Resources.attendance, Security.IsAllowed<CanViewInOutBoard>())
                 .Add<LiveMapsPanel>("Live Maps", PRSDesktop.Resources.map, CanViewMaps)
-                .Add<DailyReport>("Daily Report", PRSDesktop.Resources.report, ClientFactory.IsSupported<TimeSheet, Assignment>() && Security.IsAllowed<CanViewDailyReports>())
+                .Add<DailyReport>("Daily Report", PRSDesktop.Resources.report, Security.IsAllowed<CanViewDailyReports>())
                 .Lock());
         foreach(var (_, groupList) in tab.Groups)
         {
@@ -1882,9 +1858,6 @@ public partial class MainWindow : IPanelHostControl
     }
     private bool CheckTimesheetBypass(bool message)
     {
-        if (!ClientFactory.IsSupported<TimeSheet>())
-            return true;
-
         var isClockedOn = IsClockedOn();
 
         if (!Security.IsAllowed<CanBypassTimeBench>())

+ 2 - 3
prs.desktop/Panels/DailyReports/WindowTrackerSummary.xaml.cs

@@ -29,9 +29,8 @@ namespace PRSDesktop
             InitializeComponent();
             grid.Children.Add(history);
 
-            trackers = ClientFactory.IsSupported<WindowTracker>()
-                ? new Client<WindowTracker>().Load(Filter<WindowTracker>.Where(x => x.Employee.ID).IsEqualTo(employeeid))
-                : new WindowTracker[] { };
+            trackers = Client.Query(Filter<WindowTracker>.Where(x => x.Employee.ID).IsEqualTo(employeeid))
+                .ToArray<WindowTracker>();
 
             var timestamps = new List<DateTime>();
 

+ 3 - 3
prs.desktop/Panels/Jobs/ServicePanel_Old.xaml.cs

@@ -95,9 +95,9 @@ public partial class ServicePanel_Old : UserControl, IPanel<Job>
         ServiceGrid.BeforeRefresh += ServiceGrid_BeforeRefresh;
         ServiceGrid.AfterRefresh += ServiceGrid_AfterRefresh;
 
-        Orders.Visibility = ClientFactory.IsSupported<PurchaseOrderItem>() ? Visibility.Visible : Visibility.Collapsed;
-        Requisitions.Visibility = ClientFactory.IsSupported<Requisition>() ? Visibility.Visible : Visibility.Collapsed;
-        Assignments.Visibility = ClientFactory.IsSupported<Assignment>() ? Visibility.Visible : Visibility.Collapsed;
+        Orders.Visibility = Visibility.Visible;
+        Requisitions.Visibility = Visibility.Visible;
+        Assignments.Visibility = Visibility.Visible;
         Forms.Visibility = Security.CanView<JobForm>() ? Visibility.Visible : Visibility.Collapsed;
         Invoices.Visibility = Security.CanView<Invoice>() ? Visibility.Visible : Visibility.Collapsed;
 

+ 23 - 30
prs.desktop/Panels/PanelHost.cs

@@ -125,20 +125,17 @@ public class PanelHost : IPanelHost
 
     private void CreateModules(string section, DataModel model)
     {
-        if (ClientFactory.IsSupported<CustomModule>())
+        foreach (var (module, image) in CustomModuleUtils.LoadCustomModuleThumbnails(section, model))
         {
-            foreach (var (module, image) in CustomModuleUtils.LoadCustomModuleThumbnails(section, model))
+            HostControl.CreatePanelAction(new PanelAction
             {
-                HostControl.CreatePanelAction(new PanelAction
+                Caption = module.Name ?? "",
+                Image = image,
+                OnExecute = (action) =>
                 {
-                    Caption = module.Name ?? "",
-                    Image = image,
-                    OnExecute = (action) =>
-                    {
-                        ClickModule(action, module);
-                    }
-                });
-            }
+                    ClickModule(action, module);
+                }
+            });
         }
     }
 
@@ -415,26 +412,22 @@ public class PanelHost : IPanelHost
 
         if (CurrentPanel is not null)
         {
-            //Logger.Send(LogType.Information, "", string.Format("Heartbeat: {0}", CurrentPanel_Label));
-            if (ClientFactory.IsSupported<ModuleTracking>())
-            {
-                var keys = TrackedKeys;
-                TrackedKeys = 0;
-                var clicks = TrackedClicks;
-                TrackedClicks = 0;
+            var keys = TrackedKeys;
+            TrackedKeys = 0;
+            var clicks = TrackedClicks;
+            TrackedClicks = 0;
 
-                var tracking = new ModuleTracking
-                {
-                    Date = DateTime.Today,
-                    Module = CurrentModuleName,
-                    Clicks = clicks,
-                    Keys = keys,
-                    ActiveTime = clicks + keys > 0 ? time : new TimeSpan(),
-                    IdleTime = clicks + keys == 0 ? time : new TimeSpan()
-                };
-                tracking.User.ID = ClientFactory.UserGuid;
-                new Client<ModuleTracking>().Save(tracking, "", (mt, ex) => { });
-            }
+            var tracking = new ModuleTracking
+            {
+                Date = DateTime.Today,
+                Module = CurrentModuleName,
+                Clicks = clicks,
+                Keys = keys,
+                ActiveTime = clicks + keys > 0 ? time : new TimeSpan(),
+                IdleTime = clicks + keys == 0 ? time : new TimeSpan()
+            };
+            tracking.User.ID = ClientFactory.UserGuid;
+            Client.Save(tracking, "", (mt, ex) => { });
 
             CurrentPanel.Heartbeat(time);
         }

+ 15 - 23
prs.desktop/Panels/Tasks/TasksByStatusControl.xaml.cs

@@ -263,32 +263,24 @@ public partial class TasksByStatusControl : UserControl, ITaskControl, INotifyPr
 
     private void SetupKanbanTypesLookup(IEnumerable<KanbanType> kanbanTypes)
     {
-        if (ClientFactory.IsSupported<KanbanType>())
-        {
-            var tasktypes = new Dictionary<Guid, string>
-                {
-                    { CoreUtils.FullGuid, "All Types" },
-                    { Guid.Empty, "Unallocated Types" }
-                };
-            foreach(var type in kanbanTypes)
+        var tasktypes = new Dictionary<Guid, string>
             {
-                tasktypes.Add(type.ID, type.Description);
-            }
-
-            TaskTypes.ItemsSource = tasktypes;
-            if (tasktypes.ContainsKey(Host.KanbanSettings.StatusSettings.SelectedType))
-                TaskTypes.SelectedValue = Host.KanbanSettings.StatusSettings.SelectedType;
-            else
-                TaskTypes.SelectedValue = CoreUtils.FullGuid;
-
-            TaskTypesLabel.Visibility = Visibility.Visible;
-            TaskTypes.Visibility = Visibility.Visible;
-        }
-        else
+                { CoreUtils.FullGuid, "All Types" },
+                { Guid.Empty, "Unallocated Types" }
+            };
+        foreach(var type in kanbanTypes)
         {
-            TaskTypesLabel.Visibility = Visibility.Collapsed;
-            TaskTypes.Visibility = Visibility.Collapsed;
+            tasktypes.Add(type.ID, type.Description);
         }
+
+        TaskTypes.ItemsSource = tasktypes;
+        if (tasktypes.ContainsKey(Host.KanbanSettings.StatusSettings.SelectedType))
+            TaskTypes.SelectedValue = Host.KanbanSettings.StatusSettings.SelectedType;
+        else
+            TaskTypes.SelectedValue = CoreUtils.FullGuid;
+
+        TaskTypesLabel.Visibility = Visibility.Visible;
+        TaskTypes.Visibility = Visibility.Visible;
     }
 
     #endregion