/// <summary> /// Called when an FCO or folder changes /// </summary> /// <param name="subject"> /// the object the event(s) happened to /// </param> /// <param name="eventMask"> /// objectevent_enum values ORed together /// </param> /// <param name="param"> /// extra information provided for cetertain event types /// </param> public void ObjectEvent( MgaObject subject, uint eventMask, object param) { if (!componentEnabled) { return; } else if (isXMLImportInProgress) { return; } //else if (isProjectInTransation) //{ // return; //} if (subject.HasReadOnlyAccess() || subject.IsLibObject) { return; } uint uOBJEVENT_CREATED = 0; uint uOBJEVENT_COPIED = 0; unchecked { uOBJEVENT_CREATED = (uint)objectevent_enum.OBJEVENT_CREATED; } unchecked { uOBJEVENT_COPIED = (uint)objectevent_enum.OBJEVENT_COPIED; } if ((eventMask & uOBJEVENT_COPIED) != 0) { isCopied = true; } else if ((eventMask & uOBJEVENT_CREATED) != 0 && subject.Status == 0) // check Status, since object can be created and deleted in same tx { if (isCopied) { // handle copy event isCopied = false; } else { //subject.Project.RootMeta.RootFolder.DefinedFCOByName["Task", //MgaMetaBase task; //if (task.MetaRef == subject.MetaBase.MetaRef) { } // handle new object event if (subject.MetaBase.Name == "Task" || subject.MetaBase.Name == "WorkflowRef") { Type t = Type.GetTypeFromProgID(DecoratorName); if (t != null) { (subject as MgaFCO).RegistryValue["decorator"] = DecoratorName; } } bool isBasicTask = (subject.MetaBase.Name == "Task"); if (subject.MetaBase.Name == "Task" || subject.MetaBase.Name == "ExecutionTask") { using (InterpreterSelectionForm form = new InterpreterSelectionForm()) { form.addon = this; form.Init(); IEnumerable<MgaAtom> taskChildren = subject.ExGetParent(). ChildObjects. OfType<MgaAtom>(). Where(x => x.ExDstFcos().Count() == 0). Where(x => x.ID != subject.ID); form.lbTasks.Items.Clear(); foreach (var currTask in taskChildren) { var atomWrapper = new MgaAtomWrapper(currTask); form.lbTasks.Items.Add(new MgaAtomWrapper(currTask)); form.lbTasks.SelectedItem = atomWrapper; } if (form.lbTasks.Items.Count > 0) { form.lbTasks.SetSelected(0, true); } if (!isBasicTask) // remove interpreter selection and reset positions { form.lbInterpreters.Items.Clear(); form.lbInterpreters.Visible = false; form.lblSelectInterpreter.Visible = false; form.chbAutoConnect.Location = form.label1.Location; form.label1.Location = form.lblSelectInterpreter.Location; form.lbTasks.Location = form.lbInterpreters.Location; } DialogResult dgr = form.ShowDialog(); if (dgr == DialogResult.OK) { if (isBasicTask) { ComComponent c = form.lbInterpreters.SelectedItem as ComComponent; try { if (c != null && c.isValid) { (subject as MgaFCO).StrAttrByName["COMName"] = c.ProgId; } } catch { MessageBox.Show("Cannot save interpreter settings. 'COMName' is not a parameter of 'Task'."); } } //Flow if (form.chbAutoConnect.Checked && (form.lbTasks.SelectedItem != null)) { MgaAtomWrapper selectedTask = form.lbTasks.SelectedItem as MgaAtomWrapper; MgaAtom lastInWorkflow = null; if (selectedTask != null) { lastInWorkflow = selectedTask.Atom; } if (lastInWorkflow != null) { MgaMetaRole role = ((subject.ExGetParent() as MgaModel). Meta as MgaMetaModel).RoleByName["Flow"]; (subject.ExGetParent() as MgaModel).CreateSimplerConnDisp( role, lastInWorkflow as MgaFCO, subject as MgaFCO); } } } } } } } // TODO: Handle object events (OR eventMask with the members of objectevent_enum) // Warning: Only those events are received that you have subscribed for by setting ComponentConfig.eventMask // MessageBox.Show(eventMask.ToString()); }
/// <summary> /// Called when an FCO or folder changes /// </summary> /// <param name="subject"> /// the object the event(s) happened to /// </param> /// <param name="eventMask"> /// objectevent_enum values ORed together /// </param> /// <param name="param"> /// extra information provided for cetertain event types /// </param> public void ObjectEvent( MgaObject subject, uint eventMask, object param) { if (!componentEnabled) { return; } else if (isXMLImportInProgress) { return; } //else if (isProjectInTransation) //{ // return; //} if (subject.HasReadOnlyAccess() || subject.IsLibObject) { return; } uint uOBJEVENT_CREATED = 0; uint uOBJEVENT_COPIED = 0; unchecked { uOBJEVENT_CREATED = (uint)objectevent_enum.OBJEVENT_CREATED; } unchecked { uOBJEVENT_COPIED = (uint)objectevent_enum.OBJEVENT_COPIED; } if ((eventMask & uOBJEVENT_COPIED) != 0) { isCopied = true; } else if ((eventMask & uOBJEVENT_CREATED) != 0 && subject.Status == 0) // check Status, since object can be created and deleted in same tx { if (isCopied) { // handle copy event isCopied = false; } else { //subject.Project.RootMeta.RootFolder.DefinedFCOByName["Task", //MgaMetaBase task; //if (task.MetaRef == subject.MetaBase.MetaRef) { } // handle new object event bool isBasicTask = (subject.MetaBase.Name == "Task"); if (subject.MetaBase.Name == "Task" || subject.MetaBase.Name == "ExecutionTask") { if (subject.MetaBase.Name == "Task" && string.IsNullOrEmpty((subject as MgaFCO).StrAttrByName["COMName"]) == false) { return; } if (subject.MetaBase.Name == "ExecutionTask" && string.IsNullOrEmpty((subject as MgaFCO).StrAttrByName["Invocation"]) == false) { return; } using (InterpreterSelectionForm form = new InterpreterSelectionForm()) { form.addon = this; form.Init(); HashSet <string> taskKinds = new HashSet <string>() { "ExecutionTask", "Task" }; IEnumerable <MgaAtom> taskChildren = subject.ExGetParent(). ChildObjects. OfType <MgaAtom>(). Where(x => x.ExDstFcos().Count() == 0). Where(x => x.ID != subject.ID). Where(x => taskKinds.Contains(x.Meta.Name)); form.lbTasks.Items.Clear(); foreach (var currTask in taskChildren) { var atomWrapper = new MgaAtomWrapper(currTask); form.lbTasks.Items.Add(new MgaAtomWrapper(currTask)); form.lbTasks.SelectedItem = atomWrapper; } if (form.lbTasks.Items.Count > 0) { form.lbTasks.SetSelected(0, true); } if (!isBasicTask) // remove interpreter selection and reset positions { form.lbInterpreters.Items.Clear(); form.lbInterpreters.Visible = false; form.lblSelectInterpreter.Visible = false; form.chbAutoConnect.Location = form.label1.Location; form.label1.Location = form.lblSelectInterpreter.Location; form.lbTasks.Location = form.lbInterpreters.Location; } DialogResult dgr = form.ShowDialog(); if (dgr == DialogResult.OK) { if (isBasicTask) { ComComponent c = form.lbInterpreters.SelectedItem as ComComponent; try { if (c != null && c.isValid) { (subject as MgaFCO).StrAttrByName["COMName"] = c.ProgId; } } catch { MessageBox.Show("Cannot save interpreter settings. 'COMName' is not a parameter of 'Task'."); } } //Flow if (form.chbAutoConnect.Checked && (form.lbTasks.SelectedItem != null)) { MgaAtomWrapper selectedTask = form.lbTasks.SelectedItem as MgaAtomWrapper; MgaAtom lastInWorkflow = null; if (selectedTask != null) { lastInWorkflow = selectedTask.Atom; } if (lastInWorkflow != null) { MgaMetaRole role = ((subject.ExGetParent() as MgaModel). Meta as MgaMetaModel).RoleByName["Flow"]; (subject.ExGetParent() as MgaModel).CreateSimplerConnDisp( role, lastInWorkflow as MgaFCO, subject as MgaFCO); } } } } } } } // TODO: Handle object events (OR eventMask with the members of objectevent_enum) // Warning: Only those events are received that you have subscribed for by setting ComponentConfig.eventMask // MessageBox.Show(eventMask.ToString()); }