Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4#region Using directives5 6using System;7using System.Management.Automation;8 9#endregion10 11namespace Microsoft.Management.Infrastructure.CimCmdlets12{13    /// <summary>14    /// <para>15    /// Write progress record of given activity16    /// </para>17    /// </summary>18    internal sealed class CimWriteProgress : CimBaseAction19    {20        /// <summary>21        /// Initializes a new instance of the <see cref="CimWriteProgress"/> class.22        /// </summary>23        /// <param name="activity">24        ///  Activity identifier of the given activity25        /// </param>26        /// <param name="currentOperation">27        /// current operation description of the given activity28        /// </param>29        /// <param name="statusDescription">30        /// current status description of the given activity31        /// </param>32        /// <param name="percentageCompleted">33        /// percentage completed of the given activity34        /// </param>35        /// <param name="secondsRemaining">36        /// how many seconds remained for the given activity37        /// </param>38        public CimWriteProgress(39            string theActivity,40            int theActivityID,41            string theCurrentOperation,42            string theStatusDescription,43            uint thePercentageCompleted,44            uint theSecondsRemaining)45        {46            this.Activity = theActivity;47            this.ActivityID = theActivityID;48            this.CurrentOperation = theCurrentOperation;49            if (string.IsNullOrEmpty(theStatusDescription))50            {51                this.StatusDescription = CimCmdletStrings.DefaultStatusDescription;52            }53            else54            {55                this.StatusDescription = theStatusDescription;56            }57 58            this.PercentageCompleted = thePercentageCompleted;59            this.SecondsRemaining = theSecondsRemaining;60        }61 62        /// <summary>63        /// <para>64        /// Write progress record to powershell65        /// </para>66        /// </summary>67        /// <param name="cmdlet"></param>68        public override void Execute(CmdletOperationBase cmdlet)69        {70            DebugHelper.WriteLog(71                "...Activity {0}: id={1}, remain seconds ={2}, percentage completed = {3}",72                4,73                this.Activity,74                this.ActivityID,75                this.SecondsRemaining,76                this.PercentageCompleted);77 78            ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");79            ProgressRecord record = new(80                this.ActivityID,81                this.Activity,82                this.StatusDescription);83            record.Activity = this.Activity;84            record.ParentActivityId = 0;85            record.SecondsRemaining = (int)this.SecondsRemaining;86            record.PercentComplete = (int)this.PercentageCompleted;87            cmdlet.WriteProgress(record);88        }89 90        #region members91 92        /// <summary>93        /// Gets the activity of the given activity.94        /// </summary>95        internal string Activity { get; }96 97        /// <summary>98        /// Gets the activity identifier of the given activity.99        /// </summary>100        internal int ActivityID { get; }101 102        /// <summary>103        /// Gets the current operation text of the given activity.104        /// </summary>105        internal string CurrentOperation { get; }106 107        /// <summary>108        /// Gets the status description of the given activity.109        /// </summary>110        internal string StatusDescription { get; }111 112        /// <summary>113        /// Gets the percentage completed of the given activity.114        /// </summary>115        internal uint PercentageCompleted { get; }116 117        /// <summary>118        /// Gets the number of seconds remaining for the given activity.119        /// </summary>120        internal uint SecondsRemaining { get; }121 122        #endregion123    }124}125