| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 | using Comal.Classes;using InABox.Clients;using InABox.Core;using InABox.Rpc;using InABox.Wpf;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace PRSDesktop.Forms.Issues;/// <summary>/// Interaction logic for IssuesWindow.xaml/// </summary>public partial class IssuesWindow : Window{    public IQueryProviderFactory ClientFactory    {        set => Grid.ClientFactory = value;    }    public IssuesWindow()    {        InitializeComponent();    }    private void Window_Loaded(object sender, RoutedEventArgs e)    {        Grid.Refresh(true, true);    }    public static void Execute()    {        var license = Client.Query(new Filter<License>().All(), Columns.None<License>().Add(x => x.Data))            .ToObjects<License>().FirstOrDefault();        var customerID = Guid.Empty;        if(license is not null && LicenseUtils.TryDecryptLicense(license.Data, out var result, out var error))        {            customerID = result.CustomerID;        }        if(customerID == Guid.Empty)        {            MessageWindow.ShowMessage("Could not load issues: no customer ID", "Error");            return;        }        var transport = new RpcClientSocketTransport(["remote.prsdigital.com.au:8006"]);        var client = new RpcClient<Kanban>(transport);        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;        }        var issues = new IssuesWindow();        // Save the old property if it exists.        var prop = DatabaseSchema.Property(typeof(Kanban), IssuesGrid.CustomerProperty.Name) as CustomProperty;        // Load the new property.        DatabaseSchema.Load([IssuesGrid.CustomerProperty]);        issues.Grid.CustomerID = customerID;        issues.ClientFactory = new _Factory(transport);        issues.ShowDialog();        // Return DB schema to what it was.        DatabaseSchema.Unload([IssuesGrid.CustomerProperty]);        if(prop is not null)        {            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)!;        }    }}
 |