forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCimWriteProgress.cs
More file actions
124 lines (109 loc) · 3.91 KB
/
Copy pathCimWriteProgress.cs
File metadata and controls
124 lines (109 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#region Using directives
using System;
using System.Management.Automation;
#endregion
namespace Microsoft.Management.Infrastructure.CimCmdlets
{
/// <summary>
/// <para>
/// Write progress record of given activity
/// </para>
/// </summary>
internal sealed class CimWriteProgress : CimBaseAction
{
/// <summary>
/// Initializes a new instance of the <see cref="CimWriteProgress"/> class.
/// </summary>
/// <param name="activity">
/// Activity identifier of the given activity
/// </param>
/// <param name="currentOperation">
/// current operation description of the given activity
/// </param>
/// <param name="statusDescription">
/// current status description of the given activity
/// </param>
/// <param name="percentageCompleted">
/// percentage completed of the given activity
/// </param>
/// <param name="secondsRemaining">
/// how many seconds remained for the given activity
/// </param>
public CimWriteProgress(
string theActivity,
int theActivityID,
string theCurrentOperation,
string theStatusDescription,
uint thePercentageCompleted,
uint theSecondsRemaining)
{
this.Activity = theActivity;
this.ActivityID = theActivityID;
this.CurrentOperation = theCurrentOperation;
if (string.IsNullOrEmpty(theStatusDescription))
{
this.StatusDescription = CimCmdletStrings.DefaultStatusDescription;
}
else
{
this.StatusDescription = theStatusDescription;
}
this.PercentageCompleted = thePercentageCompleted;
this.SecondsRemaining = theSecondsRemaining;
}
/// <summary>
/// <para>
/// Write progress record to powershell
/// </para>
/// </summary>
/// <param name="cmdlet"></param>
public override void Execute(CmdletOperationBase cmdlet)
{
DebugHelper.WriteLog(
"...Activity {0}: id={1}, remain seconds ={2}, percentage completed = {3}",
4,
this.Activity,
this.ActivityID,
this.SecondsRemaining,
this.PercentageCompleted);
ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");
ProgressRecord record = new(
this.ActivityID,
this.Activity,
this.StatusDescription);
record.Activity = this.Activity;
record.ParentActivityId = 0;
record.SecondsRemaining = (int)this.SecondsRemaining;
record.PercentComplete = (int)this.PercentageCompleted;
cmdlet.WriteProgress(record);
}
#region members
/// <summary>
/// Gets the activity of the given activity.
/// </summary>
internal string Activity { get; }
/// <summary>
/// Gets the activity identifier of the given activity.
/// </summary>
internal int ActivityID { get; }
/// <summary>
/// Gets the current operation text of the given activity.
/// </summary>
internal string CurrentOperation { get; }
/// <summary>
/// Gets the status description of the given activity.
/// </summary>
internal string StatusDescription { get; }
/// <summary>
/// Gets the percentage completed of the given activity.
/// </summary>
internal uint PercentageCompleted { get; }
/// <summary>
/// Gets the number of seconds remaining for the given activity.
/// </summary>
internal uint SecondsRemaining { get; }
#endregion
}
}