@@ -36,9 +36,9 @@ public PSSyncOutputEvents(PSCmdlet cmdlet)
36
36
{
37
37
this . cmdlet = cmdlet ;
38
38
// TODO: CLU
39
- this . runspace = RunspaceFactory . CreateRunspace ( null ) ;
39
+ this . runspace = RunspaceFactory . CreateRunspace ( InitialSessionState . CreateDefault ( ) ) ;
40
40
//this.runspace = RunspaceFactory.CreateRunspace(this.cmdlet.Host);
41
- this . runspace . Open ( ) ;
41
+ // this.runspace.Open();
42
42
}
43
43
44
44
private static string FormatDuration ( TimeSpan ts )
@@ -47,7 +47,7 @@ private static string FormatDuration(TimeSpan ts)
47
47
{
48
48
return String . Format ( "{0:00}:{1:00}:{2:00}" , ts . Hours , ts . Minutes , ts . Seconds ) ;
49
49
}
50
- return String . Format ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsFormatDuration" ) , ts . Days , ts . Hours , ts . Minutes , ts . Seconds ) ;
50
+ return String . Format ( Rsrc . PSSyncOutputEventsFormatDuration , ts . Days , ts . Hours , ts . Minutes , ts . Seconds ) ;
51
51
}
52
52
53
53
public void ProgressCopyStatus ( ProgressRecord record )
@@ -57,13 +57,13 @@ public void ProgressCopyStatus(ProgressRecord record)
57
57
58
58
public void ProgressCopyStatus ( double precentComplete , double avgThroughputMbps , TimeSpan remainingTime )
59
59
{
60
- LogProgress ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCopying" ) , precentComplete , remainingTime , avgThroughputMbps ) ;
60
+ LogProgress ( 0 , Rsrc . PSSyncOutputEventsCopying , precentComplete , remainingTime , avgThroughputMbps ) ;
61
61
}
62
62
63
63
public void ProgressCopyComplete ( TimeSpan elapsed )
64
64
{
65
- LogProgressComplete ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCopying" ) ) ;
66
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForCopy" ) , FormatDuration ( elapsed ) ) ;
65
+ LogProgressComplete ( 0 , Rsrc . PSSyncOutputEventsCopying ) ;
66
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForCopy , FormatDuration ( elapsed ) ) ;
67
67
}
68
68
69
69
public void ProgressUploadStatus ( ProgressRecord record )
@@ -73,75 +73,87 @@ public void ProgressUploadStatus(ProgressRecord record)
73
73
74
74
public void ProgressUploadStatus ( double precentComplete , double avgThroughputMbps , TimeSpan remainingTime )
75
75
{
76
- LogProgress ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsUploading" ) , precentComplete , remainingTime , avgThroughputMbps ) ;
76
+ LogProgress ( 0 , Rsrc . PSSyncOutputEventsUploading , precentComplete , remainingTime , avgThroughputMbps ) ;
77
77
}
78
78
79
79
private void LogProgress ( int activityId , string activity , double precentComplete , TimeSpan remainingTime , double avgThroughputMbps )
80
80
{
81
- var message = String . Format ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsLogProgress" ) ,
81
+ var message = String . Format ( Rsrc . PSSyncOutputEventsLogProgress ,
82
82
precentComplete ,
83
83
FormatDuration ( remainingTime ) ,
84
84
avgThroughputMbps ) ;
85
85
var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}" , activityId , activity , message , ( int ) remainingTime . TotalSeconds , ( int ) precentComplete ) ;
86
+ // TODO: CLU
87
+ /*
86
88
using (var ps = System.Management.Automation.PowerShell.Create())
87
89
{
88
90
ps.Runspace = runspace;
89
91
// TODO: CLU
90
92
//ps.AddScript(progressCommand);
91
- ps . Invoke ( ) ;
93
+ // ps.Invoke();
92
94
}
95
+ */
93
96
}
94
97
95
98
private void LogProgressComplete ( int activityId , string activity )
96
99
{
97
- var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , activityId , activity , Rsrc . ResourceManager . GetString ( "PSSyncOutputEventsLogProgressCompleteCompleted" ) ) ;
100
+ var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , activityId , activity , Rsrc . PSSyncOutputEventsLogProgressCompleteCompleted ) ;
101
+ // TODO: CLU
102
+ /*
98
103
using (var ps = System.Management.Automation.PowerShell.Create())
99
104
{
100
105
ps.Runspace = runspace;
101
106
// TODO: CLU
102
107
//ps.AddScript(progressCommand);
103
- ps . Invoke ( ) ;
108
+ // ps.Invoke();
104
109
}
110
+ */
105
111
}
106
112
107
113
public void MessageCreatingNewPageBlob ( long pageBlobSize )
108
114
{
109
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCreatingNewPageBlob, pageBlobSize" ) ) ;
115
+ LogMessage ( Rsrc . PSSyncOutputEventsCreatingNewPageBlob , pageBlobSize ) ;
110
116
}
111
117
112
118
private void LogMessage ( string format , params object [ ] parameters )
113
119
{
114
120
var message = String . Format ( format , parameters ) ;
115
121
var verboseMessage = String . Format ( "Write-Host '{0}'" , message ) ;
122
+ // TODO: CLU
123
+ /*
116
124
using (var ps = System.Management.Automation.PowerShell.Create())
117
125
{
118
126
ps.Runspace = runspace;
119
127
// TODO: CLU
120
128
//ps.AddScript(verboseMessage);
121
- ps . Invoke ( ) ;
129
+ // ps.Invoke();
122
130
}
131
+ */
123
132
}
124
133
125
134
private void LogError ( Exception e )
126
135
{
136
+ // TODO: CLU
137
+ /*
127
138
using (var ps = System.Management.Automation.PowerShell.Create())
128
139
{
129
140
ps.Runspace = runspace;
130
141
ps.AddCommand("Write-Error");
131
142
ps.AddParameter("ErrorRecord", new ErrorRecord(e, String.Empty, ErrorCategory.NotSpecified, null));
132
- ps . Invoke ( ) ;
143
+ // ps.Invoke();
133
144
}
145
+ */
134
146
}
135
147
136
148
public void MessageResumingUpload ( )
137
149
{
138
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsResumingUpload" ) ) ;
150
+ LogMessage ( Rsrc . PSSyncOutputEventsResumingUpload ) ;
139
151
}
140
152
141
153
public void ProgressUploadComplete ( TimeSpan elapsed )
142
154
{
143
- LogProgressComplete ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsUploading" ) ) ;
144
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForUpload" ) , FormatDuration ( elapsed ) ) ;
155
+ LogProgressComplete ( 0 , Rsrc . PSSyncOutputEventsUploading ) ;
156
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForUpload , FormatDuration ( elapsed ) ) ;
145
157
}
146
158
147
159
public void ProgressDownloadStatus ( ProgressRecord record )
@@ -151,13 +163,13 @@ public void ProgressDownloadStatus(ProgressRecord record)
151
163
152
164
public void ProgressDownloadStatus ( double precentComplete , double avgThroughputMbps , TimeSpan remainingTime )
153
165
{
154
- LogProgress ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDownloading" ) , precentComplete , remainingTime , avgThroughputMbps ) ;
166
+ LogProgress ( 0 , Rsrc . PSSyncOutputEventsDownloading , precentComplete , remainingTime , avgThroughputMbps ) ;
155
167
}
156
168
157
169
public void ProgressDownloadComplete ( TimeSpan elapsed )
158
170
{
159
- LogProgressComplete ( 0 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDownloading" ) ) ;
160
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForDownload" ) , FormatDuration ( elapsed ) ) ;
171
+ LogProgressComplete ( 0 , Rsrc . PSSyncOutputEventsDownloading ) ;
172
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForDownload , FormatDuration ( elapsed ) ) ;
161
173
}
162
174
163
175
public void ProgressOperationStatus ( ProgressRecord record )
@@ -167,19 +179,19 @@ public void ProgressOperationStatus(ProgressRecord record)
167
179
168
180
public void ProgressOperationStatus ( double percentComplete , double avgThroughputMbps , TimeSpan remainingTime )
169
181
{
170
- LogProgress ( 1 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCalculatingMD5Hash" ) , percentComplete , remainingTime , avgThroughputMbps ) ;
182
+ LogProgress ( 1 , Rsrc . PSSyncOutputEventsCalculatingMD5Hash , percentComplete , remainingTime , avgThroughputMbps ) ;
171
183
}
172
184
173
185
public void ProgressOperationComplete ( TimeSpan elapsed )
174
186
{
175
- LogProgressComplete ( 1 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCalculatingMD5Hash" ) ) ;
176
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsElapsedTimeForOperation" ) , FormatDuration ( elapsed ) ) ;
187
+ LogProgressComplete ( 1 , Rsrc . PSSyncOutputEventsCalculatingMD5Hash ) ;
188
+ LogMessage ( Rsrc . PSSyncOutputEventsElapsedTimeForOperation , FormatDuration ( elapsed ) ) ;
177
189
}
178
190
179
191
180
192
public void ErrorUploadFailedWithExceptions ( IList < Exception > exceptions )
181
193
{
182
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsUploadFailedWithException" ) ) ;
194
+ LogMessage ( Rsrc . PSSyncOutputEventsUploadFailedWithException ) ;
183
195
foreach ( var exception in exceptions )
184
196
{
185
197
LogError ( exception ) ;
@@ -188,17 +200,17 @@ public void ErrorUploadFailedWithExceptions(IList<Exception> exceptions)
188
200
189
201
public void MessageCalculatingMD5Hash ( string filePath )
190
202
{
191
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsCalculatingMD5HashForFile" ) , filePath ) ;
203
+ LogMessage ( Rsrc . PSSyncOutputEventsCalculatingMD5HashForFile , filePath ) ;
192
204
}
193
205
194
206
public void MessageMD5HashCalculationFinished ( )
195
207
{
196
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsMD5HashCalculationFinished" ) ) ;
208
+ LogMessage ( Rsrc . PSSyncOutputEventsMD5HashCalculationFinished ) ;
197
209
}
198
210
199
211
public void MessageRetryingAfterANetworkDisruption ( )
200
212
{
201
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsRetryingAfterANetworkDisruption" ) ) ;
213
+ LogMessage ( Rsrc . PSSyncOutputEventsRetryingAfterANetworkDisruption ) ;
202
214
}
203
215
204
216
public void DebugRetryingAfterException ( Exception lastException )
@@ -215,71 +227,80 @@ public void DebugRetryingAfterException(Exception lastException)
215
227
216
228
public void MessageDetectingActualDataBlocks ( )
217
229
{
218
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDetectingActualDataBlocks" ) ) ;
230
+ LogMessage ( Rsrc . PSSyncOutputEventsDetectingActualDataBlocks ) ;
219
231
}
220
232
221
233
public void MessageDetectingActualDataBlocksCompleted ( )
222
234
{
223
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsDetectingActualDataBlocksCompleted" ) ) ;
235
+ LogMessage ( Rsrc . PSSyncOutputEventsDetectingActualDataBlocksCompleted ) ;
224
236
}
225
237
226
238
public void MessagePrintBlockRange ( IndexRange range )
227
239
{
228
- LogMessage ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsPrintBlockRange" ) , range , range . Length ) ;
240
+ LogMessage ( Rsrc . PSSyncOutputEventsPrintBlockRange , range , range . Length ) ;
229
241
}
230
242
231
243
public void DebugEmptyBlockDetected ( IndexRange range )
232
244
{
233
- LogDebug ( Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsEmptyBlockDetected" ) , range . ToString ( ) ) ;
245
+ LogDebug ( Rsrc . PSSyncOutputEventsEmptyBlockDetected , range . ToString ( ) ) ;
234
246
}
235
247
236
248
private void LogDebug ( string format , params object [ ] parameters )
237
249
{
238
250
var message = String . Format ( format , parameters ) ;
239
251
var debugMessage = String . Format ( "Write-Debug -Message '{0}'" , message ) ;
252
+ // TODO: CLU
253
+ /*
240
254
using (var ps = System.Management.Automation.PowerShell.Create())
241
255
{
242
256
ps.Runspace = runspace;
243
257
// TODO: CLU
244
258
//ps.AddScript(debugMessage);
245
- ps . Invoke ( ) ;
259
+ // ps.Invoke();
246
260
}
261
+ */
247
262
}
248
263
249
264
public void ProgressEmptyBlockDetection ( int processedRangeCount , int totalRangeCount )
250
265
{
266
+ // TODO: CLU
267
+ /*
251
268
using (var ps = System.Management.Automation.PowerShell.Create())
252
269
{
253
270
if (processedRangeCount >= totalRangeCount)
254
271
{
255
272
256
- var progressCommand1 = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed" , 2 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsProgressEmptyBlockDetection" ) , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsEmptyBlockDetectionCompleted" ) ) ;
273
+ var progressCommand1 = String.Format(@"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -Completed", 2, Rsrc.PSSyncOutputEventsProgressEmptyBlockDetection, Rsrc.PSSyncOutputEventsEmptyBlockDetectionCompleted);
257
274
ps.Runspace = runspace;
258
275
// TODO: CLU
259
276
//ps.AddScript(progressCommand1);
260
- ps . Invoke ( ) ;
277
+ // ps.Invoke();
261
278
return;
262
279
}
263
280
264
- var progressCommand = String . Format ( @"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}" , 2 , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsProgressEmptyBlockDetection" ) , Rsrc . ResourceManager . GetString ( " PSSyncOutputEventsEmptyBlockDetectionDetecting" ) , - 1 , ( ( double ) processedRangeCount / totalRangeCount ) * 100 ) ;
281
+ var progressCommand = String.Format(@"Write-Progress -Id {0} -Activity '{1}' -Status '{2}' -SecondsRemaining {3} -PercentComplete {4}", 2, Rsrc.PSSyncOutputEventsProgressEmptyBlockDetection, Rsrc.PSSyncOutputEventsEmptyBlockDetectionDetecting, -1, ((double)processedRangeCount / totalRangeCount) * 100);
265
282
ps.Runspace = runspace;
266
283
// TODO: CLU
267
284
//ps.AddScript(progressCommand);
268
- ps . Invoke ( ) ;
285
+ // ps.Invoke();
269
286
}
287
+ */
270
288
}
271
289
272
290
public void WriteVerboseWithTimestamp ( string message , params object [ ] args )
273
291
{
292
+ // TODO: CLU
293
+ /*
274
294
var messageWithTimeStamp = string.Format(CultureInfo.CurrentCulture, "{0:T} - {1}", DateTime.Now, string.Format(message, args));
275
295
var progressCommand = String.Format(@"Write-Verbose -Message {0}", messageWithTimeStamp);
276
296
using (var ps = System.Management.Automation.PowerShell.Create())
277
297
{
278
298
ps.Runspace = runspace;
279
299
// TODO: CLU
280
300
//ps.AddScript(progressCommand);
281
- ps . Invoke ( ) ;
301
+ // ps.Invoke();
282
302
}
303
+ */
283
304
}
284
305
285
306
@@ -295,7 +316,8 @@ protected virtual void Dispose(bool disposing)
295
316
{
296
317
if ( disposing )
297
318
{
298
- runspace . Dispose ( ) ;
319
+ // TODO: CLU
320
+ //runspace.Dispose();
299
321
}
300
322
this . disposed = true ;
301
323
}
0 commit comments