Пример #1
0
        protected override void  EndProcessing()
        {
            base.EndProcessing();

            Column columnOutput = new Column();

            columnOutput.DataType             = _datatype;
            columnOutput.DisplayMemberBinding = String.Format("{{Binding Path={0}}}", _bindingpath);
            columnOutput.DisplayNameId        = SMHelpers.MakeMPElementSafeUniqueIdentifier(_displayname);
            columnOutput.DisplayNameString    = _displayname;
            if (_name != null)
            {
                columnOutput.Name = _name;
            }
            else
            {
                columnOutput.Name = SMHelpers.MakeMPElementSafeUniqueIdentifier("Column");
            }
            columnOutput.Property = _bindingpath;
            columnOutput.Width    = _width;

            if (PassThru)
            {
                WriteObject(columnOutput);
            }
        }
Пример #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            //Create subscription and set configurable properties
            InstanceTypeSubscription instancetypeSubscription = new InstanceTypeSubscription(_operationtype, _class.Id, _criteria);
            NotificationSubscription subscription             = new NotificationSubscription(_displayname, _description, instancetypeSubscription);

            subscription.Enabled = _enabled;
            subscription.TemplateIds.Add(_template.Id);
            subscription.Name = SMHelpers.MakeMPElementSafeUniqueIdentifier("NotificationSubscription");

            //TODO: Do we need these or do they have defaults set?
            //subscription.MaximumRunningTimeSeconds = 7200;
            //subscription.RetryDelaySeconds = 60;
            //subscription.EnableBatchProcessing = true;

            //Add recipient users
            if (_recipients != null)
            {
                foreach (EnterpriseManagementObject recipient in _recipients)
                {
                    subscription.Recipients.Add(new NotificationSubscriptionRecipient(recipient.Id.ToString(), NotificationSubscriptionRecipientType.ToRecipient));
                }
            }

            _mg.Subscription.InsertSubscription(_managementpack.Id, subscription);
        }
Пример #3
0
        //TODO: Add support for this at some point

        /*
         * [Parameter(ValueFromPipeline = false, Mandatory = false)]
         * public ManagementPackImage Image
         * {
         *  get { return _image; }
         *  set { _image = value; }
         * }
         */

        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            //Create a new folder and set it's parent folder and display name
            ManagementPackFolder folder = new ManagementPackFolder(_managementpack, SMHelpers.MakeMPElementSafeUniqueIdentifier("Folder"), ManagementPackAccessibility.Public);

            folder.DisplayName  = _displayname;
            folder.ParentFolder = _parentfolder;

            //TODO: Parameterize this someday
            //Set the systemfolder icon to be the icon that is used
            ManagementPackElementReference <ManagementPackImage> foldericonreference = (ManagementPackElementReference <ManagementPackImage>)_mg.Resources.GetResource <ManagementPackImage>(Images.Microsoft_EnterpriseManagement_ServiceManager_UI_Console_Image_Folder, SMHelpers.GetManagementPack(ManagementPacks.Microsoft_EnterpriseManagement_ServiceManager_UI_Console, _mg));
            ManagementPackImageReference image = new ManagementPackImageReference(folder, foldericonreference, _managementpack);

            //Submit changes
            _managementpack.AcceptChanges();
        }
Пример #4
0
        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));
            }
        }