コード例 #1
0
ファイル: Presentation.cs プロジェクト: microsoft/smlets
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            ManagementPackView view = _mg.Presentation.GetView(_view.Id);
            ManagementPack     mp   = view.GetManagementPack();

            view.Status = ManagementPackElementStatus.PendingDelete;
            string viewInfo = view.Name;

            if (view.DisplayName != null)
            {
                viewInfo = view.DisplayName;
            }

            if (ShouldProcess(viewInfo))
            {
                mp.AcceptChanges();
            }
        }
コード例 #2
0
ファイル: Presentation.cs プロジェクト: microsoft/smlets
        protected override void ProcessRecord()
        {
            try
            {
                base.ProcessRecord();

                ManagementPackView view = new ManagementPackView(ManagementPack, SMHelpers.MakeMPElementSafeUniqueIdentifier("View"), ManagementPackAccessibility.Internal);
                view.DisplayName = _DisplayName;     //Set the display name according to what the user specified
                view.Target      = _Class;           //Set the class according to what the user specified

                //TODO: Parameterize these later
                view.Visible       = true;
                view.Accessibility = ManagementPackAccessibility.Public;
                view.Enabled       = true;
                view.Category      = "NotUsed";

                //Set the parent folder that was passed in
                ManagementPackFolderItem folderitem = new ManagementPackFolderItem(view, _Folder);

                //Add the management pack references to the MP
                if (_ManagementPackReferences != null)
                {
                    foreach (KeyValuePair <string, ManagementPackReference> kvp in _ManagementPackReferences)
                    {
                        _ManagementPack.References.Add(kvp);
                    }
                }

                //Get the Grid view type and set it for the view
                ManagementPack mpConsole = SMHelpers.GetManagementPack(ManagementPacks.Microsoft_EnterpriseManagement_ServiceManager_UI_Console, _mg);
                view.TypeID = mpConsole.GetViewType("GridViewType");

                #region DataAdapters

                DataAdapter daEMO          = new DataAdapter();
                DataAdapter daAdvancedList = new DataAdapter();

                if (_Projection != null)
                {
                    daEMO.Name = "dataportal:EnterpriseManagementObjectAdapter";
                    daEMO.Type = "Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectProjectionAdapter";
                }
                else
                {
                    daEMO.Name = "dataportal:EnterpriseManagementObjectProjectionAdapter";
                    daEMO.Type = "Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectAdapter";
                }

                daEMO.Assembly = "Microsoft.EnterpriseManagement.UI.SdkDataAccess";

                daAdvancedList.Name     = "viewframework://Adapters/AdvancedList";
                daAdvancedList.Assembly = "Microsoft.EnterpriseManagement.UI.ViewFramework";
                daAdvancedList.Type     = "Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportAdapter";

                Collection <DataAdapter> collDataAdpaters = new Collection <DataAdapter>();
                collDataAdpaters.Add(daEMO);
                collDataAdpaters.Add(daAdvancedList);

                #endregion DataAdapters

                view.Configuration = CreateViewConfiguration(collDataAdpaters, _columns);

                foreach (Column column in _columns)
                {
                    ManagementPackStringResource mpsr = new ManagementPackStringResource(view.GetManagementPack(), column.DisplayNameId);
                    mpsr.DisplayName = column.DisplayNameString;
                }

                //Set the image
                if (_image != null)
                {
                    ManagementPackElementReference <ManagementPackImage> viewIconReference = (ManagementPackElementReference <ManagementPackImage>)_mg.Resources.GetResource <ManagementPackImage>(_image.Name, _image.GetManagementPack());
                    ManagementPackImageReference imageref = new ManagementPackImageReference(view, viewIconReference, view.GetManagementPack());
                }

                view.GetManagementPack().AcceptChanges();

                if (PassThru)
                {
                    //Pass the new object to the pipeline
                    WriteObject(view);
                }
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, "NewView", ErrorCategory.InvalidOperation, DisplayName));
            }
        }