Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. #region Info
  2. /// <summary>
  3. /// Summary text
  4. /// Automatically unbatch a feeder parent material on move next.
  5. /// Action Groups:
  6. /// BusinessObjects.MaterialCollection.MoveToNextStep.Post
  7. /// Depends On:
  8. /// Is Dependency For:
  9. /// Exceptions:
  10. /// </summary>
  11. #endregion
  12.  
  13. MaterialCollection moveMaterialsToNextStepInput = new MaterialCollection();
  14.  
  15. if (Input.Keys.Contains("MaterialCollection"))
  16. {
  17.  
  18. MaterialCollection mats = Input["MaterialCollection"] as MaterialCollection ?? null;
  19.  
  20. if (mats != null && mats.Count > 0)
  21. {
  22. moveMaterialsToNextStepInput = mats;
  23. }
  24.  
  25. }
  26.  
  27. if (moveMaterialsToNextStepInput != null)
  28. {
  29. if (moveMaterialsToNextStepInput.Count > 0)
  30. {
  31. MaterialCollection toUnbatchAndTerminate = new MaterialCollection();
  32. foreach (Material materialInput in moveMaterialsToNextStepInput)
  33. {
  34. if (materialInput != null)
  35. {
  36. materialInput.LoadChildren();
  37. if (materialInput.Step != null & materialInput.Form != null && materialInput.SubMaterials != null)
  38. {
  39. materialInput.Step.LoadAttributes();
  40. if (materialInput.Step.HasAttribute(ASMConstants.IsMaterialBatchingAvailableAttribute))
  41. {
  42. if ((bool)materialInput.Step.Attributes[ASMConstants.IsMaterialBatchingAvailableAttribute]
  43. && materialInput.Form == ASMConstants.MaterialFormBatch
  44. && materialInput.SubMaterialCount > 0
  45. && materialInput.SubMaterials.All(c => c.Form == ASMConstants.MaterialFormModule)
  46. && materialInput.UniversalState == Foundation.Common.Base.UniversalState.Active
  47. )
  48. {
  49.  
  50. if (materialInput.PrimaryQuantity != 0)
  51. {
  52. ASMUtilities.ThrowLocalizedException(ASMConstants.CreateBatchRuleQuantityMustBeZeroLocalizedMessage);
  53. }
  54.  
  55. // Add material to list of DEE-relevant materials
  56. toUnbatchAndTerminate.Add(materialInput);
  57. }
  58. }
  59. }
  60. }
  61. }
  62.  
  63. if (toUnbatchAndTerminate.Count > 0)
  64. {
  65. DeeContextHelper.SetContextParameter("CustomUnbatchFeeders_Materials", toUnbatchAndTerminate);
  66. return true;
  67. }
  68. }
  69. }
  70.  
  71. return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement