/// <summary> /// Create an instance of the mfg import command /// </summary> public RwMfgImportViewModel() { planningObject = null; isSelectedPlanningObjectValid = false; MfgCollection = new ObservableCollection <string>(); SourceFilename = string.Empty; ChooseSourceFileCommand = new RwActionCommand(ChooseSourceFileExecuted, ChooseSourceFileCanExecute); ExecuteMfgImportCommand = new RwActionCommand(MfgImportExecuted, MfgImportCanExecute); MfgLibraryPickedEvent = new RwActionCommand(MfgLibraryPickedExecuted, MfgLibraryPickedCanExecute); }
/// <summary> /// Create an instance of the mfg import command /// </summary> public RwImportMfgViewModel() { planningObject = null; isSelectedPlanningObjectValid = false; MfgCollection = new ObservableCollection <string>(); defaultMfgGroupBoxHeader = "Manufacturing features import list"; MfgGroupBoxHeader = defaultMfgGroupBoxHeader; SourceFilename = string.Empty; ChooseSourceFileCommand = new RwActionCommand(ChooseSourceFileExecuted, ChooseSourceFileCanExecute); ExecuteMfgImportCommand = new RwActionCommand(MfgImportExecuted, MfgImportCanExecute); MfgLibraryPickedEvent = new RwActionCommand(MfgLibraryPickedExecuted, MfgLibraryPickedCanExecute); MfgCollection.CollectionChanged += OnMfgCollectionChanged; }
/// <summary> /// Group the components by the variant name column of the resource tree /// </summary> /// <param name="component">The current component</param> private void GroupComponentByVariantName(TxComponent component) { /* * Thanks to Siemens API Team for support * https://community.plm.automation.siemens.com/t5/Tecnomatix-Developer-Forum/Variant-name/m-p/550867#M1499 */ ITxPlanningObject planningObject = component.PlanningRepresentation; if (planningObject is ITxPlanningVariantSetAssignable variantSetAssignable && component.Visibility != TxDisplayableObjectVisibility.CannotBeDisplayed) { ITxPlanningVariantSet variantSet = variantSetAssignable.GetVariantSet(); if (variantSet != null) { AddToDictionary(variantSet.Name, component); } else { AddToDictionary("EMPTY", component); } } }
/// <summary> /// Execute the pick event on a selected planning object /// </summary> /// <param name="obj">The control of the UI</param> private void MfgLibraryPickedExecuted(object obj) { try { isSelectedPlanningObjectValid = false; if (obj is TxObjEditBoxControl control) { planningObject = control.Object as ITxPlanningObject; if (planningObject != null) { if (planningObject.PlanningType.Equals("PmMfgLibrary")) { isSelectedPlanningObjectValid = true; } } } } catch (TxPlanningObjectNotLoadedException exception) { TxMessageBox.Show($"{exception.Message}", "Mfg import - Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } }
/// <summary> /// Query the eMServer fields /// </summary> /// <param name="emsCacheManager">Cache manager for emServer fields</param> /// <param name="index">The string indexer, normally "wpMfgLibrary"</param> /// <param name="attribute">The attribue for setting on eMServer cached field</param> /// <param name="planningObject">The planning object, here it is the MfgLibrary</param> /// <param name="collection">The collection with required objects, in this case the mfg names</param> private static void QueryEmsCache(TxEmsCacheManager emsCacheManager, string index, string attribute, ITxPlanningObject planningObject, TxObjectList collection) { emsCacheManager.Clear(); emsCacheManager[index].SetAttributes(attribute); if (planningObject != null && collection == null) { emsCacheManager[index].SetRootObject(planningObject); } else if (planningObject == null && collection != null) { emsCacheManager[index].SetRootObjects(collection); } emsCacheManager.CacheData(); }