Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Info
- /// <summary>
- /// Summary text
- /// Automatically unbatch a feeder parent material on move next.
- /// Action Groups:
- /// BusinessObjects.MaterialCollection.MoveToNextStep.Post
- /// Depends On:
- /// Is Dependency For:
- /// Exceptions:
- /// </summary>
- #endregion
- MaterialCollection moveMaterialsToNextStepInput = new MaterialCollection();
- if (Input.Keys.Contains("MaterialCollection"))
- {
- MaterialCollection mats = Input["MaterialCollection"] as MaterialCollection ?? null;
- if (mats != null && mats.Count > 0)
- {
- moveMaterialsToNextStepInput = mats;
- }
- }
- if (moveMaterialsToNextStepInput != null)
- {
- if (moveMaterialsToNextStepInput.Count > 0)
- {
- MaterialCollection toUnbatchAndTerminate = new MaterialCollection();
- foreach (Material materialInput in moveMaterialsToNextStepInput)
- {
- if (materialInput != null)
- {
- materialInput.LoadChildren();
- if (materialInput.Step != null & materialInput.Form != null && materialInput.SubMaterials != null)
- {
- materialInput.Step.LoadAttributes();
- if (materialInput.Step.HasAttribute(ASMConstants.IsMaterialBatchingAvailableAttribute))
- {
- if ((bool)materialInput.Step.Attributes[ASMConstants.IsMaterialBatchingAvailableAttribute]
- && materialInput.Form == ASMConstants.MaterialFormBatch
- && materialInput.SubMaterialCount > 0
- && materialInput.SubMaterials.All(c => c.Form == ASMConstants.MaterialFormModule)
- && materialInput.UniversalState == Foundation.Common.Base.UniversalState.Active
- )
- {
- if (materialInput.PrimaryQuantity != 0)
- {
- ASMUtilities.ThrowLocalizedException(ASMConstants.CreateBatchRuleQuantityMustBeZeroLocalizedMessage);
- }
- // Add material to list of DEE-relevant materials
- toUnbatchAndTerminate.Add(materialInput);
- }
- }
- }
- }
- }
- if (toUnbatchAndTerminate.Count > 0)
- {
- DeeContextHelper.SetContextParameter("CustomUnbatchFeeders_Materials", toUnbatchAndTerminate);
- return true;
- }
- }
- }
- return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement