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
155 lines (135 loc) · 4.52 KB
/
Copy pathCimWriteProgress.cs
File metadata and controls
155 lines (135 loc) · 4.52 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*============================================================================
* Copyright (C) Microsoft Corporation, All rights reserved.
*============================================================================
*/
#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>
/// Constructor
/// </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,
UInt32 thePercentageCompleted,
UInt32 theSecondsRemaining)
{
this.activity = theActivity;
this.activityID = theActivityID;
this.currentOperation = theCurrentOperation;
if (String.IsNullOrEmpty(theStatusDescription))
{
this.statusDescription = Strings.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 ProgressRecord(
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>
/// Activity of the given activity
/// </summary>
private string activity;
/// <summary>
/// Activity identifier of the given activity
/// </summary>
private int activityID;
/// <summary>
/// current operation text of the given activity
/// </summary>
private string currentOperation;
/// <summary>
/// status description of the given activity
/// </summary>
private string statusDescription;
/// <summary>
/// percentage completed of the given activity
/// </summary>
private UInt32 percentageCompleted;
/// <summary>
/// how many seconds remained for the given activity
/// </summary>
private UInt32 secondsRemaining;
internal string Activity
{
get { return activity; }
}
internal int ActivityID
{
get { return activityID; }
}
internal string CurrentOperation
{
get { return currentOperation; }
}
internal string StatusDescription
{
get { return statusDescription; }
}
internal UInt32 PercentageCompleted
{
get { return percentageCompleted; }
}
internal UInt32 SecondsRemaining
{
get { return secondsRemaining; }
}
#endregion
}//End Class
}//End namespace