LogikalElevationGrid.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Windows;
  8. using System.Windows.Media.Imaging;
  9. using Comal.Classes;
  10. using InABox.Core;
  11. using InABox.DynamicGrid;
  12. using InABox.Integration.Logikal;
  13. using InABox.Wpf;
  14. using InABox.WPF;
  15. using jdk.nashorn.tools;
  16. using Microsoft.Win32;
  17. using PRSDesktop.Integrations.Logikal;
  18. namespace PRSDesktop;
  19. public class LogikalElevationGrid : LogikalGrid<LogikalElevationSummary>
  20. {
  21. public Guid ProjectID { get; set; }
  22. public string Phase { get; set; }
  23. protected override void Init()
  24. {
  25. base.Init();
  26. HiddenColumns.Add(x => x.ID);
  27. //ActionColumns.Add(new DynamicMenuColumn(BuildMenu) { Position = DynamicActionColumnPosition.Start });
  28. }
  29. protected override void DoReconfigure(DynamicGridOptions options)
  30. {
  31. base.DoReconfigure(options);
  32. options.MultiSelect = true;
  33. }
  34. //private void BuildMenu(DynamicMenuColumn column, CoreRow? row)
  35. //{
  36. // column.AddItem("Download Parts List", PRSDesktop.Resources.doc_xls, GetBOM);
  37. //}
  38. //private void GetBOM(CoreRow? r)
  39. //{
  40. // if (r != null && Client != null)
  41. // {
  42. // var id = r.Get<LogikalElevation, Guid>(x => x.ID);
  43. // Client.GetBillOfMaterials(ProjectID, id, true)
  44. // .Error(e =>
  45. // {
  46. // Dispatcher.BeginInvoke(() =>
  47. // {
  48. // MessageWindow.ShowError("Unable to retrieve parts", e.Message, e.Status.ToString());
  49. // });
  50. // })
  51. // .Success<LogikalBOMResponse<LogikalProfile,LogikalComponent,LogikalGlass,LogikalLabour>>(p =>
  52. // {
  53. // var sfd = new SaveFileDialog();
  54. // sfd.Filter = "Excel Files (*.xlsx)|*.xlsx";
  55. // sfd.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ElevationPartsList.xlsx");
  56. // if (sfd.ShowDialog() == true)
  57. // {
  58. // File.WriteAllBytes(sfd.FileName, p.ExcelData);
  59. // var pInfo = new ProcessStartInfo(sfd.FileName) { UseShellExecute = true };
  60. // Process.Start(pInfo);
  61. // }
  62. // });
  63. // }
  64. //}
  65. protected override void DoGet(LogikalClient client, IProgress<string> progress)
  66. {
  67. Items = new List<LogikalElevationSummary>();
  68. if (ProjectID != Guid.Empty)
  69. {
  70. client.GetElevationSummaries(ProjectID, Phase)
  71. .Always(NotifyResponseReceived)
  72. .Success<LogikalElevationSummaryResponse<LogikalElevationSummary>>(p =>
  73. {
  74. Items = p.Elevations.ToList();
  75. });
  76. }
  77. }
  78. }