Пример #1
0
 void Location_In(bool _Ok, EnterpriseManagementObject _LocationEMO, ManagementPackClass _mpClass)
 {
     try
     {
         EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(_mpClass);
         IDataItem itemIdentity = dataType.CreateProxyInstance(_LocationEMO);
         this.TemplateLocationItem.sip.Instance = itemIdentity;
     }
     catch (Exception e)
     {
         System.Windows.MessageBox.Show(DateTime.Now + " : " + "Error in LocIN() : " + e.Message);
     }
 }
Пример #2
0
 void Location_In(bool _Ok, EnterpriseManagementObject _LocationEMO, ManagementPackClass _mpClass)
 {
     try
     {
         //Trace.WriteLine(DateTime.Now + " : " + "Enter LocIN()");
         EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(_mpClass);
         IDataItem itemIdentity = dataType.CreateProxyInstance(_LocationEMO);
         this.TemplateLocationItem.sip.Instance = itemIdentity;
         strModel = itemIdentity["$DisplayName$"].ToString();
     }
     catch (Exception e)
     {
         Trace.WriteLine(DateTime.Now + " : " + "Error in LocIN() : " + e.Message);
     }
 }
Пример #3
0
        private void brd_CI_Edit_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (this.ListViewCI.SelectedItem != null)
            {
                EnterpriseManagementObject SelectEMO = (EnterpriseManagementObject)ListViewCI.SelectedItem;
                //Convert EnterpriseManagementObject to IDataItem
                EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(ConfItemClass);
                IDataItem itemIdentity = dataType.CreateProxyInstance(SelectEMO);

                //Open Console form for created object
                Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
            }
            else
            {
                MessageBox.Show("Please select object!", "No object selected", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #4
0
        private void brd_Loc_Edit_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (LocationTreeView.SelectedItem != null)
            {
                TreeViewItem TR = (TreeViewItem)LocationTreeView.SelectedItem;
                // Get an object by GUID
                Guid G = new Guid(TR.Tag.ToString());
                EnterpriseManagementObject treeviewEMO = emg.EntityObjects.GetObject <EnterpriseManagementObject>(G, ObjectQueryOptions.Default);
                //Convert EnterpriseManagementObject to IDataItem
                EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(locationClass);
                IDataItem itemIdentity = dataType.CreateProxyInstance(treeviewEMO);

                //Open Console form for created object
                Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
            }
            else
            {
                MessageBox.Show("Please select location!", "No location selected", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #5
0
        private void brd_Loc_Create_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (LocationTreeView.SelectedItem != null)
            {
                CreatableEnterpriseManagementObject newLocation = new CreatableEnterpriseManagementObject(emg, locationClass);

                //Add some property values
                newLocation[locationClass, "DisplayName"].Value = "Add some info";
                newLocation.Commit();

                //Treeview Item - Parent Item
                TreeViewItem TR = (TreeViewItem)LocationTreeView.SelectedItem;
                // Get an object by GUID
                Guid G = new Guid(TR.Tag.ToString());
                EnterpriseManagementObject treeviewEMO = emg.EntityObjects.GetObject <EnterpriseManagementObject>(G, ObjectQueryOptions.Default);

                CreatableEnterpriseManagementRelationshipObject relationship = new CreatableEnterpriseManagementRelationshipObject(emg, relationClass);
                relationship.SetSource(treeviewEMO);
                relationship.SetTarget(newLocation);
                relationship.Commit();

                //FillTreeView.Now(emg, locationClass, relationClass, LocationTreeView);
                Fill();


                //Convert EnterpriseManagementObject to IDataItem
                EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(locationClass);
                IDataItem newlocationDataItem = dataType.CreateProxyInstance(newLocation);

                //Open Console form for created object
                //ConsoleContextHelper.Instance.PopoutForm(itemIdentity);
                Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(newlocationDataItem);
            }
            else
            {
                MessageBox.Show("Please select parent location!", "No location selected", MessageBoxButton.OK, MessageBoxImage.Warning);
                Trace.WriteLine(DateTime.Now + " : " + "Not have Values for create Rel");
            }
        }
Пример #6
0
        private void lbOpen_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (ListViewCI.SelectedItem != null)
            {
                //ManagementPack mpSystem = emg.GetManagementPack("System.Library", "31bf3856ad364e35", new Version());
                //ConfItemClass = emg.EntityTypes.GetClass("System.ConfigItem", mpSystem);
                //ListViewItem LVItem = (ListViewItem)ListViewCI.SelectedItem;
                // Get an object by GUID
                //Guid G = new Guid(LVItem.Tag.ToString());
                //Guid G = (Guid)((EnterpriseManagementObject)ListViewCI.SelectedItem).Id;
                EnterpriseManagementObject ListViewEMO = (EnterpriseManagementObject)ListViewCI.SelectedItem;
                //EnterpriseManagementObject ListViewEMO = emg.EntityObjects.GetObject<EnterpriseManagementObject>(G, ObjectQueryOptions.Default);
                //Convert EnterpriseManagementObject to IDataItem
                EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(ConfItemClass);
                IDataItem itemIdentity = dataType.CreateProxyInstance(ListViewEMO);

                //Open Console form for created object
                Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
            }
            else
            {
                MessageBox.Show("Please select Configuration Item!", "No Configuration Item selected", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #7
0
        public override void ExecuteCommand(IList <Microsoft.EnterpriseManagement.ConsoleFramework.NavigationModelNodeBase> nodes, Microsoft.EnterpriseManagement.ConsoleFramework.NavigationModelNodeTask task, ICollection <string> parameters)
        {
            try
            {
                // LogFile _LogFile = new LogFile(@"C:\LogForms.txt", true);
                IDataItem dataItem = null;
                //There will only ever be one item because we are going to limit this task to single select
                foreach (NavigationModelNodeBase node in nodes)
                {
                    //Check if task was started from form
                    bool startedFromForm = FormUtilities.Instance.IsNodeWithinForm(nodes[0]);
                    //If started from form
                    if (startedFromForm)
                    {
                        dataItem = FormUtilities.Instance.GetFormDataContext(node);
                    }
                    //Else started from view
                    else
                    {
                        dataItem = node;
                    }
                }

                EnterpriseManagementGroup emg = GetSession();
                ManagementPack            mpAssetCore;
                ManagementPack            mpNetworkAssetLibrary;
                ManagementPack            mpCMLibrary;

                ManagementPackClass classWindowsComputer;
                ManagementPackClass classDeployedComputer;


                ManagementPackRelationship relComputerRunsWindowsComputer;
                mpAssetCore                    = emg.ManagementPacks.GetManagementPack("SMCenter.AssetManagement.Core", "75b45bd6835084b1", new Version());
                mpNetworkAssetLibrary          = emg.ManagementPacks.GetManagementPack("SMCenter.NetworkAssetManagement.Library", "75b45bd6835084b1", new Version());
                mpCMLibrary                    = emg.ManagementPacks.GetManagementPack("Microsoft.SystemCenter.ConfigurationManager", "31bf3856ad364e35", new Version());
                classWindowsComputer           = emg.EntityTypes.GetClass("SMCenter.WindowsComputer", mpNetworkAssetLibrary);
                classDeployedComputer          = emg.EntityTypes.GetClass("SMCenter.DeployedComputer", mpNetworkAssetLibrary);
                relComputerRunsWindowsComputer = emg.EntityTypes.GetRelationshipClass("Microsoft.SystemCenter.ConfigurationManager.DeployedComputerRunsWindowsComputer", mpCMLibrary);

                EnterpriseManagementObject WC = null;
                Guid CurrentNodeId            = (Guid)dataItem["$Id$"];
                EnterpriseManagementObject DC = emg.EntityObjects.GetObject <EnterpriseManagementObject>(CurrentNodeId, ObjectQueryOptions.Default);
                //if (WC.IsInstanceOf(classWindowsComputer))
                //{
                //    var rels = emg.EntityObjects.GetRelationshipObjectsWhereTarget<EnterpriseManagementObject>(WC.Id, relComputerRunsWindowsComputer, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
                //    foreach (EnterpriseManagementRelationshipObject<EnterpriseManagementObject> rel in rels)
                //    {
                //        DC = rel.SourceObject;
                //    }
                //}
                //else
                //{
                //    //_LogFile.Write(String.Format("No DC"), false);
                //    System.Windows.MessageBox.Show(DateTime.Now + " : " + "ExecuteCommand Error : " + "Текущий объект не является Windows Computer.");
                //}

                if (DC.IsInstanceOf(classDeployedComputer))
                {
                    var rels = emg.EntityObjects.GetRelationshipObjectsWhereSource <EnterpriseManagementObject>(DC.Id, relComputerRunsWindowsComputer, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
                    foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> rel in rels)
                    {
                        WC = rel.TargetObject;
                    }
                }
                else
                {
                    //_LogFile.Write(String.Format("No DC"), false);
                    System.Windows.MessageBox.Show(DateTime.Now + " : " + "ExecuteCommand Error : " + "Текущий объект не является Deployed Computer.");
                }

                if (WC != null)
                {
                    EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(classWindowsComputer);
                    IDataItem itemIdentity = dataType.CreateProxyInstance(WC);
                    Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
                }
                else
                {
                    System.Windows.MessageBox.Show(DateTime.Now + " : Нет связанных Windows Computer!", "Service Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(DateTime.Now + " : " + "ExecuteCommand Error : " + ex.Message);
            }
        }
Пример #8
0
        public override void ExecuteCommand(IList <NavigationModelNodeBase> nodes, NavigationModelNodeTask task, ICollection <string> parameters)
        {
            //Used for idataitem (form mode, 1=new form, 2=edit form);
            int iMode = 0;

            //Set title for messageboxes
            string sAppTitle = "Assign Incident Directly To Analyst";

            //Connect to MG
            IServiceContainer       isContainer = (IServiceContainer)FrameworkServices.GetService(typeof(IServiceContainer));
            IManagementGroupSession imgSession  = (IManagementGroupSession)isContainer.GetService(typeof(IManagementGroupSession));

            if (imgSession == null)
            {
                MessageBox.Show("Failed to connect to the current session", sAppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            EnterpriseManagementGroup emg = imgSession.ManagementGroup;

            //Get the incident class (System.WorkItem.Incident)
            ManagementPackClass classIncident = emg.EntityTypes.GetClass(new Guid("A604B942-4C7B-2FB2-28DC-61DC6F465C68"));

            //Microsoft.Windows.Library
            ManagementPack mpWindows =
                emg.ManagementPacks.GetManagementPack(new Guid("545131F0-58DE-1914-3A82-4FCAC9100A33"));

            //Get the Microsoft.AD.User class
            ManagementPackClass mpcADUser = emg.EntityTypes.GetClass("Microsoft.AD.User", mpWindows);

            //Return the currently selected incident reference
            NavigationModelNodeBase selincident = nodes[0];

            //Form mode (not new)?
            if (selincident.Location.AbsoluteUri.IndexOf("FormDisplay", 0) > 0)
            {
                iMode = 2;
            }

            //Get objects
            EnterpriseManagementObject emoSelIncident = null;
            IDataItem i = ConsoleContextHelper.Instance.GetFormDataContext(nodes[0]);

            //Get the analyst settings class and MP
            ManagementPack      mpSetting     = emg.ManagementPacks.GetManagementPack(new Guid("56d5c2d6-7e19-59ff-7a81-ac8a331fcb3f"));
            ManagementPackClass classSettings = mpSetting.GetClass("AssignSettingsClass");

            //Get the emo for the settings
            EnterpriseManagementObject emoSettings = emg.EntityObjects.GetObject <EnterpriseManagementObject>(classSettings.Id, ObjectQueryOptions.Default);

            //TP names
            string sAssignedTo = "AssignedUser";
            string sActionLog  = "ActionLogs";

            if (emoSettings[classSettings, "AssignedUserAlias"].Value != null)
            {
                sAssignedTo = emoSettings[classSettings, "AssignedUserAlias"].Value.ToString();
            }
            if (emoSettings[classSettings, "ActionLogAlias"].Value != null)
            {
                sActionLog = emoSettings[classSettings, "ActionLogAlias"].Value.ToString();
            }

            //Check if new
            if (!(bool)i["$IsNew$"])
            {
                //Now get the guid of the selected workitem. Depending on the view type, the return will be different, so take it after the last "."
                //There are lots of ways of doing this, this is not the best way but it was the first I learnt and it works
                string strGuid = selincident.GetId().Substring(selincident.GetId().LastIndexOf('.') + 1);

                //Get the emo of the workitem via it's guid
                emoSelIncident = emg.EntityObjects.GetObject <EnterpriseManagementObject>(new Guid(strGuid), ObjectQueryOptions.Default);
            }
            //Creating new incident
            else
            {
                iMode = 1;
            }

            //Was task was run from an workitem opened for editing, as opposed to a list or view?
            if (selincident.Location.AbsoluteUri.IndexOf("FormDisplay", 0) != -1)
            {
                iMode = 2;
            }

            //Get the status guid
            Guid gStatus = Guid.NewGuid();

            try
            {
                //"New" status will throw an exception to must catch here
                if (i["Status"] != null)
                {
                    gStatus = (Guid)(i["Status"] as IDataItem)["Id"];
                }
            }
            catch
            {
            }

            //Get the incident class (System.WorkItem.Incident)
            ManagementPackClass mpcIncident = emg.EntityTypes.GetClass(new Guid("a604b942-4c7b-2fb2-28dc-61dc6f465c68"));

            //Check if the incident is closed
            if (gStatus == new Guid("bd0ae7c4-3315-2eb3-7933-82dfc482dbaf"))
            {
                MessageBox.Show("This incident cannot be reassigned as it has been closed.", sAppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //Note - we are alllowing resolved incidents to be re-assigned, to prevent this, uncomment the following block:

            /*else if (gStatus == new Guid("2b8830b6-59f0-f574-9c2a-f4b4682f1681"))
             * {
             *  MessageBox.Show("This incident cannot be reassigned as it has been resolved.", sAppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
             *  return;
             * }
             */

            //Current assignee and Id
            string sId       = "";
            string sUser     = "";
            string sTierGuid = "";

            if (iMode == 0)
            {
                //View mode
                sUser = this.GetProperty(ref emg, emoSelIncident, ref mpcADUser, "DisplayName");
                sId   = emoSelIncident[mpcIncident, "Id"].Value.ToString();
                if (emoSelIncident[mpcIncident, "TierQueue"].Value != null)
                {
                    sTierGuid = ((ManagementPackEnumeration)emoSelIncident[mpcIncident, "TierQueue"].Value).Id.ToString();
                }
            }
            else
            {
                //New or edit form mode
                try
                {
                    //Get display name of current assignee
                    if (i[sAssignedTo] == null)
                    {
                        sUser = "******";
                    }
                    else
                    {
                        sUser = (string)(i[sAssignedTo] as IDataItem)["DisplayName"];
                    }
                }
                catch
                {
                    //Set no assignee
                    sUser = "******";
                }
                sId = (string)i["Id"];
                try
                {
                    //Check current tier queue enum value
                    if (i["TierQueue"] != null)
                    {
                        sTierGuid = ((Guid)(i["TierQueue"] as IDataItem)["Id"]).ToString();
                    }
                }
                catch
                {
                }
            }

            //Create a new instance of the form and set it up
            AssignForm af = new AssignForm();

            af.sTierGuid        = sTierGuid;
            af.Text             = "Assign incident " + sId + " directly to Analyst - currently assigned to " + sUser;
            af.textDefault.Text = sUser;
            af.emg = emg;

            //Show the analyst/tier selection form
            DialogResult dr = af.ShowDialog();

            if (dr != DialogResult.Cancel)
            {
                //Get the samaccountname from the right hand part of the combobox.text after the !
                string sADUserName = af.comboAnalysts.Text.Substring(af.comboAnalysts.Text.LastIndexOf("(") + 1);
                //Remove last )
                sADUserName = sADUserName.Substring(0, sADUserName.Length - 1);

                //Format to get the display name only from the left part - this is used for the actionlog entry
                string sADUserDisplayName = af.comboAnalysts.Text.Substring(0, af.comboAnalysts.Text.LastIndexOf("(")).Trim();

                try
                {
                    //Set the query for the user - note - usernames are assumed unique across configured domains
                    //If this is not the case, you need to customise these criteria to include a domain
                    string sADUserCriteria = String.Format(@"
                        <Criteria xmlns=""http://Microsoft.EnterpriseManagement.Core.Criteria/"">
                        <Reference Id=""Microsoft.Windows.Library"" PublicKeyToken=""{0}"" Version=""{1}"" Alias=""MSWinLib"" />
                        <Expression>
                        <SimpleExpression>
                        <ValueExpressionLeft>
                        <Property>$Target/Property[Type='MSWinLib!Microsoft.AD.User']/UserName$</Property>
                        </ValueExpressionLeft>
                        <Operator>Equal</Operator>
                        <ValueExpressionRight>
                        <Value>" + sADUserName + @"</Value>
                        </ValueExpressionRight>
                        </SimpleExpression>
                        </Expression>
                        </Criteria>
                        ", mpWindows.KeyToken, mpWindows.Version.ToString());

                    //Object query options
                    ObjectQueryOptions objQueryOpts = new ObjectQueryOptions();
                    objQueryOpts.ObjectRetrievalMode = ObjectRetrievalOptions.Buffered;
                    objQueryOpts.DefaultPropertyRetrievalBehavior = ObjectPropertyRetrievalBehavior.All;
                    //We are searching via samAccountName so there will be only 1 item
                    objQueryOpts.MaxResultCount = 1;

                    //Get the AD User CI object
                    EnterpriseManagementObjectCriteria emocADUser =
                        new EnterpriseManagementObjectCriteria(sADUserCriteria, mpcADUser, emg);
                    IObjectReader <EnterpriseManagementObject> orADUser = emg.EntityObjects.GetObjectReader <EnterpriseManagementObject>(emocADUser, objQueryOpts);
                    EnterpriseManagementObject emoAssignToUser          = orADUser.ElementAt(0);

                    if (iMode == 0)
                    {
                        //View mode - create a new assigned to user relationship
                        ManagementPackRelationship relAssignedToUser =
                            emg.EntityTypes.GetRelationshipClass(new Guid("15e577a3-6bf9-6713-4eac-ba5a5b7c4722"));
                        CreatableEnterpriseManagementRelationshipObject cemroAssignedToUser =
                            new CreatableEnterpriseManagementRelationshipObject(emg, relAssignedToUser);

                        //Set the source and target...
                        cemroAssignedToUser.SetSource(emoSelIncident);
                        cemroAssignedToUser.SetTarget(emoAssignToUser);

                        //Save
                        cemroAssignedToUser.Commit();

                        //Add a new comment
                        this.AddActionLogEntry(emg, emoSelIncident, "Incident was assigned to " + sADUserDisplayName, af.textComment.Text);

                        //Check tier
                        if (af.bShowTier)
                        {
                            if (af.comboTier.Text == "")
                            {
                                emoSelIncident[classIncident, "TierQueue"].Value = null;
                            }
                            else
                            {
                                ManagementPackEnumeration mpeTier = emg.EntityTypes.GetEnumeration(new Guid(af.comboTierGuids.Items[af.comboTier.SelectedIndex].ToString()));
                                emoSelIncident[classIncident, "TierQueue"].Value = mpeTier;
                            }
                            emoSelIncident.Commit();
                        }

                        //Refresh the current incident view
                        this.RequestViewRefresh();
                    }
                    else
                    {
                        //Note - IDataItem property names depend on the type projection being used and may differ from these

                        //Form mode, create a proxy to the emo user object to set on the form
                        EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(mpcADUser);
                        IDataItem iUser = dataType.CreateProxyInstance(emoAssignToUser);
                        i[sAssignedTo] = iUser;

                        //Check tier
                        if (af.bShowTier)
                        {
                            if (af.comboTier.Text == "")
                            {
                                //Remove tier
                                i["TierQueue"] = null;
                            }
                            else
                            {
                                //Set tier, get enum first
                                ManagementPackEnumeration mpeTier = emg.EntityTypes.GetEnumeration(new Guid(af.comboTierGuids.Items[af.comboTier.SelectedIndex].ToString()));
                                i["TierQueue"] = mpeTier;
                            }
                        }
                        //Uncommenting this will cause the IDataItem to be saved and thus update the actual object in the database, normally you don't want to do this
                        //as you want the user to click OK or cancel on the form instead
                        //EnterpriseManagementObjectProjectionDataType.UpdateDataItem(i);

                        //IDataItem Action log
                        //
                        //Get the System.WorkItem.Library mp
                        ManagementPack mpWorkItemLibrary = emg.ManagementPacks.GetManagementPack(new Guid("405D5590-B45F-1C97-024F-24338290453E"));
                        //Get the actionlog class
                        ManagementPackClass mpcActionLog =
                            emg.EntityTypes.GetClass("System.WorkItem.TroubleTicket.ActionLog", mpWorkItemLibrary);

                        //Create a new action log entry as an idataitem
                        CreatableEnterpriseManagementObject cemoActionLog =
                            new CreatableEnterpriseManagementObject(emg, mpcActionLog);
                        EnterpriseManagementObjectDataType dataTypeLog = new EnterpriseManagementObjectDataType(mpcActionLog);
                        IDataItem iLog = dataTypeLog.CreateProxyInstance(cemoActionLog);

                        //Setup the new action log entry
                        iLog["Id"]          = Guid.NewGuid().ToString();
                        iLog["Description"] = af.textComment.Text;
                        iLog["Title"]       = "Reassignment Comment";
                        iLog["EnteredBy"]   = UserPrincipal.Current.DisplayName;
                        iLog["EnteredDate"] = DateTime.Now.ToUniversalTime();

                        //Set action type (this also adds the icon and is required)
                        ManagementPackEnumeration enumActionLog =
                            mpWorkItemLibrary.GetEnumerations().GetItem("System.WorkItem.ActionLogEnum.TaskExecuted");
                        iLog["ActionType"] = enumActionLog;

                        //This adds the new idataitem log entry to the entries displayed on the form, it does not over-write the existing entries
                        i[sActionLog] = iLog;
                    }
                }
                catch (System.Exception e)
                {
                    //Oops
                    MessageBox.Show(e.Message + "\n\n" + e.StackTrace, sAppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
        }
Пример #9
0
        private void CabelsTreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                TreeViewItem SelectedTreeItem = (TreeViewItem)this.CablesTreeView.SelectedItem;

                if (SelectedTreeItem.Header.ToString().Contains("Cable.Footage"))
                {
                }
                else
                {
                    //Get CurrentNode

                    Guid G = new Guid(SelectedTreeItem.Tag.ToString());
                    EMO = emg.EntityObjects.GetObject <EnterpriseManagementObject>(G, ObjectQueryOptions.Default);

                    //Guid Id_NA = new Guid();
                    if (EMO.IsInstanceOf(classModule))
                    {
                        EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(classModule);
                        IDataItem itemIdentity = dataType.CreateProxyInstance(EMO);
                        Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
                    }
                    else if (EMO.IsInstanceOf(classNodePort))
                    {
                        var items = emg.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(G, relNodeComposedOfNetworkAdapter, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
                        foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> relobj in items)
                        {
                            EMO = relobj.SourceObject;
                        }
                        EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(classNode);
                        IDataItem itemIdentity = dataType.CreateProxyInstance(EMO);
                        Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
                    }
                    else if (EMO.IsInstanceOf(classDeviceNetworkAdapter))
                    {
                        var items = emg.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(G, relDeviceHostNetworkAdapter, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
                        foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> relobj in items)
                        {
                            EMO = relobj.SourceObject;
                        }
                        EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(classDevice);
                        IDataItem itemIdentity = dataType.CreateProxyInstance(EMO);
                        Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
                    }
                    else if (EMO.IsInstanceOf(classComputerNetworkAdapter))
                    {
                        var items = emg.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(G, relComputerHostsComputerNetworkAdapter, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
                        foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> relobj in items)
                        {
                            EMO = relobj.SourceObject;
                        }
                        EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(classWindowsComputer);
                        IDataItem itemIdentity = dataType.CreateProxyInstance(EMO);
                        Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
                    }
                    //else if (EMO.IsInstanceOf(classPatchPanelPort))
                    //{
                    //    var items = emg.EntityObjects.GetRelationshipObjectsWhereTarget<EnterpriseManagementObject>(G, relNodeComposedOfNetworkAdapter, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
                    //    foreach (EnterpriseManagementRelationshipObject<EnterpriseManagementObject> relobj in items)
                    //    {
                    //        EMO = relobj.SourceObject;
                    //    }
                    //    EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(classPatchPanel);
                    //    IDataItem itemIdentity = dataType.CreateProxyInstance(EMO);
                    //    Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(itemIdentity);
                    //}
                    else
                    {
                        System.Windows.MessageBox.Show("Unknown object!");
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("CabelsTreeView_MouseDoubleClick procedure error : " + ex.Message, "Service Manager", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }