using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.IO; using System.Linq; using System.Windows; using System.Windows.Media.Imaging; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; using InABox.Integration.Logikal; using InABox.Wpf; using InABox.WPF; using jdk.nashorn.tools; using Microsoft.Win32; using PRSDesktop.Integrations.Logikal; namespace PRSDesktop; public class LogikalElevationGrid : LogikalGrid { public Guid ProjectID { get; set; } public string Phase { get; set; } protected override void Init() { base.Init(); HiddenColumns.Add(x => x.ID); //ActionColumns.Add(new DynamicMenuColumn(BuildMenu) { Position = DynamicActionColumnPosition.Start }); } protected override void DoReconfigure(DynamicGridOptions options) { base.DoReconfigure(options); options.MultiSelect = true; } //private void BuildMenu(DynamicMenuColumn column, CoreRow? row) //{ // column.AddItem("Download Parts List", PRSDesktop.Resources.doc_xls, GetBOM); //} //private void GetBOM(CoreRow? r) //{ // if (r != null && Client != null) // { // var id = r.Get(x => x.ID); // Client.GetBillOfMaterials(ProjectID, id, true) // .Error(e => // { // Dispatcher.BeginInvoke(() => // { // MessageWindow.ShowError("Unable to retrieve parts", e.Message, e.Status.ToString()); // }); // }) // .Success>(p => // { // var sfd = new SaveFileDialog(); // sfd.Filter = "Excel Files (*.xlsx)|*.xlsx"; // sfd.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ElevationPartsList.xlsx"); // if (sfd.ShowDialog() == true) // { // File.WriteAllBytes(sfd.FileName, p.ExcelData); // var pInfo = new ProcessStartInfo(sfd.FileName) { UseShellExecute = true }; // Process.Start(pInfo); // } // }); // } //} protected override void DoGet(LogikalClient client, IProgress progress) { Items = new List(); if (ProjectID != Guid.Empty) { client.GetElevationSummaries(ProjectID, Phase) .Always(NotifyResponseReceived) .Success>(p => { Items = p.Elevations.ToList(); }); } } }