LogikalStyle.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using InABox.Integration.Logikal;
  2. using System;
  3. using System.Collections.Generic;
  4. using InABox.Integration.Awg;
  5. namespace PRSDesktop.Integrations.Logikal
  6. {
  7. public class LogikalStyle : LogikalItem, ILogikalStyle
  8. {
  9. public String Code { get; set; }
  10. public String Description { get; set; }
  11. public double Cost { get; set; }
  12. public AwgStyleType StyleType { get; set; }
  13. public override void ValidateQuery(string sql, List<string> errors)
  14. {
  15. ValidateField(sql, nameof(Code), errors);
  16. ValidateField(sql, nameof(Description), errors);
  17. ValidateField(sql, nameof(Cost), errors);
  18. ValidateField(sql, nameof(StyleType), errors);
  19. }
  20. public static String SQL = $@"select distinct
  21. upper(case c.[ColorTypeSupplier]
  22. when -1 then
  23. case coalesce(c.[PowderID],'')
  24. when '' then c.[ColorName]
  25. else case coalesce(c.[Thickness],'')
  26. when '' then c.[PowderID]
  27. else printf('%s-%s',c.[PowderID],c.[Thickness])
  28. end
  29. end
  30. else c.[ColorName]
  31. end) as [{nameof(Code)}],
  32. case c.[ColorTypeSupplier]
  33. when -1 then
  34. case coalesce(c.[PowderID],'')
  35. when '' then c.[ColorName]
  36. else case coalesce(c.[Thickness],'')
  37. when '' then printf('%s (%s)',c.[ColorName],c.[PowderID])
  38. else printf('%s %s (%s)',c.[ColorName],c.[Thickness],c.[PowderID])
  39. end
  40. end
  41. else coalesce(c.[ColorDescription],c.[ColorName])
  42. end as [{nameof(Description)}],
  43. case c.[ColorTypeSupplier]
  44. when -1 then
  45. case c.[ColorType]
  46. when 0 then {(int)AwgStyleType.Powdercoated}
  47. when 1 then {(int)AwgStyleType.Varnished}
  48. when 2 then {(int)AwgStyleType.Taped}
  49. when 3 then {(int)AwgStyleType.Anodised}
  50. else {(int)AwgStyleType.Mill}
  51. end
  52. else {(int)AwgStyleType.Intrinsic}
  53. end as [{nameof(StyleType)}],
  54. coalesce(b.[PriceCoating],0.0) as [{nameof(Cost)}]
  55. from
  56. Colors c
  57. left outer join
  58. profilebars b on c.[ColorId] = b.[LK_ColorId]
  59. where
  60. coalesce(c.[ColorName], '') <> ''";
  61. }
  62. }
  63. //case b.[ColorTypeInternal] WHEN 7 THEN 1 WHEN 335 THEN 2 WHEN 191 THEN 4 WHEN 141 THEN 5 ELSE 0 END AS [{nameof(StyleType)}],
  64. /*
  65. * Further investigation into ProfileBars.ColorTypeInternal turns up an “18” (powdercoat?) and “6” (unsure)
  66. I also found that I could go to Logikal / User Database / Colors and export the Color Database to Excel. It doesn’t give us the numbers, but when I want to try and add a color, it gave me four options – Powdercoated, Varnished, Taped or Anodized.
  67. So somehow, I’m expecting to have a maximum of 4 (or 5) unique numbers to identify the color type. If -1 is unspecified, then
  68. Powdercoated appears to be 7
  69. Anodized should be either 11 (Colors.ColorTypeSupplier) or 335 (ProfileBars.ColorTypeInternal)
  70. Varnished (Stainless?) might be 12 (Colors.ColorTypeSupplier) or 191 (ProfileBars.ColorTypeInternal)
  71. Taped (PVC?) might be 0 (Colors.ColorTypeSupplier) or 141 (ProfileBars.ColorTypeInternal)
  72. */
  73. /*
  74. * select distinct
  75. c.[ColorName] as [{nameof(Code)}],
  76. c.[ColorName] as [{nameof(Description)}] ,
  77. coalesce(b.[PriceCoating],0.0) as [{nameof(Cost)}],
  78. c.[ColorTypeSupplier],
  79. coalesce(b.ColorTypeInternal,0),
  80. case c.[ColorTypeSupplier] WHEN 7 THEN 1 WHEN 11 THEN 3 WHEN 12 THEN 4 WHEN 0 THEN 5 ELSE 0 END AS [TreatmentType],
  81. case b.[ColorTypeInternal] WHEN 7 THEN 1 WHEN 335 THEN 2 WHEN 191 THEN 4 WHEN 141 THEN 5 ELSE 0 END AS [TreatmentType2]
  82. from
  83. Colors c
  84. left outer join
  85. profilebars b on c.[ColorId] = b.[LK_ColorId]
  86. */